Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 doInitAttempt += 1; | 232 doInitAttempt += 1; |
233 if (doInitAttempt > 3) | 233 if (doInitAttempt > 3) |
234 return; | 234 return; |
235 | 235 |
236 browser.tabs.sendMessage(popupPageId, { | 236 browser.tabs.sendMessage(popupPageId, { |
237 type: "composer.dialog.init", | 237 type: "composer.dialog.init", |
238 sender: sender.page.id, | 238 sender: sender.page.id, |
239 filters: message.filters | 239 filters: message.filters |
240 }).catch(e => | 240 }).catch(e => |
241 { | 241 { |
242 // Firefox 57 sometimes sets the status for a window to "complete" | 242 // Firefox sometimes sets the status for a window to "complete" before |
Wladimir Palant
2017/11/23 11:49:00
Nit: Please drop the version number, we don't know
kzar
2017/11/23 12:31:53
Done.
| |
243 // before it is ready to receive messages[1]. As a workaround we'll | 243 // it is ready to receive messages[1]. As a workaround we'll try again a |
244 // try again a few times with a second delay. | 244 // few times with a second delay. |
245 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1418655 | 245 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1418655 |
246 setTimeout(doInit, 1000); | 246 setTimeout(doInit, 1000); |
kzar
2017/11/21 15:39:20
Initially I retried every 100ms, but then I found
| |
247 }); | 247 }); |
248 }; | 248 }; |
249 if (window.tabs[0].status != "complete") | 249 if (window.tabs[0].status != "complete") |
250 { | 250 { |
251 let updateListener = (tabId, changeInfo, tab) => | 251 let updateListener = (tabId, changeInfo, tab) => |
252 { | 252 { |
253 if (tabId == popupPageId && changeInfo.status == "complete") | 253 if (tabId == popupPageId && changeInfo.status == "complete") |
254 { | 254 { |
255 browser.tabs.onUpdated.removeListener(updateListener); | 255 browser.tabs.onUpdated.removeListener(updateListener); |
256 doInit(); | 256 doInit(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 { | 304 { |
305 return quoteCSS(message.CSS); | 305 return quoteCSS(message.CSS); |
306 }); | 306 }); |
307 | 307 |
308 ext.pages.onLoading.addListener(page => | 308 ext.pages.onLoading.addListener(page => |
309 { | 309 { |
310 // A newly opened tab that is still loading has its URL set to about:blank | 310 // A newly opened tab that is still loading has its URL set to about:blank |
311 if (/^https?:/.test(page.url.protocol)) | 311 if (/^https?:/.test(page.url.protocol)) |
312 page.sendMessage({type: "composer.content.finished"}); | 312 page.sendMessage({type: "composer.content.finished"}); |
313 }); | 313 }); |
LEFT | RIGHT |