FetchResponse should set its internal response text encoding name
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 18:49:07 +0000 (18:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 18:49:07 +0000 (18:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181284

Patch by Youenn Fablet <youenn@apple.com> on 2018-01-04
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt:

Source/WebCore:

Covered by rebased test.

* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::create): Set response text encoding based on content type charset.

Source/WebKit:

* WebProcess/Storage/ServiceWorkerClientFetch.cpp:
(WebKit::ServiceWorkerClientFetch::didReceiveResponse): Set default encoding to UTF-8.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226410 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp

index a015418..45f583a 100644 (file)
@@ -1,5 +1,14 @@
 2018-01-04  Youenn Fablet  <youenn@apple.com>
 
+        FetchResponse should set its internal response text encoding name
+        https://bugs.webkit.org/show_bug.cgi?id=181284
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt:
+
+2018-01-04  Youenn Fablet  <youenn@apple.com>
+
         Service Worker should expose redirect mode for navigation loads as manual
         https://bugs.webkit.org/show_bug.cgi?id=181067
 
index fb92e9f..5a10ffe 100644 (file)
@@ -1,7 +1,7 @@
 
 
 FAIL Service Worker headers in the request of a fetch event assert_unreached: unexpected rejection: assert_true: request specifies "Upgrade-Insecure Requests header as inserted by Fetch expected true got false Reached unreachable code
-FAIL Service Worker responds to fetch event with string assert_unreached: unexpected rejection: assert_equals: The character set of the response created with a string should be UTF-8 expected "UTF-8" but got "windows-1252" Reached unreachable code
+PASS Service Worker responds to fetch event with string 
 PASS Service Worker responds to fetch event with blob body 
 PASS Service Worker responds to fetch event with the referrer URL 
 PASS Service Worker responds to fetch event with an existing client id 
index ecb94aa..e781797 100644 (file)
@@ -1,3 +1,15 @@
+2018-01-04  Youenn Fablet  <youenn@apple.com>
+
+        FetchResponse should set its internal response text encoding name
+        https://bugs.webkit.org/show_bug.cgi?id=181284
+
+        Reviewed by Alex Christensen.
+
+        Covered by rebased test.
+
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::create): Set response text encoding based on content type charset.
+
 2018-01-04  John Wilander  <wilander@apple.com>
 
         Storage Access API: Remove JavaScript confirm() prompt from Document::requestStorageAccess()
index aabac8c..2bf0032 100644 (file)
@@ -116,6 +116,7 @@ ExceptionOr<Ref<FetchResponse>> FetchResponse::create(ScriptExecutionContext& co
     r->m_contentType = contentType;
     auto mimeType = extractMIMETypeFromMediaType(contentType);
     r->m_internalResponse.setMimeType(mimeType.isEmpty() ? defaultMIMEType() : mimeType);
+    r->m_internalResponse.setTextEncodingName(extractCharsetFromMediaType(contentType));
 
     r->m_internalResponse.setHTTPStatusCode(status);
     r->m_internalResponse.setHTTPStatusText(statusText);
index 9829b77..3c154ba 100644 (file)
@@ -1,5 +1,15 @@
 2018-01-04  Youenn Fablet  <youenn@apple.com>
 
+        FetchResponse should set its internal response text encoding name
+        https://bugs.webkit.org/show_bug.cgi?id=181284
+
+        Reviewed by Alex Christensen.
+
+        * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
+        (WebKit::ServiceWorkerClientFetch::didReceiveResponse): Set default encoding to UTF-8.
+
+2018-01-04  Youenn Fablet  <youenn@apple.com>
+
         Implement Cache API partitioning based on ClientOrigin
         https://bugs.webkit.org/show_bug.cgi?id=181240
 
index 2cdf2bf..2a5c12a 100644 (file)
@@ -127,8 +127,10 @@ void ServiceWorkerClientFetch::didReceiveResponse(ResourceResponse&& response)
     // In case of main resource and mime type is the default one, we set it to text/html to pass more service worker WPT tests.
     // FIXME: We should refine our MIME type sniffing strategy for synthetic responses.
     if (m_loader->originalRequest().requester() == ResourceRequest::Requester::Main) {
-        if (response.mimeType() == defaultMIMEType())
+        if (response.mimeType() == defaultMIMEType()) {
             response.setMimeType(ASCIILiteral("text/html"));
+            response.setTextEncodingName(ASCIILiteral("UTF-8"));
+        }
     }
     response.setSource(ResourceResponse::Source::ServiceWorker);