Title: [260556] trunk
Revision
260556
Author
[email protected]
Date
2020-04-22 21:56:44 -0700 (Wed, 22 Apr 2020)

Log Message

Unreviewed, reverting r260535.
https://bugs.webkit.org/show_bug.cgi?id=210897

Causes crashes in WK1 (Requested by smfr on #webkit).

Reverted changeset:

"[ Mac wk2 ] imported/w3c/web-platform-tests/notifications
/event-onclose.html is flaky failing."
https://bugs.webkit.org/show_bug.cgi?id=209483
https://trac.webkit.org/changeset/260535

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (260555 => 260556)


--- trunk/LayoutTests/ChangeLog	2020-04-23 04:46:14 UTC (rev 260555)
+++ trunk/LayoutTests/ChangeLog	2020-04-23 04:56:44 UTC (rev 260556)
@@ -1,3 +1,17 @@
+2020-04-22  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r260535.
+        https://bugs.webkit.org/show_bug.cgi?id=210897
+
+        Causes crashes in WK1 (Requested by smfr on #webkit).
+
+        Reverted changeset:
+
+        "[ Mac wk2 ] imported/w3c/web-platform-tests/notifications
+        /event-onclose.html is flaky failing."
+        https://bugs.webkit.org/show_bug.cgi?id=209483
+        https://trac.webkit.org/changeset/260535
+
 2020-04-22  Diego Pino Garcia  <[email protected]>
 
         [GTK] Gardening, update test expectations

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (260555 => 260556)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2020-04-23 04:46:14 UTC (rev 260555)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2020-04-23 04:56:44 UTC (rev 260556)
@@ -1028,6 +1028,8 @@
 
 webkit.org/b/209295 [ Debug ] imported/w3c/web-platform-tests/service-workers/service-worker/respond-with-body-accessed-response.https.html  [ Pass Failure ]
 
+webkit.org/b/209483 imported/w3c/web-platform-tests/notifications/event-onclose.html [ Pass Failure ]
+
 webkit.org/b/209503 [ Debug ] http/tests/referrer-policy-anchor/origin/cross-origin-http.https.html [ Pass Crash ]
 
 webkit.org/b/209564 svg/as-image/svg-image-with-data-uri-background.html [ Pass ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (260555 => 260556)


--- trunk/Source/WebCore/ChangeLog	2020-04-23 04:46:14 UTC (rev 260555)
+++ trunk/Source/WebCore/ChangeLog	2020-04-23 04:56:44 UTC (rev 260556)
@@ -1,3 +1,17 @@
+2020-04-22  Commit Queue  <[email protected]>
+
+        Unreviewed, reverting r260535.
+        https://bugs.webkit.org/show_bug.cgi?id=210897
+
+        Causes crashes in WK1 (Requested by smfr on #webkit).
+
+        Reverted changeset:
+
+        "[ Mac wk2 ] imported/w3c/web-platform-tests/notifications
+        /event-onclose.html is flaky failing."
+        https://bugs.webkit.org/show_bug.cgi?id=209483
+        https://trac.webkit.org/changeset/260535
+
 2020-04-22  Darin Adler  <[email protected]>
 
         [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK

Modified: trunk/Source/WebCore/Modules/notifications/Notification.cpp (260555 => 260556)


--- trunk/Source/WebCore/Modules/notifications/Notification.cpp	2020-04-23 04:46:14 UTC (rev 260555)
+++ trunk/Source/WebCore/Modules/notifications/Notification.cpp	2020-04-23 04:56:44 UTC (rev 260556)
@@ -64,6 +64,7 @@
     , m_body(options.body)
     , m_tag(options.tag)
     , m_state(Idle)
+    , m_showNotificationTimer(&document, *this, &Notification::show)
 {
     if (!options.icon.isEmpty()) {
         auto iconURL = document.completeURL(options.icon);
@@ -71,9 +72,8 @@
             m_icon = iconURL;
     }
 
-    queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this] {
-        show();
-    });
+    m_showNotificationTimer.startOneShot(0_s);
+    m_showNotificationTimer.suspendIfNeeded();
 }
 
 Notification::~Notification() = default;
@@ -94,8 +94,10 @@
         dispatchErrorEvent();
         return;
     }
-    if (client.show(this))
+    if (client.show(this)) {
         m_state = Showing;
+        setPendingActivity(*this);
+    }
 }
 
 void Notification::close()
@@ -141,16 +143,28 @@
     if (m_state == Closed)
         return;
     m_state = Closed;
+    unsetPendingActivity(*this);
 }
 
