Bug 1525245 - Stabilize cookiePolicy/cookiePermission for live documents - part 8 - Tests for ServiceWorkers and cookie settings changing, r=Ehsan
☠☠ backed out by ca64604d4b78 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 07 Mar 2019 10:17:55 +0000
changeset 520728 9affaf0cb998cc06c0faa17f6960712b3feb9dbb
parent 520727 a91b7ebe8bdd6bd6017f6be530c0c805e23f8fee
child 520729 4772db3625b36cbd3a46cfd0822a563692f42374
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1525245
milestone67.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 1525245 - Stabilize cookiePolicy/cookiePermission for live documents - part 8 - Tests for ServiceWorkers and cookie settings changing, r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D18956
netwerk/cookie/test/browser/browser.ini
netwerk/cookie/test/browser/browser_serviceWorker.js
netwerk/cookie/test/browser/file_empty.js
netwerk/cookie/test/browser/head.js
--- a/netwerk/cookie/test/browser/browser.ini
+++ b/netwerk/cookie/test/browser/browser.ini
@@ -1,10 +1,12 @@
 [DEFAULT]
 support-files =
   file_empty.html
+  file_empty.js
   head.js
 
 [browser_broadcastChannel.js]
 [browser_indexedDB.js]
 [browser_originattributes.js]
 [browser_storage.js]
+[browser_serviceWorker.js]
 [browser_sharedWorker.js]
new file mode 100644
--- /dev/null
+++ b/netwerk/cookie/test/browser/browser_serviceWorker.js
@@ -0,0 +1,24 @@
+CookiePolicyHelper.runTest("ServiceWorker", {
+  prefs: [
+    ["dom.serviceWorkers.exemptFromPerDomainMax", true],
+    ["dom.ipc.processCount", 1],
+    ["dom.serviceWorkers.enabled", true],
+    ["dom.serviceWorkers.testing.enabled", true],
+  ],
+
+  cookieJarAccessAllowed: async _ => {
+    await content.navigator.serviceWorker.register("file_empty.js").then(
+      reg => { ok(true, "ServiceWorker can be used!"); return reg; },
+      _ => { ok(false, "ServiceWorker cannot be used! " + _); }).then(
+      reg => reg.unregister(),
+      _ => { ok(false, "unregister failed"); }).
+      catch(e => ok(false, "Promise rejected: " + e));
+  },
+
+  cookieJarAccessDenied: async _ => {
+    await content.navigator.serviceWorker.register("file_empty.js").then(
+      _ => { ok(false, "ServiceWorker cannot be used!"); },
+      _ => { ok(true, "ServiceWorker cannot be used!"); }).
+      catch(e => ok(false, "Promise rejected: " + e));
+  },
+});
new file mode 100644
--- /dev/null
+++ b/netwerk/cookie/test/browser/file_empty.js
@@ -0,0 +1,1 @@
+/* nothing here */
--- a/netwerk/cookie/test/browser/head.js
+++ b/netwerk/cookie/test/browser/head.js
@@ -19,66 +19,74 @@ const TEST_TOP_PAGE = TEST_DOMAIN + TEST
 // page.
 this.CookiePolicyHelper = {
   runTest(testName, config) {
     // Testing allowed to blocked by cookie behavior
     this._createTest(testName,
                      config.cookieJarAccessAllowed,
                      config.cookieJarAccessDenied,
                      config.cleanup,
+                     config.prefs,
                      {
                        fromBehavior: BEHAVIOR_ACCEPT,
                        toBehavior: BEHAVIOR_REJECT,
                        fromPermission: PERM_DEFAULT,
                        toPermission: PERM_DEFAULT,
                      });
 
     // Testing blocked to allowed by cookie behavior
     this._createTest(testName,
                      config.cookieJarAccessDenied,
                      config.cookieJarAccessAllowed,
                      config.cleanup,
+                     config.prefs,
                      {
                        fromBehavior: BEHAVIOR_REJECT,
                        toBehavior: BEHAVIOR_ACCEPT,
                        fromPermission: PERM_DEFAULT,
                        toPermission: PERM_DEFAULT,
                      });
 
     // Testing allowed to blocked by cookie permission
     this._createTest(testName,
                      config.cookieJarAccessAllowed,
                      config.cookieJarAccessDenied,
                      config.cleanup,
+                     config.prefs,
                      {
                        fromBehavior: BEHAVIOR_REJECT,
                        toBehavior: BEHAVIOR_REJECT,
                        fromPermission: PERM_ALLOW,
                        toPermission: PERM_DEFAULT,
                      });
 
     // Testing blocked to allowed by cookie permission
     this._createTest(testName,
                      config.cookieJarAccessDenied,
                      config.cookieJarAccessAllowed,
                      config.cleanup,
+                     config.prefs,
                      {
                        fromBehavior: BEHAVIOR_ACCEPT,
                        toBehavior: BEHAVIOR_ACCEPT,
                        fromPermission: PERM_DENY,
                        toPermission: PERM_DEFAULT,
                      });
   },
 
-  _createTest(testName, goodCb, badCb, cleanupCb, config) {
+  _createTest(testName, goodCb, badCb, cleanupCb, prefs, config) {
     add_task(async _ => {
       info("Starting " + testName + ": " + config.toSource());
 
       await SpecialPowers.flushPrefEnv();
 
+      if (prefs) {
+        await SpecialPowers.pushPrefEnv({"set": prefs });
+      }
+
       let uri = Services.io.newURI(TEST_DOMAIN);
 
       // Let's set the first cookie pref.
       Services.perms.add(uri, "cookie", config.fromPermission);
       await SpecialPowers.pushPrefEnv({"set": [
         ["network.cookie.cookieBehavior", config.fromBehavior],
       ]});