Title: [207864] trunk
Revision
207864
Author
[email protected]
Date
2016-10-25 21:45:04 -0700 (Tue, 25 Oct 2016)

Log Message

Updating attribute by textContent must create a single mutation record and custom element reaction
https://bugs.webkit.org/show_bug.cgi?id=164003

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Rebaselined the test now that all test cases are passing.

* web-platform-tests/custom-elements/reactions/Node-expected.txt:

Source/WebCore:

The bug was caused by setTextContent not invoking setNodeValue for Attr nodes.
Use setNodeValue to match the specification: https://dom.spec.whatwg.org/#dom-node-textcontent

Test: fast/dom/MutationObserver/text-content-on-attr.html

* dom/Node.cpp:
(WebCore::Node::setTextContent):

LayoutTests:

Added a test for ensuring mutating the attribute by nodeValue and textContent creates exactly one mutation record.

* fast/custom-elements/reactions-for-webkit-extensions.html: Updated the description.
* fast/dom/MutationObserver/text-content-on-attr-expected.txt: Added.
* fast/dom/MutationObserver/text-content-on-attr.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207863 => 207864)


--- trunk/LayoutTests/ChangeLog	2016-10-26 01:57:44 UTC (rev 207863)
+++ trunk/LayoutTests/ChangeLog	2016-10-26 04:45:04 UTC (rev 207864)
@@ -1,3 +1,16 @@
+2016-10-25  Ryosuke Niwa  <[email protected]>
+
+        Updating attribute by textContent must create a single mutation record and custom element reaction
+        https://bugs.webkit.org/show_bug.cgi?id=164003
+
+        Reviewed by Chris Dumez.
+
+        Added a test for ensuring mutating the attribute by nodeValue and textContent creates exactly one mutation record.
+
+        * fast/custom-elements/reactions-for-webkit-extensions.html: Updated the description.
+        * fast/dom/MutationObserver/text-content-on-attr-expected.txt: Added.
+        * fast/dom/MutationObserver/text-content-on-attr.html: Added.
+
 2016-10-25  Michael Catanzaro  <[email protected]>
 
         Unreviewed, fix duplicate GTK expectations

Modified: trunk/LayoutTests/fast/custom-elements/reactions-for-webkit-extensions.html (207863 => 207864)


--- trunk/LayoutTests/fast/custom-elements/reactions-for-webkit-extensions.html	2016-10-26 01:57:44 UTC (rev 207863)
+++ trunk/LayoutTests/fast/custom-elements/reactions-for-webkit-extensions.html	2016-10-26 04:45:04 UTC (rev 207864)
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
 <head>
-<title>Custom Elements: CEReactions on Attr interface</title>
+<title>Custom Elements: CEReactions on HTMLElement interface</title>
 <meta name="author" title="Ryosuke Niwa" href=""
-<meta name="assert" content="value of Attr interface must have CEReactions">
+<meta name="assert" content="webkitdropzone of HTMLElement interface must have CEReactions">
 <meta name="help" content="https://dom.spec.whatwg.org/#node">
 <script src=""
 <script src=""

Added: trunk/LayoutTests/fast/dom/MutationObserver/text-content-on-attr-expected.txt (0 => 207864)


--- trunk/LayoutTests/fast/dom/MutationObserver/text-content-on-attr-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/MutationObserver/text-content-on-attr-expected.txt	2016-10-26 04:45:04 UTC (rev 207864)
@@ -0,0 +1,16 @@
+This tests mutating the attribute value by the setters of textContent and nodeValue. WebKit should insert exactly one record
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+element.attributes.title.textContent = "new"; records = observer.takeRecords()
+PASS records[0].attributeName is "title"
+PASS records.length is 1
+
+element.attributes.title.nodeValue = "world"; records = observer.takeRecords()
+PASS records[0].attributeName is "title"
+PASS records.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/MutationObserver/text-content-on-attr.html (0 => 207864)


--- trunk/LayoutTests/fast/dom/MutationObserver/text-content-on-attr.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/MutationObserver/text-content-on-attr.html	2016-10-26 04:45:04 UTC (rev 207864)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests mutating the attribute value by the setters of textContent and nodeValue. WebKit should insert exactly one record');
+
+let element = document.createElement('div');
+element.setAttribute('title', 'hello');
+
+let observer = new MutationObserver(function (records) { });
+observer.observe(element, {attributes: true});
+
+var records;
+evalAndLog('element.attributes.title.textContent = "new"; records = observer.takeRecords()');
+shouldBe('records[0].attributeName', '"title"');
+shouldBe('records.length', '1');
+
+debug('');
+
+evalAndLog('element.attributes.title.nodeValue = "world"; records = observer.takeRecords()');
+shouldBe('records[0].attributeName', '"title"');
+shouldBe('records.length', '1');
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (207863 => 207864)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-26 01:57:44 UTC (rev 207863)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-26 04:45:04 UTC (rev 207864)
@@ -1,3 +1,14 @@
+2016-10-25  Ryosuke Niwa  <[email protected]>
+
+        Updating attribute by textContent must create a single mutation record and custom element reaction
+        https://bugs.webkit.org/show_bug.cgi?id=164003
+
+        Reviewed by Chris Dumez.
+
+        Rebaselined the test now that all test cases are passing.
+
+        * web-platform-tests/custom-elements/reactions/Node-expected.txt:
+
 2016-10-25  Brady Eidson  <[email protected]>
 
         IndexedDB 2.0: Support IDBObjectStore openKeyCursor.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Node-expected.txt (207863 => 207864)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Node-expected.txt	2016-10-26 01:57:44 UTC (rev 207863)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Node-expected.txt	2016-10-26 04:45:04 UTC (rev 207864)
