michael@0: // ---------------------------------------------------------------------------- michael@0: // Test whether an install fails when authentication is required and bad michael@0: // credentials are given michael@0: // This verifies bug 312473 michael@0: function test() { michael@0: requestLongerTimeout(2); michael@0: Harness.authenticationCallback = get_auth_info; michael@0: Harness.downloadFailedCallback = download_failed; 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: "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.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_auth_info() { michael@0: return [ "baduser", "badpass" ]; michael@0: } michael@0: michael@0: function download_failed(install) { michael@0: is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should have failed"); michael@0: } michael@0: michael@0: function install_ended(install, addon) { michael@0: ok(false, "Add-on should not have installed"); michael@0: install.cancel(); michael@0: } michael@0: michael@0: function finish_test(count) { michael@0: is(count, 0, "No add-ons should have been installed"); michael@0: var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1'] michael@0: .getService(Components.interfaces.nsIHttpAuthManager); michael@0: authMgr.clearAll(); michael@0: michael@0: Services.perms.remove("example.com", "install"); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: Harness.finish(); michael@0: }