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

Unified Diff: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.html
diff --git a/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.html b/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.html
new file mode 100644
index 0000000000000000000000000000000000000000..7a4092ef356bb45a9480cca01cede1ac916e49b0
--- /dev/null
+++ b/LayoutTests/imported/web-platform-tests/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title id='title'>HTMLOptionsCollection</title>
+<script src="../../../../../../resources/testharness.js"></script>
+<script src="../../../../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
+<select id="selly">
+ <option id="id1" name="name1">1</option>
+ <option id="id2" name="name2">2</option>
+ <option id="id3" name="name3">3</option>
+ <option id="id4" name="name4">4</option>
+ <option name="nameonly">nameonly</option>
+ <option id="id3">duplicate ID</option>
+ <option name="name4">duplicate name</option>
+ <option id="mixed1">mixed ID</option>
+ <option name="mixed1">mixed name</option>
+</select>
+
+<script>
+var selly;
+setup(function() {
+ selly = document.getElementById('selly');
+});
+
+test(function () {
+ assert_equals(selly.namedItem('nameonly')["value"], "nameonly");
+}, "if only one item has a *name* or id value matching the parameter, return that object and stop");
+
+test(function () {
+ assert_equals(selly.namedItem('id2')["value"], "2");
+}, "if only one item has a name or *id* value matching the parameter, return that object and stop");
+
+test(function () {
+ assert_equals(selly.namedItem('thisdoesnotexist'), null);
+}, "if no item has a name or id value matching the parameter, return null and stop");
+
+test(function () {
+ var testarr = [];
+ for (var i = 0; i < selly.namedItem('id3').length; i++) {
+ testarr.push(selly.namedItem('id3')[i].text);
+ }
+ assert_array_equals(testarr, ['3','duplicate ID']);
+}, "return an HTMLOptionsCollection in correct order for repeated 'id' value");
+
+test(function () {
+ var testarr = [];
+ for (var i = 0; i < selly.namedItem('name4').length; i++) {
+ testarr.push(selly.namedItem('name4')[i].text);
+ }
+ assert_array_equals(testarr, ['4', 'duplicate name']);
+}, "return an HTMLOptionsCollection in correct order for repeated 'name' value");
+
+test(function () {
+ var testarr = [];
+ for (var i = 0; i < selly.namedItem('mixed1').length; i++) {
+ testarr.push(selly.namedItem('mixed1')[i].text);
+ }
+ assert_array_equals(testarr, ['mixed ID', 'mixed name']);
+}, "return an HTMLOptionsCollection in correct order for repeated mixed value");
+</script>

Powered by Google App Engine
This is Rietveld 408576698