Title: [154662] trunk
- Revision
- 154662
- Author
- [email protected]
- Date
- 2013-08-26 20:46:42 -0700 (Mon, 26 Aug 2013)
Log Message
Elements in a node list of the form element's name getter should not be added to the past names map
https://bugs.webkit.org/show_bug.cgi?id=120279
Reviewed by Darin Adler.
Source/WebCore:
Don't add the element in the named items to the past names map when there are multiple elements.
This matches IE10's behavior and the specified behavior in HTML5:
http://www.w3.org/TR/2013/WD-html51-20130528/forms.html#dom-form-nameditem
Test: fast/forms/past-names-map-should-not-contain-nodelist-item.html
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::getNamedElements):
LayoutTests:
Add a regression test.
* fast/forms/past-names-map-should-not-contain-nodelist-item-expected.txt: Added.
* fast/forms/past-names-map-should-not-contain-nodelist-item.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (154661 => 154662)
--- trunk/LayoutTests/ChangeLog 2013-08-27 03:33:21 UTC (rev 154661)
+++ trunk/LayoutTests/ChangeLog 2013-08-27 03:46:42 UTC (rev 154662)
@@ -1,3 +1,15 @@
+2013-08-26 Ryosuke Niwa <[email protected]>
+
+ Elements in a node list of the form element's name getter should not be added to the past names map
+ https://bugs.webkit.org/show_bug.cgi?id=120279
+
+ Reviewed by Darin Adler.
+
+ Add a regression test.
+
+ * fast/forms/past-names-map-should-not-contain-nodelist-item-expected.txt: Added.
+ * fast/forms/past-names-map-should-not-contain-nodelist-item.html: Added.
+
2013-08-26 Alexey Proskuryakov <[email protected]>
[Mac] can-read-in-dragstart-event.html and can-read-in-copy-and-cut-events.html fail
Added: trunk/LayoutTests/fast/forms/past-names-map-should-not-contain-nodelist-item-expected.txt (0 => 154662)
--- trunk/LayoutTests/fast/forms/past-names-map-should-not-contain-nodelist-item-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/past-names-map-should-not-contain-nodelist-item-expected.txt 2013-08-27 03:46:42 UTC (rev 154662)
@@ -0,0 +1,15 @@
+This test ensures that none of elements in a node list returned by the named getter of a form element are added to the past names map of the element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS form['foo'].length is 2
+PASS form['foo'][0] is form.firstChild
+PASS form['foo'][1] is form.lastChild
+PASS form.lastChild.name = 'bar'; form['bar'] is form.lastChild
+PASS form.firstChild.name = 'bar'; form['bar'].length is 2
+PASS form['foo'] is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/past-names-map-should-not-contain-nodelist-item.html (0 => 154662)
--- trunk/LayoutTests/fast/forms/past-names-map-should-not-contain-nodelist-item.html (rev 0)
+++ trunk/LayoutTests/fast/forms/past-names-map-should-not-contain-nodelist-item.html 2013-08-27 03:46:42 UTC (rev 154662)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<body>
+<form><input type="text" name="foo"><input type="text" name="foo"></form>
+<script src=""
+<script>
+
+description("This test ensures that none of elements in a node list returned by the named getter of a form element are added to the past names map of the element.");
+
+var form = document.querySelector('form');
+shouldBe("form['foo'].length", "2");
+shouldBe("form['foo'][0]", "form.firstChild");
+shouldBe("form['foo'][1]", "form.lastChild");
+shouldBe("form.lastChild.name = 'bar'; form['bar']", "form.lastChild");
+shouldBe("form.firstChild.name = 'bar'; form['bar'].length", "2");
+shouldBeUndefined("form['foo']", "form.firstChild");
+
+form.style.display = 'none';
+
+var successfullyParsed = true;
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (154661 => 154662)
--- trunk/Source/WebCore/ChangeLog 2013-08-27 03:33:21 UTC (rev 154661)
+++ trunk/Source/WebCore/ChangeLog 2013-08-27 03:46:42 UTC (rev 154662)
@@ -1,5 +1,21 @@
2013-08-26 Ryosuke Niwa <[email protected]>
+ Elements in a node list of the form element's name getter should not be added to the past names map
+ https://bugs.webkit.org/show_bug.cgi?id=120279
+
+ Reviewed by Darin Adler.
+
+ Don't add the element in the named items to the past names map when there are multiple elements.
+ This matches IE10's behavior and the specified behavior in HTML5:
+ http://www.w3.org/TR/2013/WD-html51-20130528/forms.html#dom-form-nameditem
+
+ Test: fast/forms/past-names-map-should-not-contain-nodelist-item.html
+
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::getNamedElements):
+
+2013-08-26 Ryosuke Niwa <[email protected]>
+
Windows build fix after r154658.
* page/AutoscrollController.cpp:
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (154661 => 154662)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2013-08-27 03:33:21 UTC (rev 154661)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2013-08-27 03:46:42 UTC (rev 154662)
@@ -639,7 +639,7 @@
// FIXME: The specification says we should not add the element from the past when names map when namedItems is not empty.
HTMLFormControlElement* elementFromPast = elementFromPastNamesMap(name);
- if (namedItems.size() && namedItems.first() != elementFromPast)
+ if (namedItems.size() == 1 && namedItems.first() != elementFromPast)
addElementToPastNamesMap(static_cast<HTMLFormControlElement*>(namedItems.first().get()), name);
else if (elementFromPast && namedItems.find(elementFromPast) == notFound)
namedItems.append(elementFromPast);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes