browser_inspector_highlighter-iframes_01.js (2499B)
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 "use strict"; 5 6 // Testing that moving the mouse over the document with the element picker 7 // started highlights nodes 8 9 const NESTED_FRAME_SRC = 10 "data:text/html;charset=utf-8," + 11 "nested iframe<section>nested div</section>"; 12 13 const OUTER_FRAME_SRC = 14 "data:text/html;charset=utf-8," + 15 "little frame<main>little div</main>" + 16 "<iframe src='" + 17 NESTED_FRAME_SRC + 18 "' />"; 19 20 const TEST_URI = 21 "data:text/html;charset=utf-8," + 22 "iframe tests for inspector" + 23 '<iframe src="' + 24 OUTER_FRAME_SRC + 25 '" />'; 26 27 add_task(async function () { 28 const { toolbox, inspector } = await openInspectorForURL(TEST_URI); 29 const outerFrameMainSelector = ["iframe", "main"]; 30 const innerFrameSectionSelector = ["iframe", "iframe", "section"]; 31 32 const outerFrameMainNodeFront = await getNodeFrontInFrames( 33 outerFrameMainSelector, 34 inspector 35 ); 36 const outerFrameHighlighterTestFront = await getHighlighterTestFront( 37 toolbox, 38 { target: outerFrameMainNodeFront.targetFront } 39 ); 40 41 const innerFrameSectionNodeFront = await getNodeFrontInFrames( 42 innerFrameSectionSelector, 43 inspector 44 ); 45 const innerFrameHighlighterTestFront = await getHighlighterTestFront( 46 toolbox, 47 { target: innerFrameSectionNodeFront.targetFront } 48 ); 49 50 info("Waiting for element picker to activate."); 51 await startPicker(inspector.toolbox); 52 53 info("Moving mouse over outerFrameDiv"); 54 await hoverElement(inspector, outerFrameMainSelector); 55 56 ok( 57 await outerFrameHighlighterTestFront.assertHighlightedNode( 58 outerFrameMainSelector.at(-1) 59 ), 60 "outerFrameDiv is highlighted." 61 ); 62 63 info("Moving mouse over innerFrameDiv"); 64 await hoverElement(inspector, innerFrameSectionSelector); 65 ok( 66 await innerFrameHighlighterTestFront.assertHighlightedNode( 67 innerFrameSectionSelector.at(-1) 68 ), 69 "innerFrameDiv is highlighted." 70 ); 71 72 info("Selecting root node"); 73 await selectNode(inspector.walker.rootNode, inspector); 74 75 info("Selecting an element from the nested iframe directly"); 76 await selectNodeInFrames(innerFrameSectionSelector, inspector); 77 78 is( 79 inspector.breadcrumbs.nodeHierarchy.length, 80 9, 81 "Breadcrumbs have 9 items." 82 ); 83 84 info("Waiting for element picker to deactivate."); 85 await toolbox.nodePicker.stop({ canceled: true }); 86 });