browser_application_panel_target-switching.js (2345B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test switching for the top-level target. 6 7 // We use about:robots, because this page will run in the parent process. 8 // Navigating from about:robots to a regular content page will always trigger 9 // a target switch, with or without fission. 10 const PARENT_PROCESS_URI = "about:robots"; 11 const CONTENT_PROCESS_URI_WORKERS = 12 URL_ROOT + "resources/service-workers/simple.html"; 13 const CONTENT_PROCESS_URI_MANIFEST = 14 URL_ROOT + "resources/manifest/load-ok.html"; 15 16 // test workers when target switching 17 add_task(async function () { 18 await enableApplicationPanel(); 19 20 info("Open a page that runs in the parent process"); 21 const { panel, commands, tab } = 22 await openNewTabAndApplicationPanel(PARENT_PROCESS_URI); 23 const doc = panel.panelWin.document; 24 25 info("Check for non-existing service worker"); 26 selectPage(panel, "service-workers"); 27 const isWorkerListEmpty = !!doc.querySelector(".js-registration-list-empty"); 28 ok(isWorkerListEmpty, "No Service Worker displayed"); 29 30 info("Navigate to a page that runs in the child process"); 31 await navigateTo(CONTENT_PROCESS_URI_WORKERS); 32 33 info("Wait until the service worker appears in the application panel"); 34 await waitUntil(() => getWorkerContainers(doc).length === 1); 35 36 // close the tab 37 info("Closing the tab."); 38 await unregisterAllWorkers(commands.client, doc); 39 await BrowserTestUtils.removeTab(tab); 40 }); 41 42 // test manifest when target switching 43 add_task(async function () { 44 await enableApplicationPanel(); 45 46 info("Open a page that runs in the parent process"); 47 const { panel, tab } = 48 await openNewTabAndApplicationPanel(PARENT_PROCESS_URI); 49 const doc = panel.panelWin.document; 50 51 info("Waiting for the 'no manifest' message to appear"); 52 selectPage(panel, "manifest"); 53 await waitUntil(() => doc.querySelector(".js-manifest-empty") !== null); 54 55 info("Navigate to a page that runs in the child process"); 56 await navigateTo(CONTENT_PROCESS_URI_MANIFEST); 57 58 info("Waiting for the manifest to load"); 59 selectPage(panel, "manifest"); 60 await waitUntil(() => doc.querySelector(".js-manifest") !== null); 61 ok(true, "Manifest loaded successfully"); 62 63 // close the tab 64 info("Closing the tab."); 65 await BrowserTestUtils.removeTab(tab); 66 });