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

Unified Diff: LayoutTests/fast/forms/form-radio-node-list.html

Issue 119063002: Have HTMLFormElement's named getter return a RadioNodeList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update expected output for inspector/console/console-format-collections Created 7 years 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/fast/forms/form-radio-node-list.html
diff --git a/LayoutTests/fast/forms/form-radio-node-list.html b/LayoutTests/fast/forms/form-radio-node-list.html
new file mode 100644
index 0000000000000000000000000000000000000000..faecee11ad341b55f18793b0857b8ece48825ede
--- /dev/null
+++ b/LayoutTests/fast/forms/form-radio-node-list.html
@@ -0,0 +1,91 @@
+<!doctype html>
+<html>
+<body>
esprehn 2013/12/19 11:02:48 We usually leave out <html> and <body>
sof 2013/12/19 12:15:05 Done.
+<script src="../../resources/js-test.js"></script>
+<form id="f1">
+ <button id=n1></button>
+ <fieldset id=n1><legend id=legend1></legend></fieldset>
+ <input name=n1 type=hidden>
+ <input name=n1 type=image>
+ <input name=n1 type=text>
+ <input name=n1 type=radio>
+ <keygen id=n1></keygen>
+ <output id=n1></output>
+ <object name=n1></object>
+ <select name=n1><option id=n1></option></select>
+ <textarea id=n1></textarea>
+ <div id=n1></div>
+ <option id=n1></option>
+</form>
+<form id="f2">
+ <button id=n1></button>
esprehn 2013/12/19 11:02:48 You have duplicate ids in here, is that on purpose
sof 2013/12/19 12:15:05 It's key that they are for this test, yes.
+ <keygen id=n1></keygen>
+ <output id=n1></output>
+ <object name=n1></object>
+ <select name=n1><option id=n1></option></select>
+ <input name=n1 type=hidden>
+ <input name=n1 type=image>
+ <input name=n1 type=text>
+ <input name=n2 type=image>
+ <img name=n2></img>
+ <img id=n2></img>
+</form>
+<script>
+description("Test RadioNodeLists returned by the HTMLFormElement named-getter.");
+
+var form1 = document.getElementById("f1");
+shouldBe("form1.elements.length", "10");
+
+var radioNodeList;
+
+function testListedElements() {
+ debug("Check that only 'listed elements' are included in the list, if any.");
+ radioNodeList = form1["n1"];
+ shouldBe("radioNodeList.length", "10");
+
+ shouldBeTrue("radioNodeList[0] instanceof HTMLButtonElement");
+ shouldBeTrue("radioNodeList[1] instanceof HTMLFieldSetElement");
+ shouldBeTrue("radioNodeList[2] instanceof HTMLInputElement");
+ shouldBe("radioNodeList[2].type", "'hidden'");
+ shouldBeTrue("radioNodeList[3] instanceof HTMLInputElement");
+ shouldBe("radioNodeList[3].type", "'text'");
+ shouldBeTrue("radioNodeList[4] instanceof HTMLInputElement");
+ shouldBe("radioNodeList[4].type", "'radio'");
+ shouldBeTrue("radioNodeList[5] instanceof HTMLKeygenElement");
+ shouldBeTrue("radioNodeList[6] instanceof HTMLOutputElement");
+ shouldBeTrue("radioNodeList[7] instanceof HTMLObjectElement");
+ shouldBeTrue("radioNodeList[8] instanceof HTMLSelectElement");
+ shouldBeTrue("radioNodeList[9] instanceof HTMLTextAreaElement");
+ debug("");
esprehn 2013/12/19 11:02:48 Remove this empty debug.
sof 2013/12/19 12:15:05 Done.
+}
+
+function testImageElement2ndPhase() {
esprehn 2013/12/19 11:02:48 Can this just be a separate test?
sof 2013/12/19 12:15:05 ok, done.
+ debug("Check that if no 'listed elements' match by name, img elements are picked instead.");
+
+ function verifyLength(n) {
+ shouldBe("radioNodeList.length", n.toString());
+ for (var i = 0; i < n; i++)
+ shouldBeTrue("radioNodeList[" + i + "] instanceof HTMLImageElement");
esprehn 2013/12/19 11:02:48 Dynamic tests like this are very hard to follow, I
sof 2013/12/19 12:15:05 ok, abstracted out.
+ }
+
+ var form2 = document.getElementById("f2");
+ radioNodeList = form2["n2"];
+ verifyLength(2);
+
+ var button = document.createElement("button");
+ button.name = "n2";
+ form2.appendChild(button);
+ verifyLength(2);
+
+ var img = document.createElement("img");
+ img.name = "n2";
+ form2.appendChild(img);
+ verifyLength(3);
+}
+
+testListedElements();
+testImageElement2ndPhase();
+</script>
+<p id="description"></p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698