Browse Source

this fixes #205

pull/2/head
gorhill 10 years ago
parent
commit
05d8c51580
  1. 17
      platform/firefox/vapi-background.js
  2. 12
      src/js/messaging.js
  3. 8
      src/js/pagestats.js

17
platform/firefox/vapi-background.js

@ -1086,9 +1086,14 @@ var httpObserver = {
11: 'xmlhttprequest',
12: 'object',
14: 'font',
15: 'media',
16: 'websocket',
21: 'image'
},
mimeTypeMap: {
'audio': 15,
'video': 15
},
get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -1260,6 +1265,18 @@ var httpObserver = {
return vAPI.noTabId;
},
rawtypeFromContentType: function(channel) {
var mime = channel.contentType;
if ( !mime ) {
return 0;
}
var pos = mime.indexOf('/');
if ( pos === -1 ) {
pos = mime.length;
}
return this.mimeTypeMap[mime.slice(0, pos)] || 0;
},
observe: function(channel, topic) {
if ( channel instanceof Ci.nsIHttpChannel === false ) {
return;

12
src/js/messaging.js

@ -452,17 +452,25 @@ var evaluateURLs = function(tabId, requests) {
//console.debug('messaging.js/contentscript-end.js: processing %d requests', requests.length);
var pageStore = µm.pageStoreFromTabId(tabId);
var µmuri = µm.URI;
var typeMap = tagNameToRequestTypeMap;
var request;
var request, type;
var i = requests.length;
while ( i-- ) {
request = requests[i];
type = typeMap[request.tagName];
request.blocked = µm.mustBlock(
rootHostname,
µmuri.hostnameFromURI(request.url),
typeMap[request.tagName]
type
);
// https://github.com/gorhill/uMatrix/issues/205
// If blocked, the URL must be recorded by the page store, so as to ensure
// they are properly reflected in the matrix.
if ( request.blocked && pageStore ) {
pageStore.recordRequest(type, request.url, true);
}
}
if ( collapse ) {

8
src/js/pagestats.js

@ -373,6 +373,10 @@ PageStore.prototype.dispose = function() {
/******************************************************************************/
PageStore.prototype.recordRequest = function(type, url, block) {
if ( !this.requests.createEntryIfNotExists(url, type, block) ) {
return;
}
// Count blocked/allowed requests
this.requestStats.record(type, block);
@ -387,10 +391,6 @@ PageStore.prototype.recordRequest = function(type, url, block) {
this.perLoadAllowedRequestCount++;
}
if ( !this.requests.createEntryIfNotExists(url, type, block) ) {
return;
}
var hostname = µm.URI.hostnameFromURI(url);
this.distinctRequestCount++;

Loading…
Cancel
Save