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 --- .../test/browser/browser_aboutdebugging_routes.js | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js (limited to 'devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js') diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js new file mode 100644 index 0000000000..6295d37503 --- /dev/null +++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js @@ -0,0 +1,114 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Test that the initial route is /setup + */ +add_task(async function () { + info("Check root route redirects to setup page"); + const { document, tab } = await openAboutDebugging(); + is(document.location.hash, "#/setup"); + + await removeTab(tab); +}); + +/** + * Test that the routes in about:debugging show the proper views and document.title + */ +add_task(async function () { + // enable USB devices mocks + const mocks = new Mocks(); + + const { document, tab } = await openAboutDebugging(); + + info("Check 'This Firefox' route"); + document.location.hash = "#/runtime/this-firefox"; + await waitUntil(() => document.querySelector(".qa-runtime-page")); + const infoLabel = document.querySelector(".qa-runtime-name").textContent; + // NOTE: when using USB Mocks, we see only "Firefox" as the device name + ok(infoLabel.includes("Firefox"), "Runtime is displayed as Firefox"); + ok(!infoLabel.includes(" on "), "Runtime is not associated to any device"); + is( + document.title, + "Debugging - Runtime / this-firefox", + "Checking title for 'runtime' page" + ); + + info("Check 'Setup' page"); + document.location.hash = "#/setup"; + await waitUntil(() => document.querySelector(".qa-connect-page")); + ok(true, "Setup page has been shown"); + is(document.title, "Debugging - Setup", "Checking title for 'setup' page"); + + info("Check 'USB device runtime' page"); + // connect to a mocked USB runtime + mocks.createUSBRuntime("1337id", { + deviceName: "Fancy Phone", + name: "Lorem ipsum", + }); + mocks.emitUSBUpdate(); + await connectToRuntime("Fancy Phone", document); + // navigate to it via URL + document.location.hash = "#/runtime/1337id"; + await waitUntil(() => document.querySelector(".qa-runtime-page")); + const runtimeLabel = document.querySelector(".qa-runtime-name").textContent; + is( + document.title, + "Debugging - Runtime / 1337id", + "Checking title for 'runtime' page with USB device" + ); + ok( + runtimeLabel.includes("Lorem ipsum"), + "Runtime is displayed with the mocked name" + ); + + await removeTab(tab); +}); + +/** + * Test that an invalid route redirects to / (currently This Firefox page) + */ +add_task(async function () { + info("Check an invalid route redirects to root"); + const { document, tab } = await openAboutDebugging(); + + info("Waiting for a non setup page to load"); + document.location.hash = "#/runtime/this-firefox"; + await waitUntil(() => document.querySelector(".qa-runtime-page")); + + info("Update hash & wait for a redirect to root (connect page)"); + document.location.hash = "#/lorem-ipsum"; + await waitUntil(() => document.querySelector(".qa-connect-page")); + is(document.title, "Debugging - Setup", "Checking title for 'setup' page"); + is(document.location.hash, "#/setup", "Redirected to root"); + + await removeTab(tab); +}); + +/** + * Test that routes from old about:debugging redirect to this Firefox. + */ +add_task(async function testOldAboutDebuggingRoutes() { + info("Check that routes from old about:debugging redirect to this Firefox"); + const { document, tab } = await openAboutDebugging(); + + const routes = ["addons", "tabs", "workers"]; + for (const route of routes) { + info("Move to setup page before testing the route"); + document.location.hash = "#/setup"; + await waitUntil(() => document.querySelector(".qa-connect-page")); + + info(`Check that navigating to ${route} redirects to This Firefox`); + document.location.hash = route; + await waitUntil(() => document.querySelector(".qa-runtime-page")); + is( + document.location.hash, + "#/runtime/this-firefox", + `${route} was redirected to This Firefox` + ); + } + + await removeTab(tab); +}); -- cgit v1.2.3