diff options
Diffstat (limited to 'devtools/client/application/test/browser/browser_application_panel_target-switching.js')
-rw-r--r-- | devtools/client/application/test/browser/browser_application_panel_target-switching.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/devtools/client/application/test/browser/browser_application_panel_target-switching.js b/devtools/client/application/test/browser/browser_application_panel_target-switching.js new file mode 100644 index 0000000000..ff8d521e30 --- /dev/null +++ b/devtools/client/application/test/browser/browser_application_panel_target-switching.js @@ -0,0 +1,68 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Test switching for the top-level target. + +// We use about:robots, because this page will run in the parent process. +// Navigating from about:robots to a regular content page will always trigger +// a target switch, with or without fission. +const PARENT_PROCESS_URI = "about:robots"; +const CONTENT_PROCESS_URI_WORKERS = + URL_ROOT + "resources/service-workers/simple.html"; +const CONTENT_PROCESS_URI_MANIFEST = + URL_ROOT + "resources/manifest/load-ok.html"; + +// test workers when target switching +add_task(async function () { + await enableApplicationPanel(); + + info("Open a page that runs in the parent process"); + const { panel, commands, tab } = await openNewTabAndApplicationPanel( + PARENT_PROCESS_URI + ); + const doc = panel.panelWin.document; + + info("Check for non-existing service worker"); + selectPage(panel, "service-workers"); + const isWorkerListEmpty = !!doc.querySelector(".js-registration-list-empty"); + ok(isWorkerListEmpty, "No Service Worker displayed"); + + info("Navigate to a page that runs in the child process"); + await navigateTo(CONTENT_PROCESS_URI_WORKERS); + + info("Wait until the service worker appears in the application panel"); + await waitUntil(() => getWorkerContainers(doc).length === 1); + + // close the tab + info("Closing the tab."); + await unregisterAllWorkers(commands.client, doc); + await BrowserTestUtils.removeTab(tab); +}); + +// test manifest when target switching +add_task(async function () { + await enableApplicationPanel(); + + info("Open a page that runs in the parent process"); + const { panel, tab } = await openNewTabAndApplicationPanel( + PARENT_PROCESS_URI + ); + const doc = panel.panelWin.document; + + info("Waiting for the 'no manifest' message to appear"); + selectPage(panel, "manifest"); + await waitUntil(() => doc.querySelector(".js-manifest-empty") !== null); + + info("Navigate to a page that runs in the child process"); + await navigateTo(CONTENT_PROCESS_URI_MANIFEST); + + info("Waiting for the manifest to load"); + selectPage(panel, "manifest"); + await waitUntil(() => doc.querySelector(".js-manifest") !== null); + ok(true, "Manifest loaded successfully"); + + // close the tab + info("Closing the tab."); + await BrowserTestUtils.removeTab(tab); +}); |