diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 5e860e2..73c292f 100644 --- a/platform/firefox/vapi-background.js +++ b/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; diff --git a/src/js/messaging.js b/src/js/messaging.js index 568aa63..bd5e143 100644 --- a/src/js/messaging.js +++ b/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 ) { diff --git a/src/js/pagestats.js b/src/js/pagestats.js index 75b065c..4c8b2bf 100644 --- a/src/js/pagestats.js +++ b/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++;