1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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);
});
|