+void Notification::queueTask(Function<void()>&& task)
+{
+    auto* document = this->document();
+    if (!document)
+        return;
+
+    document->eventLoop().queueTask(TaskSource::UserInteraction, WTFMove(task));
+}
+
 void Notification::dispatchShowEvent()
 {
-    queueTaskToDispatchEvent(*this, TaskSource::UserInteraction, Event::create(eventNames().showEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    queueTask([this, pendingActivity = makePendingActivity(*this)] {
+        dispatchEvent(Event::create(eventNames().showEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    });
 }
 
 void Notification::dispatchClickEvent()
 {
-    queueTaskKeepingObjectAlive(*this, TaskSource::UserInteraction, [this] {
+    queueTask([this, pendingActivity = makePendingActivity(*this)] {
         WindowFocusAllowedIndicator windowFocusAllowed;
         dispatchEvent(Event::create(eventNames().clickEvent, Event::CanBubble::No, Event::IsCancelable::No));
     });
@@ -158,13 +172,17 @@
 
 void Notification::dispatchCloseEvent()
 {
-    queueTaskToDispatchEvent(*this, TaskSource::UserInteraction, Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    queueTask([this, pendingActivity = makePendingActivity(*this)] {
+        dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    });
     finalize();
 }
 
 void Notification::dispatchErrorEvent()
 {
-    queueTaskToDispatchEvent(*this, TaskSource::UserInteraction, Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    queueTask([this, pendingActivity = makePendingActivity(*this)] {
+        dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    });
 }
 
 auto Notification::permission(Document& document) -> Permission
@@ -197,22 +215,6 @@
     NotificationController::from(page)->client().requestPermission(&document, WTFMove(callback));
 }
 
-void Notification::eventListenersDidChange()
-{
-    m_hasRelevantEventListener = hasEventListeners(eventNames().clickEvent)
-        || hasEventListeners(eventNames().closeEvent)
-        || hasEventListeners(eventNames().errorEvent)
-        || hasEventListeners(eventNames().showEvent);
-}
-
-// A Notification object must not be garbage collected while the list of notifications contains its corresponding
-// notification and it has an event listener whose type is click, show, close, or error.
-// See https://notifications.spec.whatwg.org/#garbage-collection
-bool Notification::virtualHasPendingActivity() const
-{
-    return m_state == Showing && m_hasRelevantEventListener;
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(NOTIFICATIONS)

Modified: trunk/Source/WebCore/Modules/notifications/Notification.h (260555 => 260556)


--- trunk/Source/WebCore/Modules/notifications/Notification.h	2020-04-23 04:46:14 UTC (rev 260555)
+++ trunk/Source/WebCore/Modules/notifications/Notification.h	2020-04-23 04:56:44 UTC (rev 260556)
@@ -37,6 +37,7 @@
 #include "EventTarget.h"
 #include "NotificationDirection.h"
 #include "NotificationPermission.h"
+#include "SuspendableTimer.h"
 #include <wtf/URL.h>
 #include "WritingMode.h"
 
@@ -95,16 +96,15 @@
     Document* document() const;
     EventTargetInterface eventTargetInterface() const final { return NotificationEventTargetInterfaceType; }
 
+    void queueTask(Function<void()>&&);
+
     // ActiveDOMObject
     const char* activeDOMObjectName() const final;
     void suspend(ReasonForSuspension);
     void stop() final;
-    bool virtualHasPendingActivity() const final;
 
-    // EventTarget
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
-    void eventListenersDidChange() final;
 
     String m_title;
     Direction m_direction;
@@ -115,7 +115,8 @@
 
     enum State { Idle, Showing, Closed };
     State m_state { Idle };
-    bool m_hasRelevantEventListener { false };
+
+    SuspendableTimer m_showNotificationTimer;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to