Title: [291888] trunk
Revision
291888
Author
[email protected]
Date
2022-03-25 14:19:35 -0700 (Fri, 25 Mar 2022)

Log Message

Add support for focused and visible ServiceWorkerWindowClient states
https://bugs.webkit.org/show_bug.cgi?id=238372

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt:
* web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt:
* web-platform-tests/service-workers/service-worker/clients-matchall-client-types.https-expected.txt:
* web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt:
* web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt:

Source/WebCore:

Add visible and focused to ServiceWorkerClientData.
In case document visibility or focused state changes, we push the corresponding ServiceWorkerClientData to network process.

Test: http/wpt/service-workers/client-properties.https.html

* dom/Document.cpp:
* dom/Document.h:
* page/FocusController.cpp:
* workers/service/ServiceWorkerClient.h:
* workers/service/ServiceWorkerClientData.cpp:
* workers/service/ServiceWorkerClientData.h:
* workers/service/ServiceWorkerClients.cpp:
* workers/service/ServiceWorkerWindowClient.cpp:
* workers/service/ServiceWorkerWindowClient.h:

LayoutTests:

* http/wpt/service-workers/client-properties-worker.js: Added.
* http/wpt/service-workers/client-properties.https-expected.txt: Added.
* http/wpt/service-workers/client-properties.https.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291887 => 291888)


--- trunk/LayoutTests/ChangeLog	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/LayoutTests/ChangeLog	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,3 +1,14 @@
+2022-03-25  Youenn Fablet  <[email protected]>
+
+        Add support for focused and visible ServiceWorkerWindowClient states
+        https://bugs.webkit.org/show_bug.cgi?id=238372
+
+        Reviewed by Brady Eidson.
+
+        * http/wpt/service-workers/client-properties-worker.js: Added.
+        * http/wpt/service-workers/client-properties.https-expected.txt: Added.
+        * http/wpt/service-workers/client-properties.https.html: Added.
+
 2022-03-25  Devin Rousso  <[email protected]>
 
         `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)

Added: trunk/LayoutTests/http/wpt/service-workers/client-properties-worker.js (0 => 291888)


--- trunk/LayoutTests/http/wpt/service-workers/client-properties-worker.js	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/client-properties-worker.js	2022-03-25 21:19:35 UTC (rev 291888)
@@ -0,0 +1,10 @@
+async function doTest(event)
+{
+    let data = ""
+    const currentClients = await self.clients.matchAll({includeUncontrolled: true});
+    for (let client of currentClients) {
+        data.push({id:client.id, visibilityState:client.visibilityState, focused:client.focused, frameType:client.frameType });
+    }
+    event.source.postMessage(data);
+}
+self.addEventListener("message", doTest);

Added: trunk/LayoutTests/http/wpt/service-workers/client-properties.https-expected.txt (0 => 291888)


--- trunk/LayoutTests/http/wpt/service-workers/client-properties.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/client-properties.https-expected.txt	2022-03-25 21:19:35 UTC (rev 291888)
@@ -0,0 +1,5 @@
+
+PASS Setup worker
+PASS Test self as client
+PASS Test hidden self as client
+

Added: trunk/LayoutTests/http/wpt/service-workers/client-properties.https.html (0 => 291888)


--- trunk/LayoutTests/http/wpt/service-workers/client-properties.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/service-workers/client-properties.https.html	2022-03-25 21:19:35 UTC (rev 291888)
@@ -0,0 +1,47 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+var scope = "";
+var activeWorker;
+
+promise_test(async (test) => {
+    var registration = await navigator.serviceWorker.register("client-properties-worker.js", { scope : scope });
+    activeWorker = registration.active;
+    if (activeWorker)
+        return;
+    activeWorker = registration.installing;
+    return new Promise(resolve => {
+        activeWorker.addEventListener('statechange', () => {
+            if (activeWorker.state === "activated")
+                resolve();
+        });
+    });
+}, "Setup worker");
+
+promise_test(async (test) => {
+    if (document.hidden)
+        await new Promise(resolve => document.visibilityChange = resolve);
+    activeWorker.postMessage("test");
+    const data = "" new Promise(resolve => navigator.serviceWorker._onmessage_ = (event) => resolve(event.data));
+    assert_equals(data.length, 1);
+    assert_equals(data[0].frameType, "top-level");
+    assert_equals(data[0].visibilityState, "visible");
+    assert_true(data[0].focused, "focused");
+}, "Test self as client");
+
+promise_test(async (test) => {
+    if (!window.internals)
+        return;
+
+    internals.setPageVisibility(false);
+    activeWorker.postMessage("test");
+    const data = "" new Promise(resolve => navigator.serviceWorker._onmessage_ = (event) => resolve(event.data));
+    assert_equals(data[0].visibilityState, "hidden");
+}, "Test hidden self as client");
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (291887 => 291888)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,3 +1,16 @@
+2022-03-25  Youenn Fablet  <[email protected]>
+
+        Add support for focused and visible ServiceWorkerWindowClient states
+        https://bugs.webkit.org/show_bug.cgi?id=238372
+
+        Reviewed by Brady Eidson.
+
+        * web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/clients-matchall-client-types.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt:
+
 2022-03-25  Devin Rousso  <[email protected]>
 
         `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt (291887 => 291888)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/extendable-message-event.https-expected.txt	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,6 +1,6 @@
 
 PASS Post an extendable message from a top-level client
