Title: [206026] trunk
Revision
206026
Author
cdu...@apple.com
Date
2016-09-16 09:32:34 -0700 (Fri, 16 Sep 2016)

Log Message

Cloning a textarea does not clone the textarea's value
https://bugs.webkit.org/show_bug.cgi?id=156637

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Import corresponding W3C web platform test.

* web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps-expected.txt: Added.
* web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html: Added.
* web-platform-tests/html/semantics/forms/the-textarea-element/w3c-import.log:

Source/WebCore:

Update WebKit so that cloning a textarea element also clones its value.
This matches the HTML specification after:
- https://github.com/whatwg/html/pull/1784

The new behavior also matches Chrome and Edge.

Test: imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::copyNonAttributePropertiesFromElement):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::copyNonAttributePropertiesFromElement):
* html/HTMLTextAreaElement.h:

LayoutTests:

Update existing test to reflect behavior change.

* fast/forms/checkValidity-cloneNode-crash-expected.txt:
* fast/forms/checkValidity-cloneNode-crash.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206025 => 206026)


--- trunk/LayoutTests/ChangeLog	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/LayoutTests/ChangeLog	2016-09-16 16:32:34 UTC (rev 206026)
@@ -1,3 +1,15 @@
+2016-09-16  Chris Dumez  <cdu...@apple.com>
+
+        Cloning a textarea does not clone the textarea's value
+        https://bugs.webkit.org/show_bug.cgi?id=156637
+
+        Reviewed by Ryosuke Niwa.
+
+        Update existing test to reflect behavior change.
+
+        * fast/forms/checkValidity-cloneNode-crash-expected.txt:
+        * fast/forms/checkValidity-cloneNode-crash.html:
+
 2016-09-16  Youenn Fablet  <you...@apple.com>
 
         [Fetch API] Headers should be combine with ',' and not ', '

Modified: trunk/LayoutTests/fast/forms/checkValidity-cloneNode-crash-expected.txt (206025 => 206026)


--- trunk/LayoutTests/fast/forms/checkValidity-cloneNode-crash-expected.txt	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/LayoutTests/fast/forms/checkValidity-cloneNode-crash-expected.txt	2016-09-16 16:32:34 UTC (rev 206026)
@@ -10,9 +10,9 @@
 PASS element.checkValidity() is true
 PASS element2.checkValidity() is false
 PASS element.checkValidity() is true
-PASS element2.value is ""
-PASS element2.checkValidity() is false
+PASS element2.value is "a"
 PASS element2.checkValidity() is true
+PASS element2.checkValidity() is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/forms/checkValidity-cloneNode-crash.html (206025 => 206026)


--- trunk/LayoutTests/fast/forms/checkValidity-cloneNode-crash.html	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/LayoutTests/fast/forms/checkValidity-cloneNode-crash.html	2016-09-16 16:32:34 UTC (rev 206026)
@@ -44,8 +44,8 @@
     element.value = "a";
     shouldBeTrue("element.checkValidity()");
     element2 = element.cloneNode();
