|
1 // ---------------------------------------------------------------------------- |
|
2 // Test that an install that requires cookies to be sent succeeds when cookies |
|
3 // are set and third party cookies are disabled. |
|
4 // This verifies bug 462739 |
|
5 function test() { |
|
6 Harness.installEndedCallback = install_ended; |
|
7 Harness.installsCompletedCallback = finish_test; |
|
8 Harness.setup(); |
|
9 |
|
10 var cm = Components.classes["@mozilla.org/cookiemanager;1"] |
|
11 .getService(Components.interfaces.nsICookieManager2); |
|
12 cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false, |
|
13 false, true, (Date.now() / 1000) + 60); |
|
14 |
|
15 var pm = Services.perms; |
|
16 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
17 |
|
18 Services.prefs.setIntPref("network.cookie.cookieBehavior", 1); |
|
19 |
|
20 var triggers = encodeURIComponent(JSON.stringify({ |
|
21 "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" |
|
22 })); |
|
23 gBrowser.selectedTab = gBrowser.addTab(); |
|
24 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
25 } |
|
26 |
|
27 function install_ended(install, addon) { |
|
28 install.cancel(); |
|
29 } |
|
30 |
|
31 function finish_test(count) { |
|
32 is(count, 1, "1 Add-on should have been successfully installed"); |
|
33 |
|
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 |
|
40 Services.perms.remove("example.com", "install"); |
|
41 |
|
42 gBrowser.removeCurrentTab(); |
|
43 Harness.finish(); |
|
44 } |