Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
synthetic context for blocked popup testing missing property members
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 7, 2014
1 parent 58159e3 commit 029a375
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 029a375

Please sign in to comment.