-FAIL Post an extendable message from a nested client assert_equals: event `source` property `focused` expected false but got true
+PASS Post an extendable message from a nested client
 PASS Post loopback extendable messages
 PASS Post extendable messages among service workers
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt (291887 => 291888)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-get.https-expected.txt	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,5 +1,5 @@
 
-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"])
+PASS Test Clients.get()
 PASS Test successful Clients.get(FetchEvent.resultingClientId)
 PASS Test unsuccessful Clients.get(FetchEvent.resultingClientId)
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt (291887 => 291888)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall-exact-controller.https-expected.txt	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,4 +1,3 @@
 
+PASS Test Clients.matchAll() with exact controller
 
-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"])
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt (291887 => 291888)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/clients-matchall.https-expected.txt	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,4 +1,3 @@
 
+PASS Test Clients.matchAll()
 
-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"])
-

Modified: trunk/Source/WebCore/ChangeLog (291887 => 291888)


--- trunk/Source/WebCore/ChangeLog	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/ChangeLog	2022-03-25 21:19:35 UTC (rev 291888)
@@ -1,3 +1,25 @@
+2022-03-25  Youenn Fablet  <[email protected]>
+
+        Add support for focused and visible ServiceWorkerWindowClient states
+        https://bugs.webkit.org/show_bug.cgi?id=238372
+
+        Reviewed by Brady Eidson.
+
+        Add visible and focused to ServiceWorkerClientData.
+        In case document visibility or focused state changes, we push the corresponding ServiceWorkerClientData to network process.
+
+        Test: http/wpt/service-workers/client-properties.https.html
+
+        * dom/Document.cpp:
+        * dom/Document.h:
+        * page/FocusController.cpp:
+        * workers/service/ServiceWorkerClient.h:
+        * workers/service/ServiceWorkerClientData.cpp:
+        * workers/service/ServiceWorkerClientData.h:
+        * workers/service/ServiceWorkerClients.cpp:
+        * workers/service/ServiceWorkerWindowClient.cpp:
+        * workers/service/ServiceWorkerWindowClient.h:
+
 2022-03-25  Devin Rousso  <[email protected]>
 
         `PointerEvent.movementX` always 0 (breaks https://noisecraft.app/)

Modified: trunk/Source/WebCore/dom/Document.cpp (291887 => 291888)


--- trunk/Source/WebCore/dom/Document.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -562,6 +562,7 @@
     , m_settings(settings)
     , m_quirks(makeUniqueRef<Quirks>(*this))
     , m_cachedResourceLoader(createCachedResourceLoader(frame))
+    , m_creationURL(url)
     , m_domTreeVersion(++s_globalTreeVersion)
     , m_styleScope(makeUnique<Style::Scope>(*this))
     , m_extensionStyleSheets(makeUnique<ExtensionStyleSheets>(*this))
@@ -1863,6 +1864,9 @@
         for (auto& callback : callbacks)
             callback();
     }
+#if ENABLE(SERVICE_WORKER)
+    updateServiceWorkerClientData();
+#endif
 }
 
 VisibilityState Document::visibilityState() const
@@ -8766,7 +8770,11 @@
         m_serviceWorkerConnection->unregisterServiceWorkerClient(identifier());
 
     m_serviceWorkerConnection = serviceWorkerConnection;
+    updateServiceWorkerClientData();
+}
 