-    shouldBeEqualToString("element2.value", "");
-    shouldBeFalse("element2.checkValidity()");
+    shouldBeEqualToString("element2.value", "a");
+    shouldBeTrue("element2.checkValidity()");
     element2.value = element.value;
     shouldBeTrue("element2.checkValidity()");
 }

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206025 => 206026)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-09-16 16:32:34 UTC (rev 206026)
@@ -1,3 +1,16 @@
+2016-09-16  Chris Dumez  <cdu...@apple.com>
+
+        Cloning a textarea does not clone the textarea's value
+        https://bugs.webkit.org/show_bug.cgi?id=156637
+
+        Reviewed by Ryosuke Niwa.
+
+        Import corresponding W3C web platform test.
+
+        * web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps-expected.txt: Added.
+        * web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html: Added.
+        * web-platform-tests/html/semantics/forms/the-textarea-element/w3c-import.log:
+
 2016-09-16  Youenn Fablet  <you...@apple.com>
 
         [Fetch API] Headers should be combine with ',' and not ', '

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps-expected.txt (0 => 206026)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps-expected.txt	2016-09-16 16:32:34 UTC (rev 206026)
@@ -0,0 +1,4 @@
+
+PASS textarea element's value should be cloned 
+PASS textarea element's dirty value flag should be cloned, so setAttribute doesn't affect the cloned textarea's value 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html (0 => 206026)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html	2016-09-16 16:32:34 UTC (rev 206026)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Cloning of textarea elements</title>
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="help" href=""
+<link rel="author" title="Domenic Denicola" href=""
+
+<script src=""
+<script src=""
+
+<script>
+"use strict";
+
+test(() => {
+  const textarea = document.createElement("textarea");
+  textarea.value = "foo bar";
+
+  const copy = textarea.cloneNode();
+  assert_equals(copy.value, "foo bar");
+}, "textarea element's value should be cloned");
+
+test(() => {
+  const textarea = document.createElement("textarea");
+  textarea.value = "foo bar";
+
+  const copy = textarea.cloneNode();
+  copy.setAttribute("value", "something else");
+
+  assert_equals(copy.value, "foo bar");
+}, "textarea element's dirty value flag should be cloned, so setAttribute doesn't affect the cloned textarea's value");
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/w3c-import.log (206025 => 206026)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/w3c-import.log	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/w3c-import.log	2016-09-16 16:32:34 UTC (rev 206026)
@@ -15,6 +15,7 @@
 None
 ------------------------------------------------------------------------
 List of files:
+/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html
 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/textarea-newline-bidi-expected.html
 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/textarea-newline-bidi.html
 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/textarea-type.html

Modified: trunk/Source/WebCore/ChangeLog (206025 => 206026)


--- trunk/Source/WebCore/ChangeLog	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/Source/WebCore/ChangeLog	2016-09-16 16:32:34 UTC (rev 206026)
@@ -1,3 +1,24 @@
+2016-09-16  Chris Dumez  <cdu...@apple.com>
+
+        Cloning a textarea does not clone the textarea's value
+        https://bugs.webkit.org/show_bug.cgi?id=156637
+
+        Reviewed by Ryosuke Niwa.
+
+        Update WebKit so that cloning a textarea element also clones its value.
+        This matches the HTML specification after:
+        - https://github.com/whatwg/html/pull/1784
+
+        The new behavior also matches Chrome and Edge.
+
+        Test: imported/w3c/web-platform-tests/html/semantics/forms/the-textarea-element/cloning-steps.html
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::copyNonAttributePropertiesFromElement):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::copyNonAttributePropertiesFromElement):
+        * html/HTMLTextAreaElement.h:
+
 2016-09-16  Jer Noble  <jer.no...@apple.com>
 
         [media-source] Only fire 'resize' events when new sized frame is displayed, not parsed.

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (206025 => 206026)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2016-09-16 16:32:34 UTC (rev 206026)
@@ -954,7 +954,7 @@
 
 void HTMLInputElement::copyNonAttributePropertiesFromElement(const Element& source)
 {
-    const HTMLInputElement& sourceElement = static_cast<const HTMLInputElement&>(source);
+    auto& sourceElement = downcast<HTMLInputElement>(source);
 
     m_valueIfDirty = sourceElement.m_valueIfDirty;
     m_wasModifiedByUser = false;

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (206025 => 206026)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2016-09-16 16:32:34 UTC (rev 206026)
@@ -587,4 +587,15 @@
     return textBlockStyle;
 }
 
+void HTMLTextAreaElement::copyNonAttributePropertiesFromElement(const Element& source)
+{
+    auto& sourceElement = downcast<HTMLTextAreaElement>(source);
+
+    setValueCommon(sourceElement.value());
+    m_isDirty = sourceElement.m_isDirty;
+    HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
+
+    updateValidity();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (206025 => 206026)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2016-09-16 16:21:58 UTC (rev 206025)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2016-09-16 16:32:34 UTC (rev 206026)
@@ -55,6 +55,7 @@
     
     TextControlInnerTextElement* innerTextElement() const final;
     RenderStyle createInnerTextStyle(const RenderStyle&) const final;
+    void copyNonAttributePropertiesFromElement(const Element&) final;
 
     void rendererWillBeDestroyed();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to