summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/test/browser_inspector_highlighter-iframes_01.js
blob: bfc6905b2d0ef559371004f28a00fd1012bfd1a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

// Testing that moving the mouse over the document with the element picker
// started highlights nodes

const NESTED_FRAME_SRC =
  "data:text/html;charset=utf-8," +
  "nested iframe<section>nested div</section>";

const OUTER_FRAME_SRC =
  "data:text/html;charset=utf-8," +
  "little frame<main>little div</main>" +
  "<iframe src='" +
  NESTED_FRAME_SRC +
  "' />";

const TEST_URI =
  "data:text/html;charset=utf-8," +
  "iframe tests for inspector" +
  '<iframe src="' +
  OUTER_FRAME_SRC +
  '" />';

add_task(async function () {
  const { toolbox, inspector } = await openInspectorForURL(TEST_URI);
  const outerFrameMainSelector = ["iframe", "main"];
  const innerFrameSectionSelector = ["iframe", "iframe", "section"];

  const outerFrameMainNodeFront = await getNodeFrontInFrames(
    outerFrameMainSelector,
    inspector
  );
  const outerFrameHighlighterTestFront = await getHighlighterTestFront(
    toolbox,
    { target: outerFrameMainNodeFront.targetFront }
  );

  const innerFrameSectionNodeFront = await getNodeFrontInFrames(
    innerFrameSectionSelector,
    inspector
  );
  const innerFrameHighlighterTestFront = await getHighlighterTestFront(
    toolbox,
    { target: innerFrameSectionNodeFront.targetFront }
  );

  info("Waiting for element picker to activate.");
  await startPicker(inspector.toolbox);

  info("Moving mouse over outerFrameDiv");
  await hoverElement(inspector, outerFrameMainSelector);

  ok(
    await outerFrameHighlighterTestFront.assertHighlightedNode(
      isEveryFrameTargetEnabled()
        ? outerFrameMainSelector.at(-1)
        : outerFrameMainSelector
    ),
    "outerFrameDiv is highlighted."
  );

  info("Moving mouse over innerFrameDiv");
  await hoverElement(inspector, innerFrameSectionSelector);
  ok(
    await innerFrameHighlighterTestFront.assertHighlightedNode(
      isEveryFrameTargetEnabled()
        ? innerFrameSectionSelector.at(-1)
        : innerFrameSectionSelector
    ),
    "innerFrameDiv is highlighted."
  );

  info("Selecting root node");
  await selectNode(inspector.walker.rootNode, inspector);

  info("Selecting an element from the nested iframe directly");
  await selectNodeInFrames(innerFrameSectionSelector, inspector);

  is(
    inspector.breadcrumbs.nodeHierarchy.length,
    9,
    "Breadcrumbs have 9 items."
  );

  info("Waiting for element picker to deactivate.");
  await toolbox.nodePicker.stop({ canceled: true });
});