browser_storage_delete_all.js (3436B)
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 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 = gPanelWindow.document.getElementById( 17 "storage-table-popup" 18 ); 19 const menuDeleteAllItem = contextMenu.querySelector( 20 "#storage-table-popup-delete-all" 21 ); 22 23 info("test state before delete"); 24 const beforeState = [ 25 [ 26 ["localStorage", "http://test1.example.org"], 27 ["key", "ls1", "ls2"], 28 ], 29 [["localStorage", "http://sectest1.example.org"], ["iframe-u-ls1"]], 30 [["localStorage", "https://sectest1.example.org"], ["iframe-s-ls1"]], 31 [ 32 ["sessionStorage", "http://test1.example.org"], 33 ["key", "ss1"], 34 ], 35 [ 36 ["sessionStorage", "http://sectest1.example.org"], 37 ["iframe-u-ss1", "iframe-u-ss2"], 38 ], 39 [["sessionStorage", "https://sectest1.example.org"], ["iframe-s-ss1"]], 40 [ 41 ["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], 42 [1, 2, 3], 43 ], 44 [ 45 ["Cache", "http://test1.example.org", "plop"], 46 [ 47 MAIN_DOMAIN + "404_cached_file.js", 48 MAIN_DOMAIN + "browser_storage_basic.js", 49 ], 50 ], 51 ]; 52 53 await checkState(beforeState); 54 55 info("do the delete"); 56 const deleteHosts = [ 57 [["localStorage", "https://sectest1.example.org"], "iframe-s-ls1", "name"], 58 [ 59 ["sessionStorage", "https://sectest1.example.org"], 60 "iframe-s-ss1", 61 "name", 62 ], 63 [ 64 ["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], 65 1, 66 "name", 67 ], 68 [ 69 ["Cache", "http://test1.example.org", "plop"], 70 MAIN_DOMAIN + "404_cached_file.js", 71 "url", 72 ], 73 ]; 74 75 for (const [store, rowName, cellToClick] of deleteHosts) { 76 const storeName = store.join(" > "); 77 78 await selectTreeItem(store); 79 80 const eventWait = gUI.once("store-objects-cleared"); 81 82 const cell = getRowCells(rowName)[cellToClick]; 83 await waitForContextMenu(contextMenu, cell, () => { 84 info(`Opened context menu in ${storeName}, row '${rowName}'`); 85 contextMenu.activateItem(menuDeleteAllItem); 86 }); 87 88 await eventWait; 89 } 90 91 info("test state after delete"); 92 const afterState = [ 93 // iframes from the same host, one secure, one unsecure, are independent 94 // from each other. Delete all in one doesn't touch the other one. 95 [ 96 ["localStorage", "http://test1.example.org"], 97 ["key", "ls1", "ls2"], 98 ], 99 [["localStorage", "http://sectest1.example.org"], ["iframe-u-ls1"]], 100 [["localStorage", "https://sectest1.example.org"], []], 101 [ 102 ["sessionStorage", "http://test1.example.org"], 103 ["key", "ss1"], 104 ], 105 [ 106 ["sessionStorage", "http://sectest1.example.org"], 107 ["iframe-u-ss1", "iframe-u-ss2"], 108 ], 109 [["sessionStorage", "https://sectest1.example.org"], []], 110 [["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], []], 111 [["Cache", "http://test1.example.org", "plop"], []], 112 ]; 113 114 await checkState(afterState); 115 });