mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
better fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1232354, as pointed out in comments
This commit is contained in:
parent
a76703b6ad
commit
2725479709
@ -207,11 +207,7 @@ var contentObserver = {
|
|||||||
// - Enable uBlock
|
// - Enable uBlock
|
||||||
// - Services and all other global variables are undefined
|
// - Services and all other global variables are undefined
|
||||||
// Hopefully will eventually understand why this happens.
|
// Hopefully will eventually understand why this happens.
|
||||||
if ( Services === undefined ) {
|
if ( Services === undefined || !context ) {
|
||||||
return this.ACCEPT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !context ) {
|
|
||||||
return this.ACCEPT;
|
return this.ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +215,13 @@ var contentObserver = {
|
|||||||
this.handlePopup(location, origin, context);
|
this.handlePopup(location, origin, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1232354
|
||||||
|
// For modern versions of Firefox, the frameId/parentFrameId
|
||||||
|
// information can be found in channel.loadInfo of the HTTP observer.
|
||||||
|
if ( this.canE10S ) {
|
||||||
|
return this.ACCEPT;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !location.schemeIs('http') && !location.schemeIs('https') ) {
|
if ( !location.schemeIs('http') && !location.schemeIs('https') ) {
|
||||||
return this.ACCEPT;
|
return this.ACCEPT;
|
||||||
}
|
}
|
||||||
@ -245,19 +248,12 @@ var contentObserver = {
|
|||||||
return this.ACCEPT;
|
return this.ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1232354
|
|
||||||
// For top-level resources, no need to send information to the
|
|
||||||
// main process.
|
|
||||||
let isTopContext = context === context.top;
|
|
||||||
if ( isTopContext && this.canE10S ) {
|
|
||||||
return this.ACCEPT;
|
|
||||||
}
|
|
||||||
|
|
||||||
let messageManager = getMessageManager(context);
|
let messageManager = getMessageManager(context);
|
||||||
if ( messageManager === null ) {
|
if ( messageManager === null ) {
|
||||||
return this.ACCEPT;
|
return this.ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isTopContext = context === context.top;
|
||||||
var parentFrameId;
|
var parentFrameId;
|
||||||
if ( isTopContext ) {
|
if ( isTopContext ) {
|
||||||
parentFrameId = -1;
|
parentFrameId = -1;
|
||||||
|
@ -2026,11 +2026,11 @@ var httpObserver = {
|
|||||||
if ( bucket === undefined ) {
|
if ( bucket === undefined ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var i = bucket.charCodeAt(0);
|
var i = bucket.charCodeAt(bucket.length - 1);
|
||||||
if ( bucket.length === 1 ) {
|
if ( bucket.length === 1 ) {
|
||||||
this.pendingURLToIndex.delete(url);
|
this.pendingURLToIndex.delete(url);
|
||||||
} else {
|
} else {
|
||||||
this.pendingURLToIndex.set(url, bucket.slice(1));
|
this.pendingURLToIndex.set(url, bucket.slice(0, -1));
|
||||||
}
|
}
|
||||||
var preq = this.pendingRingBuffer[i];
|
var preq = this.pendingRingBuffer[i];
|
||||||
preq._key = ''; // mark as "serviced"
|
preq._key = ''; // mark as "serviced"
|
||||||
@ -2225,8 +2225,15 @@ var httpObserver = {
|
|||||||
var pendingRequest = this.lookupPendingRequest(URI.spec);
|
var pendingRequest = this.lookupPendingRequest(URI.spec);
|
||||||
|
|
||||||
// https://github.com/gorhill/uMatrix/issues/390#issuecomment-155759004
|
// https://github.com/gorhill/uMatrix/issues/390#issuecomment-155759004
|
||||||
var rawtype = 1;
|
var loadInfo = channel.loadInfo,
|
||||||
var loadInfo = channel.loadInfo;
|
rawtype = 1,
|
||||||
|
frameId = 0,
|
||||||
|
parentFrameId = -1;
|
||||||
|
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1232354
|
||||||
|
// https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/addons/WebRequest.jsm#537-553
|
||||||
|
// For modern Firefox, loadInfo contains the information about the
|
||||||
|
// context of the network request.
|
||||||
if ( loadInfo ) {
|
if ( loadInfo ) {
|
||||||
rawtype = loadInfo.externalContentPolicyType !== undefined ?
|
rawtype = loadInfo.externalContentPolicyType !== undefined ?
|
||||||
loadInfo.externalContentPolicyType :
|
loadInfo.externalContentPolicyType :
|
||||||
@ -2234,6 +2241,11 @@ var httpObserver = {
|
|||||||
if ( !rawtype ) {
|
if ( !rawtype ) {
|
||||||
rawtype = 1;
|
rawtype = 1;
|
||||||
}
|
}
|
||||||
|
frameId = loadInfo.frameOuterWindowID ? loadInfo.frameOuterWindowID : loadInfo.outerWindowID;
|
||||||
|
parentFrameId = loadInfo.frameOuterWindowID ? loadInfo.outerWindowID : loadInfo.parentOuterWindowID;
|
||||||
|
if ( frameId === parentFrameId ) {
|
||||||
|
parentFrameId = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pendingRequest !== null ) {
|
if ( pendingRequest !== null ) {
|
||||||
@ -2259,6 +2271,8 @@ var httpObserver = {
|
|||||||
pendingRequest = this.syntheticPendingRequest;
|
pendingRequest = this.syntheticPendingRequest;
|
||||||
pendingRequest.tabId = this.tabIdFromChannel(channel);
|
pendingRequest.tabId = this.tabIdFromChannel(channel);
|
||||||
pendingRequest.rawtype = rawtype;
|
pendingRequest.rawtype = rawtype;
|
||||||
|
pendingRequest.frameId = frameId;
|
||||||
|
pendingRequest.parentFrameId = parentFrameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this.handleRequest(channel, URI, pendingRequest) ) {
|
if ( this.handleRequest(channel, URI, pendingRequest) ) {
|
||||||
|
@ -77,10 +77,9 @@ var onBeforeRequest = function(details) {
|
|||||||
// > the outer frame.
|
// > the outer frame.
|
||||||
// > (ref: https://developer.chrome.com/extensions/webRequest)
|
// > (ref: https://developer.chrome.com/extensions/webRequest)
|
||||||
var isFrame = requestType === 'sub_frame';
|
var isFrame = requestType === 'sub_frame';
|
||||||
var frameId = isFrame ? details.parentFrameId : details.frameId;
|
|
||||||
|
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/114
|
// https://github.com/chrisaljoudi/uBlock/issues/114
|
||||||
var requestContext = pageStore.createContextFromFrameId(frameId);
|
var requestContext = pageStore.createContextFromFrameId(isFrame ? details.parentFrameId : details.frameId);
|
||||||
|
|
||||||
// Setup context and evaluate
|
// Setup context and evaluate
|
||||||
var requestURL = details.url;
|
var requestURL = details.url;
|
||||||
@ -109,9 +108,8 @@ var onBeforeRequest = function(details) {
|
|||||||
// Not blocked
|
// Not blocked
|
||||||
if ( µb.isAllowResult(result) ) {
|
if ( µb.isAllowResult(result) ) {
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/114
|
// https://github.com/chrisaljoudi/uBlock/issues/114
|
||||||
frameId = details.frameId;
|
if ( details.parentFrameId !== -1 && isFrame ) {
|
||||||
if ( frameId > 0 && isFrame ) {
|
pageStore.setFrame(details.frameId, requestURL);
|
||||||
pageStore.setFrame(frameId, requestURL);
|
|
||||||
}
|
}
|
||||||
requestContext.dispose();
|
requestContext.dispose();
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user