browser_storage_indexeddb_navigation.js (2268B)
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 requestLongerTimeout(3); 8 9 add_task(async function () { 10 const URL1 = URL_ROOT_COM_SSL + "storage-indexeddb-simple.html"; 11 const URL2 = URL_ROOT_NET_SSL + "storage-indexeddb-simple-alt.html"; 12 13 // open tab 14 await openTabAndSetupStorage(URL1); 15 const doc = gPanelWindow.document; 16 17 // Check first domain 18 // check that host appears in the storage tree 19 checkTree(doc, ["indexedDB", "https://example.com"]); 20 // check the table for values 21 await selectTreeItem([ 22 "indexedDB", 23 "https://example.com", 24 "db (default)", 25 "store", 26 ]); 27 checkStorageData("lorem", JSON.stringify({ key: "lorem", value: "ipsum" })); 28 29 // clear db before navigating to a new domain 30 info("Removing database…"); 31 await clearStorage(); 32 33 // Check second domain 34 await navigateTo(URL2); 35 info("Creating database in the second domain…"); 36 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 37 const win = content.wrappedJSObject; 38 await win.setup(); 39 }); 40 // wait for storage tree refresh, and check host 41 info("Checking storage tree…"); 42 await waitUntil(() => isInTree(doc, ["indexedDB", "https://example.net"])); 43 44 ok( 45 !isInTree(doc, ["indexedDB", "https://example.com"]), 46 "example.com item is not in the tree anymore" 47 ); 48 49 // TODO: select tree and check on storage data. 50 // We cannot do it yet since we do not detect newly created indexed db's when 51 // navigating. See Bug 1273802 52 53 // reload the current tab, and check again 54 await reloadBrowser(); 55 // wait for storage tree refresh, and check host 56 info("Checking storage tree…"); 57 await waitUntil(() => isInTree(doc, ["indexedDB", "https://example.net"])); 58 59 info("Check that the indexedDB node still has the expected label"); 60 is( 61 getTreeNodeLabel(doc, ["indexedDB"]), 62 "Indexed DB", 63 "indexedDB item is properly displayed" 64 ); 65 }); 66 67 async function clearStorage() { 68 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 69 const win = content.wrappedJSObject; 70 await win.clear(); 71 }); 72 }