Changeset 226191 in webkit
- Timestamp:
- Dec 20, 2017 11:16:10 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r226188 r226191 1 2017-12-20 Youenn Fablet <youenn@apple.com> 2 3 Support service worker interception of request with blob body 4 https://bugs.webkit.org/show_bug.cgi?id=181035 5 6 Reviewed by Chris Dumez. 7 8 * web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt: 9 * web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt: 10 1 11 2017-12-20 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event.https-expected.txt
r226066 r226191 17 17 PASS Service Worker responds to fetch event with the correct integrity_metadata 18 18 PASS FetchEvent#body is a string 19 FAIL FetchEvent#body is a blob assert_equals: expected "it's me the blob and more blob!" but got "" 19 PASS FetchEvent#body is a blob 20 20 PASS Service Worker responds to fetch event with the correct keepalive value 21 21 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-xhr.https-expected.txt
r226126 r226191 6 6 PASS event.request has the expected headers for cross-origin POST. 7 7 PASS FetchEvent#request.body contains XHR request data (string) 8 FAIL FetchEvent#request.body contains XHR request data (blob) promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "test blob" but got """ 8 PASS FetchEvent#request.body contains XHR request data (blob) 9 9 PASS FetchEvent#request.method is set to XHR method 10 10 PASS XHR using OPTIONS method 11 FAIL XHR with form data promise_test: Unhandled rejection with value: object "Error: assert_ true: form data response content is as expected expected true got false"11 FAIL XHR with form data promise_test: Unhandled rejection with value: object "Error: assert_equals: expected (string) "POST" but got (undefined) undefined" 12 12 FAIL XHR with mode/credentials set promise_test: Unhandled rejection with value: object "Error: assert_equals: expected "include" but got "same-origin"" 13 13 PASS XHR to data URL -
trunk/Source/WebCore/ChangeLog
r226190 r226191 1 2017-12-20 Youenn Fablet <youenn@apple.com> 2 3 Support service worker interception of request with blob body 4 https://bugs.webkit.org/show_bug.cgi?id=181035 5 6 Reviewed by Chris Dumez. 7 8 Covered by updated test. 9 10 Add support for getting blob request bodies within service worker. 11 Disable interception of requests with form datas. 12 13 * Modules/fetch/FetchBody.cpp: 14 (WebCore::FetchBody::fromFormData): 15 * Modules/fetch/FetchBody.h: 16 * workers/service/context/ServiceWorkerFetch.cpp: 17 (WebCore::ServiceWorkerFetch::dispatchFetchEvent): 18 * workers/service/context/ServiceWorkerFetch.h: 19 * workers/service/context/ServiceWorkerThread.cpp: 20 (WebCore::ServiceWorkerThread::postFetchTask): 21 1 22 2017-12-20 Jeremy Jones <jeremyj@apple.com> 2 23 -
trunk/Source/WebCore/Modules/fetch/FetchBody.cpp
r226162 r226191 71 71 } 72 72 73 std::optional<FetchBody> FetchBody::fromFormData(FormData* formData) 74 { 75 if (!formData || formData->isEmpty()) 76 return std::nullopt; 77 78 if (auto buffer = formData->asSharedBuffer()) { 73 std::optional<FetchBody> FetchBody::fromFormData(FormData& formData) 74 { 75 ASSERT(!formData.isEmpty()); 76 77 if (auto buffer = formData.asSharedBuffer()) { 79 78 FetchBody body; 80 79 body.m_consumer.setData(buffer.releaseNonNull()); … … 82 81 } 83 82 84 // FIXME: Support blob and form data bodies. 83 auto url = formData.asBlobURL(); 84 if (!url.isNull()) { 85 // FIXME: Properly set mime type and size of the blob. 86 Ref<const Blob> blob = Blob::deserialize(url, { }, 0, { }); 87 return FetchBody { WTFMove(blob) }; 88 } 89 90 // FIXME: Support form data bodies. 85 91 return std::nullopt; 86 92 } -
trunk/Source/WebCore/Modules/fetch/FetchBody.h
r224956 r226191 59 59 FetchBody() = default; 60 60 61 static std::optional<FetchBody> fromFormData(FormData *);61 static std::optional<FetchBody> fromFormData(FormData&); 62 62 63 63 void loadingFailed(); -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r226172 r226191 911 911 RetainPtr<CFDictionaryRef> attributes; 912 912 #if CAN_DISALLOW_USER_INSTALLED_FONTS 913 if (m_allowUserInstalledFonts == FontCache::AllowUserInstalledFonts::No) {913 if (m_allowUserInstalledFonts == AllowUserInstalledFonts::No) { 914 914 CFTypeRef keys[] = { kCTFontFamilyNameAttribute, kCTFontUserInstalledAttribute }; 915 915 CFTypeRef values[] = { familyNameString.get(), kCFBooleanFalse }; … … 949 949 RetainPtr<CFDictionaryRef> attributes; 950 950 #if CAN_DISALLOW_USER_INSTALLED_FONTS 951 if (m_allowUserInstalledFonts == FontCache::AllowUserInstalledFonts::No) {951 if (m_allowUserInstalledFonts == AllowUserInstalledFonts::No) { 952 952 CFTypeRef keys[] = { kCTFontEnabledAttribute, nameAttribute, kCTFontUserInstalledAttribute }; 953 953 CFTypeRef values[] = { kCFBooleanTrue, postScriptNameString.get(), kCFBooleanFalse }; -
trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.cpp
r226126 r226191 92 92 } 93 93 94 Ref<FetchEvent> dispatchFetchEvent(Ref<Client>&& client,WorkerGlobalScope& globalScope, std::optional<ServiceWorkerClientIdentifier> clientId, ResourceRequest&& request, String&& referrer, FetchOptions&& options)94 void dispatchFetchEvent(Ref<Client>&& client, ServiceWorkerGlobalScope& globalScope, std::optional<ServiceWorkerClientIdentifier> clientId, ResourceRequest&& request, String&& referrer, FetchOptions&& options) 95 95 { 96 96 ASSERT(globalScope.isServiceWorkerGlobalScope()); 97 97 98 98 auto requestHeaders = FetchHeaders::create(FetchHeaders::Guard::Immutable, HTTPHeaderMap { request.httpHeaderFields() }); 99 auto fetchRequest = FetchRequest::create(globalScope, FetchBody::fromFormData(request.httpBody()), WTFMove(requestHeaders), WTFMove(request), WTFMove(options), WTFMove(referrer)); 99 100 auto* formData = request.httpBody(); 101 std::optional<FetchBody> body; 102 if (formData && !formData->isEmpty()) { 103 body = FetchBody::fromFormData(*formData); 104 if (!body) { 105 client->didNotHandle(); 106 return; 107 } 108 } 109 110 auto fetchRequest = FetchRequest::create(globalScope, WTFMove(body), WTFMove(requestHeaders), WTFMove(request), WTFMove(options), WTFMove(referrer)); 100 111 101 112 FetchEvent::Init init; … … 119 130 if (event->defaultPrevented()) { 120 131 client->didFail(); 121 return event;132 return; 122 133 } 123 134 client->didNotHandle(); 124 135 // FIXME: Handle soft update. 125 136 } 126 return event; 137 138 globalScope.updateExtendedEventsSet(event.ptr()); 127 139 } 128 140 -
trunk/Source/WebCore/workers/service/context/ServiceWorkerFetch.h
r226126 r226191 39 39 class ResourceResponse; 40 40 struct ServiceWorkerClientIdentifier; 41 class ServiceWorkerGlobalScope; 41 42 class SharedBuffer; 42 class WorkerGlobalScope;43 43 44 44 namespace ServiceWorkerFetch { … … 55 55 }; 56 56 57 Ref<FetchEvent> dispatchFetchEvent(Ref<Client>&&,WorkerGlobalScope&, std::optional<ServiceWorkerClientIdentifier>, ResourceRequest&&, String&& referrer, FetchOptions&&);57 void dispatchFetchEvent(Ref<Client>&&, ServiceWorkerGlobalScope&, std::optional<ServiceWorkerClientIdentifier>, ResourceRequest&&, String&& referrer, FetchOptions&&); 58 58 }; 59 59 -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
r226126 r226191 97 97 // FIXME: request and options come straigth from IPC so are already isolated. We should be able to take benefit of that. 98 98 runLoop().postTaskForMode([client = WTFMove(client), clientId, request = request.isolatedCopy(), referrer = referrer.isolatedCopy(), options = options.isolatedCopy()] (ScriptExecutionContext& context) mutable { 99 auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(context); 100 auto fetchEvent = ServiceWorkerFetch::dispatchFetchEvent(WTFMove(client), serviceWorkerGlobalScope, clientId, WTFMove(request), WTFMove(referrer), WTFMove(options)); 101 serviceWorkerGlobalScope.updateExtendedEventsSet(fetchEvent.ptr()); 99 ServiceWorkerFetch::dispatchFetchEvent(WTFMove(client), downcast<ServiceWorkerGlobalScope>(context), clientId, WTFMove(request), WTFMove(referrer), WTFMove(options)); 102 100 }, WorkerRunLoop::defaultMode()); 103 101 } -
trunk/Source/WebKit/ChangeLog
r226189 r226191 1 2017-12-20 Youenn Fablet <youenn@apple.com> 2 3 Support service worker interception of request with blob body 4 https://bugs.webkit.org/show_bug.cgi?id=181035 5 6 Reviewed by Chris Dumez. 7 8 In case of service worker, remove the connection check to get access to the blob registry. 9 Apply this for cloning blobs registered by another process. 10 11 * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp: 12 (WebKit::NetworkBlobRegistry::registerBlobURL): 13 * NetworkProcess/FileAPI/NetworkBlobRegistry.h: 14 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 15 (WebKit::NetworkConnectionToWebProcess::registerBlobURLFromURL): 16 * NetworkProcess/NetworkConnectionToWebProcess.h: 17 * NetworkProcess/NetworkConnectionToWebProcess.messages.in: 18 * WebProcess/FileAPI/BlobRegistryProxy.cpp: 19 (WebKit::BlobRegistryProxy::registerBlobURL): 20 1 21 2017-12-20 Daniel Bates <dabates@apple.com> 2 22 -
trunk/Source/WebKit/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
r216764 r226191 72 72 } 73 73 74 void NetworkBlobRegistry::registerBlobURL(NetworkConnectionToWebProcess* connection, const WebCore::URL& url, const WebCore::URL& srcURL )74 void NetworkBlobRegistry::registerBlobURL(NetworkConnectionToWebProcess* connection, const WebCore::URL& url, const WebCore::URL& srcURL, bool shouldBypassConnectionCheck) 75 75 { 76 76 // The connection may not be registered if NetworkProcess prevously crashed for any reason. 77 77 BlobForConnectionMap::iterator mapIterator = m_blobsForConnection.find(connection); 78 if (mapIterator == m_blobsForConnection.end()) 79 return; 78 if (mapIterator == m_blobsForConnection.end()) { 79 if (!shouldBypassConnectionCheck) 80 return; 81 mapIterator = m_blobsForConnection.add(connection, HashSet<URL>()).iterator; 82 } 80 83 81 84 blobRegistry().registerBlobURL(url, srcURL); 82 85 83 ASSERT( mapIterator->value.contains(srcURL));86 ASSERT(shouldBypassConnectionCheck || mapIterator->value.contains(srcURL)); 84 87 mapIterator->value.add(url); 85 88 } -
trunk/Source/WebKit/NetworkProcess/FileAPI/NetworkBlobRegistry.h
r209184 r226191 49 49 void registerFileBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const String& path, RefPtr<SandboxExtension>&&, const String& contentType); 50 50 void registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, Vector<WebCore::BlobPart>&&, const String& contentType); 51 void registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL );51 void registerBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL, bool shouldBypassConnectionCheck); 52 52 void registerBlobURLOptionallyFileBacked(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL, const String& fileBackedPath, const String& contentType); 53 53 void registerBlobURLForSlice(NetworkConnectionToWebProcess*, const WebCore::URL&, const WebCore::URL& srcURL, int64_t start, int64_t end); -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r225934 r226191 390 390 } 391 391 392 void NetworkConnectionToWebProcess::registerBlobURLFromURL(const URL& url, const URL& srcURL )393 { 394 NetworkBlobRegistry::singleton().registerBlobURL(this, url, srcURL );392 void NetworkConnectionToWebProcess::registerBlobURLFromURL(const URL& url, const URL& srcURL, bool shouldBypassConnectionCheck) 393 { 394 NetworkBlobRegistry::singleton().registerBlobURL(this, url, srcURL, shouldBypassConnectionCheck); 395 395 } 396 396 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
r225934 r226191 111 111 void registerFileBlobURL(const WebCore::URL&, const String& path, SandboxExtension::Handle&&, const String& contentType); 112 112 void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>&&, const String& contentType); 113 void registerBlobURLFromURL(const WebCore::URL&, const WebCore::URL& srcURL );113 void registerBlobURLFromURL(const WebCore::URL&, const WebCore::URL& srcURL, bool shouldBypassConnectionCheck); 114 114 void preregisterSandboxExtensionsForOptionallyFileBackedBlob(const Vector<String>& fileBackedPath, SandboxExtension::HandleArray&&); 115 115 void registerBlobURLOptionallyFileBacked(const WebCore::URL&, const WebCore::URL& srcURL, const String& fileBackedPath, const String& contentType); -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
r225934 r226191 43 43 RegisterFileBlobURL(WebCore::URL url, String path, WebKit::SandboxExtension::Handle extensionHandle, String contentType) 44 44 RegisterBlobURL(WebCore::URL url, Vector<WebCore::BlobPart> blobParts, String contentType) 45 RegisterBlobURLFromURL(WebCore::URL url, WebCore::URL srcURL )45 RegisterBlobURLFromURL(WebCore::URL url, WebCore::URL srcURL, bool shouldBypassConnectionCheck) 46 46 PreregisterSandboxExtensionsForOptionallyFileBackedBlob(Vector<String> filePaths, WebKit::SandboxExtension::HandleArray extensionHandles) 47 47 RegisterBlobURLOptionallyFileBacked(WebCore::URL url, WebCore::URL srcURL, String fileBackedPath, String contentType) -
trunk/Source/WebKit/WebProcess/FileAPI/BlobRegistryProxy.cpp
r225282 r226191 32 32 #include "WebProcess.h" 33 33 #include <WebCore/BlobDataFileReference.h> 34 #include <WebCore/SWContextManager.h> 34 35 35 36 using namespace WebCore; … … 55 56 void BlobRegistryProxy::registerBlobURL(const URL& url, const URL& srcURL) 56 57 { 57 WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLFromURL(url, srcURL), 0); 58 bool shouldBypassConnectionCheck = false; 59 #if ENABLE(SERVICE_WORKER) 60 shouldBypassConnectionCheck = SWContextManager::singleton().connection(); 61 #endif 62 WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RegisterBlobURLFromURL { url, srcURL, shouldBypassConnectionCheck }, 0); 58 63 } 59 64
Note: See TracChangeset
for help on using the changeset viewer.