Changeset 225531 in webkit
- Timestamp:
- Dec 5, 2017 12:56:13 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r225513 r225531 1 2017-12-05 Chris Dumez <cdumez@apple.com> 2 3 Add support for ServiceWorkerContainer.prototype.ready 4 https://bugs.webkit.org/show_bug.cgi?id=180383 5 6 Reviewed by Youenn Fablet. 7 8 Rebaseline WPT test coverage container.ready now that it is passing. 9 10 * web-platform-tests/service-workers/service-worker/ready.https-expected.txt: 11 1 12 2017-12-04 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt
r224947 r225531 1 CONSOLE MESSAGE: Unhandled Promise Rejection: UnknownError: serviceWorker.ready() is not yet implemented2 3 Harness Error (FAIL), message = serviceWorker.ready() is not yet implemented4 1 5 2 PASS ready returns the same Promise object 6 3 PASS ready returns a Promise object in the context of the related document 7 FAIL ready on a controlled document promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 8 FAIL ready on a potential controlled document promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 9 FAIL ready on an iframe whose parent registers a new service worker promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 10 FAIL ready on an iframe that installs a new service worker promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 11 FAIL ready after a longer matched registration registered promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 12 FAIL access ready after it has been resolved promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 13 FAIL access ready on uninstalling registration that is resurrected promise_test: Unhandled rejection with value: object "UnknownError: serviceWorker.ready() is not yet implemented" 4 PASS ready on a controlled document 5 PASS ready on a potential controlled document 6 PASS ready on an iframe whose parent registers a new service worker 7 PASS ready on an iframe that installs a new service worker 8 PASS ready after a longer matched registration registered 9 PASS access ready after it has been resolved 10 PASS access ready on uninstalling registration that is resurrected 14 11 -
trunk/Source/WebCore/ChangeLog
r225529 r225531 1 2017-12-05 Chris Dumez <cdumez@apple.com> 2 3 Add support for ServiceWorkerContainer.prototype.ready 4 https://bugs.webkit.org/show_bug.cgi?id=180383 5 6 Reviewed by Youenn Fablet. 7 8 Add support for ServiceWorkerContainer.prototype.ready: 9 - https://w3c.github.io/ServiceWorker/#navigator-service-worker-ready 10 11 No new tests, rebaselined existing test. 12 13 * workers/service/SWClientConnection.h: 14 * workers/service/ServiceWorkerContainer.cpp: 15 (WebCore::ServiceWorkerContainer::ServiceWorkerContainer): 16 (WebCore::ServiceWorkerContainer::ready): 17 * workers/service/ServiceWorkerContainer.h: 18 * workers/service/ServiceWorkerRegistrationKey.h: 19 * workers/service/server/SWServer.cpp: 20 (WebCore::SWServer::resolveRegistrationReadyRequests): 21 * workers/service/server/SWServer.h: 22 * workers/service/server/SWServerRegistration.cpp: 23 (WebCore::SWServerRegistration::activate): 24 (WebCore::SWServerRegistration::setIsUninstalling): 25 * workers/service/server/SWServerRegistration.h: 26 1 27 2017-12-05 Yusuke Suzuki <utatane.tea@gmail.com> 2 28 -
trunk/Source/WebCore/workers/service/SWClientConnection.h
r225526 r225531 63 63 virtual void getRegistrations(const SecurityOrigin& topOrigin, const URL& clientURL, GetRegistrationsCallback&&) = 0; 64 64 65 using WhenRegistrationReadyCallback = WTF::Function<void(ServiceWorkerRegistrationData&&)>; 66 virtual void whenRegistrationReady(const SecurityOrigin& topOrigin, const URL& clientURL, WhenRegistrationReadyCallback&&) = 0; 67 65 68 virtual void addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier) = 0; 66 69 virtual void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier) = 0; -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp
r225513 r225531 58 58 { 59 59 suspendIfNeeded(); 60 61 m_readyPromise.reject(Exception { UnknownError, ASCIILiteral("serviceWorker.ready() is not yet implemented") });62 60 } 63 61 … … 77 75 { 78 76 m_navigator.deref(); 77 } 78 79 auto ServiceWorkerContainer::ready() -> ReadyPromise& 80 { 81 if (!m_readyPromise) { 82 m_readyPromise = std::make_unique<ReadyPromise>(); 83 84 auto* context = scriptExecutionContext(); 85 if (!context) 86 return *m_readyPromise; 87 88 auto contextIdentifier = this->contextIdentifier(); 89 callOnMainThread([this, connection = makeRef(ensureSWClientConnection()), topOrigin = context->topOrigin().isolatedCopy(), clientURL = context->url().isolatedCopy(), contextIdentifier]() mutable { 90 connection->whenRegistrationReady(topOrigin, clientURL, [this, contextIdentifier](auto&& registrationData) { 91 ScriptExecutionContext::postTaskTo(contextIdentifier, [this, registrationData = crossThreadCopy(registrationData)](auto&) mutable { 92 if (m_isStopped) 93 return; 94 95 auto registration = ServiceWorkerRegistration::getOrCreate(*scriptExecutionContext(), *this, WTFMove(registrationData)); 96 m_readyPromise->resolve(WTFMove(registration)); 97 }); 98 }); 99 }); 100 } 101 return *m_readyPromise; 79 102 } 80 103 -
trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h
r225513 r225531 57 57 58 58 using ReadyPromise = DOMPromiseProxy<IDLInterface<ServiceWorkerRegistration>>; 59 ReadyPromise& ready() { return m_readyPromise; }59 ReadyPromise& ready(); 60 60 61 61 using RegistrationOptions = ServiceWorkerRegistrationOptions; … … 111 111 void stop() final; 112 112 113 ReadyPromisem_readyPromise;113 std::unique_ptr<ReadyPromise> m_readyPromise; 114 114 115 115 NavigatorBase& m_navigator; -
trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h
r225398 r225531 42 42 43 43 bool operator==(const ServiceWorkerRegistrationKey&) const; 44 bool isMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const;44 WEBCORE_EXPORT bool isMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const; 45 45 bool originIsMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const; 46 46 size_t scopeLength() const { return m_scope.string().length(); } -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r225526 r225531 645 645 } 646 646 647 void SWServer::resolveRegistrationReadyRequests(SWServerRegistration& registration) 648 { 649 for (auto* connection : m_connections.values()) 650 connection->resolveRegistrationReadyRequests(registration); 651 } 652 653 void SWServer::Connection::whenRegistrationReady(uint64_t registrationReadyRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL) 654 { 655 if (auto* registration = doRegistrationMatching(topOrigin, clientURL)) { 656 if (registration->activeWorker()) { 657 registrationReady(registrationReadyRequestIdentifier, registration->data()); 658 return; 659 } 660 } 661 m_registrationReadyRequests.append({ topOrigin, clientURL, registrationReadyRequestIdentifier }); 662 } 663 664 void SWServer::Connection::resolveRegistrationReadyRequests(SWServerRegistration& registration) 665 { 666 m_registrationReadyRequests.removeAllMatching([&](auto& request) { 667 if (!registration.key().isMatching(request.topOrigin, request.clientURL)) 668 return false; 669 670 registrationReady(request.identifier, registration.data()); 671 return true; 672 }); 673 } 674 647 675 } // namespace WebCore 648 676 -
trunk/Source/WebCore/workers/service/server/SWServer.h
r225526 r225531 76 76 WEBCORE_EXPORT void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&); 77 77 const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); } 78 void resolveRegistrationReadyRequests(SWServerRegistration&); 78 79 79 80 // Messages to the client WebProcess … … 82 83 virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0; 83 84 virtual void notifyClientsOfControllerChange(const HashSet<DocumentIdentifier>& contextIdentifiers, const ServiceWorkerData& newController) = 0; 85 virtual void registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&&) = 0; 84 86 85 87 protected: … … 92 94 WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier); 93 95 WEBCORE_EXPORT void syncTerminateWorker(ServiceWorkerIdentifier); 96 WEBCORE_EXPORT void whenRegistrationReady(uint64_t registrationReadyRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL); 94 97 95 98 private: … … 100 103 virtual void startScriptFetchInClient(const ServiceWorkerJobDataIdentifier&) = 0; 101 104 105 struct RegistrationReadyRequest { 106 SecurityOriginData topOrigin; 107 URL clientURL; 108 uint64_t identifier; 109 }; 110 102 111 SWServer& m_server; 103 112 Identifier m_identifier; 113 Vector<RegistrationReadyRequest> m_registrationReadyRequests; 104 114 }; 105 115 … … 152 162 153 163 void setClientActiveWorker(ServiceWorkerClientIdentifier, ServiceWorkerIdentifier); 164 void resolveRegistrationReadyRequests(SWServerRegistration&); 154 165 155 166 private: -
trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp
r225526 r225531 262 262 // FIXME: For each service worker client whose creation URL matches registration's scope url... 263 263 264 // The registration now has an active worker so we need to check if there are any ready promises that were waiting for this. 265 m_server.resolveRegistrationReadyRequests(*this); 266 264 267 // For each service worker client who is using registration: 265 268 // - Set client's active worker to registration's active worker. … … 298 301 } 299 302 303 void SWServerRegistration::setIsUninstalling(bool value) 304 { 305 if (m_uninstalling == value) 306 return; 307 308 m_uninstalling = value; 309 310 if (!m_uninstalling && activeWorker()) { 311 // Registration with active worker has been resurrected, we need to check if any ready promises were waiting for this. 312 m_server.resolveRegistrationReadyRequests(*this); 313 } 314 } 315 300 316 } // namespace WebCore 301 317 -
trunk/Source/WebCore/workers/service/server/SWServerRegistration.h
r225483 r225531 57 57 58 58 bool isUninstalling() const { return m_uninstalling; } 59 void setIsUninstalling(bool value) { m_uninstalling = value; }59 void setIsUninstalling(bool); 60 60 61 61 void setLastUpdateTime(double time) { m_lastUpdateTime = time; } -
trunk/Source/WebKit/ChangeLog
r225526 r225531 1 2017-12-05 Chris Dumez <cdumez@apple.com> 2 3 Add support for ServiceWorkerContainer.prototype.ready 4 https://bugs.webkit.org/show_bug.cgi?id=180383 5 6 Reviewed by Youenn Fablet. 7 8 * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: 9 (WebKit::WebSWServerConnection::whenRegistrationReady): 10 (WebKit::WebSWServerConnection::resolveRegistrationReadyRequests): 11 * StorageProcess/ServiceWorker/WebSWServerConnection.h: 12 * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: 13 * WebProcess/Storage/WebSWClientConnection.cpp: 14 (WebKit::WebSWClientConnection::matchRegistration): 15 (WebKit::WebSWClientConnection::whenRegistrationReady): 16 (WebKit::WebSWClientConnection::registrationReady): 17 (WebKit::WebSWClientConnection::getRegistrations): 18 * WebProcess/Storage/WebSWClientConnection.h: 19 * WebProcess/Storage/WebSWClientConnection.messages.in: 20 1 21 2017-12-05 Youenn Fablet <youenn@apple.com> 2 22 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
r225526 r225531 199 199 } 200 200 201 void WebSWServerConnection::registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&& registrationData) 202 { 203 send(Messages::WebSWClientConnection::RegistrationReady { registrationReadyRequestIdentifier, WTFMove(registrationData) }); 204 } 205 201 206 void WebSWServerConnection::getRegistrations(uint64_t registrationMatchRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL) 202 207 { -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
r225526 r225531 78 78 void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final; 79 79 void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController); 80 void registrationReady(uint64_t registrationReadyRequestIdentifier, WebCore::ServiceWorkerRegistrationData&&) final; 80 81 81 82 void startFetch(uint64_t fetchIdentifier, std::optional<WebCore::ServiceWorkerIdentifier>, const WebCore::ResourceRequest&, const WebCore::FetchOptions&, const IPC::FormDataReference&); … … 96 97 97 98 PAL::SessionID m_sessionID; 98 99 99 Ref<IPC::Connection> m_contentConnection; 100 100 RefPtr<IPC::Connection> m_contextConnection; 101 101 HashMap<WebCore::DocumentIdentifier, WebCore::ClientOrigin> m_clientOrigins; 102 }; // class WebSWServerConnection102 }; 103 103 104 104 } // namespace WebKit -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
r225526 r225531 37 37 38 38 MatchRegistration(uint64_t serviceRegistrationMatchRequestIdentifier, struct WebCore::SecurityOriginData topOrigin, WebCore::URL clientURL) 39 WhenRegistrationReady(uint64_t serviceRegistrationMatchRequestIdentifier, struct WebCore::SecurityOriginData topOrigin, WebCore::URL clientURL) 39 40 GetRegistrations(uint64_t serviceRegistrationMatchRequestIdentifier, struct WebCore::SecurityOriginData topOrigin, WebCore::URL clientURL) 40 41 RegisterServiceWorkerClient(struct WebCore::SecurityOriginData topOrigin, WebCore::DocumentIdentifier identifier, struct WebCore::ServiceWorkerClientData data, std::optional<WebCore::ServiceWorkerIdentifier> controllingServiceWorkerIdentifier) -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r225526 r225531 151 151 } 152 152 153 uint64_t requestIdentifier = ++m_previousMatchRegistrationTaskIdentifier; 154 m_ongoingMatchRegistrationTasks.add(requestIdentifier, WTFMove(callback)); 155 send(Messages::WebSWServerConnection::MatchRegistration(requestIdentifier, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL)); 153 uint64_t callbackID = ++m_previousCallbackIdentifier; 154 m_ongoingMatchRegistrationTasks.add(callbackID, WTFMove(callback)); 155 send(Messages::WebSWServerConnection::MatchRegistration(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL)); 156 } 157 158 void WebSWClientConnection::whenRegistrationReady(const SecurityOrigin& topOrigin, const URL& clientURL, WhenRegistrationReadyCallback&& callback) 159 { 160 uint64_t callbackID = ++m_previousCallbackIdentifier; 161 m_ongoingRegistrationReadyTasks.add(callbackID, WTFMove(callback)); 162 send(Messages::WebSWServerConnection::WhenRegistrationReady(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL)); 163 } 164 165 void WebSWClientConnection::registrationReady(uint64_t callbackID, WebCore::ServiceWorkerRegistrationData&& registrationData) 166 { 167 ASSERT(registrationData.activeWorker); 168 if (auto callback = m_ongoingRegistrationReadyTasks.take(callbackID)) 169 callback(WTFMove(registrationData)); 156 170 } 157 171 … … 165 179 } 166 180 167 uint64_t requestIdentifier = ++m_previousGetRegistrationsTaskIdentifier;168 m_ongoingGetRegistrationsTasks.add( requestIdentifier, WTFMove(callback));169 send(Messages::WebSWServerConnection::GetRegistrations( requestIdentifier, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));181 uint64_t callbackID = ++m_previousCallbackIdentifier; 182 m_ongoingGetRegistrationsTasks.add(callbackID, WTFMove(callback)); 183 send(Messages::WebSWServerConnection::GetRegistrations(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL)); 170 184 } 171 185 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
r225526 r225531 82 82 void didMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData>&&); 83 83 void didGetRegistrations(uint64_t matchRequestIdentifier, Vector<WebCore::ServiceWorkerRegistrationData>&&); 84 void whenRegistrationReady(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, WhenRegistrationReadyCallback&&) final; 85 void registrationReady(uint64_t callbackID, WebCore::ServiceWorkerRegistrationData&&); 84 86 85 87 void getRegistrations(const WebCore::SecurityOrigin& topOrigin, const WebCore::URL& clientURL, GetRegistrationsCallback&&) final; … … 101 103 UniqueRef<WebSWOriginTable> m_swOriginTable; 102 104 103 uint64_t m_previous MatchRegistrationTaskIdentifier { 0 };105 uint64_t m_previousCallbackIdentifier { 0 }; 104 106 HashMap<uint64_t, RegistrationCallback> m_ongoingMatchRegistrationTasks; 105 106 uint64_t m_previousGetRegistrationsTaskIdentifier { 0 };107 107 HashMap<uint64_t, GetRegistrationsCallback> m_ongoingGetRegistrationsTasks; 108 HashMap<uint64_t, WhenRegistrationReadyCallback> m_ongoingRegistrationReadyTasks; 108 109 109 110 }; // class WebSWServerConnection -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in
r225184 r225531 40 40 DidMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData> data) 41 41 DidGetRegistrations(uint64_t matchRequestIdentifier, Vector<WebCore::ServiceWorkerRegistrationData> registrations) 42 RegistrationReady(uint64_t registrationReadyRequestIdentifier, struct WebCore::ServiceWorkerRegistrationData data) 42 43 } 43 44
Note: See TracChangeset
for help on using the changeset viewer.