1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Test whether an install fails when the xpi is corrupt. 1.6 +function test() { 1.7 + Harness.downloadFailedCallback = download_failed; 1.8 + Harness.installsCompletedCallback = finish_test; 1.9 + Harness.setup(); 1.10 + 1.11 + var pm = Services.perms; 1.12 + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); 1.13 + 1.14 + var triggers = encodeURIComponent(JSON.stringify({ 1.15 + "Corrupt XPI": TESTROOT + "corrupt.xpi" 1.16 + })); 1.17 + gBrowser.selectedTab = gBrowser.addTab(); 1.18 + gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); 1.19 +} 1.20 + 1.21 +function download_failed(install) { 1.22 + is(install.error, AddonManager.ERROR_CORRUPT_FILE, "Install should fail"); 1.23 +} 1.24 + 1.25 +function finish_test(count) { 1.26 + is(count, 0, "No add-ons should have been installed"); 1.27 + Services.perms.remove("example.com", "install"); 1.28 + 1.29 + var doc = gBrowser.contentDocument; 1.30 + is(doc.getElementById("status").textContent, "-207", "Callback should have seen the failure"); 1.31 + 1.32 + gBrowser.removeCurrentTab(); 1.33 + Harness.finish(); 1.34 +}