|
1 // ---------------------------------------------------------------------------- |
|
2 // Test that an install that requires cookies to be sent succeeds when cookies |
|
3 // are set |
|
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 var triggers = encodeURIComponent(JSON.stringify({ |
|
19 "Cookie check": TESTROOT + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi" |
|
20 })); |
|
21 gBrowser.selectedTab = gBrowser.addTab(); |
|
22 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
23 } |
|
24 |
|
25 function install_ended(install, addon) { |
|
26 install.cancel(); |
|
27 } |
|
28 |
|
29 function finish_test(count) { |
|
30 is(count, 1, "1 Add-on should have been successfully installed"); |
|
31 |
|
32 var cm = Components.classes["@mozilla.org/cookiemanager;1"] |
|
33 .getService(Components.interfaces.nsICookieManager2); |
|
34 cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false); |
|
35 |
|
36 Services.perms.remove("example.com", "install"); |
|
37 |
|
38 gBrowser.removeCurrentTab(); |
|
39 Harness.finish(); |
|
40 } |