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-15 15:37:11 +00:00
Родитель e417e5a34d
Коммит 46e166596d
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -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) {