summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpinstall/browser_httphash.js
diff options
context:
space:
mode:
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();
-}
+});