|
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(); |
|
11 |
|
12 var pm = Services.perms; |
|
13 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
14 |
|
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 } |
|
21 |
|
22 function get_auth_info() { |
|
23 return null; |
|
24 } |
|
25 |
|
26 function download_failed(install) { |
|
27 is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should have failed"); |
|
28 } |
|
29 |
|
30 function install_ended(install, addon) { |
|
31 ok(false, "Add-on should not have installed"); |
|
32 install.cancel(); |
|
33 } |
|
34 |
|
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(); |
|
40 |
|
41 Services.perms.remove("example.com", "install"); |
|
42 |
|
43 gBrowser.removeCurrentTab(); |
|
44 Harness.finish(); |
|
45 } |