summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/mochitest/test_check_startupcache.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /toolkit/components/extensions/test/mochitest/test_check_startupcache.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/test/mochitest/test_check_startupcache.html')
-rw-r--r--toolkit/components/extensions/test/mochitest/test_check_startupcache.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/toolkit/components/extensions/test/mochitest/test_check_startupcache.html b/toolkit/components/extensions/test/mochitest/test_check_startupcache.html
new file mode 100644
index 0000000000..8cb529d18d
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_check_startupcache.html
@@ -0,0 +1,63 @@
+<!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.importESModule(
+ "resource://gre/modules/ExtensionParent.sys.mjs"
+ );
+ 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>