| Left: | ||
| Right: |
| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 } | 118 } |
| 119 catch (error) | 119 catch (error) |
| 120 { | 120 { |
| 121 } | 121 } |
| 122 | 122 |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 if (shouldWrapAPIs()) | 126 if (shouldWrapAPIs()) |
| 127 { | 127 { |
| 128 // Unlike Firefox and Microsoft Edge, Chrome doesn't have a "browser" object , | 128 // Unlike Firefox and Microsoft Edge, Chrome doesn't have a "browser" |
|
Manish Jethani
2017/10/23 02:32:45
Unrelated, but there's an ESLint error here becaus
| |
| 129 // but provides the extension API through the "chrome" namespace | 129 // object, but provides the extension API through the "chrome" namespace |
| 130 // (non-standard). | 130 // (non-standard). |
| 131 if (typeof browser == "undefined") | 131 if (typeof browser == "undefined") |
| 132 window.browser = chrome; | 132 window.browser = chrome; |
| 133 | 133 |
| 134 for (let api of asyncAPIs) | 134 for (let api of asyncAPIs) |
| 135 wrapAPI(api); | 135 wrapAPI(api); |
| 136 | |
| 137 let {addListener} = browser.runtime.onMessage; | |
| 138 browser.runtime.onMessage.addListener = function(listener) | |
| 139 { | |
| 140 addListener.call(browser.runtime.onMessage, ( | |
| 141 message, sender, sendResponse | |
| 142 ) => | |
| 143 { | |
| 144 let wait = listener(message, sender, sendResponse); | |
| 145 | |
| 146 if (wait instanceof Promise) | |
|
Manish Jethani
2017/10/23 02:32:45
There's no need to add a catch handler, Chrome (an
Wladimir Palant
2017/10/23 08:53:26
Not really, the message clearly says that not hand
Manish Jethani
2017/10/23 12:21:04
Did you mean that Chrome will no longer do this au
| |
| 147 wait.then(sendResponse); | |
| 148 | |
| 149 return !!wait; | |
| 150 }); | |
| 151 }; | |
|
Wladimir Palant
2017/10/23 08:53:26
You have a problem here, removeListener will no lo
Manish Jethani
2017/10/23 12:21:04
Done.
| |
| 136 } | 152 } |
| 137 | 153 |
| 138 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList | 154 // Workaround since HTMLCollection, NodeList, StyleSheetList, and CSSRuleList |
| 139 // didn't have iterator support before Chrome 51. | 155 // didn't have iterator support before Chrome 51. |
| 140 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 | 156 // https://bugs.chromium.org/p/chromium/issues/detail?id=401699 |
| 141 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) | 157 for (let object of [HTMLCollection, NodeList, StyleSheetList, CSSRuleList]) |
| 142 { | 158 { |
| 143 if (!(Symbol.iterator in object.prototype)) | 159 if (!(Symbol.iterator in object.prototype)) |
| 144 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; | 160 object.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; |
| 145 } | 161 } |
| 146 } | 162 } |
| OLD | NEW |