gecko/browser/base/content/test/browser_bug578534.js
2012-05-21 12:12:37 +01:00

30 lines
1.1 KiB
JavaScript

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