Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // ----------------------------------------------------------------------------
2 // Test whether an install succeeds when authentication is required
3 // This verifies bug 312473
4 function test() {
5 Harness.authenticationCallback = get_auth_info;
6 Harness.downloadFailedCallback = download_failed;
7 Harness.installEndedCallback = install_ended;
8 Harness.installsCompletedCallback = finish_test;
9 Harness.setup();
11 var pm = Services.perms;
12 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
14 var triggers = encodeURIComponent(JSON.stringify({
15 "Unsigned XPI": TESTROOT + "authRedirect.sjs?" + TESTROOT + "unsigned.xpi"
16 }));
17 gBrowser.selectedTab = gBrowser.addTab();
18 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
19 }
21 function get_auth_info() {
22 return [ "testuser", "testpass" ];
23 }
25 function download_failed(install) {
26 ok(false, "Install should not have failed");
27 }
29 function install_ended(install, addon) {
30 install.cancel();
31 }
33 function finish_test(count) {
34 is(count, 1, "1 Add-on should have been successfully installed");
35 var authMgr = Components.classes['@mozilla.org/network/http-auth-manager;1']
36 .getService(Components.interfaces.nsIHttpAuthManager);
37 authMgr.clearAll();
39 Services.perms.remove("example.com", "install");
41 gBrowser.removeCurrentTab();
42 Harness.finish();
43 }