- Revision
- 227638
- Author
- [email protected]
- Date
- 2018-01-25 15:08:23 -0800 (Thu, 25 Jan 2018)
Log Message
Clients.get(id) should only returns clients in the service worker's origin
https://bugs.webkit.org/show_bug.cgi?id=182149
<rdar://problem/36882310>
Reviewed by Youenn Fablet.
LayoutTests/imported/w3c:
Rebase WPT test that is now passing.
* web-platform-tests/service-workers/service-worker/clients-get-cross-origin.https-expected.txt:
Source/WebCore:
When looking for SW clients with a given identifier, only look in the list of
clients that have the same origin as the service worker.
No new tests, rebaselined existing test.
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::serviceWorkerClientWithOriginByID const):
(WebCore::SWServer::serviceWorkerClientByID const): Deleted.
* workers/service/server/SWServer.h:
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::findClientByIdentifier const):
* workers/service/server/SWServerWorker.h:
Source/WebKit:
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::postMessageToServiceWorker):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (227637 => 227638)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-01-25 23:08:23 UTC (rev 227638)
@@ -1,3 +1,15 @@
+2018-01-25 Chris Dumez <[email protected]>
+
+ Clients.get(id) should only returns clients in the service worker's origin
+ https://bugs.webkit.org/show_bug.cgi?id=182149
+ <rdar://problem/36882310>
+
+ Reviewed by Youenn Fablet.
+
+ Rebase WPT test that is now passing.
+
+ * web-platform-tests/service-workers/service-worker/clients-get-cross-origin.https-expected.txt:
+
2018-01-25 Youenn Fablet <[email protected]>
ShapeOutside should use same origin credentials mode
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get-cross-origin.https-expected.txt (227637 => 227638)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get-cross-origin.https-expected.txt 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get-cross-origin.https-expected.txt 2018-01-25 23:08:23 UTC (rev 227638)
@@ -1,3 +1,3 @@
-FAIL Test Clients.get() cross origin assert_equals: iframe client ID expected (undefined) undefined but got (object) [["visible", true, "https://localhost:9443/service-workers/service-worker/resources/clients-get-frame.html", "window", "nested"]]
+PASS Test Clients.get() cross origin
Modified: trunk/Source/WebCore/ChangeLog (227637 => 227638)
--- trunk/Source/WebCore/ChangeLog 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebCore/ChangeLog 2018-01-25 23:08:23 UTC (rev 227638)
@@ -1,3 +1,24 @@
+2018-01-25 Chris Dumez <[email protected]>
+
+ Clients.get(id) should only returns clients in the service worker's origin
+ https://bugs.webkit.org/show_bug.cgi?id=182149
+ <rdar://problem/36882310>
+
+ Reviewed by Youenn Fablet.
+
+ When looking for SW clients with a given identifier, only look in the list of
+ clients that have the same origin as the service worker.
+
+ No new tests, rebaselined existing test.
+
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::serviceWorkerClientWithOriginByID const):
+ (WebCore::SWServer::serviceWorkerClientByID const): Deleted.
+ * workers/service/server/SWServer.h:
+ * workers/service/server/SWServerWorker.cpp:
+ (WebCore::SWServerWorker::findClientByIdentifier const):
+ * workers/service/server/SWServerWorker.h:
+
2018-01-25 Youenn Fablet <[email protected]>
WebPluginInfoProvider should handle null host queries
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (227637 => 227638)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2018-01-25 23:08:23 UTC (rev 227638)
@@ -93,12 +93,18 @@
return worker;
}
-std::optional<ServiceWorkerClientData> SWServer::serviceWorkerClientByID(const ServiceWorkerClientIdentifier& clientIdentifier) const
+std::optional<ServiceWorkerClientData> SWServer::serviceWorkerClientWithOriginByID(const ClientOrigin& clientOrigin, const ServiceWorkerClientIdentifier& clientIdentifier) const
{
- auto iterator = m_clientsById.find(clientIdentifier);
- if (iterator == m_clientsById.end())
+ auto iterator = m_clientIdentifiersPerOrigin.find(clientOrigin);
+ if (iterator == m_clientIdentifiersPerOrigin.end())
return std::nullopt;
- return iterator->value;
+
+ if (!iterator->value.identifiers.contains(clientIdentifier))
+ return std::nullopt;
+
+ auto clientIterator = m_clientsById.find(clientIdentifier);
+ ASSERT(clientIterator != m_clientsById.end());
+ return clientIterator->value;
}
SWServerWorker* SWServer::activeWorkerFromRegistrationID(ServiceWorkerRegistrationIdentifier identifier)
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (227637 => 227638)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2018-01-25 23:08:23 UTC (rev 227638)
@@ -147,7 +147,7 @@
void fireActivateEvent(SWServerWorker&);
WEBCORE_EXPORT SWServerWorker* workerByID(ServiceWorkerIdentifier) const;
- WEBCORE_EXPORT std::optional<ServiceWorkerClientData> serviceWorkerClientByID(const ServiceWorkerClientIdentifier&) const;
+ std::optional<ServiceWorkerClientData> serviceWorkerClientWithOriginByID(const ClientOrigin&, const ServiceWorkerClientIdentifier&) const;
WEBCORE_EXPORT SWServerWorker* activeWorkerFromRegistrationID(ServiceWorkerRegistrationIdentifier);
WEBCORE_EXPORT void markAllWorkersAsTerminated();
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp (227637 => 227638)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2018-01-25 23:08:23 UTC (rev 227638)
@@ -117,7 +117,7 @@
std::optional<ServiceWorkerClientData> SWServerWorker::findClientByIdentifier(const ServiceWorkerClientIdentifier& clientId) const
{
- return m_server.serviceWorkerClientByID(clientId);
+ return m_server.serviceWorkerClientWithOriginByID(origin(), clientId);
}
void SWServerWorker::matchAll(const ServiceWorkerClientQueryOptions& options, ServiceWorkerClientsMatchAllCallback&& callback)
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.h (227637 => 227638)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2018-01-25 23:08:23 UTC (rev 227638)
@@ -92,7 +92,7 @@
void didFinishInstall(const std::optional<ServiceWorkerJobDataIdentifier>&, bool wasSuccessful);
void didFinishActivation();
void contextTerminated();
- std::optional<ServiceWorkerClientData> findClientByIdentifier(const ServiceWorkerClientIdentifier&) const;
+ WEBCORE_EXPORT std::optional<ServiceWorkerClientData> findClientByIdentifier(const ServiceWorkerClientIdentifier&) const;
void matchAll(const ServiceWorkerClientQueryOptions&, ServiceWorkerClientsMatchAllCallback&&);
void claim();
Modified: trunk/Source/WebKit/ChangeLog (227637 => 227638)
--- trunk/Source/WebKit/ChangeLog 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebKit/ChangeLog 2018-01-25 23:08:23 UTC (rev 227638)
@@ -1,3 +1,14 @@
+2018-01-25 Chris Dumez <[email protected]>
+
+ Clients.get(id) should only returns clients in the service worker's origin
+ https://bugs.webkit.org/show_bug.cgi?id=182149
+ <rdar://problem/36882310>
+
+ Reviewed by Youenn Fablet.
+
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::postMessageToServiceWorker):
+
2018-01-25 Youenn Fablet <[email protected]>
WebPluginInfoProvider should handle null host queries
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (227637 => 227638)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2018-01-25 23:06:51 UTC (rev 227637)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2018-01-25 23:08:23 UTC (rev 227638)
@@ -178,7 +178,11 @@
if (auto* sourceWorker = server().workerByID(identifier))
sourceData = ServiceWorkerOrClientData { sourceWorker->data() };
}, [&](ServiceWorkerClientIdentifier identifier) {
- if (auto clientData = server().serviceWorkerClientByID(identifier))
+ auto* destinationWorker = server().workerByID(destinationIdentifier);
+ if (!destinationWorker)
+ return;
+
+ if (auto clientData = destinationWorker->findClientByIdentifier(identifier))
sourceData = ServiceWorkerOrClientData { *clientData };
});