Backed out changeset b88172246b66 due to Win32 debug failures.
[mozilla-central.git] / xpinstall / tests / browser_signed_tampered.js
blob9a852180dfa5b757882c0e4dd96d045c87dbcf4c
1 // Load in the test harness
2 var scriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
3                              .getService(Components.interfaces.mozIJSSubScriptLoader);
5 var rootDir = getRootDirectory(window.location.href);
6 scriptLoader.loadSubScript(rootDir + "harness.js", this);
8 // ----------------------------------------------------------------------------
9 // Tests installing a signed add-on that has been tampered with after signing.
10 function test() {
11   Harness.installConfirmCallback = confirm_install;
12   Harness.installEndedCallback = check_xpi_install;
13   Harness.installsCompletedCallback = finish_test;
14   Harness.setup();
16   var pm = Services.perms;
17   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
19   var triggers = encodeURIComponent(JSON.stringify({
20     "Tampered Signed XPI": TESTROOT + "signed-tampered.xpi"
21   }));
22   gBrowser.selectedTab = gBrowser.addTab();
23   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
26 function confirm_install(window) {
27   items = window.document.getElementById("itemList").childNodes;
28   is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
29   is(items[0].name, "Tampered Signed XPI", "Should have seen the name from the trigger list");
30   is(items[0].url, TESTROOT + "signed-tampered.xpi", "Should have listed the correct url for the item");
31   is(items[0].cert, "(Object Signer)", "Should have seen the signer");
32   is(items[0].signed, "true", "Should have listed the item as signed");
33   return true;
36 function check_xpi_install(addon, status) {
37   is(status, -260, "Install should fail");
40 function finish_test() {
41   Services.perms.remove("example.com", "install");
43   gBrowser.removeCurrentTab();
44   Harness.finish();