Changeset 224453 in webkit
- Timestamp:
- Nov 3, 2017 7:12:06 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r224439 r224453 1 2017-11-03 Youenn Fablet <youenn@apple.com> 2 3 Implement ServiceWorkerContainer.getRegistration 4 https://bugs.webkit.org/show_bug.cgi?id=179253 5 6 Reviewed by Chris Dumez. 7 8 * TestExpectations: 9 * http/tests/workers/service/resources/service-worker-getRegistration-worker.js: Added. 10 * http/tests/workers/service/resources/service-worker-getRegistration.js: Added. 11 * http/tests/workers/service/service-worker-getRegistration-expected.txt: Added. 12 * http/tests/workers/service/service-worker-getRegistration.html: Added. 13 1 14 2017-11-03 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/LayoutTests/TestExpectations
r224429 r224453 173 173 imported/w3c/web-platform-tests/service-workers/service-worker/update-after-oneday.https.html [ Skip ] 174 174 imported/w3c/web-platform-tests/fetch/api/abort/general-serviceworker.https.html [ Skip ] 175 imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html [ Skip ] 175 176 176 177 imported/w3c/web-platform-tests/service-workers/service-worker/fetch-cors-xhr.https.html [ Pass Failure ] -
trunk/LayoutTests/imported/w3c/ChangeLog
r224408 r224453 1 2017-11-03 Youenn Fablet <youenn@apple.com> 2 3 Implement ServiceWorkerContainer.getRegistration 4 https://bugs.webkit.org/show_bug.cgi?id=179253 5 6 Reviewed by Chris Dumez. 7 8 * web-platform-tests/service-workers/service-worker/activation.https-expected.txt: 9 * web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt: 10 * web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt: 11 * web-platform-tests/service-workers/service-worker/getregistration.https-expected.txt: 12 * web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt: 13 * web-platform-tests/service-workers/service-worker/navigate-window.https-expected.txt: 14 * web-platform-tests/service-workers/service-worker/registration-iframe.https-expected.txt: 15 * web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt: 16 * web-platform-tests/service-workers/service-worker/synced-state.https-expected.txt: 17 1 18 2017-11-03 Youenn Fablet <youenn@apple.com> 2 19 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/activation.https-expected.txt
r224132 r224453 1 1 2 FAIL loss of controllees triggers activation promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"3 FAIL finishing a request triggers activation promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"4 FAIL skipWaiting bypasses no controllee requirement promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"5 FAIL finishing a request triggers unregister promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')"6 2 3 FAIL loss of controllees triggers activation assert_not_equals: got disallowed value null 4 FAIL finishing a request triggers activation assert_not_equals: got disallowed value null 5 FAIL skipWaiting bypasses no controllee requirement assert_not_equals: got disallowed value null 6 FAIL finishing a request triggers unregister assert_not_equals: got disallowed value null 7 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt
r224218 r224453 1 1 2 2 3 FAIL claim() should affect the originally controlling registration. promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'r.active')"3 FAIL claim() should affect the originally controlling registration. assert_equals: Should be the same registration expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]" 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt
r224132 r224453 1 CONSOLE MESSAGE: line 27: Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'r.update')1 CONSOLE MESSAGE: line 27: Unhandled Promise Rejection: NotSupportedError: ServiceWorkerRegistration::update not yet implemented 2 2 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/getregistration.https-expected.txt
r224132 r224453 1 1 2 FAIL getRegistration assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve with undefined expected (undefined) undefined but got (object) null Reached unreachable code 3 FAIL Register then getRegistration assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve to the same registration object expected object "[object ServiceWorkerRegistration]" but got null Reached unreachable code 4 FAIL Register then getRegistration with a URL having a fragment assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve to the same registration object expected object "[object ServiceWorkerRegistration]" but got null Reached unreachable code 5 FAIL getRegistration with a cross origin URL assert_unreached: unexpected rejection: assert_unreached: getRegistration with an out of origin URL should fail Reached unreachable code Reached unreachable code 6 FAIL Register then Unregister then getRegistration assert_unreached: unexpected rejection: assert_equals: getRegistration should resolve with undefined expected (undefined) undefined but got (object) null Reached unreachable code 2 PASS getRegistration 3 PASS Register then getRegistration 4 PASS Register then getRegistration with a URL having a fragment 5 PASS getRegistration with a cross origin URL 6 PASS Register then Unregister then getRegistration 7 7 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multi-globals/url-parsing.https-expected.txt
r224337 r224453 3 3 PASS register should use the relevant global of the object it was called on to resolve the script URL and the default scope URL 4 4 PASS register should use the relevant global of the object it was called on to resolve the script URL and the given scope URL 5 FAIL getRegistration should use the relevant global of the object it was called on to resolve the script URL assert_not_equals: the registration from the other frame should not be null got disallowed value null 5 PASS getRegistration should use the relevant global of the object it was called on to resolve the script URL 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigate-window.https-expected.txt
r224218 r224453 1 1 2 FAIL Clients.matchAll() should not show an old window as controlled after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating ' reg.active') Reached unreachable code3 FAIL Clients.matchAll() should not show an old window after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating ' reg.active') Reached unreachable code2 FAIL Clients.matchAll() should not show an old window as controlled after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating 'sw.postMessage') Reached unreachable code 3 FAIL Clients.matchAll() should not show an old window after it navigates. assert_unreached: unexpected rejection: null is not an object (evaluating 'sw.postMessage') Reached unreachable code 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-iframe.https-expected.txt
r224132 r224453 1 1 2 FAIL register method should use the "relevant global object" to parse its scriptURL and scope - normal case assert_unreached: unexpected rejection: null is not an object (evaluating 'document.body.appendChild') Reached unreachable code3 FAIL register method should use the "relevant global object" to parse its scriptURL and scope - error case assert_unreached: unexpected rejection: undefined is not an object (evaluating 'frame.remove') Reached unreachable code4 FAIL A scope url should start with the given script url assert_unreached: unexpected rejection: assert_equals: The scope set to a non-subdirectory of the scriptURL should reject with SecurityError expected "SecurityError" but got "TypeError" Reached unreachable code5 2 3 PASS register method should use the "relevant global object" to parse its scriptURL and scope - normal case 4 FAIL register method should use the "relevant global object" to parse its scriptURL and scope - error case assert_unreached: unexpected rejection: assert_unreached: register() should reject Reached unreachable code Reached unreachable code 5 FAIL A scope url should start with the given script url assert_unreached: unexpected rejection: assert_unreached: register() should reject Reached unreachable code Reached unreachable code 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt
r224132 r224453 1 1 2 FAIL Test skipWaiting while a client is not being controlled promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.body.appendChild')" 2 Harness Error (TIMEOUT), message = null 3 3 4 PASS Test skipWaiting while a client is not being controlled 5 TIMEOUT skipWaiting Test timed out 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/synced-state.https-expected.txt
r224218 r224453 1 1 2 FAIL worker objects for the same entity have the same state assert_equals: getRegistration should return the same object expected object "[object ServiceWorkerRegistration]" but got null 2 PASS worker objects for the same entity have the same state 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt
r224218 r224453 3 3 PASS Unregister then register resolves to a new value 4 4 FAIL Unregister then register resolves to the original value if the registration is in use. assert_unreached: unexpected rejection: assert_equals: new registration should resolve to the same registration expected object "[object ServiceWorkerRegistration]" but got object "[object ServiceWorkerRegistration]" Reached unreachable code 5 FAIL Reloading the last controlled iframe after unregistration should ensure the deletion of the registration assert_unreached: unexpected rejection: assert_equals: getRegistration should return undefined after unregistration expected (undefined) undefined but got (object) null Reached unreachable code 5 PASS Reloading the last controlled iframe after unregistration should ensure the deletion of the registration 6 6 FAIL Unregister then register does not affect existing controllee assert_unreached: unexpected rejection: assert_equals: installing version is null expected null but got object "[object ServiceWorker]" Reached unreachable code 7 7 FAIL Unregister then register resurrects the registration assert_unreached: unexpected rejection: assert_not_equals: document should have a controller got disallowed value null Reached unreachable code -
trunk/Source/WebCore/ChangeLog
r224452 r224453 1 2017-11-03 Youenn Fablet <youenn@apple.com> 2 3 Implement ServiceWorkerContainer.getRegistration 4 https://bugs.webkit.org/show_bug.cgi?id=179253 5 6 Reviewed by Chris Dumez. 7 8 Test: http/tests/workers/service/service-worker-getRegistration.html 9 10 Added a map of ServiceWorkerRegistration in ServiceWorkerContainer. 11 Removing a similar map from SWClientConnection as it is more convenient to have this map per ScriptExecutionContext. 12 13 This map allows returning the same JS object for different getRegistration. 14 Delegating the actual matching to SWServer::Connection which is implemented on the StorageProcess through IPC. 15 16 * workers/service/ServiceWorkerContainer.cpp: 17 (WebCore::ServiceWorkerContainer::getRegistration): 18 (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): 19 (WebCore::ServiceWorkerContainer::jobDidFinish): 20 * workers/service/ServiceWorkerContainer.h: 21 * workers/service/ServiceWorkerContainer.idl: 22 * workers/service/ServiceWorkerRegistration.cpp: 23 (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration): 24 (WebCore::ServiceWorkerRegistration::~ServiceWorkerRegistration): 25 * workers/service/ServiceWorkerRegistration.h: 26 * workers/service/server/SWClientConnection.cpp: 27 (WebCore::SWClientConnection::updateRegistrationState): 28 (WebCore::SWClientConnection::addServiceWorkerRegistration): Deleted. 29 (WebCore::SWClientConnection::removeServiceWorkerRegistration): Deleted. 30 * workers/service/server/SWClientConnection.h: 31 1 32 2017-11-03 Chris Dumez <cdumez@apple.com> 2 33 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp
r224403 r224453 177 177 } 178 178 179 void ServiceWorkerContainer::getRegistration(const String&, RegistrationPromise&& promise) 180 { 181 // FIXME: Implement getRegistration algorithm, for now pretend there is no registration. 182 // https://bugs.webkit.org/show_bug.cgi?id=178882 183 promise.resolve(nullptr); 179 void ServiceWorkerContainer::getRegistration(const String& clientURL, Ref<DeferredPromise>&& promise) 180 { 181 auto* context = scriptExecutionContext(); 182 if (!context) { 183 ASSERT_NOT_REACHED(); 184 promise->reject(Exception { InvalidStateError }); 185 return; 186 } 187 188 URL parsedURL = context->completeURL(clientURL); 189 if (!protocolHostAndPortAreEqual(parsedURL, context->url())) { 190 promise->reject(Exception { SecurityError, ASCIILiteral("Origin of clientURL is not client's origin") }); 191 return; 192 } 193 194 if (!m_swConnection) 195 m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID()); 196 197 return m_swConnection->matchRegistration(context->topOrigin(), parsedURL, [promise = WTFMove(promise), protectingThis = makePendingActivity(*this), this] (auto&& result) mutable { 198 if (m_isStopped) 199 return; 200 201 if (!result) { 202 promise->resolve(); 203 return; 204 } 205 206 RefPtr<ServiceWorkerRegistration> registration = m_registrations.get(result->key); 207 if (!registration) { 208 auto& context = *scriptExecutionContext(); 209 auto worker = ServiceWorker::create(context, *result->activeServiceWorkerIdentifier, result->scriptURL); 210 registration = ServiceWorkerRegistration::create(context, *this, WTFMove(result.value()), WTFMove(worker)); 211 } 212 promise->resolve<IDLInterface<ServiceWorkerRegistration>>(registration.releaseNonNull()); 213 }); 214 } 215 216 void ServiceWorkerContainer::updateRegistration(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier) 217 { 218 if (auto* registration = m_registrations.get(key)) 219 registration->updateStateFromServer(state, serviceWorkerIdentifier); 184 220 } 185 221 … … 252 288 253 289 activeServiceWorker->setState(ServiceWorker::State::Installing); 254 255 ASSERT(m_swConnection); 256 auto registration = ServiceWorkerRegistration::create(*context, *m_swConnection, WTFMove(data), *activeServiceWorker); 257 258 job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get()); 290 291 auto registration = ServiceWorkerRegistration::create(*context, *this, WTFMove(data), *activeServiceWorker); 292 293 job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration); 259 294 260 295 // Use a microtask because we need to make sure this is executed after the promise above is resolved. … … 313 348 { 314 349 auto taken = m_jobMap.take(job.data().identifier()); 315 ASSERT_UNUSED(taken, !taken || taken .get() == &job);350 ASSERT_UNUSED(taken, !taken || taken->ptr() == &job); 316 351 } 317 352 … … 329 364 bool ServiceWorkerContainer::canSuspendForDocumentSuspension() const 330 365 { 331 return true;366 return !hasPendingActivity(); 332 367 } 333 368 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h
r224218 r224453 63 63 void removeRegistration(const URL& scopeURL, Ref<DeferredPromise>&&); 64 64 65 using RegistrationPromise = DOMPromiseDeferred<IDLNullable<IDLInterface<ServiceWorkerRegistration>>>;66 void getRegistration(const String& clientURL, RegistrationPromise&&);65 void getRegistration(const String& clientURL, Ref<DeferredPromise>&&); 66 void updateRegistration(const ServiceWorkerRegistrationKey&, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&); 67 67 68 68 using RegistrationsPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<ServiceWorkerRegistration>>>; 69 69 void getRegistrations(RegistrationsPromise&&); 70 71 void addRegistration(ServiceWorkerRegistration& registration) { m_registrations.add(registration.data().key, ®istration); } 72 void removeRegistration(ServiceWorkerRegistration& registration) { m_registrations.remove(registration.data().key); } 70 73 71 74 void startMessages(); … … 94 97 void refEventTarget() final; 95 98 void derefEventTarget() final; 99 void stop() final { m_isStopped = true; } 96 100 97 101 ReadyPromise m_readyPromise; … … 100 104 101 105 RefPtr<SWClientConnection> m_swConnection; 102 HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_jobMap; 106 HashMap<uint64_t, Ref<ServiceWorkerJob>> m_jobMap; 107 108 bool m_isStopped { false }; 109 HashMap<ServiceWorkerRegistrationKey, ServiceWorkerRegistration*> m_registrations; 103 110 104 111 #ifndef NDEBUG -
trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
r224403 r224453 37 37 namespace WebCore { 38 38 39 ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& context, SWClientConnection& connection, ServiceWorkerRegistrationData&& registrationData, Ref<ServiceWorker>&& serviceWorker)39 ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& context, Ref<ServiceWorkerContainer>&& container, ServiceWorkerRegistrationData&& registrationData, Ref<ServiceWorker>&& serviceWorker) 40 40 : ActiveDOMObject(&context) 41 41 , m_registrationData(WTFMove(registrationData)) 42 42 , m_serviceWorker(WTFMove(serviceWorker)) 43 , m_con nection(connection)43 , m_container(WTFMove(container)) 44 44 { 45 45 suspendIfNeeded(); 46 47 m_connection->addServiceWorkerRegistration(*this); 46 m_container->addRegistration(*this); 48 47 } 49 48 50 49 ServiceWorkerRegistration::~ServiceWorkerRegistration() 51 50 { 52 m_con nection->removeServiceWorkerRegistration(*this);51 m_container->removeRegistration(*this); 53 52 } 54 53 -
trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h
r224403 r224453 39 39 class ScriptExecutionContext; 40 40 class ServiceWorker; 41 class ServiceWorkerContainer; 41 42 42 43 class ServiceWorkerRegistration final : public RefCounted<ServiceWorkerRegistration>, public EventTargetWithInlineData, public ActiveDOMObject, public ThreadSafeIdentified<ServiceWorkerRegistration> { … … 67 68 68 69 private: 69 ServiceWorkerRegistration(ScriptExecutionContext&, SWClientConnection&, ServiceWorkerRegistrationData&&, Ref<ServiceWorker>&&);70 ServiceWorkerRegistration(ScriptExecutionContext&, Ref<ServiceWorkerContainer>&&, ServiceWorkerRegistrationData&&, Ref<ServiceWorker>&&); 70 71 71 72 EventTargetInterface eventTargetInterface() const final; … … 79 80 ServiceWorkerRegistrationData m_registrationData; 80 81 Ref<ServiceWorker> m_serviceWorker; 81 Ref<S WClientConnection> m_connection;82 Ref<ServiceWorkerContainer> m_container; 82 83 }; 83 84 -
trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp
r224403 r224453 65 65 } 66 66 67 void SWClientConnection::addServiceWorkerRegistration(ServiceWorkerRegistration& registration)68 {69 auto result = m_registrations.ensure(registration.data().key, [] {70 return std::make_unique<HashSet<ServiceWorkerRegistration*>>();71 });72 73 ASSERT(!result.iterator->value->contains(®istration));74 result.iterator->value->add(®istration);75 76 addServiceWorkerRegistrationInServer(registration.data().key, registration.identifier());77 }78 79 void SWClientConnection::removeServiceWorkerRegistration(ServiceWorkerRegistration& registration)80 {81 auto iterator = m_registrations.find(registration.data().key);82 83 ASSERT(iterator != m_registrations.end());84 ASSERT(iterator->value && iterator->value->contains(®istration));85 iterator->value->remove(®istration);86 87 if (iterator->value->isEmpty())88 m_registrations.remove(iterator);89 90 removeServiceWorkerRegistrationInServer(registration.data().key, registration.identifier());91 }92 93 67 void SWClientConnection::jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData& exceptionData) 94 68 { … … 167 141 void SWClientConnection::updateRegistrationState(const ServiceWorkerRegistrationKey& key, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier) 168 142 { 169 auto* registrations = m_registrations.get(key); 170 if (!registrations) 171 return; 172 173 for (auto& registration : *registrations) 174 registration->updateStateFromServer(state, serviceWorkerIdentifier); 143 // FIXME: We should iterate over all service worker clients, not only documents. 144 for (auto& document : Document::allDocuments()) { 145 if (auto* container = document->serviceWorkerContainer()) 146 container->updateRegistration(key, state, serviceWorkerIdentifier); 147 } 175 148 } 176 149 -
trunk/Source/WebCore/workers/service/server/SWClientConnection.h
r224408 r224453 54 54 void finishedFetchingScript(ServiceWorkerJob&, const String&); 55 55 void failedFetchingScript(ServiceWorkerJob&, const ResourceError&); 56 void addServiceWorkerRegistration(ServiceWorkerRegistration&);57 void removeServiceWorkerRegistration(ServiceWorkerRegistration&);58 56 59 57 virtual void postMessageToServiceWorkerGlobalScope(ServiceWorkerIdentifier destinationIdentifier, Ref<SerializedScriptValue>&&, ScriptExecutionContext& source) = 0; … … 78 76 79 77 HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs; 80 HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<HashSet<ServiceWorkerRegistration*>>> m_registrations;81 78 }; 82 79
Note: See TracChangeset
for help on using the changeset viewer.