From 7b81b82e4b7093fbcc762bd75724f60d51a4db9a Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 13 Nov 2015 11:53:39 -0500 Subject: [PATCH] reversing fix to #868: does not work with latest FF/Nightly --- platform/firefox/frameModule.js | 10 ++------ platform/firefox/vapi-background.js | 37 ++++++++++------------------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 39bed5bb8..197212d60 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -210,18 +210,12 @@ var contentObserver = { }; //console.log('shouldLoad: type=' + type + ' url=' + location.spec); - var r; if ( typeof messageManager.sendRpcMessage === 'function' ) { // https://bugzil.la/1092216 - r = messageManager.sendRpcMessage(this.cpMessageName, details); + messageManager.sendRpcMessage(this.cpMessageName, details); } else { // Compatibility for older versions - r = messageManager.sendSyncMessage(this.cpMessageName, details); - } - - // Important: hard test against `false`. - if ( Array.isArray(r) && r[0] === false ) { - return this.REJECT; + messageManager.sendSyncMessage(this.cpMessageName, details); } return this.ACCEPT; diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 748d0ad39..b5f5124e4 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -2042,7 +2042,18 @@ var httpObserver = { // http-on-opening-request var pendingRequest = this.lookupPendingRequest(URI.spec); - var rawtype = channel.loadInfo && channel.loadInfo.contentPolicyType || 1; + + // https://github.com/gorhill/uMatrix/issues/390#issuecomment-155759004 + var rawtype = 1; + var loadInfo = channel.loadInfo; + if ( loadInfo ) { + rawtype = loadInfo.externalContentPolicyType !== undefined ? + loadInfo.externalContentPolicyType : + loadInfo.contentPolicyType; + if ( !rawtype ) { + rawtype = 1; + } + } // Behind-the-scene request if ( pendingRequest === null ) { @@ -2186,21 +2197,6 @@ vAPI.net.registerListeners = function() { return sourceTabId; }; - var shouldLoadMedia = function(details) { - var uri = Services.io.newURI(details.url, null, null); - - var r = vAPI.net.onBeforeRequest.callback({ - frameId: details.frameId, - hostname: uri.asciiHost, - parentFrameId: details.parentFrameId, - tabId: details.tabId, - type: 'media', - url: uri.asciiSpec - }); - - return typeof r !== 'object' || r === null; - }; - var shouldLoadListenerMessageName = location.host + ':shouldLoad'; var shouldLoadListener = function(e) { // Non blocking: it is assumed that the http observer is fired after @@ -2221,15 +2217,6 @@ vAPI.net.registerListeners = function() { sourceTabId = shouldBlockPopup(details); } - // https://github.com/gorhill/uBlock/issues/868 - // Firefox quirk: for some reasons, there are instances of resources - // for `video` tag not being reported to HTTP observers. - // If blocking, do not bother creating a pending request entry, it - // won't be used anyway. - if ( details.rawtype === 15 && shouldLoadMedia(details) === false ) { - return false; - } - // We are being called synchronously from the content process, so we // must return ASAP. The code below merely record the details of the // request into a ring buffer for later retrieval by the HTTP observer.