summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/grouping-content/the-ol-element/grouping-ol.html
blob: 80fa734a92e0d28060012b63f974e4081bdde717 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>the ol element</title>
    <link rel="author" title="dzenana" href="mailto:dzenana.trenutak@gmail.com">
    <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-ol-element">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
</head>
<body>
    <h1>Description</h1>
    <p>This test validates the ol element.</p>

    <div id="log"></div>

    <p>Ordered List</p>
    <ol id="basic">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="allAtts" reversed start="3" type="A">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="justRev" reversed>
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="basicRevGoodName" reversed="reversed">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="basicRevNameWithSpace" reversed=" reversed ">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="basicRevEmpty" reversed="" start="A">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="basicRevTrue" reversed="true">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="basicRevFalse" reversed="false">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="start2" start="2">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="negative" start="-10">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="posFloatDown" start="4.03">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="negFloatDown" start="-4.03">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="posFloatUp" start="4.9">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="negFloatUp" start="-4.9">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="exponent" start="7e2">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="decimal" start=".5">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="letter" start="A">
        <li>list item</li>
        <li>list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="middle50">
        <li>list item</li>
        <li value="50">list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="middleneg50">
        <li>list item</li>
        <li value="-50">list item</li>
        <li>list item</li>
    </ol>

    <p>Ordered List</p>
    <ol id="lots" reversed="reversed">
        <li value="10">list item</li>
        <li value="20">list item</li>
