Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/popupBlocker.js

Issue 29539831: Issue 5648 - Include lib/popupBlocker.js on Firefox (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created Sept. 8, 2017, 6:59 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | metadata.gecko-webext » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/popupBlocker.js
===================================================================
--- a/lib/popupBlocker.js
+++ b/lib/popupBlocker.js
@@ -83,44 +83,50 @@
}
function onCompleted(details)
{
if (details.frameId == 0 && details.url != "about:blank")
forgetPopup(details.tabId);
}
-chrome.webNavigation.onCreatedNavigationTarget.addListener(details =>
+// Versions of Firefox before 54 do not support
+// webNavigation.onCreatedNavigationTarget
+// https://bugzilla.mozilla.org/show_bug.cgi?id=1190687
+if ("onCreatedNavigationTarget" in chrome.webNavigation)
{
- if (loadingPopups.size == 0)
+ chrome.webNavigation.onCreatedNavigationTarget.addListener(details =>
{
- chrome.webRequest.onBeforeRequest.addListener(
- onPopupURLChanged,
- {
- urls: ["http://*/*", "https://*/*"],
- types: ["main_frame"]
- }
- );
- chrome.webNavigation.onCommitted.addListener(onPopupURLChanged);
- chrome.webNavigation.onCompleted.addListener(onCompleted);
- chrome.tabs.onRemoved.addListener(forgetPopup);
- }
+ if (loadingPopups.size == 0)
+ {
+ chrome.webRequest.onBeforeRequest.addListener(
+ onPopupURLChanged,
+ {
+ urls: ["http://*/*", "https://*/*"],
+ types: ["main_frame"]
+ }
+ );
+ chrome.webNavigation.onCommitted.addListener(onPopupURLChanged);
+ chrome.webNavigation.onCompleted.addListener(onCompleted);
+ chrome.tabs.onRemoved.addListener(forgetPopup);
+ }
- let popup = {
- url: details.url,
- sourcePage: new ext.Page({id: details.sourceTabId}),
- sourceFrame: null
- };
+ let popup = {
+ url: details.url,
+ sourcePage: new ext.Page({id: details.sourceTabId}),
+ sourceFrame: null
+ };
- loadingPopups.set(details.tabId, popup);
+ loadingPopups.set(details.tabId, popup);
- let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId);
+ let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId);
- if (checkWhitelisted(popup.sourcePage, frame))
- {
- forgetPopup(details.tabId);
- }
- else
- {
- popup.sourceFrame = frame;
- checkPotentialPopup(details.tabId, popup);
- }
-});
+ if (checkWhitelisted(popup.sourcePage, frame))
+ {
+ forgetPopup(details.tabId);
+ }
+ else
+ {
+ popup.sourceFrame = frame;
+ checkPotentialPopup(details.tabId, popup);
+ }
+ });
+}
« no previous file with comments | « no previous file | metadata.gecko-webext » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld