1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-05 02:29:38 +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, ABORT: Components.results.NS_BINDING_ABORTED,
ACCEPT: Components.results.NS_SUCCEEDED, ACCEPT: Components.results.NS_SUCCEEDED,
MAIN_FRAME: Ci.nsIContentPolicy.TYPE_DOCUMENT, MAIN_FRAME: Ci.nsIContentPolicy.TYPE_DOCUMENT,
VALID_CSP_TARGETS: 1 << Ci.nsIContentPolicy.TYPE_DOCUMENT |
1 << Ci.nsIContentPolicy.TYPE_SUBDOCUMENT,
typeMap: { typeMap: {
2: 'script', 2: 'script',
3: 'image', 3: 'image',
@ -921,7 +923,11 @@ var httpObserver = {
return; return;
} }
if ( !channelData || channelData[0] !== this.MAIN_FRAME ) { if ( !channelData ) {
return;
}
if ( 1 << channelData[0] & this.VALID_CSP_TARGETS === 0 ) {
return; return;
} }

View File

@ -247,11 +247,6 @@ var onBeforeSendHeaders = function(details) {
// To handle `inline-script`. // To handle `inline-script`.
var onHeadersReceived = function(details) { var onHeadersReceived = function(details) {
// Only root document.
if ( details.parentFrameId !== -1 ) {
return;
}
// Do not interfere with behind-the-scene requests. // Do not interfere with behind-the-scene requests.
var tabId = details.tabId; var tabId = details.tabId;
if ( tabId < 0 ) { if ( tabId < 0 ) {
@ -266,8 +261,13 @@ var onHeadersReceived = function(details) {
} }
// https://github.com/gorhill/uBlock/issues/384 // https://github.com/gorhill/uBlock/issues/384
pageStore.skipLocalMirroring = headerValue(details.responseHeaders, 'content-security-policy'); if ( details.parentFrameId === -1 ) {
pageStore.requestURL = details.url; 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.requestHostname = µb.URI.hostnameFromURI(details.url);
pageStore.requestType = 'inline-script'; pageStore.requestType = 'inline-script';
var result = pageStore.filterRequest(pageStore); var result = pageStore.filterRequest(pageStore);
@ -351,7 +351,8 @@ vAPI.net.onHeadersReceived = {
'https://*/*' 'https://*/*'
], ],
types: [ types: [
"main_frame" "main_frame",
"sub_frame"
], ],
extra: [ 'blocking', 'responseHeaders' ], extra: [ 'blocking', 'responseHeaders' ],
callback: onHeadersReceived callback: onHeadersReceived