|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function test() { |
|
6 let uriString = "http://example.com/"; |
|
7 let cookieBehavior = "network.cookie.cookieBehavior"; |
|
8 let uriObj = Services.io.newURI(uriString, null, null) |
|
9 let cp = Components.classes["@mozilla.org/cookie/permission;1"] |
|
10 .getService(Components.interfaces.nsICookiePermission); |
|
11 |
|
12 Services.prefs.setIntPref(cookieBehavior, 2); |
|
13 |
|
14 cp.setAccess(uriObj, cp.ACCESS_ALLOW); |
|
15 gBrowser.selectedTab = gBrowser.addTab(uriString); |
|
16 waitForExplicitFinish(); |
|
17 gBrowser.selectedBrowser.addEventListener("load", onTabLoaded, true); |
|
18 |
|
19 function onTabLoaded() { |
|
20 is(gBrowser.selectedBrowser.contentWindow.navigator.cookieEnabled, true, |
|
21 "navigator.cookieEnabled should be true"); |
|
22 // Clean up |
|
23 gBrowser.selectedBrowser.removeEventListener("load", onTabLoaded, true); |
|
24 gBrowser.removeTab(gBrowser.selectedTab); |
|
25 Services.prefs.setIntPref(cookieBehavior, 0); |
|
26 cp.setAccess(uriObj, cp.ACCESS_DEFAULT); |
|
27 finish(); |
|
28 } |
|
29 } |