browser_storage_delete_tree.js (2998B)
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 // Test deleting all storage items from the tree. 8 9 add_task(async function () { 10 // storage-listings.html explicitly mixes secure and insecure frames. 11 // We should not enforce https for tests using this page. 12 await pushPref("dom.security.https_first", false); 13 14 await openTabAndSetupStorage(MAIN_DOMAIN + "storage-listings.html"); 15 16 const contextMenu = 17 gPanelWindow.document.getElementById("storage-tree-popup"); 18 const menuDeleteAllItem = contextMenu.querySelector( 19 "#storage-tree-popup-delete-all" 20 ); 21 22 info("test state before delete"); 23 await checkState([ 24 [ 25 ["cookies", "http://test1.example.org"], 26 [ 27 getCookieId("c1", "test1.example.org", "/browser"), 28 getCookieId("cs2", ".example.org", "/"), 29 getCookieId("c3", "test1.example.org", "/"), 30 getCookieId("c4", ".example.org", "/"), 31 getCookieId("uc1", ".example.org", "/"), 32 getCookieId("uc2", ".example.org", "/"), 33 ], 34 ], 35 [ 36 ["localStorage", "http://test1.example.org"], 37 ["key", "ls1", "ls2"], 38 ], 39 [ 40 ["sessionStorage", "http://test1.example.org"], 41 ["key", "ss1"], 42 ], 43 [ 44 ["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], 45 [1, 2, 3], 46 ], 47 [ 48 ["Cache", "http://test1.example.org", "plop"], 49 [ 50 MAIN_DOMAIN + "404_cached_file.js", 51 MAIN_DOMAIN + "browser_storage_basic.js", 52 ], 53 ], 54 ]); 55 56 info("do the delete"); 57 const deleteHosts = [ 58 ["cookies", "http://test1.example.org"], 59 ["localStorage", "http://test1.example.org"], 60 ["sessionStorage", "http://test1.example.org"], 61 ["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], 62 ["Cache", "http://test1.example.org", "plop"], 63 ]; 64 65 for (const store of deleteHosts) { 66 const storeName = store.join(" > "); 67 68 await selectTreeItem(store); 69 70 const eventName = 71 "store-objects-" + (store[0] == "cookies" ? "edit" : "cleared"); 72 const eventWait = gUI.once(eventName); 73 74 const selector = `[data-id='${JSON.stringify(store)}'] > .tree-widget-item`; 75 const target = gPanelWindow.document.querySelector(selector); 76 ok(target, `tree item found in ${storeName}`); 77 await waitForContextMenu(contextMenu, target, () => { 78 info(`Opened tree context menu in ${storeName}`); 79 contextMenu.activateItem(menuDeleteAllItem); 80 }); 81 82 await eventWait; 83 } 84 85 info("test state after delete"); 86 await checkState([ 87 [["cookies", "http://test1.example.org"], []], 88 [["localStorage", "http://test1.example.org"], []], 89 [["sessionStorage", "http://test1.example.org"], []], 90 [["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], []], 91 [["Cache", "http://test1.example.org", "plop"], []], 92 ]); 93 });