mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibWeb: Make “create an event” set the event’s isTrusted to true
This change ensures that when then the code corresponding to the “create an event” operation at https://dom.spec.whatwg.org/#concept-event-create is called, the event’s isTrusted is set to true — as the spec requires. That causes the failures for the following WPT tests to pass: - https://wpt.fyi/results/html/semantics/forms/the-input-element/checkbox.html?run_id=5080423051034624 - https://wpt.fyi/results/html/semantics/interactive-elements/the-dialog-element/dialog-close.html?run_id=5080423051034624 …and there are likely a number of similar WPT tests that hit this same code path which this commit will cause to be changed to passes. Otherwise, without this change, the “create event” implementation doesn’t conform to the spec requirements – nor behave interoperably with other existing engines — and those WPT test would continue to fail. This change also ensures that isTrusted continues to be set to false for synthetic events.
This commit is contained in:
parent
5800b7e884
commit
1975640e31
Notes:
github-actions[bot]
2024-09-03 06:15:27 +00:00
Author: https://github.com/sideshowbarker Commit: https://github.com/LadybirdBrowser/ladybird/commit/1975640e31c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1227 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/trflynn89
3 changed files with 13 additions and 2 deletions
|
@ -0,0 +1 @@
|
|||
new Event('x').isTrusted is false
|
|
@ -0,0 +1,6 @@
|
|||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
println(`new Event('x').isTrusted is ${new Event('x').isTrusted}`);
|
||||
});
|
||||
</script>
|
|
@ -18,14 +18,18 @@ namespace Web::DOM {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(Event);
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-event-create
|
||||
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
auto event = realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
// 4. Initialize event’s isTrusted attribute to true.
|
||||
event->m_is_trusted = true;
|
||||
return event;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
return realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#inner-event-creation-steps
|
||||
|
|
Loading…
Reference in a new issue