<!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.
- "-0" 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. "-0" 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 "<= 2147483647" 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:
- "-0" 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 <cdumez@apple.com>
+
+ 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 <zalan@apple.com>
</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 "PASS" messages, followed by "TEST COMPLETE".
+
+
+* Default value
+PASS video.getAttribute('width') is null
+PASS video.width is 0
+
+* Regular value
+video.setAttribute('width', '123')
+PASS video.getAttribute('width') is "123"
+PASS video.width is 123
+video.width = 123
+PASS video.getAttribute('width') is "123"
+PASS video.width is 123
+
+* Boundary
+video.setAttribute('width', '2147483647')
+PASS video.getAttribute('width') is "2147483647"
+PASS video.width is 2147483647
+video.width = 2147483647
+PASS video.getAttribute('width') is "2147483647"
+PASS video.width is 2147483647
+
+* Out of range value
+video.setAttribute('width', '2147483649')
+PASS video.getAttribute('width') is "2147483649"
+PASS video.width is 0
+video.width = 2147483649
+PASS video.getAttribute('width') is "0"
+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 "123"
+PASS video.height is 123
+video.height = 123
+PASS video.getAttribute('height') is "123"
+PASS video.height is 123
+
+* Boundary
+video.setAttribute('height', '2147483647')
+PASS video.getAttribute('height') is "2147483647"
+PASS video.height is 2147483647
+video.height = 2147483647
+PASS video.getAttribute('height') is "2147483647"
+PASS video.height is 2147483647
+
+* Out of range value
+video.setAttribute('height', '2147483649')
+PASS video.getAttribute('height') is "2147483649"
+PASS video.height is 0
+video.height = 2147483649
+PASS video.getAttribute('height') is "0"
+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>+<script src="../../resources/js-test-pre.js"></script>
+<script>
+description("This tests covers the behavior of reflecting IDL attributes of type unsigned long");
+// https://html.spec.whatwg.org/multipage/infrastructure.html#reflecting-content-attributes-in-idl-attributes
+
+var video = document.createElement("video");
+
+debug("* Default value");
+shouldBeNull("video.getAttribute('width')");
+shouldBe("video.width", "0");
+
+debug("");
+debug("* Regular value");
+evalAndLog("video.setAttribute('width', '123')");
+shouldBeEqualToString("video.getAttribute('width')", "123");
+shouldBe("video.width", "123");
+evalAndLog("video.width = 123");
+shouldBeEqualToString("video.getAttribute('width')", "123");
+shouldBe("video.width", "123");
+
+debug("");
+debug("* Boundary");
+evalAndLog("video.setAttribute('width', '2147483647')");
+shouldBeEqualToString("video.getAttribute('width')", "2147483647");
+shouldBe("video.width", "2147483647");
+evalAndLog("video.width = 2147483647");
+shouldBeEqualToString("video.getAttribute('width')", "2147483647");
+shouldBe("video.width", "2147483647");
+
+debug("");
+debug("* Out of range value");
+evalAndLog("video.setAttribute('width', '2147483649')");
+shouldBeEqualToString("video.getAttribute('width')", "2147483649");
+shouldBe("video.width", "0");
+evalAndLog("video.width = 2147483649");
+shouldBeEqualToString("video.getAttribute('width')", "0");
+shouldBe("video.width", "0");
+
+debug("");
+debug("* Default value");
+shouldBeNull("video.getAttribute('height')");
+shouldBe("video.height", "0");
+
+debug("");
+debug("* Regular value");
+evalAndLog("video.setAttribute('height', '123')");
+shouldBeEqualToString("video.getAttribute('height')", "123");
+shouldBe("video.height", "123");
+evalAndLog("video.height = 123");
+shouldBeEqualToString("video.getAttribute('height')", "123");
+shouldBe("video.height", "123");
+
+debug("");
+debug("* Boundary");
+evalAndLog("video.setAttribute('height', '2147483647')");
+shouldBeEqualToString("video.getAttribute('height')", "2147483647");
+shouldBe("video.height", "2147483647");
+evalAndLog("video.height = 2147483647");
+shouldBeEqualToString("video.getAttribute('height')", "2147483647");
+shouldBe("video.height", "2147483647");
+
+debug("");
+debug("* Out of range value");
+evalAndLog("video.setAttribute('height', '2147483649')");
+shouldBeEqualToString("video.getAttribute('height')", "2147483649");
+shouldBe("video.height", "0");
+evalAndLog("video.height = 2147483649");
+shouldBeEqualToString("video.getAttribute('height')", "0");
+shouldBe("video.height", "0");
+
+debug("");
+</script>
+<script src="../../resources/js-test-post.js"></script>
</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 <cdumez@apple.com>
+
+ 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 <youenn.fablet@crf.canon.fr>
</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 "-0" followed by getAttribute()
</span><span class="cx"> PASS video.width: IDL set to "-0" 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 "0" but got "2147483648"
</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 "0" but got "4294967295"
</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 "-0" followed by getAttribute()
</span><span class="cx"> PASS video.height: IDL set to "-0" 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 "0" but got "2147483648"
</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 "0" but got "4294967295"
</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 "-0" followed by getAttribute()
</span><span class="cx"> PASS marquee.hspace: IDL set to "-0" 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 "0" but got "2147483648"
</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 "0" but got "4294967295"
</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 "-0" followed by getAttribute()
</span><span class="cx"> PASS marquee.vspace: IDL set to "-0" 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 "0" but got "2147483648"
</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 "0" but got "4294967295"
</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 <cdumez@apple.com>
+
+ 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.
+ - "-0" 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. "-0" 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 "<= 2147483647" and replace with an assertion
+ now that parseHTMLNonNegativeInteger() already returned values in
+ the right range.
+
</ins><span class="cx"> 2016-02-26 Zalan Bujtas <zalan@apple.com>
</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& 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& input, int& 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 <typename CharacterType>
-static bool parseHTMLNonNegativeIntegerInternal(const CharacterType* position, const CharacterType* end, unsigned& value)
</del><ins>+// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-non-negative-integers
+bool parseHTMLNonNegativeInteger(const String& input, unsigned& value)
</ins><span class="cx"> {
</span><del>- // Step 3
- while (position < end) {
- if (!isHTMLSpace(*position))
- break;
- ++position;
- }
-
- // Step 4
- if (position == end)
</del><ins>+ int signedValue;
+ if (!parseHTMLInteger(input, signedValue) || signedValue < 0)
</ins><span class="cx"> return false;
</span><del>- ASSERT_WITH_SECURITY_IMPLICATION(position < end);
</del><span class="cx">
</span><del>- // Step 5
- if (*position == '+')
- ++position;
-
- // Step 6
- if (position == end)
- return false;
- ASSERT_WITH_SECURITY_IMPLICATION(position < end);
-
- // Step 7
- if (!isASCIIDigit(*position))
- return false;
-
- // Step 8
- StringBuilder digits;
- while (position < end) {
- if (!isASCIIDigit(*position))
- break;
- digits.append(*position++);
- }
-
- // Step 9
- bool ok;
- if (digits.is8Bit())
- value = charactersToUIntStrict(digits.characters8(), digits.length(), &ok);
- else
- value = charactersToUIntStrict(digits.characters16(), digits.length(), &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& input, unsigned& 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& a, const StringImpl& b)
</span><span class="cx"> {
</span><span class="cx"> if (&a == &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&);
</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 > 0 && value <= 2147483647) ? value : defaultValue;
</del><ins>+ return (value > 0 && value <= maxHTMLNonNegativeInteger) ? value : defaultValue;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline unsigned limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(const String& 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 > 0 && value <= 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 <= 2147483647 ? value : defaultValue;
</del><ins>+ return value <= maxHTMLNonNegativeInteger ? value : defaultValue;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline unsigned limitToOnlyHTMLNonNegative(const String& 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 <= 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 <cdumez@apple.com>
+
+ 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:
+ - "-0" 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 <beidson@apple.com>
</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("+0"));
</span><span class="cx"> EXPECT_EQ(0u, testParseHTMLNonNegativeInteger("0"));
</span><del>- // FIXME: This should pass.
- // EXPECT_EQ(0u, testParseHTMLNonNegativeInteger("-0"));
- EXPECT_EQ(4294967295u, testParseHTMLNonNegativeInteger("4294967295"));
</del><ins>+ EXPECT_EQ(0u, testParseHTMLNonNegativeInteger("-0"));
+ EXPECT_EQ(2147483647u, testParseHTMLNonNegativeInteger("2147483647"));
</ins><span class="cx">
</span><span class="cx"> // Failure cases.
</span><span class="cx"> EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-1"));
</span><del>- EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("4294967296"));
</del><ins>+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("2147483648"));
+ EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("2147483649"));
</ins><span class="cx"> EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("111111111111111111"));
</span><span class="cx"> EXPECT_TRUE(parseHTMLNonNegativeIntegerFails(" -123"));
</span><span class="cx"> EXPECT_TRUE(parseHTMLNonNegativeIntegerFails("-123"));
</span></span></pre>
</div>
</div>
</body>
</html>