1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

synthetic context for blocked popup testing missing property members

This commit is contained in:
gorhill 2014-10-07 17:31:21 -04:00
parent 58159e3c05
commit 029a37596d

View File

@ -182,23 +182,25 @@ var onBeforeSendHeaders = function(details) {
return;
}
// https://github.com/gorhill/uBlock/issues/67
// We need to pass the details of the page which opened this popup,
// so that the `third-party` option works.
var µburi = µb.URI;
var referrerHostname = µburi.hostnameFromURI(referrer);
var pageDetails = {
pageHostname: referrerHostname,
pageDomain: µburi.domainFromHostname(referrerHostname)
};
//console.debug('Referrer="%s"', referrer);
// TODO: I think I should test the switch of the referrer instead, not the
// switch of the popup. If so, that would require being able to lookup
// a page store from a URL. Have to keep in mind the same URL can appear
// in multiple tabs.
var result = '';
if ( pageStore.getNetFilteringSwitch() ) {
// https://github.com/gorhill/uBlock/issues/67
// We need to pass the details of the page which opened this popup,
// so that the `third-party` option works.
// Create a synthetic context based on the referrer.
var µburi = µb.URI;
var referrerHostname = µburi.hostnameFromURI(referrer);
var pageDetails = {
pageHostname: referrerHostname,
pageDomain: µburi.domainFromHostname(referrerHostname),
};
pageDetails.rootHostname = pageDetails.pageHostname;
pageDetails.rootDomain = pageDetails.pageDomain;
//console.debug('Referrer="%s"', referrer);
result = µb.netFilteringEngine.matchStringExactType(pageDetails, requestURL, 'popup');
}