Skip to content

Commit 9d89263

Browse files
youennfwebkit-commit-queue
authored andcommitted
ServiceWorkerThreadProxy should set the correct cookie and cache partitioning options
https://bugs.webkit.org/show_bug.cgi?id=181000 Patch by Youenn Fablet <youenn@apple.com> on 2017-12-21 Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/service-workers/service-worker/fetch-response-taint.https-expected.txt: Source/WebCore: Covered by rebased test. Add a way to set the domain for cache partition explicitly on a ScriptExecutionContext. This is used by ServiceWorkerThreadProxy document to mimick the fact that it may be a service worker used by iframes that have a cross origin top document. Updated code to use that new utility routine. * Modules/websockets/WebSocketChannel.cpp: (WebCore::WebSocketChannel::connect): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::domainForCachePartition const): * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::setDomainForCachePartition): * html/DOMURL.cpp: (WebCore::DOMURL::revokeObjectURL): * inspector/agents/InspectorPageAgent.cpp: (WebCore::InspectorPageAgent::cachedResource): * loader/EmptyFrameLoaderClient.h: * loader/FrameLoader.cpp: (WebCore::FrameLoader::loadURL): * loader/archive/cf/LegacyWebArchive.cpp: (WebCore::LegacyWebArchive::create): * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setDomainForCachePartition): * testing/Internals.cpp: (WebCore::Internals::isLoadingFromMemoryCache): * workers/service/context/ServiceWorkerThreadProxy.cpp: (WebCore::topOriginURL): (WebCore::createPageForServiceWorker): (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy): * workers/service/context/ServiceWorkerThreadProxy.h: * xml/XMLHttpRequest.cpp: (WebCore::XMLHttpRequest::createRequest): Source/WebKit: Update Service Worker WebPreferencesStore based on the first web page added. This allows having the right storage blocking policy. Storing that policy in the context manager to set it properly when creating a new service worker thread proxy. Set up correctly partitioning parameters in the dummy Document used by the service worker. * UIProcess/ServiceWorkerProcessProxy.cpp: (WebKit::ServiceWorkerProcessProxy::updatePreferencesStore): * UIProcess/ServiceWorkerProcessProxy.h: * UIProcess/WebPageProxy.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::establishWorkerContextConnectionToStorageProcess): (WebKit::WebProcessPool::pageAddedToProcess): * UIProcess/WebProcessPool.h: * WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::getAuthenticationInfo): * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updatePreferencesStore): (WebKit::WebSWContextManagerConnection::installServiceWorker): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WebKitLegacy/mac: * Misc/WebCache.mm: (+[WebCache addImageToCache:forURL:forFrame:]): Canonical link: https://commits.webkit.org/196981@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226257 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a565846 commit 9d89263

28 files changed

Lines changed: 207 additions & 67 deletions

LayoutTests/imported/w3c/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2017-12-21 Youenn Fablet <youenn@apple.com>
2+
3+
ServiceWorkerThreadProxy should set the correct cookie and cache partitioning options
4+
https://bugs.webkit.org/show_bug.cgi?id=181000
5+
6+
Reviewed by Chris Dumez.
7+
8+
* web-platform-tests/service-workers/service-worker/fetch-response-taint.https-expected.txt:
9+
110
2017-12-21 Youenn Fablet <youenn@apple.com>
211

312
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-request-xhr.https.html is failing one test

LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-response-taint.https-expected.txt

Lines changed: 37 additions & 37 deletions
Large diffs are not rendered by default.

Source/WebCore/ChangeLog

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
2017-12-21 Youenn Fablet <youenn@apple.com>
2+
3+
ServiceWorkerThreadProxy should set the correct cookie and cache partitioning options
4+
https://bugs.webkit.org/show_bug.cgi?id=181000
5+
6+
Reviewed by Chris Dumez.
7+
8+
Covered by rebased test.
9+
10+
Add a way to set the domain for cache partition explicitly on a ScriptExecutionContext.
11+
This is used by ServiceWorkerThreadProxy document to mimick the fact that it may be
12+
a service worker used by iframes that have a cross origin top document.
13+
Updated code to use that new utility routine.
14+
15+
* Modules/websockets/WebSocketChannel.cpp:
16+
(WebCore::WebSocketChannel::connect):
17+
* dom/ScriptExecutionContext.cpp:
18+
(WebCore::ScriptExecutionContext::domainForCachePartition const):
19+
* dom/ScriptExecutionContext.h:
20+
(WebCore::ScriptExecutionContext::setDomainForCachePartition):
21+
* html/DOMURL.cpp:
22+
(WebCore::DOMURL::revokeObjectURL):
23+
* inspector/agents/InspectorPageAgent.cpp:
24+
(WebCore::InspectorPageAgent::cachedResource):
25+
* loader/EmptyFrameLoaderClient.h:
26+
* loader/FrameLoader.cpp:
27+
(WebCore::FrameLoader::loadURL):
28+
* loader/archive/cf/LegacyWebArchive.cpp:
29+
(WebCore::LegacyWebArchive::create):
30+
* loader/cache/CachedResourceRequest.cpp:
31+
(WebCore::CachedResourceRequest::setDomainForCachePartition):
32+
* testing/Internals.cpp:
33+
(WebCore::Internals::isLoadingFromMemoryCache):
34+
* workers/service/context/ServiceWorkerThreadProxy.cpp:
35+
(WebCore::topOriginURL):
36+
(WebCore::createPageForServiceWorker):
37+
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
38+
* workers/service/context/ServiceWorkerThreadProxy.h:
39+
* xml/XMLHttpRequest.cpp:
40+
(WebCore::XMLHttpRequest::createRequest):
41+
142
2017-12-21 Christopher Reid <chris.reid@sony.com>
243

