head.js (1859B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /** 5 * Provide infrastructure for JSWindowActor tests. 6 */ 7 8 const URL = "about:blank"; 9 const TEST_URL = "http://test2.example.org/"; 10 let windowActorOptions = { 11 parent: { 12 esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs", 13 }, 14 child: { 15 esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs", 16 }, 17 }; 18 19 function declTest(name, cfg) { 20 let { 21 url = "about:blank", 22 allFrames = false, 23 includeChrome = false, 24 matches, 25 remoteTypes, 26 messageManagerGroups, 27 events, 28 observers, 29 test, 30 } = cfg; 31 32 // Build the actor options object which will be used to register & unregister 33 // our window actor. 34 let actorOptions = { 35 parent: { ...windowActorOptions.parent }, 36 child: { ...windowActorOptions.child, events, observers }, 37 }; 38 actorOptions.allFrames = allFrames; 39 actorOptions.includeChrome = includeChrome; 40 if (matches !== undefined) { 41 actorOptions.matches = matches; 42 } 43 if (remoteTypes !== undefined) { 44 actorOptions.remoteTypes = remoteTypes; 45 } 46 if (messageManagerGroups !== undefined) { 47 actorOptions.messageManagerGroups = messageManagerGroups; 48 } 49 50 // Add a new task for the actor test declared here. 51 add_task(async function () { 52 info("Entering test: " + name); 53 54 // Register our actor, and load a new tab with the relevant URL 55 ChromeUtils.registerWindowActor("TestWindow", actorOptions); 56 try { 57 await BrowserTestUtils.withNewTab(url, async browser => { 58 info("browser ready"); 59 await Promise.resolve(test(browser, window)); 60 }); 61 } finally { 62 // Unregister the actor after the test is complete. 63 ChromeUtils.unregisterWindowActor("TestWindow"); 64 info("Exiting test: " + name); 65 } 66 }); 67 }