diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /dom/tests/mochitest/general/workerStorageAllowed.js | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/mochitest/general/workerStorageAllowed.js')
-rw-r--r-- | dom/tests/mochitest/general/workerStorageAllowed.js | 131 |
1 files changed, 96 insertions, 35 deletions
diff --git a/dom/tests/mochitest/general/workerStorageAllowed.js b/dom/tests/mochitest/general/workerStorageAllowed.js index 89e0a4b9ce..93c4c94c48 100644 --- a/dom/tests/mochitest/general/workerStorageAllowed.js +++ b/dom/tests/mochitest/general/workerStorageAllowed.js @@ -14,50 +14,88 @@ function finishTest() { self.close(); } -// Workers don't have access to localstorage or sessionstorage -ok(typeof self.localStorage == "undefined", "localStorage should be undefined"); -ok( - typeof self.sessionStorage == "undefined", - "sessionStorage should be undefined" -); - // Make sure that we can access indexedDB -try { - indexedDB; - ok(true, "WORKER getting indexedDB didn't throw"); -} catch (e) { - ok(false, "WORKER getting indexedDB should not throw"); +function idbTest() { + try { + indexedDB; + + const idbcycle = new Promise((resolve, reject) => { + const begin = indexedDB.open("door"); + begin.onerror = e => { + reject(e); + }; + begin.onsuccess = () => { + indexedDB + .databases() + .then(dbs => { + ok( + dbs.some(elem => elem.name === "door"), + "WORKER just created database should be found" + ); + const end = indexedDB.deleteDatabase("door"); + end.onerror = e => { + reject(e); + }; + end.onsuccess = () => { + resolve(); + }; + }) + .catch(err => { + reject(err); + }); + }; + }); + + idbcycle.then( + () => { + ok(true, "WORKER getting indexedDB didn't throw"); + cacheTest(); + }, + e => { + ok(false, "WORKER getting indexedDB threw " + e.message); + cacheTest(); + } + ); + } catch (e) { + ok(false, "WORKER getting indexedDB should not throw"); + cacheTest(); + } } // Make sure that we can access caches -try { - var promise = caches.keys(); - ok(true, "WORKER getting caches didn't throw"); +function cacheTest() { + try { + var promise = caches.keys(); + ok(true, "WORKER getting caches didn't throw"); - promise.then( - function () { - ok(location.protocol == "https:", "WORKER The promise was not rejected"); - workerTest(); - }, - function () { - ok( - location.protocol !== "https:", - "WORKER The promise should not have been rejected" - ); - workerTest(); - } - ); -} catch (e) { - ok( - location.protocol !== "https:", - "WORKER getting caches should not have thrown" - ); - workerTest(); + promise.then( + function () { + ok( + location.protocol == "https:", + "WORKER The promise was not rejected" + ); + workerTest(); + }, + function () { + ok( + location.protocol !== "https:", + "WORKER The promise should not have been rejected" + ); + workerTest(); + } + ); + } catch (e) { + ok( + location.protocol !== "https:", + "WORKER getting caches should not have thrown" + ); + workerTest(); + } } // Try to spawn an inner worker, and make sure that it can also access storage function workerTest() { - if (location.hash == "#inner") { + if (location.hash != "#outer") { // Don't recurse infinitely, if we are the inner worker, don't spawn another finishTest(); return; @@ -75,4 +113,27 @@ function workerTest() { e.data + " (WORKER = workerStorageAllowed.js#inner)" ); }); + + worker.addEventListener("error", function (e) { + ok(false, e.data + " (WORKER = workerStorageAllowed.js#inner)"); + + finishTest(); + }); +} + +try { + // Workers don't have access to localstorage or sessionstorage + ok( + typeof self.localStorage == "undefined", + "localStorage should be undefined" + ); + ok( + typeof self.sessionStorage == "undefined", + "sessionStorage should be undefined" + ); + + idbTest(); +} catch (e) { + ok(false, "WORKER Unwelcome exception received"); + finishTest(); } |