WebKit Bugzilla
Attachment 358348 Details for
Bug 193152
: Service Worker fetch should obey its referrer policy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193152-20190104122540.patch (text/plain), 31.54 KB, created by
youenn fablet
on 2019-01-04 12:25:40 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-01-04 12:25:40 PST
Size:
31.54 KB
patch
obsolete
>Subversion Revision: 239617 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 528289df65c0681c24fdaab6b985033357ee1e4b..73dc24d80638562dfe4962e7577ee4ac6863b0af 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,54 @@ >+2019-01-04 Youenn Fablet <youenn@apple.com> >+ >+ Service Worker fetch should obey its referrer policy >+ https://bugs.webkit.org/show_bug.cgi?id=193152 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Pass referrer policy retrieved when fetching the service worker script to the SWServer. >+ The SWServer then stores it persistently and sends it to the manager creating service workers. >+ This manager will then set the referrer policy on the dummy Document of the corresponding service worker. >+ >+ Covered by rebased test. >+ >+ * workers/WorkerScriptLoader.cpp: >+ (WebCore::WorkerScriptLoader::didReceiveResponse): >+ * workers/WorkerScriptLoader.h: >+ (WebCore::WorkerScriptLoader::referrerPolicy const): >+ * workers/service/SWClientConnection.cpp: >+ (WebCore::SWClientConnection::failedFetchingScript): >+ * workers/service/ServiceWorkerContainer.cpp: >+ (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript): >+ * workers/service/ServiceWorkerContainer.h: >+ * workers/service/ServiceWorkerContextData.cpp: >+ (WebCore::ServiceWorkerContextData::isolatedCopy const): >+ * workers/service/ServiceWorkerContextData.h: >+ (WebCore::ServiceWorkerContextData::encode const): >+ (WebCore::ServiceWorkerContextData::decode): >+ * workers/service/ServiceWorkerFetchResult.h: >+ (WebCore::ServiceWorkerFetchResult::encode const): >+ (WebCore::ServiceWorkerFetchResult::decode): >+ * workers/service/ServiceWorkerJob.cpp: >+ (WebCore::ServiceWorkerJob::notifyFinished): >+ * workers/service/ServiceWorkerJobClient.h: >+ * workers/service/context/ServiceWorkerThreadProxy.cpp: >+ (WebCore::createPageForServiceWorker): >+ * workers/service/server/RegistrationDatabase.cpp: >+ (WebCore::recordsTableSchema): >+ (WebCore::RegistrationDatabase::doPushChanges): >+ (WebCore::RegistrationDatabase::importRecords): >+ * workers/service/server/SWServer.cpp: >+ (WebCore::SWServer::addRegistrationFromStore): >+ (WebCore::SWServer::updateWorker): >+ (WebCore::SWServer::installContextData): >+ * workers/service/server/SWServer.h: >+ * workers/service/server/SWServerJobQueue.cpp: >+ (WebCore::SWServerJobQueue::scriptFetchFinished): >+ * workers/service/server/SWServerWorker.cpp: >+ (WebCore::SWServerWorker::SWServerWorker): >+ (WebCore::SWServerWorker::contextData const): >+ * workers/service/server/SWServerWorker.h: >+ > 2019-01-04 Youenn Fablet <youenn@apple.com> > > [Fetch API] Implement abortable fetch >diff --git a/Source/WebCore/workers/WorkerScriptLoader.cpp b/Source/WebCore/workers/WorkerScriptLoader.cpp >index 52ac9b6aefbcdd00444b2e335a127303843a73fa..2addffd824c3c1900d034877834d263df6d077fc 100644 >--- a/Source/WebCore/workers/WorkerScriptLoader.cpp >+++ b/Source/WebCore/workers/WorkerScriptLoader.cpp >@@ -177,6 +177,7 @@ void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const Reso > m_responseMIMEType = response.mimeType(); > m_responseEncoding = response.textEncodingName(); > m_contentSecurityPolicy = ContentSecurityPolicyResponseHeaders { response }; >+ m_referrerPolicy = response.httpHeaderField(HTTPHeaderName::ReferrerPolicy); > if (m_client) > m_client->didReceiveResponse(identifier, response); > } >diff --git a/Source/WebCore/workers/WorkerScriptLoader.h b/Source/WebCore/workers/WorkerScriptLoader.h >index 82fe5a15928a1e46e03eb2e81ed5505494de54c4..a9d0141716c7c51d6053a8303bf6e9db4bb95825 100644 >--- a/Source/WebCore/workers/WorkerScriptLoader.h >+++ b/Source/WebCore/workers/WorkerScriptLoader.h >@@ -61,6 +61,7 @@ public: > > String script(); > const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy() const { return m_contentSecurityPolicy; } >+ const String& referrerPolicy() const { return m_referrerPolicy; } > const URL& url() const { return m_url; } > const URL& responseURL() const; > const String& responseMIMEType() const { return m_responseMIMEType; } >@@ -94,6 +95,7 @@ private: > String m_responseMIMEType; > FetchOptions::Destination m_destination; > ContentSecurityPolicyResponseHeaders m_contentSecurityPolicy; >+ String m_referrerPolicy; > unsigned long m_identifier { 0 }; > bool m_failed { false }; > bool m_finishing { false }; >diff --git a/Source/WebCore/workers/service/SWClientConnection.cpp b/Source/WebCore/workers/service/SWClientConnection.cpp >index 8ed67f67cbfda5af966eff89c5340bbced18f550..f025f9332f5798fcf510fab9a41abcbda372d7b4 100644 >--- a/Source/WebCore/workers/service/SWClientConnection.cpp >+++ b/Source/WebCore/workers/service/SWClientConnection.cpp >@@ -59,7 +59,7 @@ void SWClientConnection::failedFetchingScript(ServiceWorkerJobIdentifier jobIden > { > ASSERT(isMainThread()); > >- finishFetchingScriptInServer({ { serverConnectionIdentifier(), jobIdentifier }, registrationKey, { }, { }, error }); >+ finishFetchingScriptInServer({ { serverConnectionIdentifier(), jobIdentifier }, registrationKey, { }, { }, { }, error }); > } > > bool SWClientConnection::postTaskForJob(ServiceWorkerJobIdentifier jobIdentifier, IsJobComplete isJobComplete, WTF::Function<void(ServiceWorkerJob&)>&& task) >diff --git a/Source/WebCore/workers/service/ServiceWorkerContainer.cpp b/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >index 1a65873165a760ac5ea30e1d9e09fdd26c5a07af..1d3c448e0859ddca78e9e2faebc7360ac7bb5b93 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerContainer.cpp >@@ -519,7 +519,7 @@ void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job, Fetch > job.fetchScriptWithContext(*context, cachePolicy); > } > >-void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const String& script, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy) >+void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const String& script, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const String& referrerPolicy) > { > #ifndef NDEBUG > ASSERT(m_creationThread.ptr() == &Thread::current()); >@@ -527,8 +527,8 @@ void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, con > > CONTAINER_RELEASE_LOG_IF_ALLOWED("jobFinishedLoadingScript: Successfuly finished fetching script for job %" PRIu64, job.identifier().toUInt64()); > >- callOnMainThread([connection = m_swConnection, jobDataIdentifier = job.data().identifier(), registrationKey = job.data().registrationKey().isolatedCopy(), script = script.isolatedCopy(), contentSecurityPolicy = contentSecurityPolicy.isolatedCopy()] { >- connection->finishFetchingScriptInServer({ jobDataIdentifier, registrationKey, script, contentSecurityPolicy, { } }); >+ callOnMainThread([connection = m_swConnection, jobDataIdentifier = job.data().identifier(), registrationKey = job.data().registrationKey().isolatedCopy(), script = script.isolatedCopy(), contentSecurityPolicy = contentSecurityPolicy.isolatedCopy(), referrerPolicy = referrerPolicy.isolatedCopy()] { >+ connection->finishFetchingScriptInServer({ jobDataIdentifier, registrationKey, script, contentSecurityPolicy, referrerPolicy, { } }); > }); > } > >diff --git a/Source/WebCore/workers/service/ServiceWorkerContainer.h b/Source/WebCore/workers/service/ServiceWorkerContainer.h >index 290f07351d9b21da35bd564c2479e22f128803f6..fd8c07d22cf63492f8de58718ec302614a96a5c1 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContainer.h >+++ b/Source/WebCore/workers/service/ServiceWorkerContainer.h >@@ -95,7 +95,7 @@ private: > void jobResolvedWithRegistration(ServiceWorkerJob&, ServiceWorkerRegistrationData&&, ShouldNotifyWhenResolved) final; > void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) final; > void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) final; >- void jobFinishedLoadingScript(ServiceWorkerJob&, const String& script, const ContentSecurityPolicyResponseHeaders&) final; >+ void jobFinishedLoadingScript(ServiceWorkerJob&, const String& script, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy) final; > void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Optional<Exception>&&) final; > > void jobDidFinish(ServiceWorkerJob&); >diff --git a/Source/WebCore/workers/service/ServiceWorkerContextData.cpp b/Source/WebCore/workers/service/ServiceWorkerContextData.cpp >index 2bc4e73c063336878ab3666a9d6993e4db8d2df8..7a9831df95d6f5e23ae4e44e5039a0d721dc0e1f 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContextData.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerContextData.cpp >@@ -33,7 +33,7 @@ namespace WebCore { > > ServiceWorkerContextData ServiceWorkerContextData::isolatedCopy() const > { >- return { jobDataIdentifier, registration.isolatedCopy(), serviceWorkerIdentifier, script.isolatedCopy(), contentSecurityPolicy.isolatedCopy(), scriptURL.isolatedCopy(), workerType, sessionID, loadedFromDisk, crossThreadCopy(scriptResourceMap) }; >+ return { jobDataIdentifier, registration.isolatedCopy(), serviceWorkerIdentifier, script.isolatedCopy(), contentSecurityPolicy.isolatedCopy(), referrerPolicy.isolatedCopy(), scriptURL.isolatedCopy(), workerType, sessionID, loadedFromDisk, crossThreadCopy(scriptResourceMap) }; > } > > } // namespace WebCore >diff --git a/Source/WebCore/workers/service/ServiceWorkerContextData.h b/Source/WebCore/workers/service/ServiceWorkerContextData.h >index 23c4ccf791f3b29608e64fa62bd7c34308da7341..be868e01f630ac80c29838fcd017ae1f1babd584 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerContextData.h >+++ b/Source/WebCore/workers/service/ServiceWorkerContextData.h >@@ -75,6 +75,7 @@ struct ServiceWorkerContextData { > ServiceWorkerIdentifier serviceWorkerIdentifier; > String script; > ContentSecurityPolicyResponseHeaders contentSecurityPolicy; >+ String referrerPolicy; > URL scriptURL; > WorkerType workerType; > PAL::SessionID sessionID; >@@ -90,7 +91,7 @@ struct ServiceWorkerContextData { > template<class Encoder> > void ServiceWorkerContextData::encode(Encoder& encoder) const > { >- encoder << jobDataIdentifier << registration << serviceWorkerIdentifier << script << contentSecurityPolicy << scriptURL << workerType << sessionID << loadedFromDisk; >+ encoder << jobDataIdentifier << registration << serviceWorkerIdentifier << script << contentSecurityPolicy << referrerPolicy << scriptURL << workerType << sessionID << loadedFromDisk; > encoder << scriptResourceMap; > } > >@@ -119,6 +120,10 @@ Optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder& dec > if (!decoder.decode(contentSecurityPolicy)) > return WTF::nullopt; > >+ String referrerPolicy; >+ if (!decoder.decode(referrerPolicy)) >+ return WTF::nullopt; >+ > URL scriptURL; > if (!decoder.decode(scriptURL)) > return WTF::nullopt; >@@ -139,7 +144,7 @@ Optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder& dec > if (!decoder.decode(scriptResourceMap)) > return WTF::nullopt; > >- return {{ WTFMove(*jobDataIdentifier), WTFMove(*registration), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(scriptURL), workerType, sessionID, loadedFromDisk, WTFMove(scriptResourceMap) }}; >+ return {{ WTFMove(*jobDataIdentifier), WTFMove(*registration), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(referrerPolicy), WTFMove(scriptURL), workerType, sessionID, loadedFromDisk, WTFMove(scriptResourceMap) }}; > } > > } // namespace WebCore >diff --git a/Source/WebCore/workers/service/ServiceWorkerFetchResult.h b/Source/WebCore/workers/service/ServiceWorkerFetchResult.h >index d390aa9f1b452a66a51d8f24ddfaa868f883312d..ec9ffee17c6207ca0213e37fc0abfaccbca0d066 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerFetchResult.h >+++ b/Source/WebCore/workers/service/ServiceWorkerFetchResult.h >@@ -39,6 +39,7 @@ struct ServiceWorkerFetchResult { > ServiceWorkerRegistrationKey registrationKey; > String script; > ContentSecurityPolicyResponseHeaders contentSecurityPolicy; >+ String referrerPolicy; > ResourceError scriptError; > > template<class Encoder> void encode(Encoder&) const; >@@ -48,7 +49,7 @@ struct ServiceWorkerFetchResult { > template<class Encoder> > void ServiceWorkerFetchResult::encode(Encoder& encoder) const > { >- encoder << jobDataIdentifier << registrationKey << script << contentSecurityPolicy << scriptError; >+ encoder << jobDataIdentifier << registrationKey << script << contentSecurityPolicy << referrerPolicy << scriptError; > } > > template<class Decoder> >@@ -69,6 +70,8 @@ bool ServiceWorkerFetchResult::decode(Decoder& decoder, ServiceWorkerFetchResult > return false; > if (!decoder.decode(result.contentSecurityPolicy)) > return false; >+ if (!decoder.decode(result.referrerPolicy)) >+ return false; > if (!decoder.decode(result.scriptError)) > return false; > >diff --git a/Source/WebCore/workers/service/ServiceWorkerJob.cpp b/Source/WebCore/workers/service/ServiceWorkerJob.cpp >index bbacdc01fbc484f66d13998ed905501ff6c8bd74..71d1e5281c73556da5ef897b0a46896b14544a90 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerJob.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerJob.cpp >@@ -146,7 +146,7 @@ void ServiceWorkerJob::notifyFinished() > ASSERT(m_scriptLoader); > > if (!m_scriptLoader->failed()) >- m_client->jobFinishedLoadingScript(*this, m_scriptLoader->script(), m_scriptLoader->contentSecurityPolicy()); >+ m_client->jobFinishedLoadingScript(*this, m_scriptLoader->script(), m_scriptLoader->contentSecurityPolicy(), m_scriptLoader->referrerPolicy()); > else { > auto& error = m_scriptLoader->error(); > ASSERT(!error.isNull()); >diff --git a/Source/WebCore/workers/service/ServiceWorkerJobClient.h b/Source/WebCore/workers/service/ServiceWorkerJobClient.h >index 1840f351843469cde0d66e2263235afc6875b436..4d43314cf7981222b096b184b0586b61b7f2083b 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerJobClient.h >+++ b/Source/WebCore/workers/service/ServiceWorkerJobClient.h >@@ -49,7 +49,7 @@ public: > virtual void jobResolvedWithRegistration(ServiceWorkerJob&, ServiceWorkerRegistrationData&&, ShouldNotifyWhenResolved) = 0; > virtual void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) = 0; > virtual void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) = 0; >- virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const String& script, const ContentSecurityPolicyResponseHeaders&) = 0; >+ virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const String& script, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy) = 0; > virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Optional<Exception>&&) = 0; > > virtual SWServerConnectionIdentifier connectionIdentifier() = 0; >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >index 1728076660638272fcdf3050e944962b7d99eb53..fe8e53fe7fa4fe6ed115a2327e2beb2cda0c9e93 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp >@@ -69,6 +69,10 @@ static inline UniqueRef<Page> createPageForServiceWorker(PageConfiguration&& con > document->setSiteForCookies(topOriginURL(origin)); > document->setFirstPartyForCookies(data.scriptURL); > document->setDomainForCachePartition(origin->domainForCachePartition()); >+ >+ if (auto policy = parseReferrerPolicy(data.referrerPolicy, ReferrerPolicySource::HTTPHeader)) >+ document->setReferrerPolicy(*policy); >+ > mainFrame.setDocument(WTFMove(document)); > return page; > } >diff --git a/Source/WebCore/workers/service/server/RegistrationDatabase.cpp b/Source/WebCore/workers/service/server/RegistrationDatabase.cpp >index b5c29e9072198713b24429094b18c9eb69ee4f20..9acea6fb4fbb28a81f8296bdf6400839ad06a25f 100644 >--- a/Source/WebCore/workers/service/server/RegistrationDatabase.cpp >+++ b/Source/WebCore/workers/service/server/RegistrationDatabase.cpp >@@ -48,11 +48,11 @@ > > namespace WebCore { > >-static const uint64_t schemaVersion = 3; >+static const uint64_t schemaVersion = 4; > > static const String recordsTableSchema(const String& tableName) > { >- return makeString("CREATE TABLE ", tableName, " (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, origin TEXT NOT NULL ON CONFLICT FAIL, scopeURL TEXT NOT NULL ON CONFLICT FAIL, topOrigin TEXT NOT NULL ON CONFLICT FAIL, lastUpdateCheckTime DOUBLE NOT NULL ON CONFLICT FAIL, updateViaCache TEXT NOT NULL ON CONFLICT FAIL, scriptURL TEXT NOT NULL ON CONFLICT FAIL, script TEXT NOT NULL ON CONFLICT FAIL, workerType TEXT NOT NULL ON CONFLICT FAIL, contentSecurityPolicy BLOB NOT NULL ON CONFLICT FAIL, scriptResourceMap BLOB NOT NULL ON CONFLICT FAIL)"); >+ return makeString("CREATE TABLE ", tableName, " (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE, origin TEXT NOT NULL ON CONFLICT FAIL, scopeURL TEXT NOT NULL ON CONFLICT FAIL, topOrigin TEXT NOT NULL ON CONFLICT FAIL, lastUpdateCheckTime DOUBLE NOT NULL ON CONFLICT FAIL, updateViaCache TEXT NOT NULL ON CONFLICT FAIL, scriptURL TEXT NOT NULL ON CONFLICT FAIL, script TEXT NOT NULL ON CONFLICT FAIL, workerType TEXT NOT NULL ON CONFLICT FAIL, contentSecurityPolicy BLOB NOT NULL ON CONFLICT FAIL, referrerPolicy TEXT NOT NULL ON CONFLICT FAIL, scriptResourceMap BLOB NOT NULL ON CONFLICT FAIL)"); > } > > static const String recordsTableSchema() >@@ -340,7 +340,8 @@ void RegistrationDatabase::doPushChanges(Vector<ServiceWorkerContextData>&& data > || sql.bindText(8, data.script) != SQLITE_OK > || sql.bindText(9, workerTypeToString(data.workerType)) != SQLITE_OK > || sql.bindBlob(10, cspEncoder.buffer(), cspEncoder.bufferSize()) != SQLITE_OK >- || sql.bindBlob(11, scriptResourceMapEncoder.buffer(), scriptResourceMapEncoder.bufferSize()) != SQLITE_OK >+ || sql.bindText(11, data.referrerPolicy) != SQLITE_OK >+ || sql.bindBlob(12, scriptResourceMapEncoder.buffer(), scriptResourceMapEncoder.bufferSize()) != SQLITE_OK > || sql.step() != SQLITE_DONE) { > RELEASE_LOG_ERROR(ServiceWorker, "Failed to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg()); > return; >@@ -380,8 +381,10 @@ String RegistrationDatabase::importRecords() > if (contentSecurityPolicyData.size() && !ContentSecurityPolicyResponseHeaders::decode(cspDecoder, contentSecurityPolicy)) > continue; > >+ auto referrerPolicy = sql.getColumnText(10); >+ > Vector<uint8_t> scriptResourceMapData; >- sql.getColumnBlobAsVector(10, scriptResourceMapData); >+ sql.getColumnBlobAsVector(11, scriptResourceMapData); > HashMap<URL, ServiceWorkerContextData::ImportedScript> scriptResourceMap; > > WTF::Persistence::Decoder scriptResourceMapDecoder(scriptResourceMapData.data(), scriptResourceMapData.size()); >@@ -400,7 +403,7 @@ String RegistrationDatabase::importRecords() > auto registrationIdentifier = generateObjectIdentifier<ServiceWorkerRegistrationIdentifierType>(); > auto serviceWorkerData = ServiceWorkerData { workerIdentifier, scriptURL, ServiceWorkerState::Activated, *workerType, registrationIdentifier }; > auto registration = ServiceWorkerRegistrationData { WTFMove(*key), registrationIdentifier, URL(originURL, scopePath), *updateViaCache, lastUpdateCheckTime, WTF::nullopt, WTF::nullopt, WTFMove(serviceWorkerData) }; >- auto contextData = ServiceWorkerContextData { WTF::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(scriptURL), *workerType, m_sessionID, true, WTFMove(scriptResourceMap) }; >+ auto contextData = ServiceWorkerContextData { WTF::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(referrerPolicy), WTFMove(scriptURL), *workerType, m_sessionID, true, WTFMove(scriptResourceMap) }; > > callOnMainThread([protectedThis = makeRef(*this), contextData = contextData.isolatedCopy()]() mutable { > protectedThis->addRegistrationToStore(WTFMove(contextData)); >diff --git a/Source/WebCore/workers/service/server/SWServer.cpp b/Source/WebCore/workers/service/server/SWServer.cpp >index 4377b00dc0e8a4de7a25e0acde7429804061ee67..f876b82be6abf11235f6a2697ce25adad91fe777 100644 >--- a/Source/WebCore/workers/service/server/SWServer.cpp >+++ b/Source/WebCore/workers/service/server/SWServer.cpp >@@ -140,7 +140,7 @@ void SWServer::addRegistrationFromStore(ServiceWorkerContextData&& data) > auto registrationPtr = registration.get(); > addRegistration(WTFMove(registration)); > >- auto worker = SWServerWorker::create(*this, *registrationPtr, data.scriptURL, data.script, data.contentSecurityPolicy, data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap }); >+ auto worker = SWServerWorker::create(*this, *registrationPtr, data.scriptURL, data.script, data.contentSecurityPolicy, WTFMove(data.referrerPolicy), data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap }); > registrationPtr->updateRegistrationState(ServiceWorkerRegistrationState::Active, worker.ptr()); > worker->setState(ServiceWorkerState::Activated); > } >@@ -502,9 +502,9 @@ void SWServer::removeClientServiceWorkerRegistration(Connection& connection, Ser > registration->removeClientServiceWorkerRegistration(connection.identifier()); > } > >-void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const String& script, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, WorkerType type, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap) >+void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const String& script, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const String& referrerPolicy, WorkerType type, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap) > { >- tryInstallContextData({ jobDataIdentifier, registration.data(), generateObjectIdentifier<ServiceWorkerIdentifierType>(), script, contentSecurityPolicy, url, type, sessionID(), false, WTFMove(scriptResourceMap) }); >+ tryInstallContextData({ jobDataIdentifier, registration.data(), generateObjectIdentifier<ServiceWorkerIdentifierType>(), script, contentSecurityPolicy, referrerPolicy, url, type, sessionID(), false, WTFMove(scriptResourceMap) }); > } > > void SWServer::tryInstallContextData(ServiceWorkerContextData&& data) >@@ -549,7 +549,7 @@ void SWServer::installContextData(const ServiceWorkerContextData& data) > auto* registration = m_registrations.get(data.registration.key); > RELEASE_ASSERT(registration); > >- auto worker = SWServerWorker::create(*this, *registration, data.scriptURL, data.script, data.contentSecurityPolicy, data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap }); >+ auto worker = SWServerWorker::create(*this, *registration, data.scriptURL, data.script, data.contentSecurityPolicy, String { data.referrerPolicy }, data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap }); > > auto* connection = worker->contextConnection(); > ASSERT(connection); >diff --git a/Source/WebCore/workers/service/server/SWServer.h b/Source/WebCore/workers/service/server/SWServer.h >index 2d7404811d45be3e64a293b89dfddf21f5f3715e..ca51b9bd3d0fb705b41c67a5bb6c7b507220e96c 100644 >--- a/Source/WebCore/workers/service/server/SWServer.h >+++ b/Source/WebCore/workers/service/server/SWServer.h >@@ -133,7 +133,7 @@ public: > void resolveUnregistrationJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationKey&, bool unregistrationResult); > void startScriptFetch(const ServiceWorkerJobData&, FetchOptions::Cache); > >- void updateWorker(Connection&, const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const String& script, const ContentSecurityPolicyResponseHeaders&, WorkerType, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&); >+ void updateWorker(Connection&, const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const String& script, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy, WorkerType, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&); > void terminateWorker(SWServerWorker&); > void syncTerminateWorker(SWServerWorker&); > void fireInstallEvent(SWServerWorker&); >diff --git a/Source/WebCore/workers/service/server/SWServerJobQueue.cpp b/Source/WebCore/workers/service/server/SWServerJobQueue.cpp >index d8a85b0ad33c4839d92c5b15341a8be1ee02fe89..9ec1ba686583ec8c18ff617f61436124ef585071 100644 >--- a/Source/WebCore/workers/service/server/SWServerJobQueue.cpp >+++ b/Source/WebCore/workers/service/server/SWServerJobQueue.cpp >@@ -100,7 +100,7 @@ void SWServerJobQueue::scriptFetchFinished(SWServer::Connection& connection, con > // FIXME: Update all the imported scripts as per spec. For now, we just do as if there is none. > > // FIXME: Support the proper worker type (classic vs module) >- m_server.updateWorker(connection, job.identifier(), *registration, job.scriptURL, result.script, result.contentSecurityPolicy, WorkerType::Classic, { }); >+ m_server.updateWorker(connection, job.identifier(), *registration, job.scriptURL, result.script, result.contentSecurityPolicy, result.referrerPolicy, WorkerType::Classic, { }); > } > > // https://w3c.github.io/ServiceWorker/#update-algorithm >diff --git a/Source/WebCore/workers/service/server/SWServerWorker.cpp b/Source/WebCore/workers/service/server/SWServerWorker.cpp >index b4d7b9d361a1d9d09ccbaf6afe4aebf514b7a99b..23370d2ec4f9d207b71dbd9c7cf2f9326cb874ac 100644 >--- a/Source/WebCore/workers/service/server/SWServerWorker.cpp >+++ b/Source/WebCore/workers/service/server/SWServerWorker.cpp >@@ -45,12 +45,13 @@ SWServerWorker* SWServerWorker::existingWorkerForIdentifier(ServiceWorkerIdentif > } > > // FIXME: Use r-value references for script and contentSecurityPolicy >-SWServerWorker::SWServerWorker(SWServer& server, SWServerRegistration& registration, const URL& scriptURL, const String& script, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, WorkerType type, ServiceWorkerIdentifier identifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap) >+SWServerWorker::SWServerWorker(SWServer& server, SWServerRegistration& registration, const URL& scriptURL, const String& script, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, String&& referrerPolicy, WorkerType type, ServiceWorkerIdentifier identifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap) > : m_server(server) > , m_registrationKey(registration.key()) > , m_data { identifier, scriptURL, ServiceWorkerState::Redundant, type, registration.identifier() } > , m_script(script) > , m_contentSecurityPolicy(contentSecurityPolicy) >+ , m_referrerPolicy(WTFMove(referrerPolicy)) > , m_scriptResourceMap(WTFMove(scriptResourceMap)) > { > m_data.scriptURL.removeFragmentIdentifier(); >@@ -74,7 +75,7 @@ ServiceWorkerContextData SWServerWorker::contextData() const > auto* registration = m_server.getRegistration(m_registrationKey); > ASSERT(registration); > >- return { WTF::nullopt, registration->data(), m_data.identifier, m_script, m_contentSecurityPolicy, m_data.scriptURL, m_data.type, m_server.sessionID(), false, m_scriptResourceMap }; >+ return { WTF::nullopt, registration->data(), m_data.identifier, m_script, m_contentSecurityPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, m_server.sessionID(), false, m_scriptResourceMap }; > } > > void SWServerWorker::terminate() >diff --git a/Source/WebCore/workers/service/server/SWServerWorker.h b/Source/WebCore/workers/service/server/SWServerWorker.h >index a73c86dcd2ecd38e21cc7fb2f0372f4182137012..e2f744bdcbaa254c5c5bb3b86bc3e33b5e9a4b7d 100644 >--- a/Source/WebCore/workers/service/server/SWServerWorker.h >+++ b/Source/WebCore/workers/service/server/SWServerWorker.h >@@ -112,7 +112,7 @@ public: > String userAgent() const; > > private: >- SWServerWorker(SWServer&, SWServerRegistration&, const URL&, const String& script, const ContentSecurityPolicyResponseHeaders&, WorkerType, ServiceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&); >+ SWServerWorker(SWServer&, SWServerRegistration&, const URL&, const String& script, const ContentSecurityPolicyResponseHeaders&, String&& referrerPolicy, WorkerType, ServiceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&); > > void callWhenActivatedHandler(bool success); > >@@ -121,6 +121,7 @@ private: > ServiceWorkerData m_data; > String m_script; > ContentSecurityPolicyResponseHeaders m_contentSecurityPolicy; >+ String m_referrerPolicy; > bool m_hasPendingEvents { false }; > State m_state { State::NotRunning }; > mutable Optional<ClientOrigin> m_origin; >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index ce47ba8fcf13128e2c15b68bb509a55da53a28f8..59dfeab12d1fdf2093c509c41beb161a598eb1ba 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,12 @@ >+2019-01-04 Youenn Fablet <youenn@apple.com> >+ >+ Service Worker fetch should obey its referrer policy >+ https://bugs.webkit.org/show_bug.cgi?id=193152 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt: >+ > 2019-01-04 Youenn Fablet <youenn@apple.com> > > [Fetch API] Implement abortable fetch >diff --git a/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt >index 812b46fec9a906b10d091f4a5b1d06ef1c3ca7e2..2ea4aded04f513ea08ac60820891f62bf0390210 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt >@@ -2,6 +2,6 @@ > > PASS Initialize global state (service worker registration) > FAIL Referrer for a main resource redirected with referrer-policy (origin) should only have origin. assert_equals: expected "https://localhost:9443/" but got "https://localhost:9443/service-workers/service-worker/referrer-policy-header.https.html" >-FAIL Referrer for fetch requests initiated from a service worker with referrer-policy (origin) should only have origin. assert_equals: expected "finish" but got "failure:Referer for request-headers.py?url=request-headers.py must be https://localhost:9443/ but got https://localhost:9443/service-workers/service-worker/resources/fetch-rewrite-worker-referrer-policy.js" >+PASS Referrer for fetch requests initiated from a service worker with referrer-policy (origin) should only have origin. > PASS Remove registration as a cleanup >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193152
:
358348
|
358363
|
358365
|
358381