Title: [202766] trunk
- Revision
- 202766
- Author
- commit-qu...@webkit.org
- Date
- 2016-07-01 17:55:44 -0700 (Fri, 01 Jul 2016)
Log Message
Web Inspector: Sending XHR with UTF8 encoded data shows garbled data in Resource sidebar
https://bugs.webkit.org/show_bug.cgi?id=159358
Patch by Johan K. Jensen <j...@johanjensen.dk> on 2016-07-01
Reviewed by Joseph Pecoraro.
Source/WebCore:
Test: http/tests/inspector/network/xhr-request-data-encoded-correctly.html
* inspector/InspectorNetworkAgent.cpp:
(WebCore::buildObjectForResourceRequest):
LayoutTests:
Based on Chromium patch:
<https://chromium.googlesource.com/chromium/src/+/bcbb663864624ab38b36731eb2edc839a90f9e65%5E%21/#F2>
* http/tests/inspector/network/xhr-request-data-encoded-correctly-expected.txt:
* http/tests/inspector/network/xhr-request-data-encoded-correctly.html:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (202765 => 202766)
--- trunk/LayoutTests/ChangeLog 2016-07-02 00:22:15 UTC (rev 202765)
+++ trunk/LayoutTests/ChangeLog 2016-07-02 00:55:44 UTC (rev 202766)
@@ -1,3 +1,16 @@
+2016-07-01 Johan K. Jensen <j...@johanjensen.dk>
+
+ Web Inspector: Sending XHR with UTF8 encoded data shows garbled data in Resource sidebar
+ https://bugs.webkit.org/show_bug.cgi?id=159358
+
+ Reviewed by Joseph Pecoraro.
+
+ Based on Chromium patch:
+ <https://chromium.googlesource.com/chromium/src/+/bcbb663864624ab38b36731eb2edc839a90f9e65%5E%21/#F2>
+
+ * http/tests/inspector/network/xhr-request-data-encoded-correctly-expected.txt:
+ * http/tests/inspector/network/xhr-request-data-encoded-correctly.html:
+
2016-07-01 Dean Jackson <d...@apple.com>
"image-src" support is missing. We only support "-webkit-image-src"
Added: trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly-expected.txt (0 => 202766)
--- trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly-expected.txt 2016-07-02 00:55:44 UTC (rev 202766)
@@ -0,0 +1,9 @@
+Tests XHR network resource payload is shown with correct encoding.
+
+
+== Running test suite: XHRWithRequestDataEncoding
+-- Running test case: XHRWithRequestDataIsEncodedCorrectly
+PASS: Resource should be created.
+PASS: Request data should have expected content.
+PASS: Resource load should finish.
+
Added: trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html (0 => 202766)
--- trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/xhr-request-data-encoded-correctly.html 2016-07-02 00:55:44 UTC (rev 202766)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script>
+function createXHRResource() {
+ var request = new XMLHttpRequest();
+ request.open("POST", "resources/", true);
+ request.send("utf8=👍");
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("XHRWithRequestDataEncoding");
+
+ suite.addTestCase({
+ name: "XHRWithRequestDataIsEncodedCorrectly",
+ description: "XHR with request data is encoded correctly.",
+ test: (resolve, reject) => {
+ InspectorTest.evaluateInPage("createXHRResource()");
+ WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) => {
+ let resource = event.data.resource;
+ InspectorTest.expectThat(resource instanceof WebInspector.Resource, "Resource should be created.");
+ InspectorTest.expectThat(resource.requestData === "utf8=👍", "Request data should have expected content.");
+ resource.singleFireEventListener(WebInspector.Resource.Event.LoadingDidFinish, (event) => {
+ InspectorTest.pass("Resource load should finish.");
+ resolve();
+ });
+ });
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+ <p>Tests XHR network resource payload is shown with correct encoding.</p>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (202765 => 202766)
--- trunk/Source/WebCore/ChangeLog 2016-07-02 00:22:15 UTC (rev 202765)
+++ trunk/Source/WebCore/ChangeLog 2016-07-02 00:55:44 UTC (rev 202766)
@@ -1,3 +1,15 @@
+2016-07-01 Johan K. Jensen <j...@johanjensen.dk>
+
+ Web Inspector: Sending XHR with UTF8 encoded data shows garbled data in Resource sidebar
+ https://bugs.webkit.org/show_bug.cgi?id=159358
+
+ Reviewed by Joseph Pecoraro.
+
+ Test: http/tests/inspector/network/xhr-request-data-encoded-correctly.html
+
+ * inspector/InspectorNetworkAgent.cpp:
+ (WebCore::buildObjectForResourceRequest):
+
2016-07-01 Dean Jackson <d...@apple.com>
"image-src" support is missing. We only support "-webkit-image-src"
Modified: trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp (202765 => 202766)
--- trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp 2016-07-02 00:22:15 UTC (rev 202765)
+++ trunk/Source/WebCore/inspector/InspectorNetworkAgent.cpp 2016-07-02 00:55:44 UTC (rev 202766)
@@ -205,8 +205,11 @@
.setMethod(request.httpMethod())
.setHeaders(buildObjectForHeaders(request.httpHeaderFields()))
.release();
- if (request.httpBody() && !request.httpBody()->isEmpty())
- requestObject->setPostData(request.httpBody()->flattenToString());
+ if (request.httpBody() && !request.httpBody()->isEmpty()) {
+ Vector<char> bytes;
+ request.httpBody()->flatten(bytes);
+ requestObject->setPostData(String::fromUTF8WithLatin1Fallback(bytes.data(), bytes.size()));
+ }
return requestObject;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes