browser_contextmenu_inspect.js (1478B)
1 "use strict"; 2 3 // Check that Inspect Element works in Responsive Design Mode. 4 5 const TEST_URI = `${URL_ROOT}doc_contextmenu_inspect.html`; 6 7 addRDMTask(TEST_URI, async function ({ ui, manager }) { 8 info("Open the responsive design mode and set its size to 500x500 to start"); 9 await setViewportSize(ui, manager, 500, 500); 10 11 info("Open the inspector, rule-view and select the test node"); 12 const { inspector } = await openRuleView(); 13 14 const startNodeFront = inspector.selection.nodeFront; 15 is(startNodeFront.displayName, "body", "body element is selected by default"); 16 17 const onSelected = inspector.once("inspector-updated"); 18 19 const contentAreaContextMenu = document.querySelector( 20 "#contentAreaContextMenu" 21 ); 22 const contextOpened = once(contentAreaContextMenu, "popupshown"); 23 24 info("Simulate a context menu event from the top browser."); 25 BrowserTestUtils.synthesizeMouse( 26 ui.getViewportBrowser(), 27 250, 28 100, 29 { 30 type: "contextmenu", 31 button: 2, 32 }, 33 ui.tab.linkedBrowser 34 ); 35 36 await contextOpened; 37 38 info("Triggering the inspect action"); 39 await gContextMenu.inspectNode(); 40 41 info("Hiding the menu"); 42 const contextClosed = once(contentAreaContextMenu, "popuphidden"); 43 contentAreaContextMenu.hidePopup(); 44 await contextClosed; 45 46 await onSelected; 47 const newNodeFront = inspector.selection.nodeFront; 48 is( 49 newNodeFront.displayName, 50 "div", 51 "div element is selected after using Inspect Element" 52 ); 53 });