summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/rendering/non-replaced-elements/hidden-elements.html
blob: e1bcf508e5d91348f3963792df2ca03a71e8ebaf (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
<!doctype html>
<link rel=help href="https://html.spec.whatwg.org/#hidden-elements">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div hidden></div>
<embed hidden>
<embed hidden=until-found>
<script>
const kNotHiddenElementLocalNames = [
  "source", "track",
];

const kHiddenElementLocalNames = [
  "area", "base", "basefont", "datalist", "head", "link", "meta", "noembed",
  "noframes", "param", "rp", "script", "style", "template", "title",
];

for (let name of kNotHiddenElementLocalNames) {
  test(function() {
    let element = document.createElement(name);
    document.body.appendChild(element);
    assert_equals(getComputedStyle(element).display, "inline");
  }, `${name} should not be hidden`);
}

for (let name of kHiddenElementLocalNames) {
  test(function() {
    let element = document.createElement(name);
    document.body.appendChild(element);
    assert_equals(getComputedStyle(element).display, "none");
  }, `${name} should be hidden`);
}

test(function() {
  assert_equals(getComputedStyle(document.querySelector("div[hidden]")).display, "none");
}, `div[hidden] element should be hidden`);

test(function() {
  const el = document.querySelector("embed[hidden='']");
  assert_equals(getComputedStyle(el).display, "inline");
  assert_equals(getComputedStyle(el).width, "0px");
  assert_equals(getComputedStyle(el).height, "0px");
}, `embed[hidden=''] element should be inline 0x0`);

test(function() {
  const el = document.querySelector("embed[hidden='until-found']");
  assert_equals(getComputedStyle(el).display, "inline");
  assert_equals(getComputedStyle(el).width, "0px");
  assert_equals(getComputedStyle(el).height, "0px");
  assert_equals(getComputedStyle(el).contentVisibility, "visible");
}, `embed[hidden='until-found'] element should be inline 0x0`);
</script>