<!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>[197237] 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/197237">197237</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-02-26 22:09:37 -0800 (Fri, 26 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix the behavior of reflecting IDL attributes of type unsigned long
https://bugs.webkit.org/show_bug.cgi?id=154771

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline now that more checks are passing.

* web-platform-tests/html/dom/reflection-embedded-expected.txt:
* web-platform-tests/html/dom/reflection-obsolete-expected.txt:

Source/WebCore:

Fix the behavior of reflecting IDL attributes of type unsigned long to
align with the specification:
- https://html.spec.whatwg.org/multipage/infrastructure.html#reflecting-content-attributes-in-idl-attributes
- https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers

Firefox and Chrome already follow the specification.

There were several issues with our implementation, which are all
addressed in this patch:
- Upon getting, the value returned must be in the range 0 to 2147483647.
  Otherwise, we must return the default value (0 unless specified
  otherwise). We previously returned values in the range 0 to 4294967295
  instead.
- Upon setting, we must set the content attribute to the default value
  (0 unless specified otherwise) if the input value is not in the range
  0 to 2147483647. We previously allowed values in the range 0 to
  4294967295 instead.
- &quot;-0&quot; was not recognized as a valid unsigned integer

Test: fast/dom/reflect-unsigned-long.html

* dom/Element.cpp:
(WebCore::Element::setUnsignedIntegralAttribute):
Update setUnsignedIntegralAttribute() to limit the input value in the
0 to 2147483647 range, as per the HTML specification. This method is
called by the bindings implementation of reflecting attributes setters.

* html/parser/HTMLParserIdioms.cpp:
(WebCore::parseHTMLNonNegativeInteger):
Update parseHTMLNonNegativeInteger() to call parseHTMLInteger() instead
of duplicating most of its code and fail if the value returned is
negative. This matches the algorithm in the specification:
- https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers

This has 2 behavior changes:
1. &quot;-0&quot; is now correctly parsed as 0.
2. The returned values are in the range 0 to 2147483647.

* html/parser/HTMLParserIdioms.h:
(WebCore::limitToOnlyHTMLNonNegativeNumbersGreaterThanZero):
(WebCore::limitToOnlyHTMLNonNegative):
Drop the checks for &quot;&lt;= 2147483647&quot; and replace with an assertion
now that parseHTMLNonNegativeInteger() already returned values in
the right range.

Tools:

Update API tests to cover the fixes to the parseHTMLNonNegativeInteger()
implementation:
- &quot;-0&quot; is parsed as 0.
- Range boundaries are now [0; 2147483647].

* TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp:
(TestWebKitAPI::TEST):

LayoutTests:

Add test coverage for the behavior of reflecting IDL attributes of type
unsigned long.

