Skip to content

Commit 9c6e65c

Browse files
committed
Bug 1631234 - Part 1: Add a test case to check we won't hit the assertion when we have service workers registered in the tracker who has storage access permission. r=baku
We add a test to ensure we won't hit the assertion here. https://searchfox.org/mozilla-central/rev/a4d62e09a4c46aef918667fa759bf9ae898dc258/dom/clients/manager/ClientSource.cpp#265-268 Differential Revision: https://phabricator.services.mozilla.com/D71564 UltraBlame original commit: 40881736a88ee8e3c2ebbff4091aad6305fac28e
1 parent 98e9f81 commit 9c6e65c

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

toolkit/components/antitracking/test/browser/browser.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ support-files = subResources.sjs
102102
skip-if = fission
103103
support-files = tracker.js
104104
[browser_userInteraction.js]
105+
[browser_serviceWorkersWithStorageAccessGranted.js]
106+
skip-if = fission
105107
[browser_storageAccessDoorHanger.js]
106108
skip-if = fission
107109
[browser_storageAccessPromiseRejectHandlerUserInteraction.js]
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
add_task(async _ => {
12+
13+
PermissionTestUtils.add(
14+
TEST_DOMAIN,
15+
"3rdPartyStorage^https://tracking.example.org",
16+
Services.perms.ALLOW_ACTION
17+
);
18+
19+
registerCleanupFunction(_ => {
20+
Services.perms.removeAll();
21+
});
22+
23+
AntiTracking._createTask({
24+
name:
25+
"Test that we can use service worker if we have the storage access permission",
26+
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
27+
allowList: false,
28+
callback: async _ => {
29+
await navigator.serviceWorker
30+
.register("empty.js")
31+
.then(
32+
_ => {
33+
ok(true, "ServiceWorker can be used!");
34+
},
35+
_ => {
36+
ok(false, "ServiceWorker can be used!");
37+
}
38+
)
39+
.catch(e => ok(false, "Promise rejected: " + e));
40+
},
41+
extraPrefs: [
42+
["dom.serviceWorkers.exemptFromPerDomainMax", true],
43+
["dom.serviceWorkers.enabled", true],
44+
["dom.serviceWorkers.testing.enabled", true],
45+
],
46+
expectedBlockingNotifications: 0,
47+
runInPrivateWindow: false,
48+
iframeSandbox: null,
49+
accessRemoval: null,
50+
callbackAfterRemoval: null,
51+
});
52+
53+
AntiTracking._createTask({
54+
name:
55+
"Test again to check if we can still use service worker without hit the assertion.",
56+
cookieBehavior: BEHAVIOR_REJECT_TRACKER,
57+
allowList: false,
58+
callback: async _ => {
59+
await navigator.serviceWorker
60+
.register("empty.js")
61+
.then(
62+
_ => {
63+
ok(true, "ServiceWorker can be used!");
64+
},
65+
_ => {
66+
ok(false, "ServiceWorker can be used!");
67+
}
68+
)
69+
.catch(e => ok(false, "Promise rejected: " + e));
70+
},
71+
extraPrefs: [
72+
["dom.serviceWorkers.exemptFromPerDomainMax", true],
73+
["dom.serviceWorkers.enabled", true],
74+
["dom.serviceWorkers.testing.enabled", true],
75+
],
76+
expectedBlockingNotifications: 0,
77+
runInPrivateWindow: false,
78+
iframeSandbox: null,
79+
accessRemoval: null,
80+
callbackAfterRemoval: null,
81+
});
82+
});

0 commit comments

Comments
 (0)