Skip to content

Commit

Permalink
Add TODO to look into localStorage detection bug
Browse files Browse the repository at this point in the history
This hides "window.injectScript undefined" console errors in Chrome that
started in b7e9aea

The aforementioned commit merely made the problem more visible, however.
The underlying issue (FRAME_URL/injectScript from the utils.js content
script sometimes being undefined in the supercookie.js content script)
was already present at that point.
  • Loading branch information
ghostwords committed Nov 18, 2019
1 parent cc4b04e commit 1518d01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/js/contentscripts/supercookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ if (window.top == window) {
//
// could then remove test workarounds like
// https://github.com/EFForg/privacybadger/commit/39d5d0899e22d1c451d429e44553c5f9cad7fc46

// TODO sometimes contentscripts/utils.js isn't here?!
// TODO window.FRAME_URL / window.injectScript are undefined ...
chrome.runtime.sendMessage({
type: "checkEnabledAndThirdParty",
frameUrl: window.FRAME_URL
Expand Down
13 changes: 8 additions & 5 deletions src/js/webrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,14 +682,15 @@ function dispatcher(request, sender, sendResponse) {
return sendResponse();
}

let requestHost = window.extractHostFromURL(request.frameUrl);
let frame_host = window.extractHostFromURL(request.frameUrl),
tab_host = window.extractHostFromURL(sender.tab.url);

// Ignore requests that aren't from a third party.
if (!utils.isThirdPartyDomain(requestHost, window.extractHostFromURL(sender.tab.url))) {
if (!frame_host || !utils.isThirdPartyDomain(frame_host, tab_host)) {
return sendResponse();
}

let action = checkAction(sender.tab.id, requestHost);
let action = checkAction(sender.tab.id, frame_host);
sendResponse(action == constants.COOKIEBLOCK || action == constants.USER_COOKIE_BLOCK);

break;
Expand Down Expand Up @@ -770,7 +771,7 @@ function dispatcher(request, sender, sendResponse) {
}

case "supercookieReport": {
if (badger.hasSuperCookie(request.data)) {
if (request.frameUrl && badger.hasSuperCookie(request.data)) {
recordSuperCookie(sender.tab.id, request.frameUrl);
}
break;
Expand All @@ -780,7 +781,9 @@ function dispatcher(request, sender, sendResponse) {
let tab_host = window.extractHostFromURL(sender.tab.url),
frame_host = window.extractHostFromURL(request.frameUrl);

sendResponse(badger.isPrivacyBadgerEnabled(tab_host) && utils.isThirdPartyDomain(frame_host, tab_host));
sendResponse(frame_host &&
badger.isPrivacyBadgerEnabled(tab_host) &&
utils.isThirdPartyDomain(frame_host, tab_host));

break;
}
Expand Down

0 comments on commit 1518d01

Please sign in to comment.