diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/storage/test/storage-secured-iframe-usercontextid.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/storage/test/storage-secured-iframe-usercontextid.html')
-rw-r--r-- | devtools/client/storage/test/storage-secured-iframe-usercontextid.html | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/devtools/client/storage/test/storage-secured-iframe-usercontextid.html b/devtools/client/storage/test/storage-secured-iframe-usercontextid.html new file mode 100644 index 0000000000..c3958661d4 --- /dev/null +++ b/devtools/client/storage/test/storage-secured-iframe-usercontextid.html @@ -0,0 +1,91 @@ +<!DOCTYPE HTML> +<html> +<!-- +Iframe for testing multiple host detetion in storage actor +--> +<head> + <meta charset="utf-8"> +</head> +<body> +<script type="application/javascript"> +"use strict"; +document.cookie = "sc1uc1=foobar;"; +localStorage.setItem("iframe-s-ls1uc1", "foobar"); +sessionStorage.setItem("iframe-s-ss1uc1", "foobar-2"); +dump("added cookies and storage from secured iframe\n"); + +const idbGenerator = async function () { + let request = indexedDB.open("idb-s1uc1", 1); + request.onerror = function() { + throw new Error("error opening db connection"); + }; + const db = await new Promise(done => { + request.onupgradeneeded = event => { + const _db = event.target.result; + const store1 = _db.createObjectStore("obj-s1uc1", { keyPath: "id" }); + store1.transaction.oncomplete = () => { + done(_db); + }; + }; + }); + await new Promise(done => { + request.onsuccess = done; + }); + + let transaction = db.transaction(["obj-s1uc1"], "readwrite"); + const store1 = transaction.objectStore("obj-s1uc1"); + store1.add({id: 6, name: "foo", email: "foo@bar.com"}); + store1.add({id: 7, name: "foo2", email: "foo2@bar.com"}); + await new Promise(success => { + transaction.oncomplete = success; + }); + + db.close(); + + request = indexedDB.open("idb-s2uc1", 1); + const db2 = await new Promise(done => { + request.onupgradeneeded = event => { + const _db2 = event.target.result; + const store3 = + _db2.createObjectStore("obj-s2uc1", { keyPath: "id3", autoIncrement: true }); + store3.createIndex("name2", "name2", { unique: true }); + store3.transaction.oncomplete = () => { + done(_db2); + }; + }; + }); + await new Promise(done => { + request.onsuccess = done; + }); + + transaction = db2.transaction(["obj-s2uc1"], "readwrite"); + const store3 = transaction.objectStore("obj-s2uc1"); + store3.add({id3: 16, name2: "foo", email: "foo@bar.com"}); + await new Promise(success => { + transaction.oncomplete = success; + }); + + db2.close(); + dump("added indexedDB from secured iframe\n"); +}; + +function deleteDB(dbName) { + return new Promise(resolve => { + dump("removing database " + dbName + " from " + document.location + "\n"); + indexedDB.deleteDatabase(dbName).onsuccess = resolve; + }); +} + +window.setup = async function () { + await idbGenerator(); +}; + +window.clear = async function () { + await deleteDB("idb-s1uc1"); + await deleteDB("idb-s2uc1"); + + dump("removed indexedDB data from " + document.location + "\n"); +}; +</script> +</body> +</html> |