mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
Code review of fix for https://github.com/uBlockOrigin/uBlock-issues/issues/459
Relocate workaround to the code responsible to compute filtering context, such that the workaround will also be applied in other code paths, for example also for webRequest.onHeadersReceived.
This commit is contained in:
parent
f411ab1feb
commit
875542c964
@ -53,6 +53,9 @@
|
|||||||
this.tabId = tabContext.tabId;
|
this.tabId = tabContext.tabId;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/459
|
||||||
|
// In case of a request for frame and if ever no context is specified,
|
||||||
|
// assume the origin of the context is the same as the request itself.
|
||||||
fromWebrequestDetails: function(details) {
|
fromWebrequestDetails: function(details) {
|
||||||
const tabId = details.tabId;
|
const tabId = details.tabId;
|
||||||
if ( tabId > 0 && details.type === 'main_frame' ) {
|
if ( tabId > 0 && details.type === 'main_frame' ) {
|
||||||
@ -85,6 +88,9 @@
|
|||||||
const normalURL = µBlock.normalizePageURL(0, details.documentUrl);
|
const normalURL = µBlock.normalizePageURL(0, details.documentUrl);
|
||||||
this.setTabOriginFromURL(normalURL);
|
this.setTabOriginFromURL(normalURL);
|
||||||
this.setDocOriginFromURL(normalURL);
|
this.setDocOriginFromURL(normalURL);
|
||||||
|
} else if ( this.type === 'sub_frame' ) {
|
||||||
|
const origin = this.originFromURI(this.url);
|
||||||
|
this.setDocOrigin(origin).setTabOrigin(origin);
|
||||||
} else {
|
} else {
|
||||||
this.setDocOrigin(this.tabOrigin);
|
this.setDocOrigin(this.tabOrigin);
|
||||||
}
|
}
|
||||||
|
@ -283,17 +283,6 @@ const onBeforeBehindTheSceneRequest = function(fctxt) {
|
|||||||
|
|
||||||
let result = 0;
|
let result = 0;
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/459
|
|
||||||
// In case of a request for frame and if ever no context is specified,
|
|
||||||
// assume the origin of the context is the same as the request itself.
|
|
||||||
if (
|
|
||||||
fctxt.type === 'sub_frame' &&
|
|
||||||
fctxt.getDocHostname() === 'behind-the-scene'
|
|
||||||
|
|
||||||
) {
|
|
||||||
fctxt.setDocOriginFromURL(fctxt.url).setTabOriginFromURL(fctxt.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/339
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/339
|
||||||
// Need to also test against `-scheme` since tabOrigin is normalized.
|
// Need to also test against `-scheme` since tabOrigin is normalized.
|
||||||
// Not especially elegant but for now this accomplishes the purpose of
|
// Not especially elegant but for now this accomplishes the purpose of
|
||||||
|
Loading…
Reference in New Issue
Block a user