1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_cancel.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// ---------------------------------------------------------------------------- 1.9 +// Tests that cancelling multiple installs doesn't fail 1.10 +function test() { 1.11 + Harness.installConfirmCallback = confirm_install; 1.12 + Harness.installEndedCallback = install_ended; 1.13 + Harness.installsCompletedCallback = finish_test; 1.14 + Harness.setup(); 1.15 + 1.16 + var pm = Services.perms; 1.17 + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); 1.18 + 1.19 + var triggers = encodeURIComponent(JSON.stringify({ 1.20 + "Signed XPI": TESTROOT + "signed.xpi", 1.21 + "Signed XPI 2": TESTROOT + "signed2.xpi", 1.22 + })); 1.23 + gBrowser.selectedTab = gBrowser.addTab(); 1.24 + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); 1.25 +} 1.26 + 1.27 +function get_item(items, url) { 1.28 + for (let item of items) { 1.29 + if (item.url == url) 1.30 + return item; 1.31 + } 1.32 + ok(false, "Item for " + url + " was not listed"); 1.33 + return null; 1.34 +} 1.35 + 1.36 +function confirm_install(window) { 1.37 + let items = window.document.getElementById("itemList").childNodes; 1.38 + is(items.length, 2, "Should be 2 items listed in the confirmation dialog"); 1.39 + let item = get_item(items, TESTROOT + "signed.xpi"); 1.40 + if (item) { 1.41 + is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); 1.42 + is(item.cert, "(Object Signer)", "Should have seen the signer"); 1.43 + is(item.signed, "true", "Should have listed the item as signed"); 1.44 + } 1.45 + item = get_item(items, TESTROOT + "signed2.xpi"); 1.46 + if (item) { 1.47 + is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); 1.48 + is(item.cert, "(Object Signer)", "Should have seen the signer"); 1.49 + is(item.signed, "true", "Should have listed the item as signed"); 1.50 + } 1.51 + return false; 1.52 +} 1.53 + 1.54 +function install_ended(install, addon) { 1.55 + ok(false, "Should not have seen installs complete"); 1.56 +} 1.57 + 1.58 +function finish_test(count) { 1.59 + is(count, 0, "No add-ons should have been successfully installed"); 1.60 + 1.61 + Services.perms.remove("example.com", "install"); 1.62 + 1.63 + gBrowser.removeCurrentTab(); 1.64 + Harness.finish(); 1.65 +}