Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/common-HTMLOptionsCollection.html

Issue 1144143009: W3C Test: Import web-platform-tests/html/semantics (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title id='title'>HTMLOptionsCollection</title>
6 <script src="../../../../../../resources/testharness.js"></script>
7 <script src="../../../../../../resources/testharnessreport.js"></script>
8 <div id="log"></div>
9 <select id="selly">
10 <option>1</option>
11 <option>2</option>
12 <option>3</option>
13 <option>4</option>
14 </select>
15
16 <script>
17 var selly;
18 setup(function() {
19 selly = document.getElementById('selly');
20 });
21
22 test(function () {
23 assert_equals(selly.length, 4);
24 }, "On getting, the length attribute must return the number of nodes represented by the collection.");
25
26 test(function () {
27 selly.length = 7;
28 assert_equals(selly.length, 7,
29 "Number of nodes in collection should have changed");
30 assert_equals(selly.children.length, 7,
31 "Number of children should have changed");
32 for (var i = 4; i < 7; ++i) {
33 var child = selly.children[i];
34 assert_equals(child.localName, "option",
35 "new child should be an option");
36 assert_equals(child.namespaceURI, "http://www.w3.org/1999/xhtml",
37 "new child should be an HTML element");
38 assert_equals(child.attributes.length, 0,
39 "new child should not have attributes");
40 assert_equals(child.childNodes.length, 0,
41 "new child should not have child nodes");
42 }
43 }, "Changing the length adds new nodes; The number of new nodes = new length min us old length");
44
45 test(function () {
46 var elarray = [];
47 for (var i = 0; i < selly.length; i++) {
48 elarray.push(selly[i].value);
49 }
50 assert_array_equals(elarray, ["1", "2", "3", "4", "", "", ""]);
51 }, "New nodes have no value");
52
53 test(function () {
54 selly.length = 7;
55 assert_equals(selly.length, 7,
56 "Number of nodes in collection should not have changed");
57 assert_equals(selly.children.length, 7,
58 "Number of children should not have changed");
59 }, "Setting a length equal to existing length changes nothing");
60
61 test(function () {
62 selly.length = 4;
63 assert_equals(selly[6], undefined,
64 "previously set node is now undefined");
65 assert_equals(selly.length, 4,
66 "Number of nodes in collection is correctly changed");
67 assert_equals(selly.children.length, 4,
68 "Number of children should have changed");
69 }, "Setting a length lower than the old length trims nodes from the end");
70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698