Index: blockElement.postload.js |
diff --git a/blockElement.postload.js b/blockElement.postload.js |
index a48fba297083ce78a22d03e24b872172fa4b5334..b58936ed591dea551ba91a47800501b5caa4c762 100644 |
--- a/blockElement.postload.js |
+++ b/blockElement.postload.js |
@@ -387,19 +387,37 @@ function elementPicked(event) |
{ |
type: "blockelement-open-popup" |
}, |
- response => |
+ popupId => |
{ |
- blockelementPopupId = response; |
ext.backgroundPage.sendMessage( |
{ |
type: "forward", |
- targetPageId: blockelementPopupId, |
+ targetPageId: popupId, |
payload: |
{ |
type: "blockelement-popup-init", |
filters: filters |
} |
}); |
+ |
+ // Only the top frame keeps a record of the popup window's ID, |
+ // so if this isn't the top frame we need to pass the ID on. |
+ if (window == window.top) |
+ { |
+ blockelementPopupId = popupId; |
+ } |
+ else |
+ { |
+ ext.backgroundPage.sendMessage( |
+ { |
+ type: "forward", |
+ payload: |
+ { |
+ type: "blockelement-popup-opened", |
+ popupId: popupId |
+ } |
+ }); |
+ } |
}); |
if (selectors.length > 0) |
@@ -544,6 +562,10 @@ if ("ext" in window && document instanceof HTMLDocument) |
lastRightClickEvent = null; |
lastRightClickEventIsMostRecent = false; |
break; |
+ case "blockelement-popup-opened": |
+ if (window == window.top) |
+ blockelementPopupId = msg.popupId; |
+ break; |
case "blockelement-popup-closed": |
// The onRemoved hook for the popup can create a race condition, so we |
// to be careful here. (This is not perfect, but best we can do.) |