Fix serialization of HTML Element attributes
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2016 22:52:42 +0000 (22:52 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Sep 2016 22:52:42 +0000 (22:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162356

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt:
* web-platform-tests/html/syntax/serializing-html-fragments/serializing-expected.txt:

Source/WebCore:

Fix serialization of HTML Element attributes to align with:
- https://html.spec.whatwg.org/#html-fragment-serialisation-algorithm
- https://html.spec.whatwg.org/#escapingString

In particular, we should not escape '<' and '>'.

Firefox and Chrome both match the specification.

Note that we keep escaping '<' and '>' for Element attributes in the
context of XML serialization, as per:
- https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value

No new tests, rebaselined existing test.

* editing/MarkupAccumulator.h:

LayoutTests:

Rebaseline test to reflect behavior change.

* editing/pasteboard/paste-noscript-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@206240 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/paste-noscript-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/syntax/serializing-html-fragments/serializing-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/editing/MarkupAccumulator.h

index 3871402..54bfccd 100644 (file)
@@ -1,3 +1,14 @@
+2016-09-21  Chris Dumez  <cdumez@apple.com>
+
+        Fix serialization of HTML Element attributes
+        https://bugs.webkit.org/show_bug.cgi?id=162356
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline test to reflect behavior change.
+
+        * editing/pasteboard/paste-noscript-expected.txt:
+
 2016-09-21  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Improve output of TestHarness.expect* failures
index 3c64d47..49f9f44 100644 (file)
@@ -15,7 +15,7 @@ Submit.
 <a id="anchor2">Hello</a>
 <iframe id="iframe1" src="javascript:var x = 1;" style="width: 200px; height: 100px; background-color:#cee;"></iframe>
 <iframe id="iframe1" style="width: 200px; height: 100px; background-color: rgb(204, 238, 238);"></iframe>
-<iframe id="iframe2" srcdoc="&lt;script&gt;var x = 1;&lt;/script&gt;" style="width: 200px; height: 100px; background-color:#cee;"></iframe>
+<iframe id="iframe2" srcdoc="<script>var x = 1;</script>" style="width: 200px; height: 100px; background-color:#cee;"></iframe>
 <iframe id="iframe2" style="width: 200px; height: 100px; background-color: rgb(204, 238, 238);"></iframe>
 <form id="form1" action="javascript:sayHello()" formaction="javascript:sayHello()" style="width: 200px; height: 150px; background-color:#cee;">This is a form<br><img src="../resources/abe.png"><button formaction="javascript:sayHello()">Submit.</button></form>
 <form id="form1" formaction="javascript:sayHello()" style="width: 200px; height: 150px; background-color: rgb(204, 238, 238);">This is a form<br><img src="../resources/abe.png"><button>Submit.</button></form>
index 2de4946..b7102ee 100644 (file)
@@ -1,5 +1,17 @@
 2016-09-21  Chris Dumez  <cdumez@apple.com>
 
+        Fix serialization of HTML Element attributes
+        https://bugs.webkit.org/show_bug.cgi?id=162356
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt:
+        * web-platform-tests/html/syntax/serializing-html-fragments/serializing-expected.txt:
+
+2016-09-21  Chris Dumez  <cdumez@apple.com>
+
         Fix enumeration of properties cross origin
         https://bugs.webkit.org/show_bug.cgi?id=162328
 
index a73a007..9776adc 100644 (file)
@@ -10,7 +10,7 @@ FAIL <img srcset="/images/green-256x256.png 512w" sizes="256px" data-expect="128
 FAIL <img srcset="/images/green-256x256.png 256w" sizes="512px" data-expect="512"> assert_equals: naturalWidth expected 512 but got 256
 FAIL <img srcset="/images/green-256x256.png 256w" sizes="1px" data-expect="1"> assert_equals: naturalWidth expected 1 but got 256
 FAIL <img srcset="/images/green-256x256.png 256w" sizes="0px" data-expect="0"> assert_equals: naturalWidth expected 0 but got 256
-PASS <img srcset="data:image/svg+xml,&lt;svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'%20height='20'&gt;&lt;circle%20r='1'/&gt;&lt;/svg&gt; 2x" data-expect="10"> 
-PASS <img srcset="data:image/svg+xml,&lt;svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'&gt;&lt;circle%20r='1'/&gt;&lt;/svg&gt; 2x" data-expect="10"> 
-PASS <img srcset="data:image/svg+xml,&lt;svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20height='20'&gt;&lt;circle%20r='1'/&gt;&lt;/svg&gt; 2x" data-expect="10"> 
+PASS <img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'%20height='20'><circle%20r='1'/></svg> 2x" data-expect="10"> 
+PASS <img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20width='20'><circle%20r='1'/></svg> 2x" data-expect="10"> 
+PASS <img srcset="data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='-1%20-1%202%202'%20height='20'><circle%20r='1'/></svg> 2x" data-expect="10"> 
               
index dac3f2c..498d8cb 100644 (file)
@@ -6,8 +6,8 @@ PASS innerHTML 3 <a b="c"></a>
 PASS innerHTML 4 <a b="&amp;"></a> 
 PASS innerHTML 5 <a b="&nbsp;"></a> 
 PASS innerHTML 6 <a b="&quot;"></a> 
-FAIL innerHTML 7 <a b="<"></a> assert_equals: expected "<a b=\"<\"></a>" but got "<a b=\"&lt;\"></a>"
-FAIL innerHTML 8 <a b=">"></a> assert_equals: expected "<a b=\">\"></a>" but got "<a b=\"&gt;\"></a>"
+PASS innerHTML 7 <a b="<"></a> 
+PASS innerHTML 8 <a b=">"></a> 
 PASS innerHTML 9 <svg xlink:href="a"></svg> 
 PASS innerHTML 10 <svg xmlns:svg="test"></svg> 
 PASS innerHTML 11 a 
@@ -33,8 +33,8 @@ PASS outerHTML 3 <span><a b="c"></a></span>
 PASS outerHTML 4 <span><a b="&amp;"></a></span> 
 PASS outerHTML 5 <span><a b="&nbsp;"></a></span> 
 PASS outerHTML 6 <span><a b="&quot;"></a></span> 
-FAIL outerHTML 7 <span><a b="<"></a></span> assert_equals: expected "<span><a b=\"<\"></a></span>" but got "<span><a b=\"&lt;\"></a></span>"
-FAIL outerHTML 8 <span><a b=">"></a></span> assert_equals: expected "<span><a b=\">\"></a></span>" but got "<span><a b=\"&gt;\"></a></span>"
+PASS outerHTML 7 <span><a b="<"></a></span> 
+PASS outerHTML 8 <span><a b=">"></a></span> 
 PASS outerHTML 9 <span><svg xlink:href="a"></svg></span> 
 PASS outerHTML 10 <span><svg xmlns:svg="test"></svg></span> 
 PASS outerHTML 11 <span>a</span> 
index 570ee84..66779bc 100644 (file)
@@ -1,3 +1,26 @@
+2016-09-21  Chris Dumez  <cdumez@apple.com>
+
+        Fix serialization of HTML Element attributes
+        https://bugs.webkit.org/show_bug.cgi?id=162356
+
+        Reviewed by Alex Christensen.
+
+        Fix serialization of HTML Element attributes to align with:
+        - https://html.spec.whatwg.org/#html-fragment-serialisation-algorithm
+        - https://html.spec.whatwg.org/#escapingString
+
+        In particular, we should not escape '<' and '>'.
+
+        Firefox and Chrome both match the specification.
+
+        Note that we keep escaping '<' and '>' for Element attributes in the
+        context of XML serialization, as per:
+        - https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
+
+        No new tests, rebaselined existing test.
+
+        * editing/MarkupAccumulator.h:
+
 2016-09-21  Anders Carlsson  <andersca@apple.com>
 
         support openPaymentSetup API on ApplePaySession object
index c60c06d..b51870e 100644 (file)
@@ -54,7 +54,7 @@ enum EntityMask {
     EntityMaskInPCDATA = EntityAmp | EntityLt | EntityGt,
     EntityMaskInHTMLPCDATA = EntityMaskInPCDATA | EntityNbsp,
     EntityMaskInAttributeValue = EntityAmp | EntityLt | EntityGt | EntityQuot,
-    EntityMaskInHTMLAttributeValue = EntityMaskInAttributeValue | EntityNbsp,
+    EntityMaskInHTMLAttributeValue = EntityAmp | EntityQuot | EntityNbsp,
 };
 
 // FIXME: Noncopyable?