summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js')
-rw-r--r--devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_routes.js114
1 files changed, 114 insertions, 0 deletions
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);
+});