summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/cssom-view/checkVisibility.html
blob: 3ab1cc7dc2e366302607dda7091ce3513810d112 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/w3c/csswg-drafts/issues/6850">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id=visibilityhidden style="visibility:hidden">hello</div>

<div style="content-visibility:hidden">
  <div id=cvhidden>hello</div>
</div>

<div style="content-visibility:auto">
  <div id=cvauto>hello</div>
</div>

<div id=displaynone style="display:none">hello</div>

<div id=opacityzero style="opacity:0">hello</div>

<div style="content-visibility:hidden">
  <div id=cvhiddenchildwithupdate></div>
</div>

<div style="content-visibility:hidden" id=cvhiddenwithupdate></div>

<div style="height:10000px">spacer</div>

<div style="content-visibility:auto">
  <div id=cvautooffscreen>hello</div>
</div>

<div id=cvautocontainer>
  <div id=cvautochild></div>
</div>

<div style="content-visibility:auto">
  <div style="content-visibility:auto">
    <div id=nestedcvautochild></div>
  </div>
</div>

<script>
test(() => {
  assert_false(visibilityhidden.checkVisibility({
    checkVisibilityCSS: true
  }), 'checkVisibilityCSS:true');
  assert_true(visibilityhidden.checkVisibility({
    checkVisibilityCSS: false
  }), 'checkVisibilityCSS:false');
}, 'checkVisibility on visibility:hidden element.');

test(() => {
  assert_false(cvhidden.checkVisibility());
}, 'checkVisibility on content-visibility:hidden element.');

test(() => {
  assert_true(cvauto.checkVisibility());
}, 'checkVisibility on content-visibility:auto element.');

test(() => {
  assert_true(cvautooffscreen.checkVisibility());
}, 'checkVisibility on content-visibility:auto element which is outside the viewport.');

test(() => {
  assert_false(displaynone.checkVisibility());
}, 'checkVisibility on display:none element.');

test(() => {
  assert_false(opacityzero.checkVisibility({
    checkOpacity: true
  }), 'checkOpacity:true');
  assert_true(opacityzero.checkVisibility({
    checkOpacity: false
  }), 'checkOpacity:false');
}, 'checkVisibility on opacity:0 element.');

test(() => {
  cvautocontainer.style.contentVisibility = 'auto';
  cvautochild.style.visibility = 'hidden';
  assert_false(cvautochild.checkVisibility({checkVisibilityCSS: true}));
  cvautochild.style.visibility = 'visible';
  assert_true(cvautochild.checkVisibility({checkVisibilityCSS: true}));
}, 'checkVisibility on content-visibility:auto with visibility:hidden inside.');

test(() => {
  assert_true(nestedcvautochild.checkVisibility());
}, 'checkVisibility on nested content-visibility:auto containers reports that the content is visible.');

test(() => {
  cvhiddenchildwithupdate.getBoundingClientRect();
  assert_false(cvhiddenchildwithupdate.checkVisibility());
}, 'checkVisibility on content-visibility:hidden child after forced layout update.');

test(() => {
  cvhiddenwithupdate.getBoundingClientRect();
  assert_true(cvhiddenwithupdate.checkVisibility());
}, 'checkVisibility on content-visibility:hidden element after forced layout update.');
</script>