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
|
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<!DOCTYPE HTML>
<html>
<head>
<title>Test browsingData.remove indexedDB</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script type="text/javascript">
"use strict";
// NB: Since plugins are disabled, there is never any data to clear.
// We are really testing that these operations are no-ops.
add_task(async function testPluginData() {
async function background() {
const REFERENCE_DATE = Date.now();
const TEST_CASES = [
// Clear plugin data with no since value.
{},
// Clear pluginData with recent since value.
{ since: REFERENCE_DATE - 20000 },
// Clear pluginData with old since value.
{ since: REFERENCE_DATE - 1000000 },
// Clear pluginData for specific hosts.
{ hostnames: ["bar.com", "baz.com"] },
// Clear pluginData for no hosts.
{ hostnames: [] },
];
for (let method of ["removePluginData", "remove"]) {
for (let options of TEST_CASES) {
browser.test.log(`Testing ${method} with ${JSON.stringify(options)}`);
if (method == "removePluginData") {
await browser.browsingData.removePluginData(options);
} else {
await browser.browsingData.remove(options, { pluginData: true });
}
}
}
browser.test.sendMessage("done");
}
let extension = ExtensionTestUtils.loadExtension({
background,
manifest: {
permissions: ["tabs", "browsingData"],
},
});
await extension.startup();
await extension.awaitMessage("done");
// This test has no assertions because it's only meant to check that we don't
// throw when calling removePluginData and remove with pluginData: true.
ok(true, "dummy check");
await extension.unload();
});
</script>
</body>
</html>
|