<!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." // basic - default should be 1 test(function() { assert_equals(document.getElementById("basic").start, 1, "no start attribute provided -> 1"); }, "Default start value for non-reversed list should be 1"); // decimal's first element has value of .5 which should return 1 test(function() { assert_equals(document.getElementById("decimal").start, 1, "start of .5 -> 1 (default)"); }, "IDL and content attribute parse start of '.5' correctly."); // letter's first element has value of A which should return 1 test(function() { assert_equals(document.getElementById("letter").start, 1, "start of A -> 1 (default)"); }, "IDL and content attribute parse start of 'A' correctly."); // basicRevGoodName - default should be 3 test(function() { assert_equals(document.getElementById("basicRevGoodName").start, 3, "no start attribute provided -> 3"); }, "Default start value (if none provided) for reversed list = child li elements."); // basicRevEmpty - default should be 3 test(function() { assert_equals(document.getElementById("basicRevEmpty").start, 3, "start of A -> 3 (default)"); }, "Default start value (if failed to parse) for reversed list = child li elements."); // lots - default should be 3 test(function() { assert_equals(document.getElementById("lots").start, 3, "no start attribute -> 3 (default)"); }, "Default start value for reversed list = child li elements (even with tons of other child elements)."); // adding child element changes default start value for reversed list test(function() { var myList = document.getElementById("basicRevGoodName"), myLI = document.createElement("li"); myList.appendChild(myLI); assert_equals(document.getElementById("basicRevGoodName").start, 4, "Adding child element to reversed list adds 1 to start value"); }, "Adding child element to reversed list adds 1 to start value"); // removing child element changes default start value for reversed list test(function() { var myList = document.getElementById("basicRevTrue"); myList.removeChild(myList.children[0]); assert_equals(document.getElementById("basicRevTrue").start, 2, "Deleting child element from reversed list reduces start value by 1"); }, "Deleting child element from reversed list reduces start value by 1"); // start2's first element has value of 2 test(function() { assert_equals(document.getElementById("start2").start, 2, "start of 2 -> 2"); }, "IDL and content attribute parse start of '2' correctly."); // negative's first element has value of -10 test(function() { assert_equals(document.getElementById("negative").start, -10, "start of -10 -> -10"); }, "IDL and content attribute parse start of '-10' correctly."); // posFloatDown's first element has value of 4.03 which should return 4 test(function() { assert_equals(document.getElementById("posFloatDown").start, 4, "start of 4.03 -> 4"); }, "IDL and content attribute parse start of '4.03' correctly."); // negFloatDown's first element has value of -4.03 which should return -4 test(function() { assert_equals(document.getElementById("negFloatDown").start, -4, "start of -4.03 -> -4"); }, "IDL and content attribute parse start of '-4.03' correctly."); // posFloatUp's first element has value of 4.9 which should return 4 test(function() { assert_equals(document.getElementById("posFloatUp").start, 4, "start of 4.9 -> 4"); }, "IDL and content attribute parse start of '4.9' correctly."); // negFloatUp's first element has value of -4.9 which should return -4 test(function() { assert_equals(document.getElementById("negFloatUp").start, -4, "start of -4.9 -> -4"); }, "IDL and content attribute parse start of '-4.9' correctly."); // exponent's first element has value of 7e2 which should return 7 test(function() { assert_equals(document.getElementById("exponent").start, 7, "start of 7e2 -> 7"); }, "IDL and content attribute parse start of '7e2' correctly."); </script> </body> </html>