Index: lib/popupBlocker.js |
=================================================================== |
--- a/lib/popupBlocker.js |
+++ b/lib/popupBlocker.js |
@@ -20,26 +20,26 @@ |
"use strict"; |
const {defaultMatcher} = require("matcher"); |
const {BlockingFilter, RegExpFilter} = require("filterClasses"); |
const {stringifyURL, isThirdParty, extractHostFromFrame} = require("url"); |
const {checkWhitelisted} = require("whitelisting"); |
const {logRequest} = require("devtools"); |
-let loadingPopups = Object.create(null); |
+let loadingPopups = new Map(); |
function hasLoadingPopups() |
{ |
- return Object.keys(loadingPopups).length > 0; |
+ return loadingPopups.size > 0; |
} |
function forgetPopup(tabId) |
{ |
- delete loadingPopups[tabId]; |
+ loadingPopups.delete(tabId); |
if (!hasLoadingPopups()) |
{ |
chrome.webRequest.onBeforeRequest.removeListener(onPopupURLChanged); |
chrome.webNavigation.onCommitted.removeListener(onPopupURLChanged); |
chrome.webNavigation.onCompleted.removeListener(onCompleted); |
chrome.tabs.onRemoved.removeListener(forgetPopup); |
} |
@@ -73,17 +73,17 @@ |
} |
function onPopupURLChanged(details) |
{ |
// Ignore frames inside the popup window. |
if (details.frameId != 0) |
return; |
- let popup = loadingPopups[details.tabId]; |
+ let popup = loadingPopups.get(details.tabId); |
if (popup) |
{ |
popup.url = details.url; |
if (popup.sourceFrame) |
checkPotentialPopup(details.tabId, popup); |
} |
} |
@@ -105,21 +105,24 @@ |
} |
); |
chrome.webNavigation.onCommitted.addListener(onPopupURLChanged); |
chrome.webNavigation.onCompleted.addListener(onCompleted); |
chrome.tabs.onRemoved.addListener(forgetPopup); |
} |
let {tabId} = details; |
- let popup = loadingPopups[tabId] = { |
- url: details.url, |
- sourcePage: new ext.Page({id: details.sourceTabId}), |
- sourceFrame: null |
- }; |
+ |
+ let popup = Object.create(null); |
Sebastian Noack
2017/04/29 22:46:32
As mentioned before in this review, please don't c
Manish Jethani
2017/05/04 14:47:34
Done.
|
+ popup.url = details.url; |
+ popup.sourcePage = new ext.Page({id: details.sourceTabId}); |
+ popup.sourceFrame = null; |
+ |
+ loadingPopups.set(tabId, popup); |
+ |
let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
if (checkWhitelisted(popup.sourcePage, frame)) |
{ |
forgetPopup(tabId); |
} |
else |
{ |