michael@0: // ---------------------------------------------------------------------------- michael@0: // Tests that the correct signer is presented for combinations of O and CN present. michael@0: // The signed files have (when present) O=Mozilla Testing, CN=Object Signer michael@0: // This verifies bug 372980 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 (O and CN)": TESTROOT + "signed.xpi", michael@0: "Signed XPI (CN)": TESTROOT + "signed-no-o.xpi", michael@0: "Signed XPI (O)": TESTROOT + "signed-no-cn.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, 3, "Should be 3 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 + "signed-no-o.xpi"); michael@0: if (item) { michael@0: is(item.name, "Signed XPI Test (No Org)", "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 + "signed-no-cn.xpi"); michael@0: if (item) { michael@0: is(item.name, "Signed XPI Test (No Common Name)", "Should have seen the name from the trigger list"); michael@0: is(item.cert, "(Mozilla Testing)", "Should have seen the signer"); michael@0: is(item.signed, "true", "Should have listed the item as signed"); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: function install_ended(install, addon) { michael@0: install.cancel(); michael@0: } michael@0: michael@0: function finish_test(count) { michael@0: is(count, 3, "3 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: }