1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Tests that sanitizing history will clear storage access permissions
5 // for sites without cookies or site data.
6 add_task(async function sanitizeStorageAccessPermissions() {
7 let categories = ["history", "historyFormDataAndDownloads"];
9 for (let pref of categories) {
10 await new Promise(resolve => {
11 Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
14 await SiteDataTestUtils.addToIndexedDB("https://sub.example.org");
15 await SiteDataTestUtils.addToCookies({ origin: "https://example.com" });
17 PermissionTestUtils.add(
18 "https://example.org",
20 Services.perms.ALLOW_ACTION
22 PermissionTestUtils.add(
23 "https://example.com",
25 Services.perms.ALLOW_ACTION
27 PermissionTestUtils.add(
30 Services.perms.ALLOW_ACTION
33 // Add some time in between taking the snapshot of the timestamp
34 // to avoid flakyness.
35 // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
36 await new Promise(c => setTimeout(c, 100));
37 let timestamp = Date.now();
38 // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
39 await new Promise(c => setTimeout(c, 100));
41 PermissionTestUtils.add(
44 Services.perms.ALLOW_ACTION
47 await Sanitizer.sanitize([pref], {
48 // Sanitizer and ClearDataService work with time range in PRTime (microseconds)
49 range: [timestamp * 1000, Date.now() * 1000],
53 PermissionTestUtils.testExactPermission(
57 Services.perms.UNKNOWN_ACTION
60 PermissionTestUtils.testExactPermission(
64 Services.perms.ALLOW_ACTION
67 PermissionTestUtils.testExactPermission(
68 "https://example.com",
71 Services.perms.ALLOW_ACTION
74 PermissionTestUtils.testExactPermission(
75 "https://example.org",
78 Services.perms.ALLOW_ACTION
81 await Sanitizer.sanitize([pref]);
84 PermissionTestUtils.testExactPermission(
88 Services.perms.UNKNOWN_ACTION
91 PermissionTestUtils.testExactPermission(
95 Services.perms.UNKNOWN_ACTION
98 PermissionTestUtils.testExactPermission(
99 "https://example.com",
102 Services.perms.ALLOW_ACTION
105 PermissionTestUtils.testExactPermission(
106 "https://example.org",
109 Services.perms.ALLOW_ACTION
112 await Sanitizer.sanitize([pref, "siteSettings"]);
115 PermissionTestUtils.testExactPermission(
119 Services.perms.UNKNOWN_ACTION
122 PermissionTestUtils.testExactPermission(
123 "https://example.com",
126 Services.perms.UNKNOWN_ACTION
129 PermissionTestUtils.testExactPermission(
130 "https://example.org",
133 Services.perms.UNKNOWN_ACTION