browser_inspector_textbox-menu_reopen_toolbox.js (1877B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that textbox context menu elements are still displayed correctly after reopening 6 // the toolbox. Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1510182. 7 8 add_task(async function () { 9 await addTab(`data:text/html;charset=utf-8,<div>test</div>`); 10 11 info("Testing the textbox context menu a first time"); 12 const { toolbox, inspector } = await openInspector(); 13 await checkContextMenuOnSearchbox(inspector, toolbox); 14 15 // Destroy the toolbox and try the context menu again with a new toolbox. 16 await toolbox.destroy(); 17 18 info("Testing the textbox context menu after reopening the toolbox"); 19 const { toolbox: newToolbox, inspector: newInspector } = 20 await openInspector(); 21 await checkContextMenuOnSearchbox(newInspector, newToolbox); 22 }); 23 24 async function checkContextMenuOnSearchbox(inspector, toolbox) { 25 // The same context menu is used for any text input. 26 // Here we use the inspector searchbox for this test because it is always available. 27 const searchbox = inspector.panelDoc.getElementById("inspector-searchbox"); 28 29 info( 30 "Simulating context click on the textbox and expecting the menu to open" 31 ); 32 const onContextMenu = toolbox.once("menu-open"); 33 synthesizeContextMenuEvent(searchbox); 34 await onContextMenu; 35 36 const textboxContextMenu = toolbox.getTextBoxContextMenu(); 37 info("Wait until menu items are rendered"); 38 const pasteElement = textboxContextMenu.querySelector("#editmenu-paste"); 39 await waitUntil(() => !!pasteElement.getAttribute("label")); 40 41 is( 42 pasteElement.getAttribute("label"), 43 "Paste", 44 "Paste is visible and localized" 45 ); 46 47 info("Closing the menu"); 48 const onContextMenuHidden = toolbox.once("menu-close"); 49 textboxContextMenu.hidePopup(); 50 await onContextMenuHidden; 51 }