browser_two_tabs_with_params.js (1458B)
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 add_task(async function test_broadcasting_two_tabs_with_params_command() { 9 info("Navigate the initial tab to the test URL"); 10 const tab1 = gBrowser.selectedTab; 11 await loadURL(tab1.linkedBrowser, TEST_PAGE); 12 const browsingContext1 = tab1.linkedBrowser.browsingContext; 13 14 info("Open a new tab on the same test URL"); 15 const tab2 = await addTab(TEST_PAGE); 16 const browsingContext2 = tab2.linkedBrowser.browsingContext; 17 18 const rootMessageHandler = createRootMessageHandler( 19 "session-id-broadcasting_two_tabs_command" 20 ); 21 22 const broadcastValue = await sendTestBroadcastCommand( 23 "commandwindowglobalonly", 24 "testBroadcastWithParameter", 25 { 26 value: "some-value", 27 }, 28 contextDescriptorAll, 29 rootMessageHandler 30 ); 31 ok( 32 Array.isArray(broadcastValue), 33 "The broadcast returned an array of values" 34 ); 35 36 is(broadcastValue.length, 2, "The broadcast returned 2 values as expected"); 37 38 ok( 39 broadcastValue.includes("broadcast-" + browsingContext1.id + "-some-value"), 40 "The broadcast returned the expected value from tab1" 41 ); 42 ok( 43 broadcastValue.includes("broadcast-" + browsingContext2.id + "-some-value"), 44 "The broadcast returned the expected value from tab2" 45 ); 46 rootMessageHandler.destroy(); 47 });