[Webkit-unassigned] [Bug 234730] New: window event listeners callback order different in Safari than Chrome and Firefox

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 28 14:18:08 PST 2021


https://bugs.webkit.org/show_bug.cgi?id=234730

            Bug ID: 234730
           Summary: window event listeners callback order different in
                    Safari than Chrome and Firefox
           Product: WebKit
           Version: Safari 15
          Hardware: Mac (Intel)
                OS: macOS 11
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: New Bugs
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: opendarwin at lapcatsoftware.com

Created attachment 448055

  --> https://bugs.webkit.org/attachment.cgi?id=448055&action=review

Sample html demonstrating the inconsistency

The EventTarget.addEventListener() method has a boolean useCapture parameter:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#parameters

This mostly works the same in all browsers. However, it works differently in Safari for some window events such as "load" and "beforeunload":
https://developer.mozilla.org/en-US/docs/Web/API/Window#events

The target of these events is the window object itself, so technically you could say there are no capturing or bubbling event phases.

Consider the following code:

window.addEventListener("load", () => { console.log("load false"); }, false);
window.addEventListener("load", () => { console.log("load true"); }, true);
window.addEventListener("beforeunload", () => { console.log("beforeunload false"); }, false);
window.addEventListener("beforeunload", () => { console.log("beforeunload true"); }, true);

In Safari, the above useCapture true listeners are called prior to the above useCapture false listeners. However, in Chrome and Firefox, these listeners are called in the order registered, as if the useCapture parameter were irrelevant.

I won't argue which behavior is "correct". I'm just noting that Safari is inconsistent with the other browsers.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211228/3f6115c3/attachment.htm>


More information about the webkit-unassigned mailing list