Changeset 291888 in webkit
- Timestamp:
- Mar 25, 2022 2:19:35 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 19 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/wpt/service-workers/client-properties-worker.js (added)
-
LayoutTests/http/wpt/service-workers/client-properties.https-expected.txt (added)
-
LayoutTests/http/wpt/service-workers/client-properties.https.html (added)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Document.cpp (modified) (3 diffs)
-
Source/WebCore/dom/Document.h (modified) (3 diffs)
-
Source/WebCore/page/FocusController.cpp (modified) (2 diffs)
-
Source/WebCore/workers/service/ServiceWorkerClient.cpp (modified) (1 diff)
-
Source/WebCore/workers/service/ServiceWorkerClient.h (modified) (1 diff)
-
Source/WebCore/workers/service/ServiceWorkerClientData.cpp (modified) (2 diffs)
-
Source/WebCore/workers/service/ServiceWorkerClientData.h (modified) (3 diffs)
-
Source/WebCore/workers/service/ServiceWorkerClients.cpp (modified) (1 diff)
-
Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp (modified) (1 diff)
-
Source/WebCore/workers/service/ServiceWorkerWindowClient.h (modified) (1 diff)
-
Source/WebCore/workers/service/server/SWServer.cpp (modified) (1 diff)
-
Source/WebCore/workers/service/server/SWServer.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r291886 r291888 1 2022-03-25 Youenn Fablet <youenn@apple.com> 2 3 Add support for focused and visible ServiceWorkerWindowClient states 4 https://bugs.webkit.org/show_bug.cgi?id=238372 5 6 Reviewed by Brady Eidson. 7 8 * http/wpt/service-workers/client-properties-worker.js: Added. 9 * http/wpt/service-workers/client-properties.https-expected.txt: Added. 10 * http/wpt/service-workers/client-properties.https.html: Added. 11 1 12 2022-03-25 Devin Rousso <drousso@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/ChangeLog
r291886 r291888 1 2022-03-25 Youenn Fablet <youenn@apple.com> 2 3 Add support for focused and visible ServiceWorkerWindowClient states 4 https://bugs.webkit.org/show_bug.cgi?id=238372 5 6 Reviewed by Brady Eidson. 7 8 * web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt: 9 * web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt: 10 * web-platform-tests/service-workers/service-worker/clients-matchall-client-types.https-expected.txt: 11 * web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt: 12 * web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt: 13 1 14 2022-03-25 Devin Rousso <drousso@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt
r267647 r291888 1 1 2 2 PASS Post an extendable message from a top-level client 3 FAIL Post an extendable message from a nested client assert_equals: event `source` property `focused` expected false but got true 3 PASS Post an extendable message from a nested client 4 4 PASS Post loopback extendable messages 5 5 PASS Post extendable messages among service workers -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt
r288201 r291888 1 1 2 FAIL Test Clients.get() assert_array_equals: expected property 1 to be false but got true (expected array ["visible", false, "https://localhost:9443/service-workers/service-worker/resources/clients-get-frame.html#2", "window", "nested"] got ["visible", true, "https://localhost:9443/service-workers/service-worker/resources/clients-get-frame.html#2", "window", "nested"])2 PASS Test Clients.get() 3 3 PASS Test successful Clients.get(FetchEvent.resultingClientId) 4 4 PASS Test unsuccessful Clients.get(FetchEvent.resultingClientId) -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt
r262254 r291888 1 1 2 PASS Test Clients.matchAll() with exact controller 2 3 3 FAIL Test Clients.matchAll() with exact controller assert_array_equals: expected property 1 to be false but got true (expected array ["visible", false, "https://localhost:9443/service-workers/service-worker/resources/blank.html?clients-matchAll#2", "window", "nested"] got ["visible", true, "https://localhost:9443/service-workers/service-worker/resources/blank.html?clients-matchAll#2", "window", "nested"])4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt
r262254 r291888 1 1 2 PASS Test Clients.matchAll() 2 3 3 FAIL Test Clients.matchAll() assert_array_equals: expected property 1 to be false but got true (expected array ["visible", false, "https://localhost:9443/service-workers/service-worker/resources/blank.html?clients-matchAll#2", "window", "nested"] got ["visible", true, "https://localhost:9443/service-workers/service-worker/resources/blank.html?clients-matchAll#2", "window", "nested"])4 -
trunk/Source/WebCore/ChangeLog
r291886 r291888 1 2022-03-25 Youenn Fablet <youenn@apple.com> 2 3 Add support for focused and visible ServiceWorkerWindowClient states 4 https://bugs.webkit.org/show_bug.cgi?id=238372 5 6 Reviewed by Brady Eidson. 7 8 Add visible and focused to ServiceWorkerClientData. 9 In case document visibility or focused state changes, we push the corresponding ServiceWorkerClientData to network process. 10 11 Test: http/wpt/service-workers/client-properties.https.html 12 13 * dom/Document.cpp: 14 * dom/Document.h: 15 * page/FocusController.cpp: 16 * workers/service/ServiceWorkerClient.h: 17 * workers/service/ServiceWorkerClientData.cpp: 18 * workers/service/ServiceWorkerClientData.h: 19 * workers/service/ServiceWorkerClients.cpp: 20 * workers/service/ServiceWorkerWindowClient.cpp: 21 * workers/service/ServiceWorkerWindowClient.h: 22 1 23 2022-03-25 Devin Rousso <drousso@apple.com> 2 24 -
trunk/Source/WebCore/dom/Document.cpp
r291741 r291888 563 563 , m_quirks(makeUniqueRef<Quirks>(*this)) 564 564 , m_cachedResourceLoader(createCachedResourceLoader(frame)) 565 , m_creationURL(url) 565 566 , m_domTreeVersion(++s_globalTreeVersion) 566 567 , m_styleScope(makeUnique<Style::Scope>(*this)) … … 1864 1865 callback(); 1865 1866 } 1867 #if ENABLE(SERVICE_WORKER) 1868 updateServiceWorkerClientData(); 1869 #endif 1866 1870 } 1867 1871 … … 8767 8771 8768 8772 m_serviceWorkerConnection = serviceWorkerConnection; 8769 8773 updateServiceWorkerClientData(); 8774 } 8775 8776 void Document::updateServiceWorkerClientData() 8777 { 8770 8778 if (!m_serviceWorkerConnection) 8771 8779 return; -
trunk/Source/WebCore/dom/Document.h
r291741 r291888 709 709 const URL& urlForBindings() const { return m_url.isEmpty() ? aboutBlankURL() : m_url; } 710 710 711 const URL& creationURL() const { return m_creationURL; } 712 711 713 // To understand how these concepts relate to one another, please see the 712 714 // comments surrounding their declaration. … … 1566 1568 #if ENABLE(SERVICE_WORKER) 1567 1569 void setServiceWorkerConnection(SWClientConnection*); 1570 void updateServiceWorkerClientData(); 1568 1571 #endif 1569 1572 … … 1817 1820 // Document URLs. 1818 1821 URL m_url; // Document.URL: The URL from which this document was retrieved. 1822 URL m_creationURL; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url. 1819 1823 URL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs. 1820 1824 URL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL). -
trunk/Source/WebCore/page/FocusController.cpp
r291044 r291888 364 364 oldFrame->selection().setFocused(false); 365 365 oldFrame->document()->dispatchWindowEvent(Event::create(eventNames().blurEvent, Event::CanBubble::No, Event::IsCancelable::No)); 366 #if ENABLE(SERVICE_WORKER) 367 auto* frame = oldFrame.get(); 368 do { 369 frame->document()->updateServiceWorkerClientData(); 370 frame = frame->tree().parent(); 371 } while (frame); 372 #endif 366 373 } 367 374 … … 369 376 newFrame->selection().setFocused(true); 370 377 newFrame->document()->dispatchWindowEvent(Event::create(eventNames().focusEvent, Event::CanBubble::No, Event::IsCancelable::No)); 378 #if ENABLE(SERVICE_WORKER) 379 auto* frame = newFrame.get(); 380 do { 381 frame->document()->updateServiceWorkerClientData(); 382 frame = frame->tree().parent(); 383 } while (frame); 384 #endif 371 385 } 372 386 -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp
r281808 r291888 42 42 Ref<ServiceWorkerClient> ServiceWorkerClient::getOrCreate(ServiceWorkerGlobalScope& context, ServiceWorkerClientData&& data) 43 43 { 44 if (auto* client = context.serviceWorkerClient(data.identifier)) 44 if (auto* client = context.serviceWorkerClient(data.identifier)) { 45 // Temporary fix until we remove reusing of same ServiceWorkerClient objects. 46 client->m_data = WTFMove(data); 45 47 return *client; 48 } 46 49 47 50 if (data.type == ServiceWorkerClientType::Window) -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.h
r286012 r291888 66 66 ExceptionOr<void> postMessage(JSC::JSGlobalObject&, JSC::JSValue message, StructuredSerializeOptions&&); 67 67 68 const ServiceWorkerClientData& data() const { return m_data; } 69 68 70 protected: 69 71 ServiceWorkerClient(ServiceWorkerGlobalScope&, ServiceWorkerClientData&&); 70 72 73 private: 71 74 ServiceWorkerClientData m_data; 72 75 }; -
trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp
r291123 r291888 59 59 ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() const & 60 60 { 61 return { identifier, type, frameType, url.isolatedCopy(), lastNavigationWasAppInitiated };61 return { identifier, type, frameType, url.isolatedCopy(), lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder }; 62 62 } 63 63 64 64 ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() && 65 65 { 66 return { identifier, type, frameType, WTFMove(url).isolatedCopy(), lastNavigationWasAppInitiated };66 return { identifier, type, frameType, WTFMove(url).isolatedCopy(), lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder }; 67 67 } 68 68 … … 79 79 isDocument ? ServiceWorkerClientType::Window : ServiceWorkerClientType::Worker, 80 80 toServiceWorkerClientFrameType(context), 81 context.url(), lastNavigationWasAppInitiated 81 document.creationURL(), lastNavigationWasAppInitiated, 82 !document.hidden(), 83 document.hasFocus(), 84 0 82 85 }; 83 86 } -
trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h
r291123 r291888 47 47 URL url; 48 48 LastNavigationWasAppInitiated lastNavigationWasAppInitiated; 49 bool isVisible { false }; 50 bool isFocused { false }; 51 uint64_t focusOrder { 0 }; 49 52 50 53 ServiceWorkerClientData isolatedCopy() const &; … … 60 63 void ServiceWorkerClientData::encode(Encoder& encoder) const 61 64 { 62 encoder << identifier << type << frameType << url << lastNavigationWasAppInitiated ;65 encoder << identifier << type << frameType << url << lastNavigationWasAppInitiated << isVisible << isFocused << focusOrder; 63 66 } 64 67 … … 91 94 return std::nullopt; 92 95 93 return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url), WTFMove(*lastNavigationWasAppInitiated) } }; 96 std::optional<bool> isVisible; 97 decoder >> isVisible; 98 if (!isVisible) 99 return std::nullopt; 100 101 std::optional<bool> isFocused; 102 decoder >> isFocused; 103 if (!isFocused) 104 return std::nullopt; 105 106 std::optional<uint64_t> focusOrder; 107 decoder >> focusOrder; 108 if (!focusOrder) 109 return std::nullopt; 110 111 return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url), WTFMove(*lastNavigationWasAppInitiated), WTFMove(*isVisible), WTFMove(*isFocused), WTFMove(*focusOrder) } }; 94 112 } 95 113 -
trunk/Source/WebCore/workers/service/ServiceWorkerClients.cpp
r291003 r291888 73 73 return ServiceWorkerClient::getOrCreate(scope, WTFMove(clientData)); 74 74 }); 75 std::sort(clients.begin(), clients.end(), [&] (auto& a, auto& b) { 76 return a->data().focusOrder > b->data().focusOrder; 77 }); 75 78 promise.resolve<IDLSequence<IDLInterface<ServiceWorkerClient>>>(WTFMove(clients)); 76 79 } -
trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp
r233122 r291888 38 38 } 39 39 40 VisibilityState ServiceWorkerWindowClient::visibilityState() const41 {42 return VisibilityState::Visible;43 }44 45 bool ServiceWorkerWindowClient::isFocused() const46 {47 return true;48 }49 50 40 void ServiceWorkerWindowClient::focus(Ref<DeferredPromise>&& promise) 51 41 { -
trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h
r225760 r291888 43 43 } 44 44 45 VisibilityState visibilityState() const ;46 bool isFocused() const ;45 VisibilityState visibilityState() const { return data().isVisible ? VisibilityState::Visible : VisibilityState::Hidden; } 46 bool isFocused() const { return data().isFocused; } 47 47 48 48 void focus(Ref<DeferredPromise>&&); -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r291467 r291888 966 966 ASSERT(m_visibleClientIdToInternalClientIdMap.get(data.identifier.object().toString()) == clientIdentifier); 967 967 ASSERT(m_clientsById.contains(clientIdentifier)); 968 if (data.isFocused) 969 data.focusOrder = ++m_focusOrder; 968 970 m_clientsById.set(clientIdentifier, WTFMove(data)); 969 971 return; -
trunk/Source/WebCore/workers/service/server/SWServer.h
r291467 r291888 306 306 bool m_hasReceivedAppBoundDomains { false }; 307 307 unsigned m_uniqueRegistrationCount { 0 }; 308 uint64_t m_focusOrder { 0 }; 308 309 }; 309 310
Note: See TracChangeset
for help on using the changeset viewer.