1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_signed_trigger.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Tests installing an signed add-on through an InstallTrigger call in web 1.6 +// content. 1.7 +function test() { 1.8 + Harness.installConfirmCallback = confirm_install; 1.9 + Harness.installEndedCallback = install_ended; 1.10 + Harness.installsCompletedCallback = finish_test; 1.11 + Harness.setup(); 1.12 + 1.13 + var pm = Services.perms; 1.14 + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); 1.15 + 1.16 + var triggers = encodeURIComponent(JSON.stringify({ 1.17 + "Signed XPI": TESTROOT + "signed.xpi" 1.18 + })); 1.19 + gBrowser.selectedTab = gBrowser.addTab(); 1.20 + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); 1.21 +} 1.22 + 1.23 +function confirm_install(window) { 1.24 + var items = window.document.getElementById("itemList").childNodes; 1.25 + is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); 1.26 + is(items[0].name, "Signed XPI Test", "Should have seen the name from the trigger list"); 1.27 + is(items[0].url, TESTROOT + "signed.xpi", "Should have listed the correct url for the item"); 1.28 + is(items[0].cert, "(Object Signer)", "Should have seen the signer"); 1.29 + is(items[0].signed, "true", "Should have listed the item as signed"); 1.30 + return true; 1.31 +} 1.32 + 1.33 +function install_ended(install, addon) { 1.34 + install.cancel(); 1.35 +} 1.36 + 1.37 +function finish_test(count) { 1.38 + is(count, 1, "1 Add-on should have been successfully installed"); 1.39 + 1.40 + Services.perms.remove("example.com", "install"); 1.41 + 1.42 + gBrowser.removeCurrentTab(); 1.43 + Harness.finish(); 1.44 +}