<!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>[201863] 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/201863">201863</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2016-06-09 07:54:50 -0700 (Thu, 09 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters
https://bugs.webkit.org/show_bug.cgi?id=154863
Reviewed by Alexey Proskuryakov.
Source/WebKit2:
Added a non-strict verions of WKStringGetUTF8CString() that will handle dangling
surrogates called WKStringGetUTF8CStringNonStrict().
* Shared/API/c/WKString.cpp:
(WKStringGetUTF8CStringImpl):
(WKStringGetUTF8CString):
(WKStringGetUTF8CStringNonStrict):
* Shared/API/c/WKString.h:
Tools:
Added a non-strict verions of WKStringGetUTF8CString() that will handle dangling
surrogates. Changed the extraction of inner text from frames in DumpRenderTree
to use the new WKStringGetUTF8CStringNonStrict() function instead of NSString
conversion since NSString doesn't have a way to handle dangling surrogates.
The code added in DumpRenderTree matches what was changed in WebKitTestRunner.
* DumpRenderTree/mac/DumpRenderTree.mm:
(dumpFramesAsText):
* WebKitTestRunner/StringFunctions.h:
(WTR::toWTFString):
LayoutTests:
New tests.
* fast/text/dangling-surrogates-expected.txt: Added.
* fast/text/dangling-surrogates.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIcWKStringcpp">trunk/Source/WebKit2/Shared/API/c/WKString.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIcWKStringh">trunk/Source/WebKit2/Shared/API/c/WKString.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreemm">trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunnerStringFunctionsh">trunk/Tools/WebKitTestRunner/StringFunctions.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextdanglingsurrogatesexpectedtxt">trunk/LayoutTests/fast/text/dangling-surrogates-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttextdanglingsurrogateshtml">trunk/LayoutTests/fast/text/dangling-surrogates.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/LayoutTests/ChangeLog        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-06-09 Michael Saboff <msaboff@apple.com>
+
+ WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters
+ https://bugs.webkit.org/show_bug.cgi?id=154863
+
+ Reviewed by Alexey Proskuryakov.
+
+ New tests.
+
+ * fast/text/dangling-surrogates-expected.txt: Added.
+ * fast/text/dangling-surrogates.html: Added.
+
</ins><span class="cx"> 2016-06-09 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r201810.
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextdanglingsurrogatesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/dangling-surrogates-expected.txt (0 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/dangling-surrogates-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/text/dangling-surrogates-expected.txt        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+This tests verifies that the test tools can handle a dangling surrogate character
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS danglingFirst is "í "
+PASS danglingSecond is "í°"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextdanglingsurrogateshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/dangling-surrogates.html (0 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/dangling-surrogates.html         (rev 0)
+++ trunk/LayoutTests/fast/text/dangling-surrogates.html        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -0,0 +1,20 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<span id="span">
+<p id="description"></p>
+<div id="console"></div>
+<script>
+ description("This tests verifies that the test tools can handle a dangling surrogate character");
+
+ var danglingFirst = "\uD803";
+ var danglingSecond = "\uDC01";
+
+ shouldBe('danglingFirst', '"\uD803"');
+ shouldBe('danglingSecond', '"\uDC01"');
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-06-09 Michael Saboff <msaboff@apple.com>
+
+ WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters
+ https://bugs.webkit.org/show_bug.cgi?id=154863
+
+ Reviewed by Alexey Proskuryakov.
+
+ Added a non-strict verions of WKStringGetUTF8CString() that will handle dangling
+ surrogates called WKStringGetUTF8CStringNonStrict().
+
+ * Shared/API/c/WKString.cpp:
+ (WKStringGetUTF8CStringImpl):
+ (WKStringGetUTF8CString):
+ (WKStringGetUTF8CStringNonStrict):
+ * Shared/API/c/WKString.h:
+
</ins><span class="cx"> 2016-06-09 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> [Threaded Compositor] Many layout tests crash when threaded compositor is enabled
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPIcWKStringcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/API/c/WKString.cpp (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/c/WKString.cpp        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Source/WebKit2/Shared/API/c/WKString.cpp        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -70,7 +70,10 @@
</span><span class="cx"> return toImpl(stringRef)->stringView().length() * 3 + 1;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize)
</del><ins>+enum StrictType { NonStrict = false, Strict = true };
+
+template <StrictType strict>
+size_t WKStringGetUTF8CStringImpl(WKStringRef stringRef, char* buffer, size_t bufferSize)
</ins><span class="cx"> {
</span><span class="cx"> if (!bufferSize)
</span><span class="cx"> return 0;
</span><span class="lines">@@ -85,7 +88,7 @@
</span><span class="cx"> result = WTF::Unicode::convertLatin1ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1);
</span><span class="cx"> } else {
</span><span class="cx"> const UChar* characters = stringView.characters16();
</span><del>- result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, /* strict */ true);
</del><ins>+ result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, strict);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
</span><span class="lines">@@ -95,6 +98,16 @@
</span><span class="cx"> return p - buffer;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+ return WKStringGetUTF8CStringImpl<StrictType::Strict>(stringRef, buffer, bufferSize);
+}
+
+size_t WKStringGetUTF8CStringNonStrict(WKStringRef stringRef, char* buffer, size_t bufferSize)
+{
+ return WKStringGetUTF8CStringImpl<StrictType::NonStrict>(stringRef, buffer, bufferSize);
+}
+
</ins><span class="cx"> bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef)
</span><span class="cx"> {
</span><span class="cx"> return toImpl(aRef)->stringView() == toImpl(bRef)->stringView();
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPIcWKStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/API/c/WKString.h (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/c/WKString.h        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Source/WebKit2/Shared/API/c/WKString.h        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx">
</span><span class="cx"> WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
</span><span class="cx"> WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize);
</span><ins>+WK_EXPORT size_t WKStringGetUTF8CStringNonStrict(WKStringRef string, char* buffer, size_t bufferSize);
</ins><span class="cx">
</span><span class="cx"> WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b);
</span><span class="cx"> WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b);
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Tools/ChangeLog        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-06-09 Michael Saboff <msaboff@apple.com>
+
+ WebKitTestRunner and DumpRenderTree do not handle dangling surrogate characters
+ https://bugs.webkit.org/show_bug.cgi?id=154863
+
+ Reviewed by Alexey Proskuryakov.
+
+ Added a non-strict verions of WKStringGetUTF8CString() that will handle dangling
+ surrogates. Changed the extraction of inner text from frames in DumpRenderTree
+ to use the new WKStringGetUTF8CStringNonStrict() function instead of NSString
+ conversion since NSString doesn't have a way to handle dangling surrogates.
+ The code added in DumpRenderTree matches what was changed in WebKitTestRunner.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (dumpFramesAsText):
+ * WebKitTestRunner/StringFunctions.h:
+ (WTR::toWTFString):
+
</ins><span class="cx"> 2016-06-08 Hunseop Jeong <hs85.jeong@samsung.com>
</span><span class="cx">
</span><span class="cx"> Try to fix the EFL build.
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -62,6 +62,8 @@
</span><span class="cx"> #import <WebKit/DOMElement.h>
</span><span class="cx"> #import <WebKit/DOMExtensions.h>
</span><span class="cx"> #import <WebKit/DOMRange.h>
</span><ins>+#import <WebKit/WKString.h>
+#import <WebKit/WKStringCF.h>
</ins><span class="cx"> #import <WebKit/WebArchive.h>
</span><span class="cx"> #import <WebKit/WebBackForwardList.h>
</span><span class="cx"> #import <WebKit/WebCache.h>
</span><span class="lines">@@ -1523,7 +1525,17 @@
</span><span class="cx"> if ([frame parentFrame])
</span><span class="cx"> result = [NSMutableString stringWithFormat:@"\n--------\nFrame: '%@'\n--------\n", [frame name]];
</span><span class="cx">
</span><del>- [result appendFormat:@"%@\n", [documentElement innerText]];
</del><ins>+ NSString *innerText = [documentElement innerText];
+ // We use WKStringGetUTF8CStringNonStrict() to convert innerText to a WK String since
+ // WKStringGetUTF8CStringNonStrict() can handle dangling surrogates and the NSString
+ // conversion methods cannot. After the conversion to a buffer, we turn that buffer into
+ // a CFString via fromUTF8WithLatin1Fallback().createCFString() which can be appended to
+ // the result without any conversion.
+ WKStringRef stringRef = WKStringCreateWithCFString((CFStringRef)innerText);
+ size_t bufferSize = WKStringGetMaximumUTF8CStringSize(stringRef);
+ auto buffer = std::make_unique<char[]>(bufferSize);
+ size_t stringLength = WKStringGetUTF8CStringNonStrict(stringRef, buffer.get(), bufferSize);
+ [result appendFormat:@"%@\n", String::fromUTF8WithLatin1Fallback(buffer.get(), stringLength - 1).createCFString().get()];
</ins><span class="cx">
</span><span class="cx"> if (gTestRunner->dumpChildFramesAsText()) {
</span><span class="cx"> NSArray *kids = [frame childFrames];
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerStringFunctionsh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/StringFunctions.h (201862 => 201863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/StringFunctions.h        2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Tools/WebKitTestRunner/StringFunctions.h        2016-06-09 14:54:50 UTC (rev 201863)
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> {
</span><span class="cx"> size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
</span><span class="cx"> auto buffer = std::make_unique<char[]>(bufferSize);
</span><del>- size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
</del><ins>+ size_t stringLength = WKStringGetUTF8CStringNonStrict(string, buffer.get(), bufferSize);
</ins><span class="cx"> return WTF::String::fromUTF8WithLatin1Fallback(buffer.get(), stringLength - 1);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>