Title: [212522] trunk
Revision
212522
Author
cdu...@apple.com
Date
2017-02-16 20:30:45 -0800 (Thu, 16 Feb 2017)

Log Message

<input>.labels is empty if type changes from text->hidden->checkbox
https://bugs.webkit.org/show_bug.cgi?id=168358

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Re-sync web-platform-test from:
https://github.com/w3c/web-platform-tests/pull/4804

* web-platform-tests/html/semantics/forms/the-label-element/labelable-elements-expected.txt:
* web-platform-tests/html/semantics/forms/the-label-element/labelable-elements.html:

Source/WebCore:

We were invalidating LabelsNodeLists on 'for' attribute change.
We now also invalidate them of 'type' attribute change since
HTMLInputElements whose type is 'hidden' do not support labels.

No new tests, updated existing test.

* dom/Document.h:
* dom/LiveNodeList.h:
(WebCore::shouldInvalidateTypeOnAttributeChange):
* html/LabelsNodeList.cpp:
(WebCore::LabelsNodeList::LabelsNodeList):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (212521 => 212522)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-17 04:30:45 UTC (rev 212522)
@@ -1,3 +1,16 @@
+2017-02-16  Chris Dumez  <cdu...@apple.com>
+
+        <input>.labels is empty if type changes from text->hidden->checkbox
+        https://bugs.webkit.org/show_bug.cgi?id=168358
+
+        Reviewed by Ryosuke Niwa.
+
+        Re-sync web-platform-test from:
+        https://github.com/w3c/web-platform-tests/pull/4804
+
+        * web-platform-tests/html/semantics/forms/the-label-element/labelable-elements-expected.txt:
+        * web-platform-tests/html/semantics/forms/the-label-element/labelable-elements.html:
+
 2017-02-16  Alex Christensen  <achristen...@webkit.org>
 
         Special URLs without a host are invalid

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/labelable-elements-expected.txt (212521 => 212522)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/labelable-elements-expected.txt	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/labelable-elements-expected.txt	2017-02-17 04:30:45 UTC (rev 212522)
@@ -10,7 +10,7 @@
 PASS Check if the button element is a labelable element 
 PASS Check if the button element can access 'labels' 
 PASS Check if the hidden input element is not a labelable element. 
-FAIL Check if the hidden input element can access 'labels' null is not an object (evaluating 'elem.labels.length')
+PASS Check if the hidden input element has null 'labels' 
 PASS Check if the input element in radio state is a labelable element 
 PASS Check if the input element in radio state can access 'labels' 
 FAIL Check if the keygen element is not a labelable element assert_not_equals: got disallowed value Element node <keygen id="testkeygen"></keygen>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/labelable-elements.html (212521 => 212522)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/labelable-elements.html	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/labelable-elements.html	2017-02-17 04:30:45 UTC (rev 212522)
@@ -36,7 +36,7 @@
 </form>
 
 <script>
-function testLabelsAttr(formElementId, labelElementId, hasLabels) {
+function testLabelsAttr(formElementId, labelElementId) {
   var elem = document.getElementById(formElementId);
   if (labelElementId) {
     assert_equals(elem.labels.length, 1);
@@ -91,9 +91,25 @@
 }, "Check if the hidden input element is not a labelable element.");
 
 test(function() {
-  testLabelsAttr("testHidden", null);
-}, "Check if the hidden input element can access 'labels'");
+  var hiddenInput = document.getElementById("testHidden");
+  assert_equals(hiddenInput.labels, null, "input[type=hidden] must have null .labels");
 
+  this.add_cleanup(function () {
+    hiddenInput.type = "hidden";
+  });
+
+  hiddenInput.type = "text";
+  testLabelsAttr("testHidden", "lbl5");
+  var labels = hiddenInput.labels;
+
+  hiddenInput.type = "hidden";
+  assert_equals(labels.length, 0, "Retained .labels NodeList should be empty after input type changed to hidden");
+
+  hiddenInput.type = "checkbox";
+  assert_true(labels === hiddenInput.labels, ".labels property must return the [SameObject] after input type is toggled back from 'hidden'");
+  assert_equals(hiddenInput.labels.length, 1, ".labels NodeList should contain the input after the input type is changed from 'hidden' to 'checkbox'");
+}, "Check if the hidden input element has null 'labels'");
+
 test(function() {
   assert_equals(document.getElementById("lbl6").control.id, "testRadio", "An input  element in radio state should be labelable.");
 }, "Check if the input element in radio state is a labelable element");

Modified: trunk/Source/WebCore/ChangeLog (212521 => 212522)


--- trunk/Source/WebCore/ChangeLog	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/Source/WebCore/ChangeLog	2017-02-17 04:30:45 UTC (rev 212522)
@@ -1,3 +1,22 @@
+2017-02-16  Chris Dumez  <cdu...@apple.com>
+
+        <input>.labels is empty if type changes from text->hidden->checkbox
+        https://bugs.webkit.org/show_bug.cgi?id=168358
+
+        Reviewed by Ryosuke Niwa.
+
+        We were invalidating LabelsNodeLists on 'for' attribute change.
+        We now also invalidate them of 'type' attribute change since
+        HTMLInputElements whose type is 'hidden' do not support labels.
+
+        No new tests, updated existing test.
+
+        * dom/Document.h:
+        * dom/LiveNodeList.h:
+        (WebCore::shouldInvalidateTypeOnAttributeChange):
+        * html/LabelsNodeList.cpp:
+        (WebCore::LabelsNodeList::LabelsNodeList):
+
 2017-02-16  Michael Catanzaro  <mcatanz...@igalia.com>
 
         Remove even more EFL from WebCore

Modified: trunk/Source/WebCore/dom/Document.h (212521 => 212522)


--- trunk/Source/WebCore/dom/Document.h	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/Source/WebCore/dom/Document.h	2017-02-17 04:30:45 UTC (rev 212522)
@@ -230,7 +230,7 @@
     InvalidateOnClassAttrChange,
     InvalidateOnIdNameAttrChange,
     InvalidateOnNameAttrChange,
-    InvalidateOnForAttrChange,
+    InvalidateOnForTypeAttrChange,
     InvalidateForFormControls,
     InvalidateOnHRefAttrChange,
     InvalidateOnAnyAttrChange,

Modified: trunk/Source/WebCore/dom/LiveNodeList.h (212521 => 212522)


--- trunk/Source/WebCore/dom/LiveNodeList.h	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/Source/WebCore/dom/LiveNodeList.h	2017-02-17 04:30:45 UTC (rev 212522)
@@ -113,8 +113,8 @@
         return attrName == HTMLNames::nameAttr;
     case InvalidateOnIdNameAttrChange:
         return attrName == HTMLNames::idAttr || attrName == HTMLNames::nameAttr;
-    case InvalidateOnForAttrChange:
-        return attrName == HTMLNames::forAttr;
+    case InvalidateOnForTypeAttrChange:
+        return attrName == HTMLNames::forAttr || attrName == HTMLNames::typeAttr;
     case InvalidateForFormControls:
         return attrName == HTMLNames::nameAttr || attrName == HTMLNames::idAttr || attrName == HTMLNames::forAttr
             || attrName == HTMLNames::formAttr || attrName == HTMLNames::typeAttr;

Modified: trunk/Source/WebCore/html/LabelsNodeList.cpp (212521 => 212522)


--- trunk/Source/WebCore/html/LabelsNodeList.cpp	2017-02-17 04:07:12 UTC (rev 212521)
+++ trunk/Source/WebCore/html/LabelsNodeList.cpp	2017-02-17 04:30:45 UTC (rev 212522)
@@ -34,7 +34,7 @@
 using namespace HTMLNames;
 
 LabelsNodeList::LabelsNodeList(LabelableElement& forNode)
-    : CachedLiveNodeList(forNode, InvalidateOnForAttrChange)
+    : CachedLiveNodeList(forNode, InvalidateOnForTypeAttrChange)
 {
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to