summaryrefslogtreecommitdiffstats
path: root/dom/base/test/test_anonymousContent_set_style.html
blob: 8c268e7378d9884f76664ee65a26169c7d0db267 (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1571650
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 1571650 - Test AnonymousContent.setStyle() API</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1571650">Mozilla Bug 1571650</a>
  <script type="application/javascript">
  const chromeDocument = SpecialPowers.wrap(document);

  info("Set z-index to anonymous content");
  const div = document.createElement("div");
  div.setAttribute("class", "set-style-test");
  const anonymousContent = chromeDocument.insertAnonymousContent(div);
  anonymousContent.setStyle("z-index", 3);

  info("Test the element which became to anonymous");
  const mozCustomContentContainerEl =
    [...SpecialPowers.InspectorUtils.getChildrenForNode(document.documentElement, true)]
      .find(n => n.classList && n.classList.contains("moz-custom-content-container"));

  const targetEl = mozCustomContentContainerEl.querySelector(".set-style-test");
  ok(targetEl, "Element which became to anonymous is found");
  is(targetEl.style.zIndex, "3", "z-index is correct");

  chromeDocument.removeAnonymousContent(anonymousContent);
  </script>
</body>
</html>