browser_aboutdebugging_navigate.js (3773B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* import-globals-from helper-collapsibilities.js */ 7 Services.scriptloader.loadSubScript( 8 CHROME_URL_ROOT + "helper-collapsibilities.js", 9 this 10 ); 11 12 /** 13 * Check that navigating from This Firefox to Connect and back to This Firefox works and 14 * does not leak. 15 */ 16 17 const TAB_URL_1 = "data:text/html,<title>TAB1</title>"; 18 const TAB_URL_2 = "data:text/html,<title>TAB2</title>"; 19 20 add_task(async function () { 21 info("Force all debug target panes to be expanded"); 22 prepareCollapsibilitiesTest(); 23 24 const { document, tab, window } = await openAboutDebugging(); 25 const AboutDebugging = window.AboutDebugging; 26 await selectThisFirefoxPage(document, AboutDebugging.store); 27 28 const connectSidebarItem = findSidebarItemByText("Setup", document); 29 const connectLink = connectSidebarItem.querySelector(".qa-sidebar-link"); 30 ok(connectSidebarItem, "Found the Connect sidebar item"); 31 32 const thisFirefoxString = getThisFirefoxString(window); 33 const thisFirefoxSidebarItem = findSidebarItemByText( 34 thisFirefoxString, 35 document 36 ); 37 const thisFirefoxLink = 38 thisFirefoxSidebarItem.querySelector(".qa-sidebar-link"); 39 ok(thisFirefoxSidebarItem, "Found the ThisFirefox sidebar item"); 40 ok( 41 isSidebarItemSelected(thisFirefoxSidebarItem), 42 "ThisFirefox sidebar item is selected by default" 43 ); 44 45 info("Open a new background tab TAB1"); 46 const backgroundTab1 = await addTab(TAB_URL_1, { background: true }); 47 48 info("Wait for the tab to appear in the debug targets with the correct name"); 49 await waitUntil(() => findDebugTargetByText("TAB1", document)); 50 51 await waitForAboutDebuggingRequests(AboutDebugging.store); 52 info("Click on the Connect item in the sidebar"); 53 connectLink.click(); 54 55 info("Wait until Connect page is displayed"); 56 await waitUntil(() => document.querySelector(".qa-connect-page")); 57 // we need to wait here because the sidebar isn't updated after mounting the page 58 info("Wait until Connect sidebar item is selected"); 59 await waitUntil(() => isSidebarItemSelected(connectSidebarItem)); 60 ok( 61 !document.querySelector(".qa-runtime-page"), 62 "Runtime page no longer rendered" 63 ); 64 65 info("Open a new tab which should be listed when we go back to This Firefox"); 66 const backgroundTab2 = await addTab(TAB_URL_2, { background: true }); 67 68 info("Click on the ThisFirefox item in the sidebar"); 69 const requestsSuccess = waitForRequestsSuccess(AboutDebugging.store); 70 thisFirefoxLink.click(); 71 72 info("Wait for all target requests to complete"); 73 await requestsSuccess; 74 75 info("Wait until ThisFirefox page is displayed"); 76 await waitUntil(() => document.querySelector(".qa-runtime-page")); 77 ok( 78 isSidebarItemSelected(thisFirefoxSidebarItem), 79 "ThisFirefox sidebar item is selected again" 80 ); 81 ok( 82 !document.querySelector(".qa-connect-page"), 83 "Connect page no longer rendered" 84 ); 85 86 info("TAB2 should already be displayed in the debug targets"); 87 await waitUntil(() => findDebugTargetByText("TAB2", document)); 88 89 info("Remove first background tab"); 90 await removeTab(backgroundTab1); 91 92 info( 93 "Check TAB1 disappears, meaning ThisFirefox client is correctly connected" 94 ); 95 await waitUntil(() => !findDebugTargetByText("TAB1", document)); 96 97 info("Remove second background tab"); 98 await removeTab(backgroundTab2); 99 100 info( 101 "Check TAB2 disappears, meaning ThisFirefox client is correctly connected" 102 ); 103 await waitUntil(() => !findDebugTargetByText("TAB2", document)); 104 105 await waitForAboutDebuggingRequests(AboutDebugging.store); 106 107 await removeTab(tab); 108 }); 109 110 function isSidebarItemSelected(item) { 111 return item.classList.contains("qa-sidebar-item-selected"); 112 }