summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-default-style-meta-from-fragment.tentative.html
blob: a9b7ba633e7deac4a4e56b559e3097a614bf70ef (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>
<meta charset=utf-8>
<title>Node.appendChild: inserting script and default-style meta from a fragment</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<link rel="alternate stylesheet" title="alternative" href="data:text/css,%23div{display:none}">
<div id="div">hello</div>
<script>
let scriptRan = false;
let computedStyleDuringInsertion = null;
test(() => {
  const div = document.getElementById("div");
  const meta = document.createElement("meta");
  meta.httpEquiv = "default-style";
  meta.content = "alternative";
  const script = document.createElement("script");
  script.textContent = `
    computedStyleDuringInsertion = getComputedStyle(div).display;
    scriptRan = true;
  `;
  const df = document.createDocumentFragment();
  df.appendChild(script);
  df.appendChild(meta);
  assert_equals(getComputedStyle(div).display, "block", "div has block display");
  assert_false(scriptRan, "script has not run before insertion");
  document.head.appendChild(df);
  assert_true(scriptRan, "script has run after insertion");
  assert_equals(computedStyleDuringInsertion, "none",
      "display: none; style was applied during DOM insertion, before " +
      "later-inserted script runs");
  assert_equals(getComputedStyle(div).display, "none",
      "style remains display: none; after insertion");
}, "Inserting <meta> that uses alternate stylesheets, applies the style " +
   "during DOM insertion, and before script runs as a result of any atomic insertions");
</script>