Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 462dacaed0ffc2326494a5299c23f613fd9d8653
      
https://github.com/WebKit/WebKit/commit/462dacaed0ffc2326494a5299c23f613fd9d8653
  Author: Ben Nham <[email protected]>
  Date:   2025-12-01 (Mon, 01 Dec 2025)

  Changed paths:
    M Source/WebCore/dom/AddEventListenerOptions.h
    M Source/WebCore/dom/AddEventListenerOptions.idl
    M Source/WebCore/dom/AddEventListenerOptionsInlines.h
    M Source/WebCore/dom/EventTarget.cpp
    M Source/WebCore/dom/RegisteredEventListener.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm

  Log Message:
  -----------
  Add webkitTrustedOnly event listener option
https://bugs.webkit.org/show_bug.cgi?id=302977
rdar://165233141

Reviewed by Sihui Liu.

This adds a webkitTrustedOnly option to addEventListener, which is similar to 
the wantsUntrusted
option supported by Gecko, except that Gecko's default for that option is 
context-dependent
(e.g. depends on whether the event listener is in a browser chrome or page 
context), whereas
webkitTrustedOnly always defaults to false (which seemed easier to reason about 
and also seemed
important for backwards compatibility).

The option prevents event listeners from firing for untrusted events. Scripts 
can already achieve a
similar effect with an early return if `!event.isTrusted`, but in some cases we 
want to avoid even
that overhead.

Currently we only support this option in the autofill world.

Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm
* Source/WebCore/dom/AddEventListenerOptions.h:
* Source/WebCore/dom/AddEventListenerOptions.idl:
* Source/WebCore/dom/AddEventListenerOptionsInlines.h:
(WebCore::AddEventListenerOptions::AddEventListenerOptions):
* Source/WebCore/dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* Source/WebCore/dom/RegisteredEventListener.h:
(WebCore::RegisteredEventListener::Options::Options):
(WebCore::RegisteredEventListener::trustedOnly const):
(WebCore::RegisteredEventListener::RegisteredEventListener):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/UserContentController.mm:
(TEST(WKUserContentController, AutoFillWorldTrustedEventHandler)):

Canonical link: https://commits.webkit.org/303686@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to