Bug 1525245 - Stabilize cookiePolicy/cookiePermission for live documents - part 7 - Tests for IndexedDB and cookie settings changing, r=Ehsan,asuth
☠☠ backed out by bc51c190590a ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 26 Feb 2019 17:37:50 +0000
changeset 461224 20f336320ce183a102a8fc02f656425006022b5b
parent 461223 d8ee13b6a17d3cbfa50e721089ebd5e2360594bd
child 461225 a565014fdd8dadda3e6f4280646b9c6c9b1841eb
push id79050
push useramarchesini@mozilla.com
push dateTue, 26 Feb 2019 19:00:07 +0000
treeherderautoland@1dcb31a1d5be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan, asuth
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 7 - Tests for IndexedDB and cookie settings changing, r=Ehsan,asuth Differential Revision: https://phabricator.services.mozilla.com/D18955
netwerk/cookie/test/browser/browser.ini
netwerk/cookie/test/browser/browser_indexedDB.js
--- a/netwerk/cookie/test/browser/browser.ini
+++ b/netwerk/cookie/test/browser/browser.ini
@@ -1,9 +1,10 @@
 [DEFAULT]
 support-files =
   file_empty.html
   head.js
 
 [browser_broadcastChannel.js]
+[browser_indexedDB.js]
 [browser_originattributes.js]
 [browser_storage.js]
 [browser_sharedWorker.js]
new file mode 100644
--- /dev/null
+++ b/netwerk/cookie/test/browser/browser_indexedDB.js
@@ -0,0 +1,82 @@
+CookiePolicyHelper.runTest("IndexedDB", {
+  cookieJarAccessAllowed: async _ => {
+    content.indexedDB.open("test", "1");
+    ok(true, "IDB should be allowed");
+  },
+
+  cookieJarAccessDenied: async _ => {
+    try {
+      content.indexedDB.open("test", "1");
+      ok(false, "IDB should be blocked");
+    } catch (e) {
+      ok(true, "IDB should be blocked");
+      is(e.name, "SecurityError", "We want a security error message.");
+    }
+  },
+});
+
+CookiePolicyHelper.runTest("IndexedDB in workers", {
+  cookieJarAccessAllowed: async _ => {
+    function nonBlockCode() {
+      indexedDB.open("test", "1");
+      postMessage(true);
+    }
+
+    let blob = new content.Blob([nonBlockCode.toString() + "; nonBlockCode();"]);
+    ok(blob, "Blob has been created");
+
+    let blobURL = content.URL.createObjectURL(blob);
+    ok(blobURL, "Blob URL has been created");
+
+    let worker = new content.Worker(blobURL);
+    ok(worker, "Worker has been created");
+
+    await new content.Promise((resolve, reject) => {
+      worker.onmessage = function(e) {
+        if (e.data) {
+          resolve();
+        } else {
+          reject();
+        }
+      };
+
+      worker.onerror = function(e) {
+        reject();
+      };
+    });
+  },
+
+  cookieJarAccessDenied: async _ => {
+    function blockCode() {
+      try {
+        indexedDB.open("test", "1");
+        postMessage(false);
+      } catch (e) {
+        postMessage(e.name == "SecurityError");
+      }
+    }
+
+    let blob = new content.Blob([blockCode.toString() + "; blockCode();"]);
+    ok(blob, "Blob has been created");
+
+    let blobURL = content.URL.createObjectURL(blob);
+    ok(blobURL, "Blob URL has been created");
+
+    let worker = new content.Worker(blobURL);
+    ok(worker, "Worker has been created");
+
+    await new content.Promise((resolve, reject) => {
+      worker.onmessage = function(e) {
+        if (e.data) {
+          resolve();
+        } else {
+          reject();
+        }
+      };
+
+      worker.onerror = function(e) {
+        reject();
+      };
+    });
+  },
+});