browser_storage_delete.js (2337B)
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 storage items 8 9 const TEST_CASES = [ 10 [["localStorage", "http://test1.example.org"], "ls1", "name"], 11 [["sessionStorage", "http://test1.example.org"], "ss1", "name"], 12 [ 13 ["cookies", "http://test1.example.org"], 14 getCookieId("c1", "test1.example.org", "/browser"), 15 "name", 16 ], 17 [ 18 ["indexedDB", "http://test1.example.org", "idb1 (default)", "obj1"], 19 1, 20 "name", 21 ], 22 [ 23 ["Cache", "http://test1.example.org", "plop"], 24 MAIN_DOMAIN + "404_cached_file.js", 25 "url", 26 ], 27 ]; 28 29 add_task(async function () { 30 // storage-listings.html explicitly mixes secure and insecure frames. 31 // We should not enforce https for tests using this page. 32 await pushPref("dom.security.https_first", false); 33 34 await openTabAndSetupStorage(MAIN_DOMAIN + "storage-listings.html"); 35 36 const contextMenu = gPanelWindow.document.getElementById( 37 "storage-table-popup" 38 ); 39 const menuDeleteItem = contextMenu.querySelector( 40 "#storage-table-popup-delete" 41 ); 42 43 for (const [treeItem, rowName, cellToClick] of TEST_CASES) { 44 const treeItemName = treeItem.join(" > "); 45 46 info(`Selecting tree item ${treeItemName}`); 47 await selectTreeItem(treeItem); 48 49 const row = getRowCells(rowName); 50 ok( 51 gUI.table.items.has(rowName), 52 `There is a row '${rowName}' in ${treeItemName}` 53 ); 54 55 const eventWait = gUI.once("store-objects-edit"); 56 57 await waitForContextMenu(contextMenu, row[cellToClick], () => { 58 info(`Opened context menu in ${treeItemName}, row '${rowName}'`); 59 contextMenu.activateItem(menuDeleteItem); 60 const truncatedRowName = String(rowName) 61 .replace(SEPARATOR_GUID, "-") 62 .substr(0, 16); 63 ok( 64 JSON.parse( 65 menuDeleteItem.getAttribute("data-l10n-args") 66 ).itemName.includes(truncatedRowName), 67 `Context menu item label contains '${rowName}' (maybe truncated)` 68 ); 69 }); 70 71 info("Awaiting for store-objects-edit event"); 72 await eventWait; 73 74 ok( 75 !gUI.table.items.has(rowName), 76 `There is no row '${rowName}' in ${treeItemName} after deletion` 77 ); 78 } 79 });