+void Document::updateServiceWorkerClientData()
+{
     if (!m_serviceWorkerConnection)
         return;
 

Modified: trunk/Source/WebCore/dom/Document.h (291887 => 291888)


--- trunk/Source/WebCore/dom/Document.h	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/dom/Document.h	2022-03-25 21:19:35 UTC (rev 291888)
@@ -708,6 +708,8 @@
     void setURL(const URL&);
     const URL& urlForBindings() const { return m_url.isEmpty() ? aboutBlankURL() : m_url; }
 
+    const URL& creationURL() const { return m_creationURL; }
+
     // To understand how these concepts relate to one another, please see the
     // comments surrounding their declaration.
     const URL& baseURL() const { return m_baseURL; }
@@ -1565,6 +1567,7 @@
 
 #if ENABLE(SERVICE_WORKER)
     void setServiceWorkerConnection(SWClientConnection*);
+    void updateServiceWorkerClientData();
 #endif
 
 #if ENABLE(VIDEO)
@@ -1816,6 +1819,7 @@
 
     // Document URLs.
     URL m_url; // Document.URL: The URL from which this document was retrieved.
+    URL m_creationURL; // https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url.
     URL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs.
     URL m_baseURLOverride; // An alternative base URL that takes precedence over m_baseURL (but not m_baseElementURL).
     URL m_baseElementURL; // The URL set by the <base> element.

Modified: trunk/Source/WebCore/page/FocusController.cpp (291887 => 291888)


--- trunk/Source/WebCore/page/FocusController.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/page/FocusController.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -363,11 +363,25 @@
         oldFrameView->stopKeyboardScrollAnimation();
         oldFrame->selection().setFocused(false);
         oldFrame->document()->dispatchWindowEvent(Event::create(eventNames().blurEvent, Event::CanBubble::No, Event::IsCancelable::No));
+#if ENABLE(SERVICE_WORKER)
+        auto* frame = oldFrame.get();
+        do {
+            frame->document()->updateServiceWorkerClientData();
+            frame = frame->tree().parent();
+        } while (frame);
+#endif
     }
 
     if (newFrame && newFrame->view() && isFocused()) {
         newFrame->selection().setFocused(true);
         newFrame->document()->dispatchWindowEvent(Event::create(eventNames().focusEvent, Event::CanBubble::No, Event::IsCancelable::No));
+#if ENABLE(SERVICE_WORKER)
+        auto* frame = newFrame.get();
+        do {
+            frame->document()->updateServiceWorkerClientData();
+            frame = frame->tree().parent();
+        } while (frame);
+#endif
     }
 
     m_page.chrome().focusedFrameChanged(newFrame.get());

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -41,8 +41,11 @@
 
 Ref<ServiceWorkerClient> ServiceWorkerClient::getOrCreate(ServiceWorkerGlobalScope& context, ServiceWorkerClientData&& data)
 {
-    if (auto* client = context.serviceWorkerClient(data.identifier))
+    if (auto* client = context.serviceWorkerClient(data.identifier)) {
+        // Temporary fix until we remove reusing of same ServiceWorkerClient objects.
+        client->m_data = WTFMove(data);
         return *client;
+    }
 
     if (data.type == ServiceWorkerClientType::Window)
         return ServiceWorkerWindowClient::create(context, WTFMove(data));

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.h (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.h	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.h	2022-03-25 21:19:35 UTC (rev 291888)
@@ -65,9 +65,12 @@
 
     ExceptionOr<void> postMessage(JSC::JSGlobalObject&, JSC::JSValue message, StructuredSerializeOptions&&);
 
+    const ServiceWorkerClientData& data() const { return m_data; }
+
 protected:
     ServiceWorkerClient(ServiceWorkerGlobalScope&, ServiceWorkerClientData&&);
 
+private:
     ServiceWorkerClientData m_data;
 };
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientData.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -58,12 +58,12 @@
 
 ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() const &
 {
-    return { identifier, type, frameType, url.isolatedCopy(), lastNavigationWasAppInitiated };
+    return { identifier, type, frameType, url.isolatedCopy(), lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder };
 }
 
 ServiceWorkerClientData ServiceWorkerClientData::isolatedCopy() &&
 {
-    return { identifier, type, frameType, WTFMove(url).isolatedCopy(), lastNavigationWasAppInitiated };
+    return { identifier, type, frameType, WTFMove(url).isolatedCopy(), lastNavigationWasAppInitiated, isVisible, isFocused, focusOrder };
 }
 
 ServiceWorkerClientData ServiceWorkerClientData::from(ScriptExecutionContext& context)
@@ -78,7 +78,10 @@
         context.identifier(),
         isDocument ? ServiceWorkerClientType::Window : ServiceWorkerClientType::Worker,
         toServiceWorkerClientFrameType(context),
-        context.url(), lastNavigationWasAppInitiated
+        document.creationURL(), lastNavigationWasAppInitiated,
+        !document.hidden(),
+        document.hasFocus(),
+        0
     };
 }
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClientData.h	2022-03-25 21:19:35 UTC (rev 291888)
@@ -46,6 +46,9 @@
     ServiceWorkerClientFrameType frameType;
     URL url;
     LastNavigationWasAppInitiated lastNavigationWasAppInitiated;
