Bug 1607984 - P11. Don't assume the page will be loaded synchronously. r=zombie

We must wait for the iframe created by extension1 to be fully loaded before we can attempt to send a message to it.
So we send a message when it is ready, and suspend the execution until this message is received.

Differential Revision: https://phabricator.services.mozilla.com/D70008
This commit is contained in:
Jean-Yves Avenard 2020-04-24 01:58:23 +00:00
parent 11eba58643
commit 9301368189

View File

@ -22,6 +22,8 @@ add_task(async function() {
browser.runtime.onMessage.addListener((msg, sender) => {
browser.test.sendMessage("received-page", { msg, sender });
});
// Let them know we're done loading the page.
browser.test.sendMessage("page-ready");
},
"page.html": `<!DOCTYPE html><meta charset="utf-8"><script src="page.js"></script>`,
},
@ -37,6 +39,7 @@ add_task(async function() {
});
await Promise.all([extension1.startup(), extension2.startup()]);
await extension1.awaitMessage("page-ready");
// Check that a message was sent within extension1.
async function checkLocalMessage(msg) {