Diff
Modified: trunk/LayoutTests/ChangeLog (286487 => 286488)
--- trunk/LayoutTests/ChangeLog 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/LayoutTests/ChangeLog 2021-12-03 14:01:14 UTC (rev 286488)
@@ -1,3 +1,13 @@
+2021-12-03 Youenn Fablet <[email protected]>
+
+ Persist NavigationPreloadState in service worker registration database
+ https://bugs.webkit.org/show_bug.cgi?id=233698
+
+ Reviewed by Chris Dumez.
+
+ * http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt:
+ * http/wpt/service-workers/service-worker-networkprocess-crash.html:
+
2021-12-03 Arcady Goldmints-Orlov <[email protected]>
[GStreamer] test http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html fails
Modified: trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt (286487 => 286488)
--- trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash-expected.txt 2021-12-03 14:01:14 UTC (rev 286488)
@@ -1,5 +1,4 @@
-
PASS Setup worker
PASS Frame being controlled
PASS Frame being controlled after network process crash
Modified: trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html (286487 => 286488)
--- trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html 2021-12-03 14:01:14 UTC (rev 286488)
@@ -35,7 +35,10 @@
}
promise_test(async (test) => {
- await registerServiceWorker();
+ const registration = await registerServiceWorker();
+ // Enable preload to validate preload persistency.
+ await registration.navigationPreload.enable();
+ await registration.navigationPreload.setHeaderValue("test");
}, "Setup worker");
promise_test(async (test) => {
@@ -54,14 +57,21 @@
let count = 0;
while (count++ < 100) {
const frame = await withFrame(scope + "/empty.html");
- if (frame.contentWindow.navigator.serviceWorker.controller)
+ if (frame.contentWindow.navigator.serviceWorker.controller) {
+ frame.remove();
break;
+ }
frame.remove();
await new Promise(resolve => setTimeout(resolve, 50));
}
assert_true(count < 100);
- await navigator.serviceWorker.getRegistration(scope);
+ const registration = await navigator.serviceWorker.getRegistration(scope);
+
+ // Validate preload persistency.
+ const state = await registration.navigationPreload.getState();
+ assert_true(state.enabled, "state.enabled");
+ assert_equals(state.headerValue, "test");
}, "Frame being controlled after network process crash");
</script>
</body>
Modified: trunk/Source/WebCore/ChangeLog (286487 => 286488)
--- trunk/Source/WebCore/ChangeLog 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/ChangeLog 2021-12-03 14:01:14 UTC (rev 286488)
@@ -1,3 +1,28 @@
+2021-12-03 Youenn Fablet <[email protected]>
+
+ Persist NavigationPreloadState in service worker registration database
+ https://bugs.webkit.org/show_bug.cgi?id=233698
+
+ Reviewed by Chris Dumez.
+
+ Whenever changing a service worker registration navigation state, trigger storing of the changes in the database.
+ To do so, we add this state to ServiceWorkerContextData.
+ When creating a SWServerRegistration, we set default values to false and "true"
+ as per https://w3c.github.io/ServiceWorker/#service-worker-registration-navigation-preload-header-value.
+
+ Covered by updated test.
+
+ * workers/service/ServiceWorkerContextData.cpp:
+ * workers/service/ServiceWorkerContextData.h:
+ * workers/service/server/RegistrationDatabase.cpp:
+ * workers/service/server/RegistrationStore.h:
+ * workers/service/server/SWServer.cpp:
+ * workers/service/server/SWServer.h:
+ * workers/service/server/SWServerJobQueue.cpp:
+ * workers/service/server/SWServerRegistration.cpp:
+ * workers/service/server/SWServerRegistration.h:
+ * workers/service/server/SWServerWorker.cpp:
+
2021-12-03 Alicia Boya GarcĂa <[email protected]>
[MSE] Fix erase range to prevent accidental deletion in files with changing durations
Modified: trunk/Source/WebCore/workers/service/NavigationPreloadState.h (286487 => 286488)
--- trunk/Source/WebCore/workers/service/NavigationPreloadState.h 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/NavigationPreloadState.h 2021-12-03 14:01:14 UTC (rev 286488)
@@ -33,8 +33,7 @@
namespace WebCore {
struct NavigationPreloadState {
- bool enabled { false };
- String headerValue;
+ static NavigationPreloadState defaultValue() { return { false, "true"_s }; }
NavigationPreloadState isolatedCopy() const & { return { enabled, headerValue.isolatedCopy() }; }
NavigationPreloadState isolatedCopy() && { return { enabled, WTFMove(headerValue).isolatedCopy() }; }
@@ -41,6 +40,9 @@
template<class Encoder> void encode(Encoder& encoder) const { encoder << enabled << headerValue; }
template<class Decoder> static std::optional<NavigationPreloadState> decode(Decoder&);
+
+ bool enabled { false };
+ String headerValue;
};
template<class Decoder>
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp (286487 => 286488)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp 2021-12-03 14:01:14 UTC (rev 286488)
@@ -47,7 +47,8 @@
loadedFromDisk,
lastNavigationWasAppInitiated,
crossThreadCopy(scriptResourceMap),
- serviceWorkerPageIdentifier
+ serviceWorkerPageIdentifier,
+ crossThreadCopy(navigationPreloadState),
};
}
@@ -67,7 +68,8 @@
loadedFromDisk,
lastNavigationWasAppInitiated,
crossThreadCopy(WTFMove(scriptResourceMap)),
- serviceWorkerPageIdentifier
+ serviceWorkerPageIdentifier,
+ crossThreadCopy(WTFMove(navigationPreloadState))
};
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h (286487 => 286488)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2021-12-03 14:01:14 UTC (rev 286488)
@@ -28,6 +28,7 @@
#include "CertificateInfo.h"
#include "ContentSecurityPolicyResponseHeaders.h"
#include "CrossOriginEmbedderPolicy.h"
+#include "NavigationPreloadState.h"
#include "ScriptBuffer.h"
#include "ScriptExecutionContextIdentifier.h"
#include "ServiceWorkerIdentifier.h"
@@ -95,6 +96,7 @@
std::optional<LastNavigationWasAppInitiated> lastNavigationWasAppInitiated;
HashMap<URL, ImportedScript> scriptResourceMap;
std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier;
+ NavigationPreloadState navigationPreloadState;
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ServiceWorkerContextData> decode(Decoder&);
@@ -107,7 +109,7 @@
void ServiceWorkerContextData::encode(Encoder& encoder) const
{
encoder << jobDataIdentifier << registration << serviceWorkerIdentifier << script << contentSecurityPolicy << crossOriginEmbedderPolicy << referrerPolicy
- << scriptURL << workerType << loadedFromDisk << lastNavigationWasAppInitiated << scriptResourceMap << certificateInfo << serviceWorkerPageIdentifier;
+ << scriptURL << workerType << loadedFromDisk << lastNavigationWasAppInitiated << scriptResourceMap << certificateInfo << serviceWorkerPageIdentifier << navigationPreloadState;
}
template<class Decoder>
@@ -175,6 +177,11 @@
if (!serviceWorkerPageIdentifier)
return std::nullopt;
+ std::optional<NavigationPreloadState> navigationPreloadState;
+ decoder >> navigationPreloadState;
+ if (!navigationPreloadState)
+ return std::nullopt;
+
return {{
WTFMove(*jobDataIdentifier),
WTFMove(*registration),
@@ -189,7 +196,8 @@
loadedFromDisk,
WTFMove(lastNavigationWasAppInitiated),
WTFMove(scriptResourceMap),
- WTFMove(*serviceWorkerPageIdentifier)
+ WTFMove(*serviceWorkerPageIdentifier),
+ WTFMove(*navigationPreloadState)
}};
}
Modified: trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp 2021-12-03 14:01:14 UTC (rev 286488)
@@ -50,7 +50,7 @@
namespace WebCore {
-static const uint64_t schemaVersion = 7;
+static const uint64_t schemaVersion = 8;
#define RECORDS_TABLE_SCHEMA_PREFIX "CREATE TABLE "
#define RECORDS_TABLE_SCHEMA_SUFFIX "(" \
@@ -67,6 +67,7 @@
", referrerPolicy TEXT NOT NULL ON CONFLICT FAIL" \
", scriptResourceMap BLOB NOT NULL ON CONFLICT FAIL" \
", certificateInfo BLOB NOT NULL ON CONFLICT FAIL" \
+ ", preloadState BLOB NOT NULL ON CONFLICT FAIL" \
")"_s;
static ASCIILiteral recordsTableSchema()
@@ -422,7 +423,7 @@
SQLiteTransaction transaction(*m_database);
transaction.begin();
- auto insertStatement = m_database->prepareStatement("INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s);
+ auto insertStatement = m_database->prepareStatement("INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s);
if (!insertStatement) {
RELEASE_LOG_ERROR(ServiceWorker, "Failed to prepare statement to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
return false;
@@ -455,6 +456,9 @@
WTF::Persistence::Encoder certificateInfoEncoder;
certificateInfoEncoder << data.certificateInfo;
+ WTF::Persistence::Encoder navigationPreloadStateEncoder;
+ navigationPreloadStateEncoder << data.navigationPreloadState;
+
if (insertStatement->bindText(1, data.registration.key.toDatabaseKey()) != SQLITE_OK
|| insertStatement->bindText(2, data.registration.scopeURL.protocolHostAndPort()) != SQLITE_OK
|| insertStatement->bindText(3, data.registration.scopeURL.path().toString()) != SQLITE_OK
@@ -468,6 +472,7 @@
|| insertStatement->bindText(11, data.referrerPolicy) != SQLITE_OK
|| insertStatement->bindBlob(12, Span { scriptResourceMapEncoder.buffer(), scriptResourceMapEncoder.bufferSize() }) != SQLITE_OK
|| insertStatement->bindBlob(13, Span { certificateInfoEncoder.buffer(), certificateInfoEncoder.bufferSize() }) != SQLITE_OK
+ || insertStatement->bindBlob(14, Span { navigationPreloadStateEncoder.buffer(), navigationPreloadStateEncoder.bufferSize() }) != SQLITE_OK
|| insertStatement->step() != SQLITE_DONE) {
RELEASE_LOG_ERROR(ServiceWorker, "Failed to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
return false;
@@ -566,6 +571,16 @@
continue;
}
+ auto navigationPreloadStateDataSpan = sql->columnBlobAsSpan(13);
+ std::optional<NavigationPreloadState> navigationPreloadState;
+
+ WTF::Persistence::Decoder navigationPreloadStateDecoder(navigationPreloadStateDataSpan);
+ navigationPreloadStateDecoder >> navigationPreloadState;
+ if (!navigationPreloadState) {
+ RELEASE_LOG_ERROR(ServiceWorker, "RegistrationDatabase::importRecords: Failed to decode navigationPreloadState");
+ continue;
+ }
+
// Validate the input for this registration.
// If any part of this input is invalid, let's skip this registration.
// FIXME: Should we return an error skipping *all* registrations?
@@ -584,7 +599,7 @@
auto registrationIdentifier = ServiceWorkerRegistrationIdentifier::generate();
auto serviceWorkerData = ServiceWorkerData { workerIdentifier, scriptURL, ServiceWorkerState::Activated, *workerType, registrationIdentifier };
auto registration = ServiceWorkerRegistrationData { WTFMove(*key), registrationIdentifier, WTFMove(scopeURL), *updateViaCache, lastUpdateCheckTime, std::nullopt, std::nullopt, WTFMove(serviceWorkerData) };
- auto contextData = ServiceWorkerContextData { std::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(*certificateInfo), WTFMove(*contentSecurityPolicy), WTFMove(*coep), WTFMove(referrerPolicy), WTFMove(scriptURL), *workerType, true, LastNavigationWasAppInitiated::Yes, WTFMove(scriptResourceMap), std::nullopt };
+ auto contextData = ServiceWorkerContextData { std::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(*certificateInfo), WTFMove(*contentSecurityPolicy), WTFMove(*coep), WTFMove(referrerPolicy), WTFMove(scriptURL), *workerType, true, LastNavigationWasAppInitiated::Yes, WTFMove(scriptResourceMap), std::nullopt, WTFMove(*navigationPreloadState) };
callOnMainThread([protectedThis = Ref { *this }, contextData = contextData.isolatedCopy()]() mutable {
protectedThis->addRegistrationToStore(WTFMove(contextData));
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2021-12-03 14:01:14 UTC (rev 286488)
@@ -178,7 +178,7 @@
if (!weakThis)
return;
if (m_hasServiceWorkerEntitlement || isValid) {
- auto registration = makeUnique<SWServerRegistration>(*this, data.registration.key, data.registration.updateViaCache, data.registration.scopeURL, data.scriptURL, data.serviceWorkerPageIdentifier);
+ auto registration = makeUnique<SWServerRegistration>(*this, data.registration.key, data.registration.updateViaCache, data.registration.scopeURL, data.scriptURL, data.serviceWorkerPageIdentifier, WTFMove(data.navigationPreloadState));
registration->setLastUpdateTime(data.registration.lastUpdateTime);
auto registrationPtr = registration.get();
addRegistration(WTFMove(registration));
@@ -583,9 +583,15 @@
if (!registration)
return;
+ storeRegistrationForWorker(worker);
+
+ registration->didFinishActivation(worker.identifier());
+}
+
+void SWServer::storeRegistrationForWorker(SWServerWorker& worker)
+{
if (m_registrationStore)
m_registrationStore->updateRegistration(worker.contextData());
- registration->didFinishActivation(worker.identifier());
}
// https://w3c.github.io/ServiceWorker/#clients-getall
@@ -675,7 +681,7 @@
void SWServer::updateWorker(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const CrossOriginEmbedderPolicy& coep, const String& referrerPolicy, WorkerType type, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier)
{
- tryInstallContextData(ServiceWorkerContextData { jobDataIdentifier, registration.data(), ServiceWorkerIdentifier::generate(), script, certificateInfo, contentSecurityPolicy, coep, referrerPolicy, url, type, false, clientIsAppInitiatedForRegistrableDomain(RegistrableDomain(url)), WTFMove(scriptResourceMap), serviceWorkerPageIdentifier });
+ tryInstallContextData(ServiceWorkerContextData { jobDataIdentifier, registration.data(), ServiceWorkerIdentifier::generate(), script, certificateInfo, contentSecurityPolicy, coep, referrerPolicy, url, type, false, clientIsAppInitiatedForRegistrableDomain(RegistrableDomain(url)), WTFMove(scriptResourceMap), serviceWorkerPageIdentifier, { } });
}
LastNavigationWasAppInitiated SWServer::clientIsAppInitiatedForRegistrableDomain(const RegistrableDomain& domain)
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2021-12-03 14:01:14 UTC (rev 286488)
@@ -194,6 +194,7 @@
void didSaveWorkerScriptsToDisk(ServiceWorkerIdentifier, ScriptBuffer&& mainScript, HashMap<URL, ScriptBuffer>&& importedScripts);
void registrationStoreImportComplete();
void registrationStoreDatabaseFailedToOpen();
+ void storeRegistrationForWorker(SWServerWorker&);
WEBCORE_EXPORT void getOriginsWithRegistrations(Function<void(const HashSet<SecurityOriginData>&)>&&);
Modified: trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp 2021-12-03 14:01:14 UTC (rev 286488)
@@ -297,7 +297,7 @@
registration->setUpdateViaCache(job.registrationOptions.updateViaCache);
RELEASE_LOG(ServiceWorker, "%p - SWServerJobQueue::runRegisterJob: Found registration %llu for job %s but it needs updating", this, registration->identifier().toUInt64(), job.identifier().loggingString().utf8().data());
} else {
- auto newRegistration = makeUnique<SWServerRegistration>(m_server, m_registrationKey, job.registrationOptions.updateViaCache, job.scopeURL, job.scriptURL, job.serviceWorkerPageIdentifier());
+ auto newRegistration = makeUnique<SWServerRegistration>(m_server, m_registrationKey, job.registrationOptions.updateViaCache, job.scopeURL, job.scriptURL, job.serviceWorkerPageIdentifier(), NavigationPreloadState::defaultValue());
m_server.addRegistration(WTFMove(newRegistration));
RELEASE_LOG(ServiceWorker, "%p - SWServerJobQueue::runRegisterJob: No existing registration for job %s, constructing a new one.", this, job.identifier().loggingString().utf8().data());
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp 2021-12-03 14:01:14 UTC (rev 286488)
@@ -43,7 +43,7 @@
return ServiceWorkerRegistrationIdentifier::generate();
}
-SWServerRegistration::SWServerRegistration(SWServer& server, const ServiceWorkerRegistrationKey& key, ServiceWorkerUpdateViaCache updateViaCache, const URL& scopeURL, const URL& scriptURL, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier)
+SWServerRegistration::SWServerRegistration(SWServer& server, const ServiceWorkerRegistrationKey& key, ServiceWorkerUpdateViaCache updateViaCache, const URL& scopeURL, const URL& scriptURL, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, NavigationPreloadState&& navigationPreloadState)
: m_identifier(generateServiceWorkerRegistrationIdentifier())
, m_registrationKey(key)
, m_updateViaCache(updateViaCache)
@@ -53,9 +53,9 @@
, m_server(server)
, m_creationTime(MonotonicTime::now())
, m_softUpdateTimer { *this, &SWServerRegistration::softUpdate }
+ , m_preloadState(WTFMove(navigationPreloadState))
{
m_scopeURL.removeFragmentIdentifier();
- m_preloadState.headerValue = "true"_s;
}
SWServerRegistration::~SWServerRegistration()
@@ -387,10 +387,11 @@
// https://w3c.github.io/ServiceWorker/#dom-navigationpreloadmanager-enable, steps run in parallel.
std::optional<ExceptionData> SWServerRegistration::enableNavigationPreload()
{
- // FIXME: Persist this data.
if (!m_activeWorker)
return ExceptionData { InvalidStateError, "No active worker"_s };
+
m_preloadState.enabled = true;
+ m_server.storeRegistrationForWorker(*m_activeWorker);
return { };
}
@@ -397,10 +398,11 @@
// https://w3c.github.io/ServiceWorker/#dom-navigationpreloadmanager-disable, steps run in parallel.
std::optional<ExceptionData> SWServerRegistration::disableNavigationPreload()
{
- // FIXME: Persist this data.
if (!m_activeWorker)
return ExceptionData { InvalidStateError, "No active worker"_s };
+
m_preloadState.enabled = false;
+ m_server.storeRegistrationForWorker(*m_activeWorker);
return { };
}
@@ -407,12 +409,13 @@
// https://w3c.github.io/ServiceWorker/#dom-navigationpreloadmanager-setheadervalue, steps run in parallel.
std::optional<ExceptionData> SWServerRegistration::setNavigationPreloadHeaderValue(String&& headerValue)
{
- // FIXME: Persist this data.
if (!isValidHTTPHeaderValue(headerValue))
return ExceptionData { TypeError, "Invalid header value"_s };
if (!m_activeWorker)
return ExceptionData { InvalidStateError, "No active worker"_s };
+
m_preloadState.headerValue = WTFMove(headerValue);
+ m_server.storeRegistrationForWorker(*m_activeWorker);
return { };
}
Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h 2021-12-03 14:01:14 UTC (rev 286488)
@@ -53,7 +53,7 @@
class SWServerRegistration : public CanMakeWeakPtr<SWServerRegistration> {
WTF_MAKE_FAST_ALLOCATED;
public:
- SWServerRegistration(SWServer&, const ServiceWorkerRegistrationKey&, ServiceWorkerUpdateViaCache, const URL& scopeURL, const URL& scriptURL, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier);
+ SWServerRegistration(SWServer&, const ServiceWorkerRegistrationKey&, ServiceWorkerUpdateViaCache, const URL& scopeURL, const URL& scriptURL, std::optional<ScriptExecutionContextIdentifier> serviceWorkerPageIdentifier, NavigationPreloadState&&);
~SWServerRegistration();
const ServiceWorkerRegistrationKey& key() const { return m_registrationKey; }
Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp (286487 => 286488)
--- trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp 2021-12-03 14:01:14 UTC (rev 286488)
@@ -88,7 +88,7 @@
{
ASSERT(m_registration);
- return { std::nullopt, m_registration->data(), m_data.identifier, m_script, m_certificateInfo, m_contentSecurityPolicy, m_crossOriginEmbedderPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, false, m_lastNavigationWasAppInitiated, m_scriptResourceMap, m_registration->serviceWorkerPageIdentifier() };
+ return { std::nullopt, m_registration->data(), m_data.identifier, m_script, m_certificateInfo, m_contentSecurityPolicy, m_crossOriginEmbedderPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, false, m_lastNavigationWasAppInitiated, m_scriptResourceMap, m_registration->serviceWorkerPageIdentifier(), m_registration->navigationPreloadState() };
}
void SWServerWorker::updateAppInitiatedValue(LastNavigationWasAppInitiated lastNavigationWasAppInitiated)
Modified: trunk/Tools/ChangeLog (286487 => 286488)
--- trunk/Tools/ChangeLog 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Tools/ChangeLog 2021-12-03 14:01:14 UTC (rev 286488)
@@ -1,3 +1,15 @@
+2021-12-03 Youenn Fablet <[email protected]>
+
+ Persist NavigationPreloadState in service worker registration database
+ https://bugs.webkit.org/show_bug.cgi?id=233698
+ <rdar://problem/85963120>
+
+ Reviewed by Chris Dumez.
+
+ Increase counter from 7 to 8.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+
2021-12-02 Jean-Yves Avenard <[email protected]>
Compilation error on Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (286487 => 286488)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2021-12-03 09:31:34 UTC (rev 286487)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2021-12-03 14:01:14 UTC (rev 286488)
@@ -59,6 +59,7 @@
#import <wtf/text/StringHash.h>
#import <wtf/text/WTFString.h>
+static NSString *serviceWorkerRegistrationFilename = @"ServiceWorkerRegistrations-8.sqlite3";
static bool serviceWorkerGlobalObjectIsAvailable;
static String expectedMessage;
@@ -2016,7 +2017,7 @@
auto path = store._configuration._serviceWorkerRegistrationDirectory.path;
NSURL* directory = [NSURL fileURLWithPath:path isDirectory:YES];
- NSURL *swDBPath = [directory URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"];
+ NSURL *swDBPath = [directory URLByAppendingPathComponent:serviceWorkerRegistrationFilename];
unsigned timeout = 0;
while (![[NSFileManager defaultManager] fileExistsAtPath:swDBPath.path] && ++timeout < 100)
@@ -2047,7 +2048,7 @@
EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:swPath.path]);
[[NSFileManager defaultManager] createDirectoryAtURL:swPath withIntermediateDirectories:YES attributes:nil error:nil];
- [[NSFileManager defaultManager] copyItemAtURL:url1 toURL:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"] error:nil];
+ [[NSFileManager defaultManager] copyItemAtURL:url1 toURL:[swPath URLByAppendingPathComponent:serviceWorkerRegistrationFilename] error:nil];
auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
websiteDataStoreConfiguration.get()._serviceWorkerRegistrationDirectory = swPath;
@@ -2449,9 +2450,9 @@
done = false;
unsigned timeout = 0;
- while (![[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"].path] && ++timeout < 20)
+ while (![[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:serviceWorkerRegistrationFilename].path] && ++timeout < 20)
TestWebKitAPI::Util::sleep(0.1);
- EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"].path]);
+ EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:serviceWorkerRegistrationFilename].path]);
// Fetch SW records
auto websiteDataTypes = adoptNS([[NSSet alloc] initWithArray:@[WKWebsiteDataTypeServiceWorkerRegistrations]]);