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

Unified Diff: blockElement.postload.js

Issue 29336576: Issue 2426 - Ensure the top frame gets blockelementPopupId (Closed)
Patch Set: Created Feb. 18, 2016, 9:12 a.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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld