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 | // ---------------------------------------------------------------------------- |
michael@0 | 2 | // Tests that the correct signer is presented for combinations of O and CN present. |
michael@0 | 3 | // The signed files have (when present) O=Mozilla Testing, CN=Object Signer |
michael@0 | 4 | // This verifies bug 372980 |
michael@0 | 5 | function test() { |
michael@0 | 6 | Harness.installConfirmCallback = confirm_install; |
michael@0 | 7 | Harness.installEndedCallback = install_ended; |
michael@0 | 8 | Harness.installsCompletedCallback = finish_test; |
michael@0 | 9 | Harness.setup(); |
michael@0 | 10 | |
michael@0 | 11 | var pm = Services.perms; |
michael@0 | 12 | pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
michael@0 | 13 | |
michael@0 | 14 | var triggers = encodeURIComponent(JSON.stringify({ |
michael@0 | 15 | "Signed XPI (O and CN)": TESTROOT + "signed.xpi", |
michael@0 | 16 | "Signed XPI (CN)": TESTROOT + "signed-no-o.xpi", |
michael@0 | 17 | "Signed XPI (O)": TESTROOT + "signed-no-cn.xpi", |
michael@0 | 18 | })); |
michael@0 | 19 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 20 | gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function get_item(items, url) { |
michael@0 | 24 | for (let item of items) { |
michael@0 | 25 | if (item.url == url) |
michael@0 | 26 | return item; |
michael@0 | 27 | } |
michael@0 | 28 | ok(false, "Item for " + url + " was not listed"); |
michael@0 | 29 | return null; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function confirm_install(window) { |
michael@0 | 33 | let items = window.document.getElementById("itemList").childNodes; |
michael@0 | 34 | is(items.length, 3, "Should be 3 items listed in the confirmation dialog"); |
michael@0 | 35 | let item = get_item(items, TESTROOT + "signed.xpi"); |
michael@0 | 36 | if (item) { |
michael@0 | 37 | is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); |
michael@0 | 38 | is(item.cert, "(Object Signer)", "Should have seen the signer"); |
michael@0 | 39 | is(item.signed, "true", "Should have listed the item as signed"); |
michael@0 | 40 | } |
michael@0 | 41 | item = get_item(items, TESTROOT + "signed-no-o.xpi"); |
michael@0 | 42 | if (item) { |
michael@0 | 43 | is(item.name, "Signed XPI Test (No Org)", "Should have seen the name from the trigger list"); |
michael@0 | 44 | is(item.cert, "(Object Signer)", "Should have seen the signer"); |
michael@0 | 45 | is(item.signed, "true", "Should have listed the item as signed"); |
michael@0 | 46 | } |
michael@0 | 47 | item = get_item(items, TESTROOT + "signed-no-cn.xpi"); |
michael@0 | 48 | if (item) { |
michael@0 | 49 | is(item.name, "Signed XPI Test (No Common Name)", "Should have seen the name from the trigger list"); |
michael@0 | 50 | is(item.cert, "(Mozilla Testing)", "Should have seen the signer"); |
michael@0 | 51 | is(item.signed, "true", "Should have listed the item as signed"); |
michael@0 | 52 | } |
michael@0 | 53 | return true; |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function install_ended(install, addon) { |
michael@0 | 57 | install.cancel(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function finish_test(count) { |
michael@0 | 61 | is(count, 3, "3 Add-ons should have been successfully installed"); |
michael@0 | 62 | |
michael@0 | 63 | Services.perms.remove("example.com", "install"); |
michael@0 | 64 | |
michael@0 | 65 | gBrowser.removeCurrentTab(); |
michael@0 | 66 | Harness.finish(); |
michael@0 | 67 | } |