browser_storage_cache_delete.js (1646B)
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 a Cache object from the tree using context menu 8 9 add_task(async function () { 10 await pushPref("dom.security.https_first", false); 11 await openTabAndSetupStorage(MAIN_DOMAIN + "storage-listings.html"); 12 13 const contextMenu = 14 gPanelWindow.document.getElementById("storage-tree-popup"); 15 const menuDeleteItem = contextMenu.querySelector( 16 "#storage-tree-popup-delete" 17 ); 18 19 const cacheToDelete = ["Cache", "http://test1.example.org", "plop"]; 20 21 info("test state before delete"); 22 await selectTreeItem(cacheToDelete); 23 ok(gUI.tree.isSelected(cacheToDelete), "Cache item is present in the tree"); 24 25 info("do the delete"); 26 const eventWait = gUI.once("store-objects-updated"); 27 28 const selector = `[data-id='${JSON.stringify( 29 cacheToDelete 30 )}'] > .tree-widget-item`; 31 const target = gPanelWindow.document.querySelector(selector); 32 ok(target, "Cache item's tree element is present"); 33 34 await waitForContextMenu(contextMenu, target, () => { 35 info("Opened tree context menu"); 36 menuDeleteItem.click(); 37 38 const cacheName = cacheToDelete[2]; 39 ok( 40 menuDeleteItem.getAttribute("label").includes(cacheName), 41 `Context menu item label contains '${cacheName}')` 42 ); 43 }); 44 45 await eventWait; 46 47 info("test state after delete"); 48 await selectTreeItem(cacheToDelete); 49 ok( 50 !gUI.tree.isSelected(cacheToDelete), 51 "Cache item is no longer present in the tree" 52 ); 53 });