Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // ----------------------------------------------------------------------------
2 // Test whether an install fails when an invalid hash is included
3 // This verifies bug 302284
4 function test() {
5 Harness.downloadFailedCallback = download_failed;
6 Harness.installsCompletedCallback = finish_test;
7 Harness.setup();
9 var pm = Services.perms;
10 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
12 var triggers = encodeURIComponent(JSON.stringify({
13 "Unsigned XPI": {
14 URL: TESTROOT + "unsigned.xpi",
15 Hash: "sha1:643b08418599ddbd1ea8a511c90696578fb844b9",
16 toString: function() { return this.URL; }
17 }
18 }));
19 gBrowser.selectedTab = gBrowser.addTab();
20 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
21 }
23 function download_failed(install) {
24 is(install.error, AddonManager.ERROR_INCORRECT_HASH, "Install should fail");
25 }
27 function finish_test(count) {
28 is(count, 0, "No add-ons should have been installed");
29 Services.perms.remove("example.com", "install");
31 gBrowser.removeCurrentTab();
32 Harness.finish();
33 }