Diff
Modified: trunk/LayoutTests/ChangeLog (292261 => 292262)
--- trunk/LayoutTests/ChangeLog 2022-04-02 06:33:18 UTC (rev 292261)
+++ trunk/LayoutTests/ChangeLog 2022-04-02 07:20:44 UTC (rev 292262)
@@ -1,3 +1,14 @@
+2022-04-02 Youenn Fablet <[email protected]>
+
+ Remove notifications from notification list when notification gets closed
+ https://bugs.webkit.org/show_bug.cgi?id=238665
+
+ Reviewed by Darin Adler.
+
+ * http/tests/workers/service/getnotifications-stop-expected.txt: Added.
+ * http/tests/workers/service/getnotifications-stop.html: Added.
+ * http/tests/workers/service/resources/getNotifications-iframe.html: Added.
+
2022-04-01 Alan Bujtas <[email protected]>
[CSS-contain] Update select element failures with bugzilla link.
Added: trunk/LayoutTests/http/tests/workers/service/getnotifications-stop-expected.txt (0 => 292262)
--- trunk/LayoutTests/http/tests/workers/service/getnotifications-stop-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/getnotifications-stop-expected.txt 2022-04-02 07:20:44 UTC (rev 292262)
@@ -0,0 +1,51 @@
+This tests that persistent notifications created by a service worker are visible to getNotifications() even after Notification objects are stopped
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Notification.permission is "granted"
+Got notifications
+There are 0 notifications
+
+Notification was shown
+Notification was shown
+Notification was shown
+Got notifications
+There are 3 notifications
+Title: Hello
+Body: Body1
+Tag: tag-a
+Title: There
+Body: Body2
+Tag: tag-b
+Title: Buddy
+Body: Body3
+Tag: tag-b
+
+Got notifications
+There are 1 notifications
+Title: Hello
+Body: Body1
+Tag: tag-a
+
+Got notifications
+There are 2 notifications
+Title: There
+Body: Body2
+Tag: tag-b
+Title: Buddy
+Body: Body3
+Tag: tag-b
+
+Loading iframe
+Get notifications from iframe
+Remove iframes to stop notifications
+Retrieving notifications from page registration object - 3
+Notification: Hello / Body1 / tag-a
+Notification: There / Body2 / tag-b
+Notification: Buddy / Body3 / tag-b
+Retrieving notifications from page registration object - end
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/workers/service/getnotifications-stop.html (0 => 292262)
--- trunk/LayoutTests/http/tests/workers/service/getnotifications-stop.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/getnotifications-stop.html 2022-04-02 07:20:44 UTC (rev 292262)
@@ -0,0 +1,116 @@
+<head>
+<script src=""
+<script src=""
+<script src=""
+<script>
+function failTheTest(msg)
+{
+ testFailed(msg);
+ if (testRunner)
+ testRunner.notifyDone();
+}
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.grantWebNotificationPermission(testURL);
+}
+
+description("This tests that persistent notifications created by a service worker are visible to getNotifications() even after Notification objects are stopped");
+
+shouldBeEqualToString("Notification.permission", "granted");
+
+var registration;
+async function registerServiceWorker() {
+ registration = await navigator.serviceWorker.register('resources/shownotification-worker.js');
+
+ if (!registration)
+ return testFailed("No registration");
+
+ if (registration.active) {
+ registration.active.postMessage("Start");
+ return;
+ }
+
+ var installingWorker = registration.installing;
+ if (!installingWorker)
+ failTheTest("No active *or* installing worker");
+
+ installingWorker.addEventListener("statechange", () => {
+ if (installingWorker.state === "activated") {
+ installingWorker.postMessage("getnotes");
+ }
+ });
+}
+
+var numberShown = 0;
+var numberGot = 0;
+
+function with_iframe(url) {
+ return new Promise(function(resolve) {
+ var frame = document.createElement('iframe');
+ frame.src = ""
+ frame._onload_ = function() { resolve(frame); };
+ document.body.appendChild(frame);
+ });
+}
+
+async function gotNotes(event)
+{
+ ++numberGot;
+
+ debug("Got notifications");
+ message = event.data.split('|')
+ for (var i = 1; i < message.length; ++i)
+ debug(message[i]);
+
+ if (numberGot == 1) {
+ event.source.postMessage("tryshow|Hello|Body1|tag-a");
+ event.source.postMessage("tryshow|There|Body2|tag-b");
+ event.source.postMessage("tryshow|Buddy|Body3|tag-b");
+ } else if (numberGot == 4) {
+ debug("Loading iframe");
+ const frame = await with_iframe("resources/getNotifications-iframe.html");
+ debug("Get notifications from iframe");
+ await frame.contentWindow.getNotifications();
+ debug("Remove iframes to stop notifications");
+ frame.remove();
+
+ const notifications = await registration.getNotifications({ tag: "" });
+
+ debug("Retrieving notifications from page registration object - " + notifications.length);
+ notifications.forEach(notification => {
+ debug("Notification: " + notification.title + " / " + notification.body + " / " + notification.tag);
+ });
+ debug("Retrieving notifications from page registration object - end");
+
+ testCompleted();
+ }
+}
+
+function shown(event)
+{
+ debug("Notification was shown");
+ ++numberShown;
+ if (numberShown == 2) {
+ event.source.postMessage("getnotes");
+ event.source.postMessage("getnotes|tag-a");
+ event.source.postMessage("getnotes|tag-b");
+ }
+}
+
+navigator.serviceWorker.addEventListener('message', event => {
+ var messageName = event.data.split('|')[0];
+
+ if (messageName == "gotnotes") {
+ gotNotes(event);
+ } else if (messageName == "shown") {
+ shown(event);
+ } else {
+ debug("Unexpected message: " + event.data);
+ }
+});
+
+</script>
+</head>
+<body _onload_="registerServiceWorker()">
+</body>
Added: trunk/LayoutTests/http/tests/workers/service/resources/getNotifications-iframe.html (0 => 292262)
--- trunk/LayoutTests/http/tests/workers/service/resources/getNotifications-iframe.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/getNotifications-iframe.html 2022-04-02 07:20:44 UTC (rev 292262)
@@ -0,0 +1,11 @@
+<head>
+<script>
+async function getNotifications()
+{
+ const registration = await navigator.serviceWorker.register('shownotification-worker.js');
+ return registration.getNotifications({ tag: "" });
+}
+</script>
+</head>
+<body>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (292261 => 292262)
--- trunk/Source/WebCore/ChangeLog 2022-04-02 06:33:18 UTC (rev 292261)
+++ trunk/Source/WebCore/ChangeLog 2022-04-02 07:20:44 UTC (rev 292262)
@@ -1,3 +1,16 @@
+2022-04-02 Youenn Fablet <[email protected]>
+
+ Remove notifications from notification list when notification gets closed
+ https://bugs.webkit.org/show_bug.cgi?id=238665
+
+ Reviewed by Darin Adler.
+
+ Test: http/tests/workers/service/getnotifications-stop.html
+
+ * Modules/notifications/Notification.cpp:
+ (WebCore::Notification::stop):
+ Do not destroy persistent permissions when the JS object gets stopped.
+
2022-04-01 Michael Saboff <[email protected]>
Stop copying StagedFrameworks to the secondary path by default
Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (292261 => 292262)
--- trunk/Source/WebCore/Modules/notifications/Notification.cpp 2022-04-02 06:33:18 UTC (rev 292261)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp 2022-04-02 07:20:44 UTC (rev 292262)
@@ -200,6 +200,9 @@
{
ActiveDOMObject::stop();
+ if (!m_serviceWorkerRegistrationURL.isNull())
+ return;
+
if (auto* client = clientFromContext())
client->notificationObjectDestroyed(*this);
}
Modified: trunk/Source/WebKit/ChangeLog (292261 => 292262)
--- trunk/Source/WebKit/ChangeLog 2022-04-02 06:33:18 UTC (rev 292261)
+++ trunk/Source/WebKit/ChangeLog 2022-04-02 07:20:44 UTC (rev 292262)
@@ -1,3 +1,16 @@
+2022-04-02 Youenn Fablet <[email protected]>
+
+ Remove notifications from notification list when notification gets closed
+ https://bugs.webkit.org/show_bug.cgi?id=238665
+
+ Reviewed by Darin Adler.
+
+ Cancelling a notification should trigger the close steps, which means removing the notification from the notification list.
+
+ * UIProcess/Notifications/WebNotificationManagerProxy.cpp:
+ (WebKit::WebNotificationManagerProxy::cancel):
+ (WebKit::WebNotificationManagerProxy::didDestroyNotification):
+
2022-04-01 Wenson Hsieh <[email protected]>
[iOS] WKFullScreenWindowController's UIViewController leaks after entering element fullscreen
Modified: trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp (292261 => 292262)
--- trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2022-04-02 06:33:18 UTC (rev 292261)
+++ trunk/Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp 2022-04-02 07:20:44 UTC (rev 292262)
@@ -112,10 +112,12 @@
m_provider->show(webPage, notification.get());
}
-void WebNotificationManagerProxy::cancel(WebPageProxy*, const UUID& pageNotificationID)
+void WebNotificationManagerProxy::cancel(WebPageProxy* page, const UUID& pageNotificationID)
{
- if (auto webNotification = m_notifications.get(pageNotificationID))
+ if (auto webNotification = m_notifications.get(pageNotificationID)) {
m_provider->cancel(*webNotification);
+ didDestroyNotification(page, pageNotificationID);
+ }
}
void WebNotificationManagerProxy::didDestroyNotification(WebPageProxy*, const UUID& pageNotificationID)