344
[WinCairo] fix build after r226245

Source/WebCore/Modules/websockets/WebSocketChannel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void WebSocketChannel::connect(const URL& requestedURL, const String& protocol)
121121
ref();
122122
Page* page = frame->page();
123123
PAL::SessionID sessionID = page ? page->sessionID() : PAL::SessionID::defaultSessionID();
124-
String partition = m_document->topDocument().securityOrigin().domainForCachePartition();
124+
String partition = m_document->domainForCachePartition();
125125
m_handle = m_socketProvider->createSocketStreamHandle(m_handshake->url(), *this, sessionID, partition);
126126
}
127127
}

Source/WebCore/dom/ScriptExecutionContext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,11 @@ JSC::ExecState* ScriptExecutionContext::execState()
524524
return execStateFromWorkerGlobalScope(workerGlobalScope);
525525
}
526526

527+
String ScriptExecutionContext::domainForCachePartition() const
528+
{
529+
return m_domainForCachePartition.isNull() ? topOrigin().domainForCachePartition() : m_domainForCachePartition;
530+
}
531+
527532
#if ENABLE(SERVICE_WORKER)
528533

529534
bool ScriptExecutionContext::hasServiceWorkerScheme()

Source/WebCore/dom/ScriptExecutionContext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ class ScriptExecutionContext : public SecurityContext {
237237

238238
JSC::ExecState* execState();
239239

240+
WEBCORE_EXPORT String domainForCachePartition() const;
241+
void setDomainForCachePartition(String&& domain) { m_domainForCachePartition = WTFMove(domain); }
242+
240243
#if ENABLE(SERVICE_WORKER)
241244
bool hasServiceWorkerScheme();
242245
ServiceWorker* activeServiceWorker() const;
@@ -323,6 +326,8 @@ class ScriptExecutionContext : public SecurityContext {
323326
RefPtr<ServiceWorker> m_activeServiceWorker;
324327
HashMap<ServiceWorkerIdentifier, ServiceWorker*> m_serviceWorkers;
325328
#endif
329+
330+
String m_domainForCachePartition;
326331
};
327332

328333
} // namespace WebCore

Source/WebCore/html/DOMURL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void DOMURL::revokeObjectURL(ScriptExecutionContext& scriptExecutionContext, con
119119
{
120120
URL url(URL(), urlString);
121121
ResourceRequest request(url);
122-
request.setDomainForCachePartition(scriptExecutionContext.topOrigin().domainForCachePartition());
122+
request.setDomainForCachePartition(scriptExecutionContext.domainForCachePartition());
123123

124124
MemoryCache::removeRequestFromSessionCaches(scriptExecutionContext, request);
125125

Source/WebCore/inspector/agents/InspectorPageAgent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ CachedResource* InspectorPageAgent::cachedResource(Frame* frame, const URL& url)
176176
CachedResource* cachedResource = frame->document()->cachedResourceLoader().cachedResource(MemoryCache::removeFragmentIdentifierIfNeeded(url));
177177
if (!cachedResource) {
178178
ResourceRequest request(url);
179-
request.setDomainForCachePartition(frame->document()->topOrigin().domainForCachePartition());
179+
request.setDomainForCachePartition(frame->document()->domainForCachePartition());
180180
cachedResource = MemoryCache::singleton().resourceForRequest(request, frame->page()->sessionID());
181181
}
182182

Source/WebCore/loader/EmptyFrameLoaderClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class WEBCORE_EXPORT EmptyFrameLoaderClient : public FrameLoaderClient {
5252
void convertMainResourceLoadToDownload(DocumentLoader*, PAL::SessionID, const ResourceRequest&, const ResourceResponse&) final { }
5353

5454
void assignIdentifierToInitialRequest(unsigned long, DocumentLoader*, const ResourceRequest&) final { }
55-
bool shouldUseCredentialStorage(DocumentLoader*, unsigned long) final { return false; }
55+
bool shouldUseCredentialStorage(DocumentLoader*, unsigned long) override { return false; }
5656
void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) final { }
5757
void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&) final { }
5858
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)

Source/WebCore/loader/FrameLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& ref
12771277
addHTTPOriginIfNeeded(request, referrerOrigin->toString());
12781278
}
12791279
if (&m_frame.tree().top() != &m_frame)
1280-
request.setDomainForCachePartition(m_frame.tree().top().document()->securityOrigin().domainForCachePartition());
1280+
request.setDomainForCachePartition(m_frame.tree().top().document()->domainForCachePartition());
12811281

12821282
addExtraFieldsToRequest(request, newLoadType, true);
12831283
if (isReload(newLoadType))

0 commit comments

Comments
 (0)