fune/browser/base/content/test/urlbar/urlbarAddonIframeContentScript.js
Mark Banner 733f0b7c97 Bug 1338195 - Define a frame-script environment for eslint and use it to clear no-undef issues for known frame script globals. r=mossop
MozReview-Commit-ID: Fcin4InbLK2

--HG--
extra : rebase_source : f94dbb2e5af83bb4d32c51a55702e6f58cc25323
2017-02-07 10:52:06 +00:00

25 lines
932 B
JavaScript

/* eslint-env mozilla/frame-script */
// Forward messages from the test to the iframe as events.
addMessageListener("TestMessage", msg => {
content.dispatchEvent(new content.CustomEvent("TestEvent", {
detail: Components.utils.cloneInto(msg.data, content),
}));
});
// Forward events from the iframe to the test as messages.
addEventListener("TestEventAck", event => {
// The waiveXrays call is copied from the contentSearch.js part of
// browser_ContentSearch.js test. Not sure whether it's necessary here.
sendAsyncMessage("TestMessageAck", Components.utils.waiveXrays(event.detail));
}, true, true);
// Send a message to the test when the iframe is loaded.
if (content.document.readyState == "complete") {
sendAsyncMessage("TestIframeLoadAck");
} else {
addEventListener("load", function onLoad(event) {
removeEventListener("load", onLoad);
sendAsyncMessage("TestIframeLoadAck");
}, true, true);
}