michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: let uriString = "http://example.com/"; michael@0: let cookieBehavior = "network.cookie.cookieBehavior"; michael@0: let uriObj = Services.io.newURI(uriString, null, null) michael@0: let cp = Components.classes["@mozilla.org/cookie/permission;1"] michael@0: .getService(Components.interfaces.nsICookiePermission); michael@0: michael@0: Services.prefs.setIntPref(cookieBehavior, 2); michael@0: michael@0: cp.setAccess(uriObj, cp.ACCESS_ALLOW); michael@0: gBrowser.selectedTab = gBrowser.addTab(uriString); michael@0: waitForExplicitFinish(); michael@0: gBrowser.selectedBrowser.addEventListener("load", onTabLoaded, true); michael@0: michael@0: function onTabLoaded() { michael@0: is(gBrowser.selectedBrowser.contentWindow.navigator.cookieEnabled, true, michael@0: "navigator.cookieEnabled should be true"); michael@0: // Clean up michael@0: gBrowser.selectedBrowser.removeEventListener("load", onTabLoaded, true); michael@0: gBrowser.removeTab(gBrowser.selectedTab); michael@0: Services.prefs.setIntPref(cookieBehavior, 0); michael@0: cp.setAccess(uriObj, cp.ACCESS_DEFAULT); michael@0: finish(); michael@0: } michael@0: }