summaryrefslogtreecommitdiffstats
path: root/dom/manifest/test/browser_Manifest_install.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/manifest/test/browser_Manifest_install.js
parentInitial commit. (diff)
downloadthunderbird-59f4b6b6d49b15c5a468f3fe34f3cfa4dd956ce2.tar.xz
thunderbird-59f4b6b6d49b15c5a468f3fe34f3cfa4dd956ce2.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/manifest/test/browser_Manifest_install.js')
-rw-r--r--dom/manifest/test/browser_Manifest_install.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/manifest/test/browser_Manifest_install.js b/dom/manifest/test/browser_Manifest_install.js
new file mode 100644
index 0000000000..d3b949be19
--- /dev/null
+++ b/dom/manifest/test/browser_Manifest_install.js
@@ -0,0 +1,58 @@
+"use strict";
+
+const { Manifests } = ChromeUtils.importESModule(
+ "resource://gre/modules/Manifest.sys.mjs"
+);
+
+const defaultURL = new URL(
+ "http://example.org/browser/dom/manifest/test/resource.sjs"
+);
+defaultURL.searchParams.set("Content-Type", "application/manifest+json");
+
+const manifestMock = JSON.stringify({
+ short_name: "hello World",
+ scope: "/browser/",
+});
+const manifestUrl = `${defaultURL}&body=${manifestMock}`;
+
+function makeTestURL() {
+ const url = new URL(defaultURL);
+ const body = `<link rel="manifest" href='${manifestUrl}'>`;
+ url.searchParams.set("Content-Type", "text/html; charset=utf-8");
+ url.searchParams.set("body", encodeURIComponent(body));
+ return url.href;
+}
+
+add_task(async function () {
+ const tabOptions = { gBrowser, url: makeTestURL() };
+
+ await BrowserTestUtils.withNewTab(tabOptions, async function (browser) {
+ let manifest = await Manifests.getManifest(browser, manifestUrl);
+ is(manifest.installed, false, "We haven't installed this manifest yet");
+
+ await manifest.install(browser);
+ is(manifest.name, "hello World", "Manifest has correct name");
+ is(manifest.installed, true, "Manifest is installed");
+ is(manifest.url, manifestUrl, "has correct url");
+ is(manifest.browser, browser, "has correct browser");
+
+ manifest = await Manifests.getManifest(browser, manifestUrl);
+ is(manifest.installed, true, "New instances are installed");
+
+ manifest = await Manifests.getManifest(browser);
+ is(manifest.installed, true, "Will find manifest without being given url");
+
+ let foundManifest = Manifests.findManifestUrl(
+ "http://example.org/browser/dom/"
+ );
+ is(foundManifest, manifestUrl, "Finds manifests within scope");
+
+ foundManifest = Manifests.findManifestUrl("http://example.org/");
+ is(foundManifest, null, "Does not find manifests outside scope");
+ });
+ // Get the cached one now
+ await BrowserTestUtils.withNewTab(tabOptions, async browser => {
+ const manifest = await Manifests.getManifest(browser, manifestUrl);
+ is(manifest.browser, browser, "has updated browser object");
+ });
+});