browser_bug578534.js (1064B)
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 const { PermissionTestUtils } = ChromeUtils.importESModule( 6 "resource://testing-common/PermissionTestUtils.sys.mjs" 7 ); 8 9 add_task(async function test() { 10 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 11 let uriString = "http://example.com/"; 12 let cookieBehavior = "network.cookie.cookieBehavior"; 13 14 await SpecialPowers.pushPrefEnv({ set: [[cookieBehavior, 2]] }); 15 PermissionTestUtils.add(uriString, "cookie", Services.perms.ALLOW_ACTION); 16 17 await BrowserTestUtils.withNewTab( 18 { gBrowser, url: uriString }, 19 async function (browser) { 20 await SpecialPowers.spawn(browser, [], function () { 21 is( 22 content.navigator.cookieEnabled, 23 true, 24 "navigator.cookieEnabled should be true" 25 ); 26 }); 27 } 28 ); 29 30 PermissionTestUtils.add(uriString, "cookie", Services.perms.UNKNOWN_ACTION); 31 });