+    bool isVisible { false };
+    bool isFocused { false };
+    uint64_t focusOrder { 0 };
 
     ServiceWorkerClientData isolatedCopy() const &;
     ServiceWorkerClientData isolatedCopy() &&;
@@ -59,7 +62,7 @@
 template<class Encoder>
 void ServiceWorkerClientData::encode(Encoder& encoder) const
 {
-    encoder << identifier << type << frameType << url << lastNavigationWasAppInitiated;
+    encoder << identifier << type << frameType << url << lastNavigationWasAppInitiated << isVisible << isFocused << focusOrder;
 }
 
 template<class Decoder>
@@ -90,7 +93,22 @@
     if (!lastNavigationWasAppInitiated)
         return std::nullopt;
 
-    return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url), WTFMove(*lastNavigationWasAppInitiated) } };
+    std::optional<bool> isVisible;
+    decoder >> isVisible;
+    if (!isVisible)
+        return std::nullopt;
+
+    std::optional<bool> isFocused;
+    decoder >> isFocused;
+    if (!isFocused)
+        return std::nullopt;
+
+    std::optional<uint64_t> focusOrder;
+    decoder >> focusOrder;
+    if (!focusOrder)
+        return std::nullopt;
+
+    return { { WTFMove(*identifier), WTFMove(*type), WTFMove(*frameType), WTFMove(*url), WTFMove(*lastNavigationWasAppInitiated), WTFMove(*isVisible), WTFMove(*isFocused), WTFMove(*focusOrder) } };
 }
 
 using ServiceWorkerClientsMatchAllCallback = CompletionHandler<void(Vector<ServiceWorkerClientData>&&)>;

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClients.cpp (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerClients.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClients.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -72,6 +72,9 @@
     auto clients = WTF::map(clientsData, [&] (auto&& clientData) {
         return ServiceWorkerClient::getOrCreate(scope, WTFMove(clientData));
     });
+    std::sort(clients.begin(), clients.end(), [&] (auto& a, auto& b) {
+        return a->data().focusOrder > b->data().focusOrder;
+    });
     promise.resolve<IDLSequence<IDLInterface<ServiceWorkerClient>>>(WTFMove(clients));
 }
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -37,16 +37,6 @@
 {
 }
 
-VisibilityState ServiceWorkerWindowClient::visibilityState() const
-{
-    return VisibilityState::Visible;
-}
-
-bool ServiceWorkerWindowClient::isFocused() const
-{
-    return true;
-}
-
 void ServiceWorkerWindowClient::focus(Ref<DeferredPromise>&& promise)
 {
     promise->reject(Exception { NotSupportedError, "windowClient.focus() is not yet supported"_s });

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h (291887 => 291888)


--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h	2022-03-25 21:19:35 UTC (rev 291888)
@@ -42,8 +42,8 @@
         return adoptRef(*new ServiceWorkerWindowClient(context, WTFMove(data)));
     }
 
-    VisibilityState visibilityState() const;
-    bool isFocused() const;
+    VisibilityState visibilityState() const { return data().isVisible ? VisibilityState::Visible : VisibilityState::Hidden; }
+    bool isFocused() const { return data().isFocused; }
 
     void focus(Ref<DeferredPromise>&&);
     void navigate(const String& url, Ref<DeferredPromise>&&);

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (291887 => 291888)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2022-03-25 21:19:35 UTC (rev 291888)
@@ -965,6 +965,8 @@
     if (!addResult.isNewEntry) {
         ASSERT(m_visibleClientIdToInternalClientIdMap.get(data.identifier.object().toString()) == clientIdentifier);
         ASSERT(m_clientsById.contains(clientIdentifier));
+        if (data.isFocused)
+            data.focusOrder = ++m_focusOrder;
         m_clientsById.set(clientIdentifier, WTFMove(data));
         return;
     }

Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (291887 => 291888)


--- trunk/Source/WebCore/workers/service/server/SWServer.h	2022-03-25 21:02:20 UTC (rev 291887)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h	2022-03-25 21:19:35 UTC (rev 291888)
@@ -305,6 +305,7 @@
     bool m_hasServiceWorkerEntitlement { false };
     bool m_hasReceivedAppBoundDomains { false };
     unsigned m_uniqueRegistrationCount { 0 };
+    uint64_t m_focusOrder { 0 };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to