| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 checkPotentialPopup(details.tabId, popup); | 81 checkPotentialPopup(details.tabId, popup); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 function onCompleted(details) | 85 function onCompleted(details) |
| 86 { | 86 { |
| 87 if (details.frameId == 0 && details.url != "about:blank") | 87 if (details.frameId == 0 && details.url != "about:blank") |
| 88 forgetPopup(details.tabId); | 88 forgetPopup(details.tabId); |
| 89 } | 89 } |
| 90 | 90 |
| 91 chrome.webNavigation.onCreatedNavigationTarget.addListener(details => | 91 // Versions of Firefox before 54 do not support |
| 92 // webNavigation.onCreatedNavigationTarget |
| 93 // https://bugzilla.mozilla.org/show_bug.cgi?id=1190687 |
| 94 if ("onCreatedNavigationTarget" in chrome.webNavigation) |
| 92 { | 95 { |
| 93 if (loadingPopups.size == 0) | 96 chrome.webNavigation.onCreatedNavigationTarget.addListener(details => |
| 94 { | 97 { |
| 95 chrome.webRequest.onBeforeRequest.addListener( | 98 if (loadingPopups.size == 0) |
| 96 onPopupURLChanged, | 99 { |
| 97 { | 100 chrome.webRequest.onBeforeRequest.addListener( |
| 98 urls: ["http://*/*", "https://*/*"], | 101 onPopupURLChanged, |
| 99 types: ["main_frame"] | 102 { |
| 100 } | 103 urls: ["http://*/*", "https://*/*"], |
| 101 ); | 104 types: ["main_frame"] |
| 102 chrome.webNavigation.onCommitted.addListener(onPopupURLChanged); | 105 } |
| 103 chrome.webNavigation.onCompleted.addListener(onCompleted); | 106 ); |
| 104 chrome.tabs.onRemoved.addListener(forgetPopup); | 107 chrome.webNavigation.onCommitted.addListener(onPopupURLChanged); |
| 105 } | 108 chrome.webNavigation.onCompleted.addListener(onCompleted); |
| 109 chrome.tabs.onRemoved.addListener(forgetPopup); |
| 110 } |
| 106 | 111 |
| 107 let popup = { | 112 let popup = { |
| 108 url: details.url, | 113 url: details.url, |
| 109 sourcePage: new ext.Page({id: details.sourceTabId}), | 114 sourcePage: new ext.Page({id: details.sourceTabId}), |
| 110 sourceFrame: null | 115 sourceFrame: null |
| 111 }; | 116 }; |
| 112 | 117 |
| 113 loadingPopups.set(details.tabId, popup); | 118 loadingPopups.set(details.tabId, popup); |
| 114 | 119 |
| 115 let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId); | 120 let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
| 116 | 121 |
| 117 if (checkWhitelisted(popup.sourcePage, frame)) | 122 if (checkWhitelisted(popup.sourcePage, frame)) |
| 118 { | 123 { |
| 119 forgetPopup(details.tabId); | 124 forgetPopup(details.tabId); |
| 120 } | 125 } |
| 121 else | 126 else |
| 122 { | 127 { |
| 123 popup.sourceFrame = frame; | 128 popup.sourceFrame = frame; |
| 124 checkPotentialPopup(details.tabId, popup); | 129 checkPotentialPopup(details.tabId, popup); |
| 125 } | 130 } |
| 126 }); | 131 }); |
| 132 } |
| OLD | NEW |