diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index d64c3fd06..565c93323 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -772,6 +772,8 @@ var httpObserver = { ABORT: Components.results.NS_BINDING_ABORTED, ACCEPT: Components.results.NS_SUCCEEDED, MAIN_FRAME: Ci.nsIContentPolicy.TYPE_DOCUMENT, + VALID_CSP_TARGETS: 1 << Ci.nsIContentPolicy.TYPE_DOCUMENT | + 1 << Ci.nsIContentPolicy.TYPE_SUBDOCUMENT, typeMap: { 2: 'script', 3: 'image', @@ -921,7 +923,11 @@ var httpObserver = { return; } - if ( !channelData || channelData[0] !== this.MAIN_FRAME ) { + if ( !channelData ) { + return; + } + + if ( 1 << channelData[0] & this.VALID_CSP_TARGETS === 0 ) { return; } diff --git a/src/js/traffic.js b/src/js/traffic.js index c0e00eb11..7981ca55d 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -247,11 +247,6 @@ var onBeforeSendHeaders = function(details) { // To handle `inline-script`. var onHeadersReceived = function(details) { - // Only root document. - if ( details.parentFrameId !== -1 ) { - return; - } - // Do not interfere with behind-the-scene requests. var tabId = details.tabId; if ( tabId < 0 ) { @@ -266,8 +261,13 @@ var onHeadersReceived = function(details) { } // https://github.com/gorhill/uBlock/issues/384 - pageStore.skipLocalMirroring = headerValue(details.responseHeaders, 'content-security-policy'); - pageStore.requestURL = details.url; + if ( details.parentFrameId === -1 ) { + pageStore.skipLocalMirroring = headerValue(details.responseHeaders, 'content-security-policy'); + } + + // Concatenating with '{inline-script}' so that the network request cache + // can distinguish from the document itself + pageStore.requestURL = details.url + '{inline-script}'; pageStore.requestHostname = µb.URI.hostnameFromURI(details.url); pageStore.requestType = 'inline-script'; var result = pageStore.filterRequest(pageStore); @@ -351,7 +351,8 @@ vAPI.net.onHeadersReceived = { 'https://*/*' ], types: [ - "main_frame" + "main_frame", + "sub_frame" ], extra: [ 'blocking', 'responseHeaders' ], callback: onHeadersReceived