Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // ---------------------------------------------------------------------------- |
michael@0 | 6 | // Tests that cancelling multiple installs doesn't fail |
michael@0 | 7 | function test() { |
michael@0 | 8 | Harness.installConfirmCallback = confirm_install; |
michael@0 | 9 | Harness.installEndedCallback = install_ended; |
michael@0 | 10 | Harness.installsCompletedCallback = finish_test; |
michael@0 | 11 | Harness.setup(); |
michael@0 | 12 | |
michael@0 | 13 | var pm = Services.perms; |
michael@0 | 14 | pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
michael@0 | 15 | |
michael@0 | 16 | var triggers = encodeURIComponent(JSON.stringify({ |
michael@0 | 17 | "Signed XPI": TESTROOT + "signed.xpi", |
michael@0 | 18 | "Signed XPI 2": TESTROOT + "signed2.xpi", |
michael@0 | 19 | })); |
michael@0 | 20 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 21 | gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function get_item(items, url) { |
michael@0 | 25 | for (let item of items) { |
michael@0 | 26 | if (item.url == url) |
michael@0 | 27 | return item; |
michael@0 | 28 | } |
michael@0 | 29 | ok(false, "Item for " + url + " was not listed"); |
michael@0 | 30 | return null; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | function confirm_install(window) { |
michael@0 | 34 | let items = window.document.getElementById("itemList").childNodes; |
michael@0 | 35 | is(items.length, 2, "Should be 2 items listed in the confirmation dialog"); |
michael@0 | 36 | let item = get_item(items, TESTROOT + "signed.xpi"); |
michael@0 | 37 | if (item) { |
michael@0 | 38 | is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); |
michael@0 | 39 | is(item.cert, "(Object Signer)", "Should have seen the signer"); |
michael@0 | 40 | is(item.signed, "true", "Should have listed the item as signed"); |
michael@0 | 41 | } |
michael@0 | 42 | item = get_item(items, TESTROOT + "signed2.xpi"); |
michael@0 | 43 | if (item) { |
michael@0 | 44 | is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); |
michael@0 | 45 | is(item.cert, "(Object Signer)", "Should have seen the signer"); |
michael@0 | 46 | is(item.signed, "true", "Should have listed the item as signed"); |
michael@0 | 47 | } |
michael@0 | 48 | return false; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function install_ended(install, addon) { |
michael@0 | 52 | ok(false, "Should not have seen installs complete"); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function finish_test(count) { |
michael@0 | 56 | is(count, 0, "No add-ons should have been successfully installed"); |
michael@0 | 57 | |
michael@0 | 58 | Services.perms.remove("example.com", "install"); |
michael@0 | 59 | |
michael@0 | 60 | gBrowser.removeCurrentTab(); |
michael@0 | 61 | Harness.finish(); |
michael@0 | 62 | } |