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

Unified Diff: lib/filterComposer.js

Issue 29602561: Issue 5817 - Make sure to send initialization message to the Block Element pop-up only after it is … (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome
Patch Set: Created Nov. 9, 2017, 2:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « composer.postload.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterComposer.js
===================================================================
--- a/lib/filterComposer.js
+++ b/lib/filterComposer.js
@@ -220,28 +220,52 @@ port.on("composer.openDialog", (message,
left: 50,
top: 50,
width: 420,
height: 200,
type: "popup"
}).then(window =>
{
let popupPageId = window.tabs[0].id;
- function onRemoved(removedPageId)
+
+ let doInit = () =>
+ {
+ browser.tabs.sendMessage(popupPageId, {
+ type: "composer.dialog.init",
+ sender: sender.page.id,
+ filters: message.filters
+ });
+ };
+ if (window.tabs[0].status != "complete")
{
- if (popupPageId == removedPageId)
+ let updateListener = (tabId, changeInfo, tab) =>
+ {
+ if (tabId == popupPageId && changeInfo.status == "complete")
+ {
+ browser.tabs.onUpdated.removeListener(updateListener);
+ doInit();
+ }
+ };
+ browser.tabs.onUpdated.addListener(updateListener);
+ }
+ else
+ doInit();
+
+ let onRemoved = removedTabId =>
Wladimir Palant 2017/11/09 14:14:12 The changes after this line aren't strictly necess
kzar 2017/11/10 14:51:50 Acknowledged.
+ {
+ if (removedTabId == popupPageId)
{
sender.page.sendMessage({
type: "composer.content.dialogClosed",
popupId: popupPageId
});
- ext.pages.onRemoved.removeListener(onRemoved);
+ browser.tabs.onRemoved.removeListener(onRemoved);
}
- }
- ext.pages.onRemoved.addListener(onRemoved);
+ };
+ browser.tabs.onRemoved.addListener(onRemoved);
if (require("info").application == "firefox" &&
navigator.oscpu.startsWith("Linux"))
{
// Work around https://bugzil.la/1408446
browser.windows.update(window.id, {width: window.width + 1});
}
return popupPageId;
« no previous file with comments | « composer.postload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld