blob: 01d361ca5ec09e2ee59f7c1faffccf500535f2e9 (
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
|
<!DOCTYPE HTML>
<html>
<head>
<title>Check StartupCache</title>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
add_task(async function check_ExtensionParent_StartupCache_is_non_empty() {
// This test aims to verify that the StartupCache of extensions is populated.
// Ideally, we would load an extension, restart the browser and confirm the
// existence of the StartupCache. That is not possible in a mochitest.
// So we will just read the contents of the StartupCache and verify that it
// populated and assume that it carries over to the next startup.
// The latter is checked in test_startup_canary.html
const { WebExtensionPolicy } = SpecialPowers.Cu.getGlobalForObject(SpecialPowers.Services);
// The Mochikit extension is part of the mochitests framework, so the fact
// that this test runs implies that the extension should have been started.
ok(
WebExtensionPolicy.getByID("mochikit@mozilla.org"),
"This test expects the Mochikit extension to be running"
);
let chromeScript = loadChromeScript(() => {
const {
ExtensionParent,
} = ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm");
const { StartupCache } = ExtensionParent;
this.sendAsyncMessage("StartupCache_data", StartupCache._data);
});
let map = await chromeScript.promiseOneMessage("StartupCache_data");
chromeScript.destroy();
// "manifests" is populated by Extension's parseManifest in Extension.jsm.
const keys = ["manifests", "mochikit@mozilla.org", "2.0", "en-US"];
for (let key of keys) {
map = map.get(key);
ok(map, `StartupCache data map contains ${key}`);
}
// At this point `map` is expected to be the return value of
// ExtensionData's parseManifest.
is(
map?.manifest?.applications?.gecko?.id,
"mochikit@mozilla.org",
"StartupCache.manifests contains a parsed manifest"
);
});
</script>
</body>
</html>
|