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

Delta Between Two Patch Sets: lib/filterComposer.js

Issue 29632569: Issue 6113 - Improve reliability of "block element" dialog (Closed)
Left Patch Set: Created Dec. 7, 2017, 1:17 p.m.
Right Patch Set: Simplify response checking logic Created Dec. 12, 2017, 12:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « composer.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 else 231 else
232 return browser.windows.get(window.id, {populate: true}); 232 return browser.windows.get(window.id, {populate: true});
233 }).then(window => 233 }).then(window =>
234 { 234 {
235 let popupPageId = window.tabs[0].id; 235 let popupPageId = window.tabs[0].id;
236 236
237 let doInitAttempt = 0; 237 let doInitAttempt = 0;
238 let doInit = () => 238 let doInit = () =>
239 { 239 {
240 doInitAttempt += 1; 240 doInitAttempt += 1;
241 if (doInitAttempt > 30) 241 if (doInitAttempt > 30)
kzar 2017/12/07 13:28:33 With other versions of Firefox e.g. 57 I found tha
242 return; 242 return;
243 243
244 browser.tabs.sendMessage(popupPageId, { 244 browser.tabs.sendMessage(popupPageId, {
245 type: "composer.dialog.init", 245 type: "composer.dialog.init",
246 sender: sender.page.id, 246 sender: sender.page.id,
247 filters: message.filters 247 filters: message.filters
248 }).then(response => 248 }).then(response =>
249 { 249 {
250 // Sometimes sendMessage incorrectly reports a success on Firefox, so 250 // Sometimes sendMessage incorrectly reports a success on Firefox, so
251 // we must check the response too. 251 // we must check the response too.
252 if (typeof response == "undefined") 252 if (!response)
Wladimir Palant 2017/12/12 12:14:52 Nit: why not `if (!response)`?
kzar 2017/12/12 12:33:14 Done.
253 throw new Error(); 253 throw new Error();
254 }).catch(e => 254 }).catch(e =>
255 { 255 {
256 // Firefox sometimes sets the status for a window to "complete" before 256 // Firefox sometimes sets the status for a window to "complete" before
257 // it is ready to receive messages[1]. As a workaround we'll try again a 257 // it is ready to receive messages[1]. As a workaround we'll try again a
258 // few times with a second delay. 258 // few times with a second delay.
259 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1418655 259 // [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1418655
260 setTimeout(doInit, 100); 260 setTimeout(doInit, 100);
261 }); 261 });
262 }; 262 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 { 318 {
319 return quoteCSS(message.CSS); 319 return quoteCSS(message.CSS);
320 }); 320 });
321 321
322 ext.pages.onLoading.addListener(page => 322 ext.pages.onLoading.addListener(page =>
323 { 323 {
324 // A newly opened tab that is still loading has its URL set to about:blank 324 // A newly opened tab that is still loading has its URL set to about:blank
325 if (/^https?:/.test(page.url.protocol)) 325 if (/^https?:/.test(page.url.protocol))
326 page.sendMessage({type: "composer.content.finished"}); 326 page.sendMessage({type: "composer.content.finished"});
327 }); 327 });
LEFTRIGHT
« composer.js ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld