michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // ---------------------------------------------------------------------------- michael@0: // Tests that cancelling multiple installs doesn't fail michael@0: function test() { michael@0: Harness.installConfirmCallback = confirm_install; michael@0: Harness.installEndedCallback = install_ended; michael@0: Harness.installsCompletedCallback = finish_test; michael@0: Harness.setup(); michael@0: michael@0: var pm = Services.perms; michael@0: pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); michael@0: michael@0: var triggers = encodeURIComponent(JSON.stringify({ michael@0: "Signed XPI": TESTROOT + "signed.xpi", michael@0: "Signed XPI 2": TESTROOT + "signed2.xpi", michael@0: })); michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); michael@0: } michael@0: michael@0: function get_item(items, url) { michael@0: for (let item of items) { michael@0: if (item.url == url) michael@0: return item; michael@0: } michael@0: ok(false, "Item for " + url + " was not listed"); michael@0: return null; michael@0: } michael@0: michael@0: function confirm_install(window) { michael@0: let items = window.document.getElementById("itemList").childNodes; michael@0: is(items.length, 2, "Should be 2 items listed in the confirmation dialog"); michael@0: let item = get_item(items, TESTROOT + "signed.xpi"); michael@0: if (item) { michael@0: is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); michael@0: is(item.cert, "(Object Signer)", "Should have seen the signer"); michael@0: is(item.signed, "true", "Should have listed the item as signed"); michael@0: } michael@0: item = get_item(items, TESTROOT + "signed2.xpi"); michael@0: if (item) { michael@0: is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); michael@0: is(item.cert, "(Object Signer)", "Should have seen the signer"); michael@0: is(item.signed, "true", "Should have listed the item as signed"); michael@0: } michael@0: return false; michael@0: } michael@0: michael@0: function install_ended(install, addon) { michael@0: ok(false, "Should not have seen installs complete"); michael@0: } michael@0: michael@0: function finish_test(count) { michael@0: is(count, 0, "No add-ons should have been successfully installed"); michael@0: michael@0: Services.perms.remove("example.com", "install"); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: Harness.finish(); michael@0: }