1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_signed_tampered.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Tests installing a signed add-on that has been tampered with after signing. 1.6 +function test() { 1.7 + Harness.installConfirmCallback = confirm_install; 1.8 + Harness.downloadFailedCallback = download_failed; 1.9 + Harness.installsCompletedCallback = finish_test; 1.10 + Harness.setup(); 1.11 + 1.12 + var pm = Services.perms; 1.13 + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); 1.14 + 1.15 + var triggers = encodeURIComponent(JSON.stringify({ 1.16 + "Tampered Signed XPI": TESTROOT + "signed-tampered.xpi" 1.17 + })); 1.18 + gBrowser.selectedTab = gBrowser.addTab(); 1.19 + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); 1.20 +} 1.21 + 1.22 +function confirm_install(window) { 1.23 + ok(false, "Should not offer to install"); 1.24 +} 1.25 + 1.26 +function download_failed(install) { 1.27 + is(install.error, AddonManager.ERROR_CORRUPT_FILE, "Install should fail"); 1.28 +} 1.29 + 1.30 +function finish_test(count) { 1.31 + is(count, 0, "No add-ons should have been installed"); 1.32 + Services.perms.remove("example.com", "install"); 1.33 + 1.34 + gBrowser.removeCurrentTab(); 1.35 + Harness.finish(); 1.36 +}