browser_session_data_constructor_race.js (1530B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_PAGE = "https://example.com/document-builder.sjs?html=tab"; 7 8 /** 9 * Check that modules created early for session data are still created with a 10 * fully initialized MessageHandler. See Bug 1743083. 11 */ 12 add_task(async function () { 13 const tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE); 14 await BrowserTestUtils.browserLoaded(tab.linkedBrowser); 15 const browsingContext = tab.linkedBrowser.browsingContext; 16 17 const root = createRootMessageHandler("session-id-event"); 18 19 info("Add some session data for the command module"); 20 await root.addSessionDataItem({ 21 moduleName: "command", 22 category: "testCategory", 23 contextDescriptor: contextDescriptorAll, 24 values: ["some-value"], 25 }); 26 27 info("Reload the current tab to create new message handlers and modules"); 28 await BrowserTestUtils.reloadTab(tab); 29 30 info( 31 "Check if the command module was created by the MessageHandler constructor" 32 ); 33 const isCreatedByMessageHandlerConstructor = await root.handleCommand({ 34 moduleName: "command", 35 commandName: "testIsCreatedByMessageHandlerConstructor", 36 destination: { 37 type: WindowGlobalMessageHandler.type, 38 id: browsingContext.id, 39 }, 40 }); 41 42 is( 43 isCreatedByMessageHandlerConstructor, 44 false, 45 "The command module from session data should not be created by the MessageHandler constructor" 46 ); 47 root.destroy(); 48 49 gBrowser.removeTab(tab); 50 });