fune/browser/base/content/test/urlbar/urlbarAddonIframeContentScript.js
Drew Willcoxon e495512377 Bug 1257550 - Awesomebar result providers should be able to add document fragments or iframes. r=mak
MozReview-Commit-ID: J4aJtETNLoO

--HG--
extra : rebase_source : 1c625cb45eba2df71e2eac2ac9d291dedc7e15d8
2016-12-21 19:14:30 -08:00

23 lines
893 B
JavaScript

// 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);
}