1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00
This commit is contained in:
gorhill 2015-01-13 11:54:54 -05:00
parent 5ec300602a
commit b436f8e829
2 changed files with 16 additions and 9 deletions

View File

@ -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;
}

View File

@ -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