Diff
Modified: trunk/LayoutTests/ChangeLog (201862 => 201863)
--- trunk/LayoutTests/ChangeLog 2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/LayoutTests/ChangeLog 2016-06-09 14:54:50 UTC (rev 201863)
@@ -1,3 +1,15 @@
+2016-06-09 Michael Saboff <[email protected]>
+
+ 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.
+
2016-06-09 Commit Queue <[email protected]>
Unreviewed, rolling out r201810.
Added: trunk/LayoutTests/fast/text/dangling-surrogates-expected.txt (0 => 201863)
--- 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)
@@ -0,0 +1,11 @@
+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
+
Added: trunk/LayoutTests/fast/text/dangling-surrogates.html (0 => 201863)
--- 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)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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>
Modified: trunk/Source/WebKit2/ChangeLog (201862 => 201863)
--- 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)
@@ -1,3 +1,19 @@
+2016-06-09 Michael Saboff <[email protected]>
+
+ 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:
+
2016-06-09 Carlos Garcia Campos <[email protected]>
[Threaded Compositor] Many layout tests crash when threaded compositor is enabled
Modified: trunk/Source/WebKit2/Shared/API/c/WKString.cpp (201862 => 201863)
--- 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)
@@ -70,7 +70,10 @@
return toImpl(stringRef)->stringView().length() * 3 + 1;
}
-size_t WKStringGetUTF8CString(WKStringRef stringRef, char* buffer, size_t bufferSize)
+enum StrictType { NonStrict = false, Strict = true };
+
+template <StrictType strict>
+size_t WKStringGetUTF8CStringImpl(WKStringRef stringRef, char* buffer, size_t bufferSize)
{
if (!bufferSize)
return 0;
@@ -85,7 +88,7 @@
result = WTF::Unicode::convertLatin1ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1);
} else {
const UChar* characters = stringView.characters16();
- result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, /* strict */ true);
+ result = WTF::Unicode::convertUTF16ToUTF8(&characters, characters + stringView.length(), &p, p + bufferSize - 1, strict);
}
if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::targetExhausted)
@@ -95,6 +98,16 @@
return p - buffer;
}
+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);
+}
+
bool WKStringIsEqual(WKStringRef aRef, WKStringRef bRef)
{
return toImpl(aRef)->stringView() == toImpl(bRef)->stringView();
Modified: trunk/Source/WebKit2/Shared/API/c/WKString.h (201862 => 201863)
--- 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)
@@ -55,6 +55,7 @@
WK_EXPORT size_t WKStringGetMaximumUTF8CStringSize(WKStringRef string);
WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t bufferSize);
+WK_EXPORT size_t WKStringGetUTF8CStringNonStrict(WKStringRef string, char* buffer, size_t bufferSize);
WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b);
WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b);
Modified: trunk/Tools/ChangeLog (201862 => 201863)
--- trunk/Tools/ChangeLog 2016-06-09 14:50:19 UTC (rev 201862)
+++ trunk/Tools/ChangeLog 2016-06-09 14:54:50 UTC (rev 201863)
@@ -1,3 +1,21 @@
+2016-06-09 Michael Saboff <[email protected]>
+
+ 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):
+
2016-06-08 Hunseop Jeong <[email protected]>
Try to fix the EFL build.
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (201862 => 201863)
--- 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)
@@ -62,6 +62,8 @@
#import <WebKit/DOMElement.h>
#import <WebKit/DOMExtensions.h>
#import <WebKit/DOMRange.h>
+#import <WebKit/WKString.h>
+#import <WebKit/WKStringCF.h>
#import <WebKit/WebArchive.h>
#import <WebKit/WebBackForwardList.h>
#import <WebKit/WebCache.h>
@@ -1523,7 +1525,17 @@
if ([frame parentFrame])
result = [NSMutableString stringWithFormat:@"\n--------\nFrame: '%@'\n--------\n", [frame name]];
- [result appendFormat:@"%@\n", [documentElement innerText]];
+ 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()];
if (gTestRunner->dumpChildFramesAsText()) {
NSArray *kids = [frame childFrames];
Modified: trunk/Tools/WebKitTestRunner/StringFunctions.h (201862 => 201863)
--- 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)
@@ -87,7 +87,7 @@
{
size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
auto buffer = std::make_unique<char[]>(bufferSize);
- size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize);
+ size_t stringLength = WKStringGetUTF8CStringNonStrict(string, buffer.get(), bufferSize);
return WTF::String::fromUTF8WithLatin1Fallback(buffer.get(), stringLength - 1);
}