<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205515] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205515">205515</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-09-06 15:59:29 -0700 (Tue, 06 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Align srcset attribute parsing with the HTML specification
https://bugs.webkit.org/show_bug.cgi?id=161636

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline a couple of W3C tests 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/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt:

Source/WebCore:

Align srcset attribute parsing with the HTML specification:
- https://html.spec.whatwg.org/#parse-a-srcset-attribute

The new behavior is also consistent with Firefox and Chrome
as all 3 browsers now pass 100% of the checks at:
- http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html

No new tests, rebaselined existing tests.

* html/parser/HTMLParserIdioms.cpp:
(WebCore::parseValidHTMLNonNegativeIntegerInternal):
(WebCore::parseValidHTMLNonNegativeInteger):
(WebCore::parseValidHTMLFloatingPointNumberInternal):
(WebCore::parseValidHTMLFloatingPointNumber):
* html/parser/HTMLParserIdioms.h:
Add convenience for parsing *valid* HTML non-negative integers and
*valid* floating point number values.

* html/parser/HTMLSrcsetParser.cpp:
(WebCore::parseDescriptors):
- Use parseValidHTMLFloatingPointNumber() to parse density so that the value
  is parsed as a valid HTML floating point number value, as per the spec.
- Use parseValidHTMLNonNegativeInteger() to parse width and height so that
  the value is parsed as a valid HTML non-negative integer value, as per the
  spec.
- Return false if descriptor does not have a h, w and x at the end as per:
  https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 13: Anything else)
- Return false if height is set but not width, as per:
  https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 14)

(WebCore::parseImageCandidatesFromSrcsetAttribute):
- Skip whitespace if URL does not end with a comma instead of assuming there is
  a single space character, as per:
  https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 8. Otherwise 1.)

LayoutTests:

Re-sync fast/hidpi/image-srcset-invalid-descriptor.html with Blink.

* fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
* fast/hidpi/image-srcset-invalid-descriptor.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorexpectedtxt">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorhtml">trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementcurrentpixeldensitybasicexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementsrcsetparseasrcsetattributeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLParserIdiomscpp">trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLParserIdiomsh">trunk/Source/WebCore/html/parser/HTMLParserIdioms.h</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLSrcsetParsercpp">trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/ChangeLog        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-09-06  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align srcset attribute parsing with the HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=161636
+
+        Reviewed by Darin Adler.
+
+        Re-sync fast/hidpi/image-srcset-invalid-descriptor.html with Blink.
+
+        * fast/hidpi/image-srcset-invalid-descriptor-expected.txt:
+        * fast/hidpi/image-srcset-invalid-descriptor.html:
+
</ins><span class="cx"> 2016-09-06  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking storage/indexeddb/objectstore-cursor.html as flaky on mac-wk2 debug.
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor-expected.txt        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,12 +1,17 @@
</span><del>-PASS document.getElementById(&quot;invalid_with_x&quot;).clientWidth is 100
-PASS document.getElementById(&quot;invalid_without_x&quot;).clientWidth is 100
-PASS document.getElementById(&quot;future_descriptor&quot;).clientWidth is 100
-PASS document.getElementById(&quot;future_descriptor_without_x&quot;).clientWidth is 100
-PASS document.getElementById(&quot;x_with_w_ignored&quot;).clientWidth is 200
-PASS document.getElementById(&quot;x_with_h_ignored&quot;).clientWidth is 200
</del><ins>+PASS document.getElementById(&quot;foo&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo2&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo3&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo4&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo5&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo6&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo7&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo8&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo9&quot;).clientWidth==200 is true
+PASS document.getElementById(&quot;foo10&quot;).clientWidth==200 is true
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span><del>-This test passes if the image below is a 100px blue square when the deviceScaleFactor is 1.
-It tests that even though the 1x resource contains many invalid descriptors, only the invalid descriptors are ignored (according to the spec).
</del><ins>+This test passes if the image below is a 200px green square when the deviceScaleFactor is 1.
+It tests that the 1x resource is ignored since it contains invalid descriptors.
+The 2x resource has an intrinsic width of 200px, since it's a 400px wide image at 2x DPR.
</ins><span class="cx">          
</span></span></pre></div>
<a id="trunkLayoutTestsfasthidpiimagesrcsetinvaliddescriptorhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/fast/hidpi/image-srcset-invalid-descriptor.html        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,31 +1,33 @@
</span><del>-&lt;html&gt;
-&lt;head&gt;
</del><ins>+&lt;!DOCTYPE html&gt;
</ins><span class="cx"> &lt;script&gt;
</span><span class="cx">     window.targetScaleFactor = 1;
</span><span class="cx"> &lt;/script&gt;
</span><del>-&lt;script src=&quot;../../resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
</del><ins>+&lt;script src=&quot;resources/srcset-helper.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx"> &lt;script src=&quot;../../resources/js-test.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script&gt;
</span><del>-    function runTest() {
-        shouldBe('document.getElementById(&quot;invalid_with_x&quot;).clientWidth', '100');
-        shouldBe('document.getElementById(&quot;invalid_without_x&quot;).clientWidth', '100');
-        shouldBe('document.getElementById(&quot;future_descriptor&quot;).clientWidth', '100');
-        shouldBe('document.getElementById(&quot;future_descriptor_without_x&quot;).clientWidth', '100');
-        shouldBe('document.getElementById(&quot;x_with_w_ignored&quot;).clientWidth', '200');
-        shouldBe('document.getElementById(&quot;x_with_h_ignored&quot;).clientWidth', '200');
-    }
</del><ins>+    addEventListener(&quot;load&quot;, function() {
+        shouldBeTrue('document.getElementById(&quot;foo&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo2&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo3&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo4&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo5&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo6&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo7&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo8&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo9&quot;).clientWidth==200');
+        shouldBeTrue('document.getElementById(&quot;foo10&quot;).clientWidth==200');
+    }, false);
</ins><span class="cx"> &lt;/script&gt;
</span><del>-&lt;/head&gt;
-
-&lt;body id=&quot;body&quot;&gt;
-    &lt;div&gt;This test passes if the image below is a 100px blue square when the deviceScaleFactor is 1.&lt;/div&gt;
-    &lt;div&gt; It tests that even though the 1x resource contains many invalid descriptors,
-        only the invalid descriptors are ignored (according to the spec).&lt;/div&gt;
-    &lt;img id=&quot;invalid_with_x&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 43q 1x dfs 3dd, resources/green-400-px-square.png 2x&quot;&gt;
-    &lt;img id=&quot;invalid_without_x&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 300q, resources/green-400-px-square.png 2x&quot;&gt;
-    &lt;img id=&quot;future_descriptor&quot; srcset=&quot;,resources/blue-100-px-square.png 1x future-descriptor(3x, 4h, whatever), resources/green-400-px-square.png 2x&quot;&gt;
-    &lt;img id=&quot;future_descriptor_without_x&quot; srcset=&quot;,resources/blue-100-px-square.png future-descriptor(3x, 4h, whatever), resources/green-400-px-square.png 2x&quot;&gt;
-    &lt;img id=&quot;x_with_w_ignored&quot; srcset=&quot;,resources/blue-100-px-square.png 1x 100w, resources/green-400-px-square.png 2x&quot;&gt;
-    &lt;img id=&quot;x_with_h_ignored&quot; srcset=&quot;,resources/blue-100-px-square.png 1x 100h, resources/green-400-px-square.png 2x&quot;&gt;
-&lt;/body&gt;
-&lt;/html&gt;
</del><ins>+&lt;div&gt;This test passes if the image below is a 200px green square when the deviceScaleFactor is 1.&lt;/div&gt;
+&lt;div&gt;It tests that the 1x resource is ignored since it contains invalid descriptors.&lt;/div&gt;
+&lt;div&gt;The 2x resource has an intrinsic width of 200px, since it's a 400px wide image at 2x DPR.&lt;/div&gt;
+&lt;img id=&quot;foo&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 43q 1x dfs 3dd, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo2&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 300q, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo3&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 100w 100w, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo4&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 100h 100h, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo5&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 100x 100h, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo6&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 100x 100w, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo7&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png -100w, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo8&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png -100h, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo9&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png -1x, resources/green-400-px-square.png 2x&quot;&gt;
+&lt;img id=&quot;foo10&quot; src=&quot;&quot; srcset=&quot;resources/blue-100-px-square.png 100h, resources/green-400-px-square.png 2x&quot;&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-09-06  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align srcset attribute parsing with the HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=161636
+
+        Reviewed by Darin Adler.
+
+        Rebaseline a couple of W3C tests 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/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt:
+
</ins><span class="cx"> 2016-09-06  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CachedResourceLoader is not taking into account fetch options to use or not cached resources
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementcurrentpixeldensitybasicexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/current-pixel-density/basic-expected.txt        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> FAIL &lt;img srcset=&quot;/images/green-256x256.png 1.6x&quot; data-expect=&quot;160&quot;&gt; assert_equals: naturalWidth expected 160 but got 256
</span><span class="cx"> FAIL &lt;img srcset=&quot;/images/green-256x256.png 2x&quot; data-expect=&quot;128&quot;&gt; assert_equals: naturalWidth expected 128 but got 256
</span><span class="cx"> FAIL &lt;img srcset=&quot;/images/green-256x256.png 10000x&quot; data-expect=&quot;0&quot;&gt; assert_equals: naturalWidth expected 0 but got 256
</span><del>-FAIL &lt;img srcset=&quot;/images/green-256x256.png 9e99999999999999999999999x&quot; data-expect=&quot;0&quot;&gt; assert_equals: naturalWidth expected 0 but got 256
</del><ins>+PASS &lt;img srcset=&quot;/images/green-256x256.png 9e99999999999999999999999x&quot; data-expect=&quot;0&quot;&gt; 
</ins><span class="cx"> PASS &lt;img srcset=&quot;/images/green-256x256.png 256w&quot; sizes=&quot;256px&quot; data-expect=&quot;256&quot;&gt; 
</span><span class="cx"> FAIL &lt;img srcset=&quot;/images/green-256x256.png 512w&quot; sizes=&quot;256px&quot; data-expect=&quot;128&quot;&gt; assert_equals: naturalWidth expected 128 but got 256
</span><span class="cx"> FAIL &lt;img srcset=&quot;/images/green-256x256.png 256w&quot; sizes=&quot;512px&quot; data-expect=&quot;512&quot;&gt; assert_equals: naturalWidth expected 512 but got 256
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsembeddedcontenttheimgelementsrcsetparseasrcsetattributeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute-expected.txt        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -26,26 +26,26 @@
</span><span class="cx"> PASS &quot;data:,a 1x&quot; 
</span><span class="cx"> PASS &quot;data:,a 1x &quot; 
</span><span class="cx"> PASS &quot;data:,a 1x,&quot; 
</span><del>-FAIL &quot;data:,a ( , data:,b 1x, ), data:,c&quot; assert_equals: expected &quot;data:,c&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a ((( , data:,b 1x, ), data:,c&quot; assert_equals: expected &quot;data:,c&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a [ , data:,b 1x, ], data:,c&quot; assert_equals: expected &quot;data:,b&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a { , data:,b 1x, }, data:,c&quot; assert_equals: expected &quot;data:,b&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a \&quot; , data:,b 1x, \&quot;, data:,c&quot; assert_equals: expected &quot;data:,b&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a \\,data:;\,b, data:,c&quot; assert_equals: expected &quot;data:;\\,b&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a ( , data:,b 1x, ), data:,c&quot; 
+PASS &quot;data:,a ((( , data:,b 1x, ), data:,c&quot; 
+PASS &quot;data:,a [ , data:,b 1x, ], data:,c&quot; 
+PASS &quot;data:,a { , data:,b 1x, }, data:,c&quot; 
+PASS &quot;data:,a \&quot; , data:,b 1x, \&quot;, data:,c&quot; 
+PASS &quot;data:,a \\,data:;\,b, data:,c&quot; 
</ins><span class="cx"> PASS &quot;data:,a, data:,b (&quot; 
</span><span class="cx"> PASS &quot;data:,a, data:,b (  &quot; 
</span><span class="cx"> PASS &quot;data:,a, data:,b (,&quot; 
</span><span class="cx"> PASS &quot;data:,a, data:,b (x&quot; 
</span><span class="cx"> PASS &quot;data:,a, data:,b ()&quot; 
</span><del>-FAIL &quot;data:,a (, data:,b&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a /*, data:,b, data:,c */&quot; assert_equals: expected &quot;data:,b&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a //, data:,b&quot; assert_equals: expected &quot;data:,b&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo foo&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo 1x&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo 1x foo&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo 1w&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo 1w foo&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a (, data:,b&quot; 
+PASS &quot;data:,a /*, data:,b, data:,c */&quot; 
+PASS &quot;data:,a //, data:,b&quot; 
+PASS &quot;data:,a foo&quot; 
+PASS &quot;data:,a foo foo&quot; 
+PASS &quot;data:,a foo 1x&quot; 
+PASS &quot;data:,a foo 1x foo&quot; 
+PASS &quot;data:,a foo 1w&quot; 
+PASS &quot;data:,a foo 1w foo&quot; 
</ins><span class="cx"> PASS &quot;data:,a 1x 1x&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w 1w&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w 1x&quot; 
</span><span class="lines">@@ -57,22 +57,22 @@
</span><span class="cx"> PASS &quot;data:,a 1h 1w 1x&quot; 
</span><span class="cx"> PASS &quot;data:,a 1x 1w 1h&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w&quot; 
</span><del>-FAIL &quot;data:,a 1h&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1h foo&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a foo 1h&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1h&quot; 
+PASS &quot;data:,a 1h foo&quot; 
+PASS &quot;data:,a foo 1h&quot; 
</ins><span class="cx"> PASS &quot;data:,a 0w&quot; 
</span><span class="cx"> PASS &quot;data:,a -1w&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w -1w&quot; 
</span><del>-FAIL &quot;data:,a 1.0w&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1.0w&quot; 
</ins><span class="cx"> PASS &quot;data:,a 1w 1.0w&quot; 
</span><del>-FAIL &quot;data:,a 1e0w&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1e0w&quot; 
</ins><span class="cx"> PASS &quot;data:,a 1w 1e0w&quot; 
</span><del>-FAIL &quot;data:,a 1www&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1www&quot; 
</ins><span class="cx"> PASS &quot;data:,a 1w 1www&quot; 
</span><del>-FAIL &quot;data:,a +1w&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a +1w&quot; 
</ins><span class="cx"> PASS &quot;data:,a 1w +1w&quot; 
</span><del>-FAIL &quot;data:,a 1W&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1W&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1W&quot; 
+PASS &quot;data:,a 1w 1W&quot; 
</ins><span class="cx"> PASS &quot;data:,a Infinityw&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w Infinityw&quot; 
</span><span class="cx"> PASS &quot;data:,a NaNw&quot; 
</span><span class="lines">@@ -79,45 +79,45 @@
</span><span class="cx"> PASS &quot;data:,a 1w NaNw&quot; 
</span><span class="cx"> PASS &quot;data:,a 0x1w&quot; 
</span><span class="cx"> PASS &quot;data:,a 0X1w&quot; 
</span><del>-FAIL &quot;data:,a 1\x01w&quot; (trailing U+0001) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+00A0) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+1680) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2001) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2002) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2003) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2004) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2005) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2006) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2007) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2008) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+2009) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+200A) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1‌w&quot; (trailing U+200C) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1‍w&quot; (trailing U+200D) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+202F) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+205F) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1 w&quot; (trailing U+3000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w&quot; (trailing U+FEFF) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1\x01w&quot; (trailing U+0001) 
+PASS &quot;data:,a 1 w&quot; (trailing U+00A0) 
+PASS &quot;data:,a 1 w&quot; (trailing U+1680) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2000) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2001) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2002) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2003) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2004) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2005) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2006) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2007) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2008) 
+PASS &quot;data:,a 1 w&quot; (trailing U+2009) 
+PASS &quot;data:,a 1 w&quot; (trailing U+200A) 
+PASS &quot;data:,a 1‌w&quot; (trailing U+200C) 
+PASS &quot;data:,a 1‍w&quot; (trailing U+200D) 
+PASS &quot;data:,a 1 w&quot; (trailing U+202F) 
+PASS &quot;data:,a 1 w&quot; (trailing U+205F) 
+PASS &quot;data:,a 1 w&quot; (trailing U+3000) 
+PASS &quot;data:,a 1w&quot; (trailing U+FEFF) 
</ins><span class="cx"> PASS &quot;data:,a \x011w&quot; (leading U+0001) 
</span><span class="cx"> PASS &quot;data:,a  1w&quot; (leading U+00A0) 
</span><del>-FAIL &quot;data:,a  1w&quot; (leading U+1680) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2001) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2002) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2003) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2004) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2005) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2006) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2007) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2008) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+2009) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+200A) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a  1w&quot; (leading U+1680) 
+PASS &quot;data:,a  1w&quot; (leading U+2000) 
+PASS &quot;data:,a  1w&quot; (leading U+2001) 
+PASS &quot;data:,a  1w&quot; (leading U+2002) 
+PASS &quot;data:,a  1w&quot; (leading U+2003) 
+PASS &quot;data:,a  1w&quot; (leading U+2004) 
+PASS &quot;data:,a  1w&quot; (leading U+2005) 
+PASS &quot;data:,a  1w&quot; (leading U+2006) 
+PASS &quot;data:,a  1w&quot; (leading U+2007) 
+PASS &quot;data:,a  1w&quot; (leading U+2008) 
+PASS &quot;data:,a  1w&quot; (leading U+2009) 
+PASS &quot;data:,a  1w&quot; (leading U+200A) 
</ins><span class="cx"> PASS &quot;data:,a ‌1w&quot; (leading U+200C) 
</span><span class="cx"> PASS &quot;data:,a ‍1w&quot; (leading U+200D) 
</span><span class="cx"> PASS &quot;data:,a  1w&quot; (leading U+202F) 
</span><del>-FAIL &quot;data:,a  1w&quot; (leading U+205F) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a  1w&quot; (leading U+3000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a  1w&quot; (leading U+205F) 
+PASS &quot;data:,a  1w&quot; (leading U+3000) 
</ins><span class="cx"> PASS &quot;data:,a 1w&quot; (leading U+FEFF) 
</span><span class="cx"> PASS &quot;data:,a 0x&quot; 
</span><span class="cx"> PASS &quot;data:,a -0x&quot; 
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx"> PASS &quot;data:,a -x&quot; 
</span><span class="cx"> PASS &quot;data:,a .x&quot; 
</span><span class="cx"> PASS &quot;data:,a -.x&quot; 
</span><del>-FAIL &quot;data:,a 1.x&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1.x&quot; 
</ins><span class="cx"> PASS &quot;data:,a .5x&quot; 
</span><span class="cx"> PASS &quot;data:,a .5e1x&quot; 
</span><span class="cx"> PASS &quot;data:,a 1x 1.5e1x&quot; 
</span><span class="lines">@@ -138,8 +138,8 @@
</span><span class="cx"> PASS &quot;data:,a 1x 1e1.5x&quot; 
</span><span class="cx"> PASS &quot;data:,a 1.0x&quot; 
</span><span class="cx"> PASS &quot;data:,a 1x 1.0x&quot; 
</span><del>-FAIL &quot;data:,a +1x&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1X&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a +1x&quot; 
+PASS &quot;data:,a 1X&quot; 
</ins><span class="cx"> PASS &quot;data:,a Infinityx&quot; 
</span><span class="cx"> PASS &quot;data:,a NaNx&quot; 
</span><span class="cx"> PASS &quot;data:,a 0x1x&quot; 
</span><span class="lines">@@ -186,53 +186,53 @@
</span><span class="cx"> PASS &quot;data:,a 1x&quot; (leading U+FEFF) 
</span><span class="cx"> PASS &quot;data:,a 1w 0h&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w -1h&quot; 
</span><del>-FAIL &quot;data:,a 1w 1.0h&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1e0h&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1hhh&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w +1h&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1H&quot; assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1w 1.0h&quot; 
+PASS &quot;data:,a 1w 1e0h&quot; 
+PASS &quot;data:,a 1w 1hhh&quot; 
+PASS &quot;data:,a 1w +1h&quot; 
+PASS &quot;data:,a 1w 1H&quot; 
</ins><span class="cx"> PASS &quot;data:,a 1w Infinityh&quot; 
</span><span class="cx"> PASS &quot;data:,a 1w NaNh&quot; 
</span><span class="cx"> PASS &quot;data:,a 0x1h&quot; 
</span><span class="cx"> PASS &quot;data:,a 0X1h&quot; 
</span><del>-FAIL &quot;data:,a 1w 1\x01h&quot; (trailing U+0001) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+00A0) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+1680) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2001) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2002) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2003) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2004) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2005) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2006) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2007) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2008) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+2009) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+200A) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1‌h&quot; (trailing U+200C) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1‍h&quot; (trailing U+200D) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+202F) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+205F) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1 h&quot; (trailing U+3000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w 1h&quot; (trailing U+FEFF) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1w 1\x01h&quot; (trailing U+0001) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+00A0) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+1680) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2000) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2001) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2002) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2003) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2004) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2005) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2006) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2007) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2008) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+2009) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+200A) 
+PASS &quot;data:,a 1w 1‌h&quot; (trailing U+200C) 
+PASS &quot;data:,a 1w 1‍h&quot; (trailing U+200D) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+202F) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+205F) 
+PASS &quot;data:,a 1w 1 h&quot; (trailing U+3000) 
+PASS &quot;data:,a 1w 1h&quot; (trailing U+FEFF) 
</ins><span class="cx"> PASS &quot;data:,a 1w \x011h&quot; (leading U+0001) 
</span><span class="cx"> PASS &quot;data:,a 1w  1h&quot; (leading U+00A0) 
</span><del>-FAIL &quot;data:,a 1w  1h&quot; (leading U+1680) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2001) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2002) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2003) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2004) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2005) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2006) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2007) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2008) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+2009) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+200A) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1w  1h&quot; (leading U+1680) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2000) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2001) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2002) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2003) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2004) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2005) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2006) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2007) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2008) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+2009) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+200A) 
</ins><span class="cx"> PASS &quot;data:,a 1w ‌1h&quot; (leading U+200C) 
</span><span class="cx"> PASS &quot;data:,a 1w ‍1h&quot; (leading U+200D) 
</span><span class="cx"> PASS &quot;data:,a 1w  1h&quot; (leading U+202F) 
</span><del>-FAIL &quot;data:,a 1w  1h&quot; (leading U+205F) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
-FAIL &quot;data:,a 1w  1h&quot; (leading U+3000) assert_equals: expected &quot;&quot; but got &quot;data:,a&quot;
</del><ins>+PASS &quot;data:,a 1w  1h&quot; (leading U+205F) 
+PASS &quot;data:,a 1w  1h&quot; (leading U+3000) 
</ins><span class="cx"> PASS &quot;data:,a 1w 1h&quot; (leading U+FEFF) 
</span><span class="cx">                                                                                                                                                                                                                                              
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/ChangeLog        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-09-06  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align srcset attribute parsing with the HTML specification
+        https://bugs.webkit.org/show_bug.cgi?id=161636
+
+        Reviewed by Darin Adler.
+
+        Align srcset attribute parsing with the HTML specification:
+        - https://html.spec.whatwg.org/#parse-a-srcset-attribute
+
+        The new behavior is also consistent with Firefox and Chrome
+        as all 3 browsers now pass 100% of the checks at:
+        - http://w3c-test.org/html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html
+
+        No new tests, rebaselined existing tests.
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::parseValidHTMLNonNegativeIntegerInternal):
+        (WebCore::parseValidHTMLNonNegativeInteger):
+        (WebCore::parseValidHTMLFloatingPointNumberInternal):
+        (WebCore::parseValidHTMLFloatingPointNumber):
+        * html/parser/HTMLParserIdioms.h:
+        Add convenience for parsing *valid* HTML non-negative integers and
+        *valid* floating point number values.
+
+        * html/parser/HTMLSrcsetParser.cpp:
+        (WebCore::parseDescriptors):
+        - Use parseValidHTMLFloatingPointNumber() to parse density so that the value
+          is parsed as a valid HTML floating point number value, as per the spec.
+        - Use parseValidHTMLNonNegativeInteger() to parse width and height so that
+          the value is parsed as a valid HTML non-negative integer value, as per the
+          spec.
+        - Return false if descriptor does not have a h, w and x at the end as per:
+          https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 13: Anything else)
+        - Return false if height is set but not width, as per:
+          https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 14)
+
+        (WebCore::parseImageCandidatesFromSrcsetAttribute):
+        - Skip whitespace if URL does not end with a comma instead of assuming there is
+          a single space character, as per:
+          https://html.spec.whatwg.org/#parse-a-srcset-attribute (step 8. Otherwise 1.)
+
</ins><span class="cx"> 2016-09-06  Fujii Hironori  &lt;Hironori.Fujii@sony.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CMake] Decouple generating bindings of WebCore and WebCoreTestSupport
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -216,6 +216,67 @@
</span><span class="cx">     return signedValue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename CharacterType&gt;
+static Optional&lt;int&gt; parseValidHTMLNonNegativeIntegerInternal(const CharacterType* position, const CharacterType* end)
+{
+    // A string is a valid non-negative integer if it consists of one or more ASCII digits.
+    for (auto* c = position; c &lt; end; ++c) {
+        if (!isASCIIDigit(*c))
+            return Nullopt;
+    }
+
+    Optional&lt;int&gt; signedValue = parseHTMLIntegerInternal(position, end);
+    if (!signedValue || signedValue.value() &lt; 0)
+        return Nullopt;
+
+    return signedValue;
+}
+
+// https://html.spec.whatwg.org/#valid-non-negative-integer
+Optional&lt;int&gt; parseValidHTMLNonNegativeInteger(StringView input)
+{
+    if (input.isEmpty())
+        return Nullopt;
+
+    if (LIKELY(input.is8Bit())) {
+        auto* start = input.characters8();
+        return parseValidHTMLNonNegativeIntegerInternal(start, start + input.length());
+    }
+
+    auto* start = input.characters16();
+    return parseValidHTMLNonNegativeIntegerInternal(start, start + input.length());
+}
+
+template &lt;typename CharacterType&gt;
+static Optional&lt;double&gt; parseValidHTMLFloatingPointNumberInternal(const CharacterType* position, size_t length)
+{
+    ASSERT(length &gt; 0);
+
+    // parseDouble() allows the string to start with a '+' or to end with a '.' but those
+    // are not valid floating point numbers as per HTML.
+    if (*position == '+' || *(position + length - 1) == '.')
+        return Nullopt;
+
+    size_t parsedLength = 0;
+    double number = parseDouble(position, length, parsedLength);
+    return parsedLength == length &amp;&amp; std::isfinite(number) ? number : Optional&lt;double&gt;();
+}
+
+// https://html.spec.whatwg.org/#valid-floating-point-number
+Optional&lt;double&gt; parseValidHTMLFloatingPointNumber(StringView input)
+{
+    if (input.isEmpty())
+        return Nullopt;
+
+    if (LIKELY(input.is8Bit())) {
+        auto* start = input.characters8();
+        return parseValidHTMLFloatingPointNumberInternal(start, input.length());
+    }
+
+    auto* start = input.characters16();
+    return parseValidHTMLFloatingPointNumberInternal(start, input.length());
+}
+
</ins><span class="cx"> static inline bool isHTMLSpaceOrDelimiter(UChar character)
</span><span class="cx"> {
</span><span class="cx">     return isHTMLSpace(character) || character == ',' || character == ';';
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -67,6 +67,12 @@
</span><span class="cx"> // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers
</span><span class="cx"> WEBCORE_EXPORT Optional&lt;int&gt; parseHTMLNonNegativeInteger(const String&amp;);
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/#valid-non-negative-integer
+Optional&lt;int&gt; parseValidHTMLNonNegativeInteger(StringView);
+
+// https://html.spec.whatwg.org/#valid-floating-point-number
+Optional&lt;double&gt; parseValidHTMLFloatingPointNumber(StringView);
+
</ins><span class="cx"> // https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-floating-point-number-values
</span><span class="cx"> Vector&lt;double&gt; parseHTMLListOfOfFloatingPointNumberValues(StringView);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLSrcsetParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp (205514 => 205515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp        2016-09-06 22:19:51 UTC (rev 205514)
+++ trunk/Source/WebCore/html/parser/HTMLSrcsetParser.cpp        2016-09-06 22:59:29 UTC (rev 205515)
</span><span class="lines">@@ -131,33 +131,33 @@
</span><span class="cx">         unsigned descriptorCharPosition = descriptor.length() - 1;
</span><span class="cx">         UChar descriptorChar = descriptor[descriptorCharPosition];
</span><span class="cx">         descriptor = descriptor.substring(0, descriptorCharPosition);
</span><del>-        bool isValid = false;
</del><span class="cx">         if (descriptorChar == 'x') {
</span><span class="cx">             if (result.hasDensity() || result.hasHeight() || result.hasWidth())
</span><span class="cx">                 return false;
</span><del>-            float density = descriptor.toFloat(isValid);
-            if (!isValid || density &lt; 0)
</del><ins>+            Optional&lt;double&gt; density = parseValidHTMLFloatingPointNumber(descriptor);
+            if (!density || density.value() &lt; 0)
</ins><span class="cx">                 return false;
</span><del>-            result.setDensity(density);
</del><ins>+            result.setDensity(density.value());
</ins><span class="cx">         } else if (descriptorChar == 'w') {
</span><span class="cx">             if (result.hasDensity() || result.hasWidth())
</span><span class="cx">                 return false;
</span><del>-            int resourceWidth = descriptor.toInt(isValid);
-            if (!isValid || resourceWidth &lt;= 0)
</del><ins>+            Optional&lt;int&gt; resourceWidth = parseValidHTMLNonNegativeInteger(descriptor);
+            if (!resourceWidth || resourceWidth.value() &lt;= 0)
</ins><span class="cx">                 return false;
</span><del>-            result.setResourceWidth(resourceWidth);
</del><ins>+            result.setResourceWidth(resourceWidth.value());
</ins><span class="cx">         } else if (descriptorChar == 'h') {
</span><span class="cx">             // This is here only for future compat purposes.
</span><span class="cx">             // The value of the 'h' descriptor is not used.
</span><span class="cx">             if (result.hasDensity() || result.hasHeight())
</span><span class="cx">                 return false;
</span><del>-            int resourceHeight = descriptor.toInt(isValid);
-            if (!isValid || resourceHeight &lt;= 0)
</del><ins>+            Optional&lt;int&gt; resourceHeight = parseValidHTMLNonNegativeInteger(descriptor);
+            if (!resourceHeight || resourceHeight.value() &lt;= 0)
</ins><span class="cx">                 return false;
</span><del>-            result.setResourceHeight(resourceHeight);
-        }
</del><ins>+            result.setResourceHeight(resourceHeight.value());
+        } else
+            return false;
</ins><span class="cx">     }
</span><del>-    return true;
</del><ins>+    return !result.hasHeight() || result.hasWidth();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // http://picture.responsiveimages.org/#parse-srcset-attr
</span><span class="lines">@@ -193,9 +193,7 @@
</span><span class="cx">             if (imageURLStart == imageURLEnd)
</span><span class="cx">                 continue;
</span><span class="cx">         } else {
</span><del>-            // Advancing position here (contrary to spec) to avoid an useless extra state machine step.
-            // Filed a spec bug: https://github.com/ResponsiveImagesCG/picture-element/issues/189
-            ++position;
</del><ins>+            skipWhile&lt;CharType, isHTMLSpace&lt;CharType&gt;&gt;(position, attributeEnd);
</ins><span class="cx">             Vector&lt;StringView&gt; descriptorTokens;
</span><span class="cx">             tokenizeDescriptors(position, attributeEnd, descriptorTokens);
</span><span class="cx">             // Contrary to spec language - descriptor parsing happens on each candidate.
</span></span></pre>
</div>
</div>

</body>
</html>