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 an unsigned add-on through an InstallTrigger call in web
10 // content. This should be blocked by the whitelist check.
11 // This verifies bug 252830
13 Harness.installConfirmCallback = confirm_install;
14 Harness.installBlockedCallback = allow_blocked;
15 Harness.installEndedCallback = check_xpi_install;
16 Harness.installsCompletedCallback = finish_test;
19 var triggers = encodeURIComponent(JSON.stringify({
20 "Unsigned XPI": TESTROOT + "unsigned.xpi"
22 gBrowser.selectedTab = gBrowser.addTab();
23 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
26 function allow_blocked(installInfo) {
27 is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window");
28 is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
32 function confirm_install(window) {
33 items = window.document.getElementById("itemList").childNodes;
34 is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
35 is(items[0].name, "Unsigned XPI", "Should have seen the name from the trigger list");
36 is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
37 is(items[0].signed, "false", "Should have listed the item as unsigned");
41 function check_xpi_install(addon, status) {
42 is(status, 0, "Install should succeed");
45 function finish_test() {
46 var em = Components.classes["@mozilla.org/extensions/manager;1"]
47 .getService(Components.interfaces.nsIExtensionManager);
48 em.cancelInstallItem("unsigned-xpi@tests.mozilla.org");
50 gBrowser.removeCurrentTab();
53 // ----------------------------------------------------------------------------