Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (239658 => 239659)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2019-01-05 20:51:14 UTC (rev 239659)
@@ -1,3 +1,13 @@
+2019-01-05 Youenn Fablet <[email protected]>
+
+ Service Worker fetch should obey its referrer policy
+ https://bugs.webkit.org/show_bug.cgi?id=193152
+
+ Reviewed by Chris Dumez.
+
+ * web-platform-tests/fetch/api/policies/referrer-origin-service-worker.https-expected.txt:
+ * web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt:
+
2019-01-04 Youenn Fablet <[email protected]>
[Fetch API] Implement abortable fetch
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-service-worker.https-expected.txt (239658 => 239659)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-service-worker.https-expected.txt 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/referrer-origin-service-worker.https-expected.txt 2019-01-05 20:51:14 UTC (rev 239659)
@@ -1,5 +1,5 @@
PASS Fetch in service worker: referrer with no-referrer policy
-FAIL Request's referrer is origin assert_equals: request's referrer is https://localhost:9443/ expected "https://localhost:9443/" but got "https://localhost:9443/fetch/api/policies/referrer-origin.js?pipe=sub"
-FAIL Cross-origin referrer is overridden by client origin assert_equals: request's referrer is https://localhost:9443/ expected "https://localhost:9443/" but got "https://localhost:9443/fetch/api/policies/referrer-origin.js?pipe=sub"
+PASS Request's referrer is origin
+PASS Cross-origin referrer is overridden by client origin
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt (239658 => 239659)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/referrer-policy-header.https-expected.txt 2019-01-05 20:51:14 UTC (rev 239659)
@@ -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="" 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
Modified: trunk/Source/WebCore/ChangeLog (239658 => 239659)
--- trunk/Source/WebCore/ChangeLog 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/ChangeLog 2019-01-05 20:51:14 UTC (rev 239659)
@@ -1,3 +1,54 @@
+2019-01-05 Youenn Fablet <[email protected]>
+
+ Service Worker fetch should obey its referrer policy
+ https://bugs.webkit.org/show_bug.cgi?id=193152
+
+ Reviewed by Chris Dumez.
+
+ 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 Simon Fraser <[email protected]>
Factor legacy WK1 code for fixed and scrolling layers into their own helper class
Modified: trunk/Source/WebCore/workers/WorkerScriptLoader.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/WorkerScriptLoader.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/WorkerScriptLoader.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -177,6 +177,7 @@
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);
}
Modified: trunk/Source/WebCore/workers/WorkerScriptLoader.h (239658 => 239659)
--- trunk/Source/WebCore/workers/WorkerScriptLoader.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/WorkerScriptLoader.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -61,6 +61,7 @@
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 @@
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 };
Modified: trunk/Source/WebCore/workers/service/SWClientConnection.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/SWClientConnection.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -59,7 +59,7 @@
{
ASSERT(isMainThread());
- finishFetchingScriptInServer({ { serverConnectionIdentifier(), jobIdentifier }, registrationKey, { }, { }, error });
+ finishFetchingScriptInServer({ { serverConnectionIdentifier(), jobIdentifier }, registrationKey, { }, { }, { }, error });
}
bool SWClientConnection::postTaskForJob(ServiceWorkerJobIdentifier jobIdentifier, IsJobComplete isJobComplete, WTF::Function<void(ServiceWorkerJob&)>&& task)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -519,7 +519,7 @@
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 @@
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, { } });
});
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -95,7 +95,7 @@
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&);
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -33,7 +33,7 @@
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
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -75,6 +75,7 @@
ServiceWorkerIdentifier serviceWorkerIdentifier;
String script;
ContentSecurityPolicyResponseHeaders contentSecurityPolicy;
+ String referrerPolicy;
URL scriptURL;
WorkerType workerType;
PAL::SessionID sessionID;
@@ -90,7 +91,7 @@
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 @@
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 @@
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
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -39,6 +39,7 @@
ServiceWorkerRegistrationKey registrationKey;
String script;
ContentSecurityPolicyResponseHeaders contentSecurityPolicy;
+ String referrerPolicy;
ResourceError scriptError;
template<class Encoder> void encode(Encoder&) const;
@@ -48,7 +49,7 @@
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 @@
return false;
if (!decoder.decode(result.contentSecurityPolicy))
return false;
+ if (!decoder.decode(result.referrerPolicy))
+ return false;
if (!decoder.decode(result.scriptError))
return false;
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -146,7 +146,7 @@
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());
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h (239658 => 239659)
--- trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -49,7 +49,7 @@
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;
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -69,6 +69,10 @@
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;
}
Modified: trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -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()
@@ -305,7 +305,7 @@
SQLiteTransaction transaction(*m_database);
transaction.begin();
- SQLiteStatement sql(*m_database, "INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s);
+ SQLiteStatement sql(*m_database, "INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s);
if (sql.prepare() != SQLITE_OK) {
RELEASE_LOG_ERROR(ServiceWorker, "Failed to prepare statement to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
return;
@@ -340,7 +340,8 @@
|| 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 @@
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 @@
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));
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -140,7 +140,7 @@
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 @@
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 @@
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);
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (239658 => 239659)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -133,7 +133,7 @@
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&);
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -100,7 +100,7 @@
// 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
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp (239658 => 239659)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2019-01-05 20:51:14 UTC (rev 239659)
@@ -45,12 +45,13 @@
}
// 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 @@
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()
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.h (239658 => 239659)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2019-01-05 18:40:18 UTC (rev 239658)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.h 2019-01-05 20:51:14 UTC (rev 239659)
@@ -112,7 +112,7 @@
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 @@
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;