summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/test/browser_inspector_highlighter-geometry_iframe.js
blob: a5f7b22a0064747439d05303c0b89f3fde080357 (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
/* 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";

// Test the creation of the geometry highlighter elements on remote frame.

const TEST_URL = `data:text/html;charset=utf-8,
  <iframe src="https://example.org/document-builder.sjs?html=${encodeURIComponent(`
    <div id='positioned' style='
      background:yellow;
      position:absolute;
      left:5rem;
      top:30px;'
    >
      Hello from iframe
    </div>`)}">
  </iframe>`;

add_task(async function () {
  const { inspector } = await openInspectorForURL(TEST_URL);

  info("Select the absolute positioned node in the iframe");
  await selectNodeInFrames(["iframe", "#positioned"], inspector);

  info("Click on the button enabling the highlighter");
  const onHighlighterShown = inspector.highlighters.once(
    "geometry-editor-highlighter-shown"
  );
  const boxModelPanel = inspector.getPanel("boxmodel");
  const button = await waitFor(() =>
    boxModelPanel.document.querySelector(".layout-geometry-editor")
  );
  button.click();

  await onHighlighterShown;
  ok(true, "Highlighter is displayed");

  info("Click on the button again to disable the highlighter");
  const onHighlighterHidden = inspector.highlighters.once(
    "geometry-editor-highlighter-hidden"
  );

  button.click();
  await onHighlighterHidden;
  ok("Highlighter is hidden");
});