1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_signed_naming.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Tests that the correct signer is presented for combinations of O and CN present. 1.6 +// The signed files have (when present) O=Mozilla Testing, CN=Object Signer 1.7 +// This verifies bug 372980 1.8 +function test() { 1.9 + Harness.installConfirmCallback = confirm_install; 1.10 + Harness.installEndedCallback = install_ended; 1.11 + Harness.installsCompletedCallback = finish_test; 1.12 + Harness.setup(); 1.13 + 1.14 + var pm = Services.perms; 1.15 + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); 1.16 + 1.17 + var triggers = encodeURIComponent(JSON.stringify({ 1.18 + "Signed XPI (O and CN)": TESTROOT + "signed.xpi", 1.19 + "Signed XPI (CN)": TESTROOT + "signed-no-o.xpi", 1.20 + "Signed XPI (O)": TESTROOT + "signed-no-cn.xpi", 1.21 + })); 1.22 + gBrowser.selectedTab = gBrowser.addTab(); 1.23 + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); 1.24 +} 1.25 + 1.26 +function get_item(items, url) { 1.27 + for (let item of items) { 1.28 + if (item.url == url) 1.29 + return item; 1.30 + } 1.31 + ok(false, "Item for " + url + " was not listed"); 1.32 + return null; 1.33 +} 1.34 + 1.35 +function confirm_install(window) { 1.36 + let items = window.document.getElementById("itemList").childNodes; 1.37 + is(items.length, 3, "Should be 3 items listed in the confirmation dialog"); 1.38 + let item = get_item(items, TESTROOT + "signed.xpi"); 1.39 + if (item) { 1.40 + is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); 1.41 + is(item.cert, "(Object Signer)", "Should have seen the signer"); 1.42 + is(item.signed, "true", "Should have listed the item as signed"); 1.43 + } 1.44 + item = get_item(items, TESTROOT + "signed-no-o.xpi"); 1.45 + if (item) { 1.46 + is(item.name, "Signed XPI Test (No Org)", "Should have seen the name from the trigger list"); 1.47 + is(item.cert, "(Object Signer)", "Should have seen the signer"); 1.48 + is(item.signed, "true", "Should have listed the item as signed"); 1.49 + } 1.50 + item = get_item(items, TESTROOT + "signed-no-cn.xpi"); 1.51 + if (item) { 1.52 + is(item.name, "Signed XPI Test (No Common Name)", "Should have seen the name from the trigger list"); 1.53 + is(item.cert, "(Mozilla Testing)", "Should have seen the signer"); 1.54 + is(item.signed, "true", "Should have listed the item as signed"); 1.55 + } 1.56 + return true; 1.57 +} 1.58 + 1.59 +function install_ended(install, addon) { 1.60 + install.cancel(); 1.61 +} 1.62 + 1.63 +function finish_test(count) { 1.64 + is(count, 3, "3 Add-ons should have been successfully installed"); 1.65 + 1.66 + Services.perms.remove("example.com", "install"); 1.67 + 1.68 + gBrowser.removeCurrentTab(); 1.69 + Harness.finish(); 1.70 +}