toolkit/mozapps/extensions/test/xpinstall/browser_auth3.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // ----------------------------------------------------------------------------
     2 // Test whether an install fails when authentication is required and it is
     3 // canceled
     4 // This verifies bug 312473
     5 function test() {
     6   Harness.authenticationCallback = get_auth_info;
     7   Harness.downloadFailedCallback = download_failed;
     8   Harness.installEndedCallback = install_ended;
     9   Harness.installsCompletedCallback = finish_test;
    10   Harness.setup();
    12   var pm = Services.perms;
    13   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
    15   var triggers = encodeURIComponent(JSON.stringify({
    16     "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.xpi"
    17   }));
    18   gBrowser.selectedTab = gBrowser.addTab();
    19   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    20 }
    22 function get_auth_info() {
    23   return null;
    24 }
    26 function download_failed(install) {
    27   is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should have failed");
    28 }
    30 function install_ended(install, addon) {
    31   ok(false, "Add-on should not have installed");
    32   install.cancel();
    33 }
    35 function finish_test(count) {
    36   is(count, 0, "No add-ons should have been installed");
    37   var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1']
    38                           .getService(Components.interfaces.nsIHttpAuthManager);
    39   authMgr.clearAll();
    41   Services.perms.remove("example.com", "install");
    43   gBrowser.removeCurrentTab();
    44   Harness.finish();
    45 }

mercurial