* fast/dom/reflect-unsigned-long-expected.txt: Added.
* fast/dom/reflect-unsigned-long.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomreflectionembeddedexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomreflectionobsoleteexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-obsolete-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</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="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreHTMLParserIdiomscpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastdomreflectunsignedlongexpectedtxt">trunk/LayoutTests/fast/dom/reflect-unsigned-long-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomreflectunsignedlonghtml">trunk/LayoutTests/fast/dom/reflect-unsigned-long.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/LayoutTests/ChangeLog        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-02-26  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Fix the behavior of reflecting IDL attributes of type unsigned long
+        https://bugs.webkit.org/show_bug.cgi?id=154771
+
+        Reviewed by Ryosuke Niwa.
+
+        Add test coverage for the behavior of reflecting IDL attributes of type
+        unsigned long.
+
+        * fast/dom/reflect-unsigned-long-expected.txt: Added.
+        * fast/dom/reflect-unsigned-long.html: Added.
+
</ins><span class="cx"> 2016-02-26  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (188611): Search field Cancel button should not overlap search text on extensions page.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomreflectunsignedlongexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/reflect-unsigned-long-expected.txt (0 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/reflect-unsigned-long-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/dom/reflect-unsigned-long-expected.txt        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+This tests covers the behavior of reflecting IDL attributes of type unsigned long
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+* Default value
+PASS video.getAttribute('width') is null
+PASS video.width is 0
+
+* Regular value
+video.setAttribute('width', '123')
+PASS video.getAttribute('width') is &quot;123&quot;
+PASS video.width is 123
+video.width = 123
+PASS video.getAttribute('width') is &quot;123&quot;
+PASS video.width is 123
+
+* Boundary
+video.setAttribute('width', '2147483647')
+PASS video.getAttribute('width') is &quot;2147483647&quot;
+PASS video.width is 2147483647
+video.width = 2147483647
+PASS video.getAttribute('width') is &quot;2147483647&quot;
+PASS video.width is 2147483647
+
+* Out of range value
+video.setAttribute('width', '2147483649')
+PASS video.getAttribute('width') is &quot;2147483649&quot;
+PASS video.width is 0
+video.width = 2147483649
+PASS video.getAttribute('width') is &quot;0&quot;
+PASS video.width is 0
+
+* Default value
+PASS video.getAttribute('height') is null
+PASS video.height is 0
+
+* Regular value
+video.setAttribute('height', '123')
+PASS video.getAttribute('height') is &quot;123&quot;
+PASS video.height is 123
+video.height = 123
+PASS video.getAttribute('height') is &quot;123&quot;
+PASS video.height is 123
+
+* Boundary
+video.setAttribute('height', '2147483647')
+PASS video.getAttribute('height') is &quot;2147483647&quot;
+PASS video.height is 2147483647
+video.height = 2147483647
+PASS video.getAttribute('height') is &quot;2147483647&quot;
+PASS video.height is 2147483647
+
+* Out of range value
+video.setAttribute('height', '2147483649')
+PASS video.getAttribute('height') is &quot;2147483649&quot;
+PASS video.height is 0
+video.height = 2147483649
+PASS video.getAttribute('height') is &quot;0&quot;
+PASS video.height is 0
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastdomreflectunsignedlonghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/dom/reflect-unsigned-long.html (0 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/reflect-unsigned-long.html                                (rev 0)
+++ trunk/LayoutTests/fast/dom/reflect-unsigned-long.html        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description(&quot;This tests covers the behavior of reflecting IDL attributes of type unsigned long&quot;);
+// https://html.spec.whatwg.org/multipage/infrastructure.html#reflecting-content-attributes-in-idl-attributes
+
+var video = document.createElement(&quot;video&quot;);
+
+debug(&quot;* Default value&quot;);
+shouldBeNull(&quot;video.getAttribute('width')&quot;);
+shouldBe(&quot;video.width&quot;, &quot;0&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Regular value&quot;);
+evalAndLog(&quot;video.setAttribute('width', '123')&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('width')&quot;, &quot;123&quot;);
+shouldBe(&quot;video.width&quot;, &quot;123&quot;);
+evalAndLog(&quot;video.width = 123&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('width')&quot;, &quot;123&quot;);
+shouldBe(&quot;video.width&quot;, &quot;123&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Boundary&quot;);
+evalAndLog(&quot;video.setAttribute('width', '2147483647')&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('width')&quot;, &quot;2147483647&quot;);
+shouldBe(&quot;video.width&quot;, &quot;2147483647&quot;);
+evalAndLog(&quot;video.width = 2147483647&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('width')&quot;, &quot;2147483647&quot;);
+shouldBe(&quot;video.width&quot;, &quot;2147483647&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Out of range value&quot;);
+evalAndLog(&quot;video.setAttribute('width', '2147483649')&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('width')&quot;, &quot;2147483649&quot;);
+shouldBe(&quot;video.width&quot;, &quot;0&quot;);
+evalAndLog(&quot;video.width = 2147483649&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('width')&quot;, &quot;0&quot;);
+shouldBe(&quot;video.width&quot;, &quot;0&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Default value&quot;);
+shouldBeNull(&quot;video.getAttribute('height')&quot;);
+shouldBe(&quot;video.height&quot;, &quot;0&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Regular value&quot;);
+evalAndLog(&quot;video.setAttribute('height', '123')&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('height')&quot;, &quot;123&quot;);
+shouldBe(&quot;video.height&quot;, &quot;123&quot;);
+evalAndLog(&quot;video.height = 123&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('height')&quot;, &quot;123&quot;);
+shouldBe(&quot;video.height&quot;, &quot;123&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Boundary&quot;);
+evalAndLog(&quot;video.setAttribute('height', '2147483647')&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('height')&quot;, &quot;2147483647&quot;);
+shouldBe(&quot;video.height&quot;, &quot;2147483647&quot;);
+evalAndLog(&quot;video.height = 2147483647&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('height')&quot;, &quot;2147483647&quot;);
+shouldBe(&quot;video.height&quot;, &quot;2147483647&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* Out of range value&quot;);
+evalAndLog(&quot;video.setAttribute('height', '2147483649')&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('height')&quot;, &quot;2147483649&quot;);
+shouldBe(&quot;video.height&quot;, &quot;0&quot;);
+evalAndLog(&quot;video.height = 2147483649&quot;);
+shouldBeEqualToString(&quot;video.getAttribute('height')&quot;, &quot;0&quot;);
+shouldBe(&quot;video.height&quot;, &quot;0&quot;);
+
+debug(&quot;&quot;);
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-02-26  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Fix the behavior of reflecting IDL attributes of type unsigned long
+        https://bugs.webkit.org/show_bug.cgi?id=154771
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline now that more checks are passing.
+
+        * web-platform-tests/html/dom/reflection-embedded-expected.txt:
+        * web-platform-tests/html/dom/reflection-obsolete-expected.txt:
+
</ins><span class="cx"> 2016-02-26  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Sync web-platform-tests up to revision 5ca8b46
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomreflectionembeddedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-embedded-expected.txt        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -9743,10 +9743,10 @@
</span><span class="cx"> PASS video.width: IDL set to &quot;-0&quot; followed by getAttribute() 
</span><span class="cx"> PASS video.width: IDL set to &quot;-0&quot; followed by IDL get 
</span><span class="cx"> PASS video.width: IDL set to 2147483648 should not throw 
</span><del>-FAIL video.width: IDL set to 2147483648 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;2147483648&quot;
</del><ins>+PASS video.width: IDL set to 2147483648 followed by getAttribute() 
</ins><span class="cx"> PASS video.width: IDL set to 2147483648 followed by IDL get 
</span><span class="cx"> PASS video.width: IDL set to 4294967295 should not throw 
</span><del>-FAIL video.width: IDL set to 4294967295 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;4294967295&quot;
</del><ins>+PASS video.width: IDL set to 4294967295 followed by getAttribute() 
</ins><span class="cx"> PASS video.width: IDL set to 4294967295 followed by IDL get 
</span><span class="cx"> PASS video.height: typeof IDL attribute 
</span><span class="cx"> PASS video.height: IDL get with DOM attribute unset 
</span><span class="lines">@@ -9872,10 +9872,10 @@
</span><span class="cx"> PASS video.height: IDL set to &quot;-0&quot; followed by getAttribute() 
</span><span class="cx"> PASS video.height: IDL set to &quot;-0&quot; followed by IDL get 
</span><span class="cx"> PASS video.height: IDL set to 2147483648 should not throw 
</span><del>-FAIL video.height: IDL set to 2147483648 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;2147483648&quot;
</del><ins>+PASS video.height: IDL set to 2147483648 followed by getAttribute() 
</ins><span class="cx"> PASS video.height: IDL set to 2147483648 followed by IDL get 
</span><span class="cx"> PASS video.height: IDL set to 4294967295 should not throw 
</span><del>-FAIL video.height: IDL set to 4294967295 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;4294967295&quot;
</del><ins>+PASS video.height: IDL set to 4294967295 followed by getAttribute() 
</ins><span class="cx"> PASS video.height: IDL set to 4294967295 followed by IDL get 
</span><span class="cx"> PASS video.poster: typeof IDL attribute 
</span><span class="cx"> PASS video.poster: IDL get with DOM attribute unset 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomreflectionobsoleteexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-obsolete-expected.txt (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-obsolete-expected.txt        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-obsolete-expected.txt        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -2771,10 +2771,10 @@
</span><span class="cx"> PASS marquee.hspace: IDL set to &quot;-0&quot; followed by getAttribute() 
</span><span class="cx"> PASS marquee.hspace: IDL set to &quot;-0&quot; followed by IDL get 
</span><span class="cx"> PASS marquee.hspace: IDL set to 2147483648 should not throw 
</span><del>-FAIL marquee.hspace: IDL set to 2147483648 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;2147483648&quot;
</del><ins>+PASS marquee.hspace: IDL set to 2147483648 followed by getAttribute() 
</ins><span class="cx"> PASS marquee.hspace: IDL set to 2147483648 followed by IDL get 
</span><span class="cx"> PASS marquee.hspace: IDL set to 4294967295 should not throw 
</span><del>-FAIL marquee.hspace: IDL set to 4294967295 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;4294967295&quot;
</del><ins>+PASS marquee.hspace: IDL set to 4294967295 followed by getAttribute() 
</ins><span class="cx"> PASS marquee.hspace: IDL set to 4294967295 followed by IDL get 
</span><span class="cx"> PASS marquee.scrollAmount: typeof IDL attribute 
</span><span class="cx"> PASS marquee.scrollAmount: IDL get with DOM attribute unset 
</span><span class="lines">@@ -3229,10 +3229,10 @@
</span><span class="cx"> PASS marquee.vspace: IDL set to &quot;-0&quot; followed by getAttribute() 
</span><span class="cx"> PASS marquee.vspace: IDL set to &quot;-0&quot; followed by IDL get 
</span><span class="cx"> PASS marquee.vspace: IDL set to 2147483648 should not throw 
</span><del>-FAIL marquee.vspace: IDL set to 2147483648 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;2147483648&quot;
</del><ins>+PASS marquee.vspace: IDL set to 2147483648 followed by getAttribute() 
</ins><span class="cx"> PASS marquee.vspace: IDL set to 2147483648 followed by IDL get 
</span><span class="cx"> PASS marquee.vspace: IDL set to 4294967295 should not throw 
</span><del>-FAIL marquee.vspace: IDL set to 4294967295 followed by getAttribute() assert_equals: expected &quot;0&quot; but got &quot;4294967295&quot;
</del><ins>+PASS marquee.vspace: IDL set to 4294967295 followed by getAttribute() 
</ins><span class="cx"> PASS marquee.vspace: IDL set to 4294967295 followed by IDL get 
</span><span class="cx"> PASS marquee.width: typeof IDL attribute 
</span><span class="cx"> PASS marquee.width: IDL get with DOM attribute unset 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/Source/WebCore/ChangeLog        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2016-02-26  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Fix the behavior of reflecting IDL attributes of type unsigned long
+        https://bugs.webkit.org/show_bug.cgi?id=154771
+
+        Reviewed by Ryosuke Niwa.
+
+        Fix the behavior of reflecting IDL attributes of type unsigned long to
+        align with the specification:
+        - https://html.spec.whatwg.org/multipage/infrastructure.html#reflecting-content-attributes-in-idl-attributes
+        - https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers
+
+        Firefox and Chrome already follow the specification.
+
+        There were several issues with our implementation, which are all
+        addressed in this patch:
+        - Upon getting, the value returned must be in the range 0 to 2147483647.
+          Otherwise, we must return the default value (0 unless specified
+          otherwise). We previously returned values in the range 0 to 4294967295
+          instead.
+        - Upon setting, we must set the content attribute to the default value
+          (0 unless specified otherwise) if the input value is not in the range
+          0 to 2147483647. We previously allowed values in the range 0 to
+          4294967295 instead.
+        - &quot;-0&quot; was not recognized as a valid unsigned integer
+
+        Test: fast/dom/reflect-unsigned-long.html
+
+        * dom/Element.cpp:
+        (WebCore::Element::setUnsignedIntegralAttribute):
+        Update setUnsignedIntegralAttribute() to limit the input value in the
+        0 to 2147483647 range, as per the HTML specification. This method is
+        called by the bindings implementation of reflecting attributes setters.
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::parseHTMLNonNegativeInteger):
+        Update parseHTMLNonNegativeInteger() to call parseHTMLInteger() instead
+        of duplicating most of its code and fail if the value returned is
+        negative. This matches the algorithm in the specification:
+        - https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers
+
+        This has 2 behavior changes:
+        1. &quot;-0&quot; is now correctly parsed as 0.
+        2. The returned values are in the range 0 to 2147483647.
+
+        * html/parser/HTMLParserIdioms.h:
+        (WebCore::limitToOnlyHTMLNonNegativeNumbersGreaterThanZero):
+        (WebCore::limitToOnlyHTMLNonNegative):
+        Drop the checks for &quot;&lt;= 2147483647&quot; and replace with an assertion
+        now that parseHTMLNonNegativeInteger() already returned values in
+        the right range.
+
</ins><span class="cx"> 2016-02-26  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (188611): Search field Cancel button should not overlap search text on extensions page.
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/Source/WebCore/dom/Element.cpp        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -2784,7 +2784,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Element::setUnsignedIntegralAttribute(const QualifiedName&amp; attributeName, unsigned value)
</span><span class="cx"> {
</span><del>-    setAttribute(attributeName, AtomicString::number(value));
</del><ins>+    setAttribute(attributeName, AtomicString::number(limitToOnlyHTMLNonNegative(value)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INDIE_UI)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -203,7 +203,7 @@
</span><span class="cx">     return ok;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers
</del><ins>+// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers
</ins><span class="cx"> bool parseHTMLInteger(const String&amp; input, int&amp; value)
</span><span class="cx"> {
</span><span class="cx">     // Step 1
</span><span class="lines">@@ -218,67 +218,17 @@
</span><span class="cx">     return parseHTMLIntegerInternal(start, start + length, value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;typename CharacterType&gt;
-static bool parseHTMLNonNegativeIntegerInternal(const CharacterType* position, const CharacterType* end, unsigned&amp; value)
</del><ins>+// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers
+bool parseHTMLNonNegativeInteger(const String&amp; input, unsigned&amp; value)
</ins><span class="cx"> {
</span><del>-    // Step 3
-    while (position &lt; end) {
-        if (!isHTMLSpace(*position))
-            break;
-        ++position;
-    }
-
-    // Step 4
-    if (position == end)
</del><ins>+    int signedValue;
+    if (!parseHTMLInteger(input, signedValue) || signedValue &lt; 0)
</ins><span class="cx">         return false;
</span><del>-    ASSERT_WITH_SECURITY_IMPLICATION(position &lt; end);
</del><span class="cx"> 
</span><del>-    // Step 5
-    if (*position == '+')
-        ++position;
-
-    // Step 6
-    if (position == end)
-        return false;
-    ASSERT_WITH_SECURITY_IMPLICATION(position &lt; end);
-
-    // Step 7
-    if (!isASCIIDigit(*position))
-        return false;
-
-    // Step 8
-    StringBuilder digits;
-    while (position &lt; end) {
-        if (!isASCIIDigit(*position))
-            break;
-        digits.append(*position++);
-    }
-
-    // Step 9
-    bool ok;
-    if (digits.is8Bit())
-        value = charactersToUIntStrict(digits.characters8(), digits.length(), &amp;ok);
-    else
-        value = charactersToUIntStrict(digits.characters16(), digits.length(), &amp;ok);
-    return ok;
</del><ins>+    value = signedValue;
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
-// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers
-bool parseHTMLNonNegativeInteger(const String&amp; input, unsigned&amp; value)
-{
-    // Step 1
-    // Step 2
-    unsigned length = input.length();
-    if (!length || input.is8Bit()) {
-        const LChar* start = input.characters8();
-        return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
-    }
-    
-    const UChar* start = input.characters16();
-    return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
-}
-
</del><span class="cx"> static bool threadSafeEqual(const StringImpl&amp; a, const StringImpl&amp; b)
</span><span class="cx"> {
</span><span class="cx">     if (&amp;a == &amp;b)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.h        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -41,6 +41,9 @@
</span><span class="cx"> bool isNotHTMLSpace(UChar);
</span><span class="cx"> bool isHTMLSpaceButNotLineBreak(UChar);
</span><span class="cx"> 
</span><ins>+// 2147483647 is 2^31 - 1.
+static const unsigned maxHTMLNonNegativeInteger = 2147483647;
+
</ins><span class="cx"> // Strip leading and trailing whitespace as defined by the HTML specification. 
</span><span class="cx"> WEBCORE_EXPORT String stripLeadingAndTrailingHTMLSpaces(const String&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -112,27 +115,31 @@
</span><span class="cx"> // https://html.spec.whatwg.org/multipage/infrastructure.html#limited-to-only-non-negative-numbers-greater-than-zero
</span><span class="cx"> inline unsigned limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(unsigned value, unsigned defaultValue = 1)
</span><span class="cx"> {
</span><del>-    return (value &gt; 0 &amp;&amp; value &lt;= 2147483647) ? value : defaultValue;
</del><ins>+    return (value &gt; 0 &amp;&amp; value &lt;= maxHTMLNonNegativeInteger) ? value : defaultValue;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline unsigned limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(const String&amp; stringValue, unsigned defaultValue = 1)
</span><span class="cx"> {
</span><del>-    unsigned value = defaultValue;
-    parseHTMLNonNegativeInteger(stringValue, value);
-    return limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(value, defaultValue);
</del><ins>+    unsigned value;
+    if (!parseHTMLNonNegativeInteger(stringValue, value) || !value)
+        value = defaultValue;
+    ASSERT(value &gt; 0 &amp;&amp; value &lt;= maxHTMLNonNegativeInteger);
+    return value;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes:idl-unsigned-long
</span><span class="cx"> inline unsigned limitToOnlyHTMLNonNegative(unsigned value, unsigned defaultValue = 0)
</span><span class="cx"> {
</span><del>-    return value &lt;= 2147483647 ? value : defaultValue;
</del><ins>+    return value &lt;= maxHTMLNonNegativeInteger ? value : defaultValue;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline unsigned limitToOnlyHTMLNonNegative(const String&amp; stringValue, unsigned defaultValue = 0)
</span><span class="cx"> {
</span><del>-    unsigned value = defaultValue;
-    parseHTMLNonNegativeInteger(stringValue, value);
-    return limitToOnlyHTMLNonNegative(value, defaultValue);
</del><ins>+    unsigned value;
+    if (!parseHTMLNonNegativeInteger(stringValue, value))
+        value = defaultValue;
+    ASSERT(value &lt;= maxHTMLNonNegativeInteger);
+    return value;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/Tools/ChangeLog        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-02-26  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Fix the behavior of reflecting IDL attributes of type unsigned long
+        https://bugs.webkit.org/show_bug.cgi?id=154771
+
+        Reviewed by Ryosuke Niwa.
+
+        Update API tests to cover the fixes to the parseHTMLNonNegativeInteger()
+        implementation:
+        - &quot;-0&quot; is parsed as 0.
+        - Range boundaries are now [0; 2147483647].
+
+        * TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp:
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2016-02-26  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: New database versions are never committed to SQLite.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreHTMLParserIdiomscpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp (197236 => 197237)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp        2016-02-27 05:51:22 UTC (rev 197236)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp        2016-02-27 06:09:37 UTC (rev 197237)
</span><span class="lines">@@ -133,13 +133,13 @@
</span><span class="cx">     // Boundaries.
</span><span class="cx">     EXPECT_EQ(0u, testParseHTMLNonNegativeInteger(&quot;+0&quot;));
</span><span class="cx">     EXPECT_EQ(0u, testParseHTMLNonNegativeInteger(&quot;0&quot;));
</span><del>-    // FIXME: This should pass.
-    // EXPECT_EQ(0u, testParseHTMLNonNegativeInteger(&quot;-0&quot;));
-    EXPECT_EQ(4294967295u, testParseHTMLNonNegativeInteger(&quot;4294967295&quot;));
</del><ins>+    EXPECT_EQ(0u, testParseHTMLNonNegativeInteger(&quot;-0&quot;));
+    EXPECT_EQ(2147483647u, testParseHTMLNonNegativeInteger(&quot;2147483647&quot;));
</ins><span class="cx"> 
</span><span class="cx">     // Failure cases.
</span><span class="cx">     EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;-1&quot;));
</span><del>-    EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;4294967296&quot;));
</del><ins>+    EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;2147483648&quot;));
+    EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;2147483649&quot;));
</ins><span class="cx">     EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;111111111111111111&quot;));
</span><span class="cx">     EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;  -123&quot;));
</span><span class="cx">     EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(&quot;-123&quot;));
</span></span></pre>
</div>
</div>

</body>
</html>