<a></a><abbr></abbr><address></address><area></area><article></article><aside></aside><audio></audio><b></b><base></base><bdi></bdi><bdo></bdo><blockquote></blockquote><body></body><br></br><button></button><canvas></canvas><caption></caption><cite></cite><code></code><col></col><colgroup></colgroup><command></command><datalist></datalist><dd></dd><del></del><details></details><dfn></dfn><dialog></dialog><div></div><dl></dl><dt></dt><em></em><embed></embed><fieldset></fieldset><figcaption></figcaption><figure></figure><footer></footer><form></form><h1></h1><h2></h2><h3></h3><h4></h4><h5></h5><h6></h6><head></head><header></header><hgroup></hgroup><hr></hr><html></html><i></i><iframe></iframe><img></img><input></input><ins></ins><kbd></kbd><keygen></keygen><label></label><legend></legend><link></link><map></map><mark></mark><menu></menu><meta></meta><meter></meter><nav></nav><noscript></noscript><object></object><ol><li></li><li></li></ol><optgroup></optgroup><option></option><output></output><p></p><param></param><pre></pre><progress></progress><q></q><rp></rp><rt></rt><ruby></ruby><s></s><samp></samp><script></script><section></section><select></select><small></small><source></source><span></span><strong></strong><style></style><sub></sub><summary></summary><sup></sup><table></table><tbody></tbody><td></td><textarea></textarea><tfoot></tfoot><th></th><thead></thead><time></time><title></title><tr></tr><track></track><u></u><ul><li></li><li></li></ul><var></var><video></video><wbr></wbr>
        <li value="-99">list item</li>
    </ol>

    <script>
        "use strict";

        var testList;

        // check that prototype matches spec's DOM interface
        test(function () {
            testList = document.getElementById("basic");
            assert_equals(Object.getPrototypeOf(testList), HTMLOListElement.prototype, "HTMLOListElement.prototype should be used for OL");
        }, "The prototype for OL is HTMLOListElement.prototype");

        // check that "own" properties reversed, start, and type are present
        test(function () {
            testList = document.getElementById("basic");
            assert_idl_attribute(testList, "reversed");
        }, "'reversed' property should be defined on OL.");

        test(function () {
            testList = document.getElementById("basic");
            assert_idl_attribute(testList, "start");
        }, "'start' property should be defined on OL.");

        test(function () {
            testList = document.getElementById("basic");
            assert_idl_attribute(testList, "type");
        }, "'type' property should be defined on OL.");

        // "The reversed, start, and type IDL attributes must reflect the respective content attributes of the same name."
        test(function () {
            testList = document.getElementById("allAtts");
            assert_true(testList.reversed);
        }, "OL's 'reversed' IDL property reflects content attribute.");

        test(function () {
            testList = document.getElementById("allAtts");
            assert_equals(testList.start, 3);
        }, "OL's 'start' IDL property reflects content attribute.");

        test(function () {
            testList = document.getElementById("allAtts");
            assert_equals(testList.type, "A");
        }, "OL's 'type' IDL property reflects content attribute.");


        // "The reversed attribute is a boolean attribute."

        // check lists for which reversed value should be false
        test(function() {
            assert_false(document.getElementById("basic").reversed, "IDL 'reversed' attribute value false when content attribute absent");
        }, "IDL 'reversed' attribute value false when content attribute absent");

        // check lists for which reversed value should be true
        test(function() {
            assert_true(document.getElementById("justRev").reversed);
            assert_true(document.getElementById("basicRevGoodName").reversed);
            assert_true(document.getElementById("basicRevNameWithSpace").reversed);
            assert_true(document.getElementById("basicRevEmpty").reversed);
            assert_true(document.getElementById("basicRevTrue").reversed);
            assert_true(document.getElementById("basicRevFalse").reversed);
        }, "IDL 'reversed' attribute value true when content attribute exists");

        // check that IDL property works to change reversed value
        test(function() {
            document.getElementById("justRev").reversed = false;
            assert_false(document.getElementById("justRev").reversed, "Changing IDL 'reversed' property changes list's reversed property.");
        }, "Changing IDL 'reversed' property changes list's reversed property.");


        // If the start attribute is present, user agents must parse it as an integer, in order to determine the attribute's value.
        // The default value, used if the attribute is missing or
        //                         if the value cannot be converted to a number according to the referenced algorithm,
        // is 1 if the element has no reversed attribute, and
        // is the number of child li elements otherwise."
        // "The start IDL attribute has the same default as its content attribute."

        test(function() {
            assert_equals(document.getElementById("basic").start, 1);
        }, "Default start value for non-reversed list should be 1");

        test(function() {
            assert_equals(document.getElementById("decimal").start, 1);
        }, "IDL and content attribute parse start of '.5' correctly.");

        test(function() {
            assert_equals(document.getElementById("letter").start, 1);
        }, "IDL and content attribute parse start of 'A' correctly.");

        test(function() {
            assert_equals(document.getElementById("basicRevGoodName").start, 1);
        }, "Default start value (if none provided) for reversed list = 1.");

        test(function() {
            assert_equals(document.getElementById("basicRevEmpty").start, 1);
        }, "Default start value (if failed to parse) for reversed list = 1.");

        test(function() {
            assert_equals(document.getElementById("lots").start, 1);
        }, "Default start value for reversed list = 1 (even with tons of other child elements).");

        test(function() {
            var myList = document.getElementById("basicRevGoodName"), myLI = document.createElement("li");
            myList.appendChild(myLI);
            assert_equals(document.getElementById("basicRevGoodName").start, 1);
        }, "Adding child element to reversed list does not change start value");

        test(function() {
            var myList = document.getElementById("basicRevTrue");
            myList.removeChild(myList.children[0]);
            assert_equals(document.getElementById("basicRevTrue").start, 1);
        }, "Deleting child element from reversed list does not change start value");

        test(function() {
            assert_equals(document.getElementById("start2").start, 2);
        }, "IDL and content attribute parse start of '2' correctly.");

        test(function() {
            assert_equals(document.getElementById("negative").start, -10);
        }, "IDL and content attribute parse start of '-10' correctly.");

        test(function() {
            assert_equals(document.getElementById("posFloatDown").start, 4);
        }, "IDL and content attribute parse start of '4.03' correctly.");

        test(function() {
            assert_equals(document.getElementById("negFloatDown").start, -4);
        }, "IDL and content attribute parse start of '-4.03' correctly.");

        test(function() {
            assert_equals(document.getElementById("posFloatUp").start, 4);
        }, "IDL and content attribute parse start of '4.9' correctly.");

        test(function() {
            assert_equals(document.getElementById("negFloatUp").start, -4);
        }, "IDL and content attribute parse start of '-4.9' correctly.");

        test(function() {
            assert_equals(document.getElementById("exponent").start, 7);
        }, "IDL and content attribute parse start of '7e2' correctly.");

    </script>
</body>
</html>