From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../browser_application_panel_target-switching.js | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 devtools/client/application/test/browser/browser_application_panel_target-switching.js (limited to 'devtools/client/application/test/browser/browser_application_panel_target-switching.js') 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); +}); -- cgit v1.2.3