Bug 1525245 - Stabilize cookiePolicy/cookiePermission for live documents - part 8 - Tests for ServiceWorkers and cookie settings changing, r=Ehsan
☠☠ backed out by 32412e6eb551 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 06 Mar 2019 17:02:25 +0000
changeset 462660 fc3c64c330b914adc88eb115c2175c84314a6c85
parent 462659 2762bf88e05093071dab3f59e1020127b1135f59
child 462661 2020227181ccbe32dd3e8cddf6860cf32634344e
push id79778
push useramarchesini@mozilla.com
push dateWed, 06 Mar 2019 17:08:17 +0000
treeherderautoland@9f8a1b410320 [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],
       ]});