browser_storage_fission_indexeddb.js (2025B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 add_task(async function () { 8 const URL = URL_ROOT_COM_SSL + "storage-indexeddb-iframe.html"; 9 10 // open tab 11 await openTabAndSetupStorage(URL); 12 const doc = gPanelWindow.document; 13 14 // check that host appears in the storage tree 15 checkTree(doc, ["indexedDB", "https://example.com"]); 16 // check the table for values 17 await selectTreeItem([ 18 "indexedDB", 19 "https://example.com", 20 "db (default)", 21 "store", 22 ]); 23 checkStorageData("foo", JSON.stringify({ key: "foo", value: "bar" })); 24 25 // check that host appears in the storage tree 26 checkTree(doc, ["indexedDB", "https://example.net"]); 27 // check the table for values 28 await selectTreeItem([ 29 "indexedDB", 30 "https://example.net", 31 "db (default)", 32 "store", 33 ]); 34 checkStorageData("lorem", JSON.stringify({ key: "lorem", value: "ipsum" })); 35 36 info("Add new data to the iframe DB"); 37 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 38 const iframe = content.document.querySelector("iframe"); 39 return SpecialPowers.spawn(iframe, [], async function () { 40 return new Promise(resolve => { 41 const request = content.window.indexedDB.open("db", 1); 42 request.onsuccess = event => { 43 const db = event.target.result; 44 const transaction = db.transaction(["store"], "readwrite"); 45 const addRequest = transaction 46 .objectStore("store") 47 .add({ key: "hello", value: "world" }); 48 addRequest.onsuccess = () => resolve(); 49 }; 50 }); 51 }); 52 }); 53 54 info("Refreshing table"); 55 doc.querySelector("#refresh-button").click(); 56 57 info("Check that table has new row"); 58 await waitUntil(() => 59 hasStorageData("hello", JSON.stringify({ key: "hello", value: "world" })) 60 ); 61 ok(true, "Table has the new data"); 62 });