@@ -1,7 +1,7 @@
 
 PASS nodeValue on Node must enqueue an attributeChanged reaction when replacing an existing attribute 
 PASS nodeValue on Node must not enqueue an attributeChanged reaction when replacing an existing unobserved attribute 
-FAIL textContent on Node must enqueue an attributeChanged reaction when replacing an existing attribute assert_array_equals: lengths differ, expected 1 got 2
+PASS textContent on Node must enqueue an attributeChanged reaction when replacing an existing attribute 
 PASS textContent on Node must not enqueue an attributeChanged reaction when replacing an existing unobserved attribute 
 PASS cloneNode on Node must enqueue an attributeChanged reaction when cloning an element with an observed attribute 
 PASS cloneNode on Node must not enqueue an attributeChanged reaction when cloning an element with an unobserved attribute 

Modified: trunk/Source/WebCore/ChangeLog (207863 => 207864)


--- trunk/Source/WebCore/ChangeLog	2016-10-26 01:57:44 UTC (rev 207863)
+++ trunk/Source/WebCore/ChangeLog	2016-10-26 04:45:04 UTC (rev 207864)
@@ -1,3 +1,18 @@
+2016-10-25  Ryosuke Niwa  <[email protected]>
+
+        Updating attribute by textContent must create a single mutation record and custom element reaction
+        https://bugs.webkit.org/show_bug.cgi?id=164003
+
+        Reviewed by Chris Dumez.
+
+        The bug was caused by setTextContent not invoking setNodeValue for Attr nodes.
+        Use setNodeValue to match the specification: https://dom.spec.whatwg.org/#dom-node-textcontent
+
+        Test: fast/dom/MutationObserver/text-content-on-attr.html
+
+        * dom/Node.cpp:
+        (WebCore::Node::setTextContent):
+
 2016-10-25  Brent Fulgham  <[email protected]>
 
         [Win][Direct2D] Use smart pointers for Direct2D Path types

Modified: trunk/Source/WebCore/dom/Node.cpp (207863 => 207864)


--- trunk/Source/WebCore/dom/Node.cpp	2016-10-26 01:57:44 UTC (rev 207863)
+++ trunk/Source/WebCore/dom/Node.cpp	2016-10-26 04:45:04 UTC (rev 207864)
@@ -1475,27 +1475,27 @@
 void Node::setTextContent(const String& text, ExceptionCode& ec)
 {           
     switch (nodeType()) {
-        case TEXT_NODE:
-        case CDATA_SECTION_NODE:
-        case COMMENT_NODE:
-        case PROCESSING_INSTRUCTION_NODE:
-            setNodeValue(text, ec);
-            return;
-        case ELEMENT_NODE:
-        case ATTRIBUTE_NODE:
-        case DOCUMENT_FRAGMENT_NODE: {
-            auto container = makeRef(downcast<ContainerNode>(*this));
-            ChildListMutationScope mutation(container);
-            container->removeChildren();
-            if (!text.isEmpty())
-                container->appendChild(document().createTextNode(text), ec);
-            return;
-        }
-        case DOCUMENT_NODE:
-        case DOCUMENT_TYPE_NODE:
-            // Do nothing.
-            return;
+    case ATTRIBUTE_NODE:
+    case TEXT_NODE:
+    case CDATA_SECTION_NODE:
+    case COMMENT_NODE:
+    case PROCESSING_INSTRUCTION_NODE:
+        setNodeValue(text, ec);
+        return;
+    case ELEMENT_NODE:
+    case DOCUMENT_FRAGMENT_NODE: {
+        auto container = makeRef(downcast<ContainerNode>(*this));
+        ChildListMutationScope mutation(container);
+        container->removeChildren();
+        if (!text.isEmpty())
+            container->appendChild(document().createTextNode(text), ec);
+        return;
     }
+    case DOCUMENT_NODE:
+    case DOCUMENT_TYPE_NODE:
+        // Do nothing.
+        return;
+    }
     ASSERT_NOT_REACHED();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to