summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/flexbox/test/browser_flexbox_container_element_rep.js
blob: d2d83527b9ade9bf0dc536e5e49ae084fc404098 (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that the flex container's element rep will display the box model highlighter on
// hover.

const TEST_URI = URL_ROOT + "doc_flexbox_specific_cases.html";

add_task(async function () {
  await addTab(TEST_URI);
  const { inspector, flexboxInspector } = await openLayoutView();
  const { document: doc } = flexboxInspector;
  const { waitForHighlighterTypeShown } = getHighlighterTestHelpers(inspector);

  const onFlexContainerRepRendered = waitForDOM(
    doc,
    ".flex-header-content .objectBox"
  );
  await selectNode("#container", inspector);
  const [flexContainerRep] = await onFlexContainerRepRendered;

  ok(flexContainerRep, "The flex container element rep is rendered.");

  info("Listen to node-highlight event and mouse over the rep");
  const onHighlight = waitForHighlighterTypeShown(
    inspector.highlighters.TYPES.BOXMODEL
  );
  EventUtils.synthesizeMouse(
    flexContainerRep,
    10,
    5,
    { type: "mouseover" },
    doc.defaultView
  );
  const { nodeFront } = await onHighlight;

  ok(nodeFront, "nodeFront was returned from highlighting the node.");
  is(nodeFront.tagName, "DIV", "The highlighted node has the correct tagName.");
  is(
    nodeFront.attributes[0].name,
    "id",
    "The highlighted node has the correct attributes."
  );
  is(
    nodeFront.attributes[0].value,
    "container",
    "The highlighted node has the correct id."
  );
});