summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/infrastructure/assumptions/html-elements.html
blob: 3fe3d201ff649aca36e49b6b78cd48a94db26806 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!doctype html>
<title>HTML styles</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#parent {
  display: none;
}

div.b {
  all: initial;
  direction: initial;
  unicode-bidi: isolate;
  display: block;
}

div.c {
  background: red;
  background: initial;
}

span.b {
  all: initial;
  direction: initial;
  unicode-bidi: initial;
  display: inline;
}
</style>
<div id="parent">
  <div class="a"></div>
  <div class="b"></div>
  <div class="c"></div>
  <span class="a"></span>
  <span class="b"></span>
  <p></p>
  <ul>
    <li>
  </ul>
  <ol>
    <li>
  </ol>
  <table>
    <tbody>
      <tr>
        <td>
  </table>
</div>
<script>
test(function() {
  assert_true('all' in document.documentElement.style);
}, "(pre-req for comparison tests) all CSS short-hand supported");

test(function() {
  assert_in_array(window.getComputedStyle(document.querySelector("div.c")).backgroundColor,
                  ["rgba(0, 0, 0, 0)", "transparent"]);
}, "(pre-req for comparison tests) initial CSS value supported");

test(function() {
  var a = document.querySelector("div.a");
  var b = document.querySelector("div.b");

  var a_styles = window.getComputedStyle(a);
  var b_styles = window.getComputedStyle(b);

  assert_equals(a_styles.length, b_styles.length, "Same properties on both div.a and div.b");

  for (var i = 0; i < a_styles.length; i++) {
    var property = a_styles[i];
    assert_equals(property, b_styles[i], "Same property on div.a and div.b");
    if (property !== "unicode-bidi") {
      assert_equals(a_styles[property], b_styles[property], "Different value for " + property);
    }
  }
}, "Compare CSS div definitions (only valid if pre-reqs pass)");

test(function() {
  var a = document.querySelector("span.a");
  var b = document.querySelector("span.b");

  var a_styles = window.getComputedStyle(a);
  var b_styles = window.getComputedStyle(b);

  assert_equals(a_styles.length, b_styles.length, "Same properties on both span.a and span.b");

  for (var i = 0; i < a_styles.length; i++) {
    var property = a_styles[i];
    assert_equals(property, b_styles[i], "Same property on span.a and span.b");
    assert_equals(a_styles[property], b_styles[property], "Different value for " + property);
  }
}, "Compare CSS span definitions (only valid if pre-reqs pass)");

test(function() {
  var p = document.getElementsByTagName("p")[0];
  var styles = window.getComputedStyle(p);
  assert_equals(styles["display"], "block");
}, "p is display: block");

test(function() {
  var ul_li = document.querySelector("ul > li");
  var styles = window.getComputedStyle(ul_li);
  assert_equals(styles["display"], "list-item");
}, "ul > li is display: list-item");

test(function() {
  var ol_li = document.querySelector("ol > li");
  var styles = window.getComputedStyle(ol_li);
  assert_equals(styles["display"], "list-item");
}, "ol > li is display: list-item");

test(function() {
  var table = document.getElementsByTagName("table")[0];
  var styles = window.getComputedStyle(table);
  assert_equals(styles["display"], "table");
}, "table is display: table");

test(function() {
  var tbody = document.getElementsByTagName("tbody")[0];
  var styles = window.getComputedStyle(tbody);
  assert_equals(styles["display"], "table-row-group");
}, "tbody is display: table-row-group");

test(function() {
  var tr = document.getElementsByTagName("tr")[0];
  var styles = window.getComputedStyle(tr);
  assert_equals(styles["display"], "table-row");
}, "tr is display: table-row");

test(function() {
  var td = document.getElementsByTagName("td")[0];
  var styles = window.getComputedStyle(td);
  assert_equals(styles["display"], "table-cell");
}, "td is display: table-cell");
</script>