summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js')
-rw-r--r--toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
index 1ce8eb55af..6f788e5122 100644
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
@@ -2,12 +2,21 @@
// Test whether an install succeeds when a valid hash is included in the HTTPS
// request
// This verifies bug 591070
-function test() {
+add_task(async function test_instal_hash_https() {
// This test currently depends on InstallTrigger.install availability.
setInstallTriggerPrefs();
- Harness.installEndedCallback = install_ended;
- Harness.installsCompletedCallback = finish_test;
+ await SpecialPowers.pushPrefEnv({
+ set: [[PREF_INSTALL_REQUIREBUILTINCERTS, false]],
+ });
+
+ const xpiFilePath = getTestFilePath("./amosigned.xpi");
+ const xpiFileHash = await IOUtils.computeHexDigest(xpiFilePath, "sha256");
+
+ const deferredInstallCompleted = Promise.withResolvers();
+
+ Harness.installEndedCallback = (install, addon) => addon.uninstall();
+ Harness.installsCompletedCallback = deferredInstallCompleted.resolve;
Harness.setup();
PermissionTestUtils.add(
@@ -15,13 +24,8 @@ function test() {
"install",
Services.perms.ALLOW_ACTION
);
- Services.prefs.setBoolPref(PREF_INSTALL_REQUIREBUILTINCERTS, false);
- var url = "https://example.com/browser/" + RELATIVE_DIR + "hashRedirect.sjs";
- url +=
- "?sha1:ee95834ad862245a9ef99ccecc2a857cadc16404|" +
- TESTROOT +
- "amosigned.xpi";
+ const url = `https://example.com/browser/${RELATIVE_DIR}hashRedirect.sjs?sha256:${xpiFileHash}|${TESTROOT}amosigned.xpi`;
var triggers = encodeURIComponent(
JSON.stringify({
@@ -38,18 +42,14 @@ function test() {
gBrowser,
TESTROOT + "installtrigger.html?" + triggers
);
-}
-
-function install_ended(install, addon) {
- return addon.uninstall();
-}
-function finish_test(count) {
+ info("Wait for the install to be completed");
+ const count = await deferredInstallCompleted.promise;
is(count, 1, "1 Add-on should have been successfully installed");
PermissionTestUtils.remove("http://example.com", "install");
- Services.prefs.clearUserPref(PREF_INSTALL_REQUIREBUILTINCERTS);
+ await SpecialPowers.popPrefEnv();
gBrowser.removeCurrentTab();
Harness.finish();
-}
+});