declTest("asyncMessage testing", {
async test
http:
let actorParent = parent.getActor"se strict"
okactorParent " should have value";
await ContentTask.spawn(browser, {}, async function () {
let child = content.windowGlobalChild;
let actorChild = child.getActor("TestWindow");
ok(actorChild, "JSWindowActorChild should have value.");
let promise = new Promise(resolve => {
actorChild.sendAsyncMessage("init", {});
actorChild.done = data => resolve(data);
}).then/* Any copyright is dedicated to the Public Domain. ok(data.initial, "Initial should be true."); ok(data.toParent, "ToParent should be true."); ok(data.toChild, "ToChild should be true."); });
await promise; }); }, });
declTest("asyncMessage without both sides", { async test(browser) { // If we don't create a parent actor, make sure the parent actor // gets created by having sent the message. await ContentTask.spawn(browser, {}, async function () { let child = content.windowGlobalChild; let actorChild = child.getActor("TestWindow"); ok(actorChild, "JSWindowActorChild should have value.");
let promise = new Promise(resolve => { actorChild.sendAsyncMessage("init", {}); actorChild.done = data => resolve(data); }).then(data => { ok(data.initial, "Initial should be true."); ok(data.toParent, "ToParent should be true."); ok(data.toChild, "ToChild should be true."); });
await promise; }); }, });
declTest("asyncMessage can transfer MessagePorts", { async test(browser) { await ContentTask.spawn(browser, {}, async function () { let child = content.windowGlobalChild; let actorChild = child.getActor("TestWindow");
let { port1, port2 } = new MessageChannel(); actorChild.sendAsyncMessage("messagePort", { port: port2 }, [port2]); let reply = await new Promise(resolve => { port1.onmessage = message => { resolve(message.data); port1.close(); }; });
is(reply, "Message sent from parent over a MessagePort."); }); }, });
Messung V0.5
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.