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

Side by Side Diff: lib/filterComposer.js

Issue 29613777: Issue 5817 - Retry sending suggested filters to block element dialog (Closed)
Patch Set: Rebased, addressed Wladimir's feedback Created Nov. 23, 2017, 12:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« composer.js ('K') | « composer.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 url: browser.extension.getURL("composer.html"), 219 url: browser.extension.getURL("composer.html"),
220 left: 50, 220 left: 50,
221 top: 50, 221 top: 50,
222 width: 420, 222 width: 420,
223 height: 200, 223 height: 200,
224 type: "popup" 224 type: "popup"
225 }).then(window => 225 }).then(window =>
226 { 226 {
227 let popupPageId = window.tabs[0].id; 227 let popupPageId = window.tabs[0].id;
228 228
229 let doInitAttempt = 0;
229 let doInit = () => 230 let doInit = () =>
230 { 231 {
232 doInitAttempt += 1;
233 if (doInitAttempt > 3)
234 return;
235
231 browser.tabs.sendMessage(popupPageId, { 236 browser.tabs.sendMessage(popupPageId, {
232 type: "composer.dialog.init", 237 type: "composer.dialog.init",
233 sender: sender.page.id, 238 sender: sender.page.id,
234 filters: message.filters 239 filters: message.filters
240 }).catch(e =>
241 {
242 // Firefox sometimes sets the status for a window to "complete" before
243 // it is ready to receive messages[1]. As a workaround we'll try again a
244 // few times with a second delay.
245 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1418655
246 setTimeout(doInit, 1000);
235 }); 247 });
236 }; 248 };
237 if (window.tabs[0].status != "complete") 249 if (window.tabs[0].status != "complete")
238 { 250 {
239 let updateListener = (tabId, changeInfo, tab) => 251 let updateListener = (tabId, changeInfo, tab) =>
240 { 252 {
241 if (tabId == popupPageId && changeInfo.status == "complete") 253 if (tabId == popupPageId && changeInfo.status == "complete")
242 { 254 {
243 browser.tabs.onUpdated.removeListener(updateListener); 255 browser.tabs.onUpdated.removeListener(updateListener);
244 doInit(); 256 doInit();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 { 304 {
293 return quoteCSS(message.CSS); 305 return quoteCSS(message.CSS);
294 }); 306 });
295 307
296 ext.pages.onLoading.addListener(page => 308 ext.pages.onLoading.addListener(page =>
297 { 309 {
298 // 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
299 if (/^https?:/.test(page.url.protocol)) 311 if (/^https?:/.test(page.url.protocol))
300 page.sendMessage({type: "composer.content.finished"}); 312 page.sendMessage({type: "composer.content.finished"});
301 }); 313 });
OLDNEW
« composer.js ('K') | « composer.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld