Bug 1586712 - Making the test 'browser/components/originattributes/test/browser/browser_permissions.js' working in Fission. r=baku
authorTim Huang <tihuang@mozilla.com>
Tue, 15 Oct 2019 14:24:34 +0000
changeset 498334 63396eab4b66da57b6c47582bbd5dbd785232d59
parent 498333 2c7f637d7fc821b1f3b19434dcf967b698e3144b
child 498335 f7440da54d66a2a29ba5333256274637ab039834
push id36717
push usernbeleuzu@mozilla.com
push dateMon, 21 Oct 2019 21:51:55 +0000
treeherdermozilla-central@563f437f24b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1586712
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1586712 - Making the test 'browser/components/originattributes/test/browser/browser_permissions.js' working in Fission. r=baku This patch also fixes the test that it doesn't really do the test due to it doesn't wait the content script to be finished. Depends on D49249 Differential Revision: https://phabricator.services.mozilla.com/D49250
browser/components/originattributes/test/browser/browser.ini
browser/components/originattributes/test/browser/browser_permissions.js
--- a/browser/components/originattributes/test/browser/browser.ini
+++ b/browser/components/originattributes/test/browser/browser.ini
@@ -87,15 +87,14 @@ skip-if = (verify && debug && (os == 'wi
 [browser_imageCacheIsolation.js]
 [browser_sharedworker.js]
 fail-if = fission
 [browser_httpauth.js]
 [browser_clientAuth.js]
 skip-if = verify
 [browser_cacheAPI.js]
 [browser_permissions.js]
-fail-if = fission
 [browser_postMessage.js]
 [browser_sanitize.js]
 fail-if = fission
 skip-if = (os == 'win') || (os == "mac" && os_version == "10.14") || (os == "linux" && bits == 64) #Bug 1544810
 [browser_windowOpenerRestriction.js]
 fail-if = fission
--- a/browser/components/originattributes/test/browser/browser_permissions.js
+++ b/browser/components/originattributes/test/browser/browser_permissions.js
@@ -9,22 +9,37 @@ const { PermissionTestUtils } = ChromeUt
 );
 
 const TEST_PAGE = "http://example.net";
 const uri = Services.io.newURI(TEST_PAGE);
 
 function disableCookies() {
   Services.cookies.removeAll();
   PermissionTestUtils.add(uri, "cookie", Services.perms.DENY_ACTION);
+
+  // A workaround for making this test working. In Bug 1330467, we separate the
+  // permissions between different firstPartyDomains, but not for the
+  // userContextID and the privateBrowsingId. So we need to manually add the
+  // permission for FPDs in order to make this test working. This test should be
+  // eventually removed once the permissions are isolated by OAs.
+  let principal = Services.scriptSecurityManager.createContentPrincipal(uri, {
+    firstPartyDomain: "example.com",
+  });
+  PermissionTestUtils.add(principal, "cookie", Services.perms.DENY_ACTION);
+
+  principal = Services.scriptSecurityManager.createContentPrincipal(uri, {
+    firstPartyDomain: "example.org",
+  });
+  PermissionTestUtils.add(principal, "cookie", Services.perms.DENY_ACTION);
 }
 
-function ensureCookieNotSet(aBrowser) {
-  ContentTask.spawn(aBrowser, null, async function() {
+async function ensureCookieNotSet(aBrowser) {
+  await SpecialPowers.spawn(aBrowser, [], async function() {
     content.document.cookie = "key=value";
-    is(
+    Assert.equal(
       content.document.cookie,
       "",
       "Setting/reading cookies should be disabled" +
         " for this domain for all origin attribute combinations."
     );
   });
 }
 
@@ -33,22 +48,33 @@ IsolationTestTools.runTests(
   ensureCookieNotSet,
   () => true,
   disableCookies
 );
 
 function enableCookies() {
   Services.cookies.removeAll();
   PermissionTestUtils.add(uri, "cookie", Services.perms.ALLOW_ACTION);
+
+  // A workaround for making this test working.
+  let principal = Services.scriptSecurityManager.createContentPrincipal(uri, {
+    firstPartyDomain: "example.com",
+  });
+  PermissionTestUtils.add(principal, "cookie", Services.perms.ALLOW_ACTION);
+
+  principal = Services.scriptSecurityManager.createContentPrincipal(uri, {
+    firstPartyDomain: "example.org",
+  });
+  PermissionTestUtils.add(principal, "cookie", Services.perms.ALLOW_ACTION);
 }
 
-function ensureCookieSet(aBrowser) {
-  ContentTask.spawn(aBrowser, null, function() {
+async function ensureCookieSet(aBrowser) {
+  await SpecialPowers.spawn(aBrowser, [], function() {
     content.document.cookie = "key=value";
-    is(
+    Assert.equal(
       content.document.cookie,
       "key=value",
       "Setting/reading cookies should be" +
         " enabled for this domain for all origin attribute combinations."
     );
   });
 }