|
Lines 100-106
void SWServerJobQueue::scriptFetchFinished(const ServiceWorkerFetchResult& resul
a/Source/WebCore/workers/service/server/SWServerJobQueue.cpp_sec1
|
| 100 |
// If newestWorker is not null, newestWorker's script url equals job's script url with the exclude fragments |
100 |
// If newestWorker is not null, newestWorker's script url equals job's script url with the exclude fragments |
| 101 |
// flag set, and script's source text is a byte-for-byte match with newestWorker's script resource's source |
101 |
// flag set, and script's source text is a byte-for-byte match with newestWorker's script resource's source |
| 102 |
// text, then: |
102 |
// text, then: |
| 103 |
if (newestWorker && equalIgnoringFragmentIdentifier(newestWorker->scriptURL(), job.scriptURL) && result.script == newestWorker->script() && doCertificatesMatch(result.certificateInfo, newestWorker->certificateInfo())) { |
103 |
if (newestWorker && equalIgnoringFragmentIdentifier(newestWorker->scriptURL(), job.scriptURL) && newestWorker->type() == job.workerType && result.script == newestWorker->script() && doCertificatesMatch(result.certificateInfo, newestWorker->certificateInfo())) { |
| 104 |
RELEASE_LOG(ServiceWorker, "%p - SWServerJobQueue::scriptFetchFinished, script and certificate are matching for registrationID=%llu", this, registration->identifier().toUInt64()); |
104 |
RELEASE_LOG(ServiceWorker, "%p - SWServerJobQueue::scriptFetchFinished, script and certificate are matching for registrationID=%llu", this, registration->identifier().toUInt64()); |
| 105 |
// FIXME: for non classic scripts, check the script’s module record's [[ECMAScriptCode]]. |
105 |
// FIXME: for non classic scripts, check the script’s module record's [[ECMAScriptCode]]. |
| 106 |
|
106 |
|
|
Lines 114-121
void SWServerJobQueue::scriptFetchFinished(const ServiceWorkerFetchResult& resul
a/Source/WebCore/workers/service/server/SWServerJobQueue.cpp_sec2
|
| 114 |
|
114 |
|
| 115 |
// FIXME: Update all the imported scripts as per spec. For now, we just do as if there is none. |
115 |
// FIXME: Update all the imported scripts as per spec. For now, we just do as if there is none. |
| 116 |
|
116 |
|
| 117 |
// FIXME: Support the proper worker type (classic vs module) |
117 |
m_server.updateWorker(job.identifier(), *registration, job.scriptURL, result.script, result.certificateInfo, result.contentSecurityPolicy, result.referrerPolicy, job.workerType, { }); |
| 118 |
m_server.updateWorker(job.identifier(), *registration, job.scriptURL, result.script, result.certificateInfo, result.contentSecurityPolicy, result.referrerPolicy, WorkerType::Classic, { }); |
|
|
| 119 |
} |
118 |
} |
| 120 |
|
119 |
|
| 121 |
// https://w3c.github.io/ServiceWorker/#update-algorithm |
120 |
// https://w3c.github.io/ServiceWorker/#update-algorithm |
|
Lines 287-293
void SWServerJobQueue::runRegisterJob(const ServiceWorkerJobData& job)
a/Source/WebCore/workers/service/server/SWServerJobQueue.cpp_sec3
|
| 287 |
// If registration is not null (in our parlance "empty"), then: |
286 |
// If registration is not null (in our parlance "empty"), then: |
| 288 |
if (auto* registration = m_server.getRegistration(m_registrationKey)) { |
287 |
if (auto* registration = m_server.getRegistration(m_registrationKey)) { |
| 289 |
auto* newestWorker = registration->getNewestWorker(); |
288 |
auto* newestWorker = registration->getNewestWorker(); |
| 290 |
if (newestWorker && equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()) && job.registrationOptions.updateViaCache == registration->updateViaCache()) { |
289 |
if (newestWorker && equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()) && job.workerType == newestWorker->type() && job.registrationOptions.updateViaCache == registration->updateViaCache()) { |
| 291 |
RELEASE_LOG(ServiceWorker, "%p - SWServerJobQueue::runRegisterJob: Found directly reusable registration %llu for job %s (DONE)", this, registration->identifier().toUInt64(), job.identifier().loggingString().utf8().data()); |
290 |
RELEASE_LOG(ServiceWorker, "%p - SWServerJobQueue::runRegisterJob: Found directly reusable registration %llu for job %s (DONE)", this, registration->identifier().toUInt64(), job.identifier().loggingString().utf8().data()); |
| 292 |
m_server.resolveRegistrationJob(job, registration->data(), ShouldNotifyWhenResolved::No); |
291 |
m_server.resolveRegistrationJob(job, registration->data(), ShouldNotifyWhenResolved::No); |
| 293 |
finishCurrentJob(); |
292 |
finishCurrentJob(); |
|
Lines 350-356
void SWServerJobQueue::runUpdateJob(const ServiceWorkerJobData& job)
a/Source/WebCore/workers/service/server/SWServerJobQueue.cpp_sec4
|
| 350 |
auto* newestWorker = registration->getNewestWorker(); |
349 |
auto* newestWorker = registration->getNewestWorker(); |
| 351 |
|
350 |
|
| 352 |
// If job's type is update, and newestWorker's script url does not equal job's script url with the exclude fragments flag set, then: |
351 |
// If job's type is update, and newestWorker's script url does not equal job's script url with the exclude fragments flag set, then: |
| 353 |
if (job.type == ServiceWorkerJobType::Update && newestWorker && !equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL())) |
352 |
if (job.type == ServiceWorkerJobType::Update && newestWorker && (!equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()) || job.workerType != newestWorker->type())) |
| 354 |
return rejectCurrentJob(ExceptionData { TypeError, "Cannot update a service worker with a requested script URL whose newest worker has a different script URL"_s }); |
353 |
return rejectCurrentJob(ExceptionData { TypeError, "Cannot update a service worker with a requested script URL whose newest worker has a different script URL"_s }); |
| 355 |
|
354 |
|
| 356 |
// Set request's cache mode to "no-cache" if any of the following are true: |
355 |
// Set request's cache mode to "no-cache" if any of the following are true: |