Index: lib/filterComposer.js |
diff --git a/lib/filterComposer.js b/lib/filterComposer.js |
index fe6d51eb9b0bb32f0fc574dced0c2b81a39a3352..3759ca58e9875ccaa175310f6bd9dab52285b7dd 100644 |
--- a/lib/filterComposer.js |
+++ b/lib/filterComposer.js |
@@ -238,20 +238,26 @@ port.on("composer.openDialog", (message, sender) => |
let doInit = () => |
{ |
doInitAttempt += 1; |
- if (doInitAttempt > 3) |
+ if (doInitAttempt > 30) |
return; |
browser.tabs.sendMessage(popupPageId, { |
type: "composer.dialog.init", |
sender: sender.page.id, |
filters: message.filters |
+ }).then(response => |
+ { |
+ // Sometimes sendMessage incorrectly reports a success on Firefox, so |
+ // we must check the response too. |
+ if (!response) |
+ throw new Error(); |
}).catch(e => |
{ |
// Firefox sometimes sets the status for a window to "complete" before |
// it is ready to receive messages[1]. As a workaround we'll try again a |
// few times with a second delay. |
// [1] - https://bugzilla.mozilla.org/show_bug.cgi?id=1418655 |
- setTimeout(doInit, 1000); |
+ setTimeout(doInit, 100); |
}); |
}; |
if (window.tabs[0].status != "complete") |