blob: ccb0884d0e072f09c0b79518bb325f5e92694784 (
plain)
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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check that the application panel only displays service workers from the
* current domain.
*/
const SIMPLE_URL = URL_ROOT + "resources/service-workers/simple.html";
const OTHER_URL = SIMPLE_URL.replace("example.com", "test1.example.com");
const EMPTY_URL = (URL_ROOT + "resources/service-workers/empty.html").replace(
"example.com",
"test2.example.com"
);
add_task(async function () {
await enableApplicationPanel();
const { panel, commands, tab } = await openNewTabAndApplicationPanel(
SIMPLE_URL
);
const doc = panel.panelWin.document;
selectPage(panel, "service-workers");
info("Wait until the service worker appears in the application panel");
await waitUntil(() => getWorkerContainers(doc).length === 1);
let scopeEl = getWorkerContainers(doc)[0].querySelector(".js-sw-scope");
ok(
scopeEl.textContent.startsWith("example.com"),
"First service worker registration is displayed for the correct domain"
);
info(
"Navigate to another page for a different domain with no service worker"
);
await navigateTo(EMPTY_URL);
info("Wait until the service worker list is updated");
await waitUntil(
() => doc.querySelector(".js-registration-list-empty") !== null
);
ok(
true,
"No service workers are shown for an empty page in a different domain."
);
info(
"Navigate to another page for a different domain with another service worker"
);
await navigateTo(OTHER_URL);
info("Wait until the service worker appears in the application panel");
await waitUntil(() => getWorkerContainers(doc).length === 1);
scopeEl = getWorkerContainers(doc)[0].querySelector(".js-sw-scope");
ok(
scopeEl.textContent.startsWith("test1.example.com"),
"Second service worker registration is displayed for the correct domain"
);
await unregisterAllWorkers(commands.client, doc);
// close the tab
info("Closing the tab.");
await BrowserTestUtils.removeTab(tab);
});
|