|
1 // ---------------------------------------------------------------------------- |
|
2 // Test that an install that requires cookies to be sent fails when cookies |
|
3 // are set and third party cookies are disabled and the request is to a third |
|
4 // party. |
|
5 // This verifies bug 462739 |
|
6 function test() { |
|
7 Harness.downloadFailedCallback = download_failed; |
|
8 Harness.installsCompletedCallback = finish_test; |
|
9 Harness.setup(); |
|
10 |
|
11 var cm = Components.classes["@mozilla.org/cookiemanager;1"] |
|
12 .getService(Components.interfaces.nsICookieManager2); |
|
13 cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false, |
|
14 false, true, (Date.now() / 1000) + 60); |
|
15 |
|
16 var pm = Services.perms; |
|
17 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
18 |
|
19 Services.prefs.setIntPref("network.cookie.cookieBehavior", 1); |
|
20 |
|
21 var triggers = encodeURIComponent(JSON.stringify({ |
|
22 "Cookie check": TESTROOT2 + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" |
|
23 })); |
|
24 gBrowser.selectedTab = gBrowser.addTab(); |
|
25 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
26 } |
|
27 |
|
28 function download_failed(install) { |
|
29 is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should fail"); |
|
30 } |
|
31 |
|
32 function finish_test(count) { |
|
33 is(count, 0, "No add-ons should have been installed"); |
|
34 var cm = Components.classes["@mozilla.org/cookiemanager;1"] |
|
35 .getService(Components.interfaces.nsICookieManager2); |
|
36 cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false); |
|
37 |
|
38 Services.prefs.clearUserPref("network.cookie.cookieBehavior"); |
|
39 Services.perms.remove("example.com", "install"); |
|
40 |
|
41 gBrowser.removeCurrentTab(); |
|
42 Harness.finish(); |
|
43 } |