Skip to content

Truly independent web browser

LibWeb: Keep the event target when propagating to non-node parents

Andreas Kling4146a280dbb3
diff --git a/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Libraries/LibWeb/DOM/EventDispatcher.cpp
index 29965db25a3..9dddd593f06 100644
--- a/Libraries/LibWeb/DOM/EventDispatcher.cpp
+++ b/Libraries/LibWeb/DOM/EventDispatcher.cpp
@@ -347,7 +347,11 @@ bool EventDispatcher::dispatch(GC::Ref<EventTarget> target, Event& event, bool l
}
// 6. If parent is a Window object, or parent is a node and target’s root is a shadow-including inclusive ancestor of parent, then:
+ // INTEROP: A parent that is neither a Window object nor a node, such as the transaction and the connection
+ // an IndexedDB request propagates its events to, is handled like a Window object too. This keeps
+ // the event's target as it propagates, as other browsers do.
if (is<HTML::Window>(parent)
+ || !is<Node>(parent)
|| (is<Node>(parent) && as<Node>(*target).root().is_shadow_including_inclusive_ancestor_of(as<Node>(*parent)))) {
// 1. If isActivationEvent is true, event’s bubbles attribute is true, activationTarget is null, and parent has activation behavior, then set activationTarget to parent.
if (is_activation_event && event.bubbles() && !activation_target && parent->has_activation_behavior())
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.txt
index a707ef583af..ab700fa0955 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.txt
@@ -2,15 +2,15 @@ Harness status: OK
Found 21 tests
-18 Pass
-3 Fail
+20 Pass
+1 Fail
Pass Returns an IDBIndex and the properties are set correctly
Pass Attempt to create an index that requires unique values on an object store already contains duplicates
Pass The index is usable right after being made
Fail Event ordering for a later deleted index
Pass Empty keyPath
-Fail Event order when unique constraint is triggered
-Fail Event ordering for ConstraintError on request
+Pass Event order when unique constraint is triggered
+Pass Event ordering for ConstraintError on request
Pass Index can be valid keys
Pass IDBObjectStore.createIndex() - empty name
Pass If an index with the name name already exists in this object store, the implementation must throw a DOMException of type ConstraintError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt
index a707ef583af..ab700fa0955 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt
@@ -2,15 +2,15 @@ Harness status: OK
Found 21 tests
-18 Pass
-3 Fail
+20 Pass
+1 Fail
Pass Returns an IDBIndex and the properties are set correctly
Pass Attempt to create an index that requires unique values on an object store already contains duplicates
Pass The index is usable right after being made
Fail Event ordering for a later deleted index
Pass Empty keyPath
-Fail Event order when unique constraint is triggered
-Fail Event ordering for ConstraintError on request
+Pass Event order when unique constraint is triggered
+Pass Event ordering for ConstraintError on request
Pass Index can be valid keys
Pass IDBObjectStore.createIndex() - empty name
Pass If an index with the name name already exists in this object store, the implementation must throw a DOMException of type ConstraintError
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.sharedworker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.sharedworker.txt
index f82ff137842..fda124c14f9 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.sharedworker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.sharedworker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail IndexedDB Request Event Propagation: Bubbling and Capturing
\ No newline at end of file
+1 Pass
+Pass IndexedDB Request Event Propagation: Bubbling and Capturing
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.txt
index f82ff137842..fda124c14f9 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail IndexedDB Request Event Propagation: Bubbling and Capturing
\ No newline at end of file
+1 Pass
+Pass IndexedDB Request Event Propagation: Bubbling and Capturing
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.worker.txt
index f82ff137842..fda124c14f9 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/request_bubble-and-capture.any.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail IndexedDB Request Event Propagation: Bubbling and Capturing
\ No newline at end of file
+1 Pass
+Pass IndexedDB Request Event Propagation: Bubbling and Capturing
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.sharedworker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.sharedworker.txt
index f4e6f747ca6..1376d7962a2 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.sharedworker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.sharedworker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Properties of error events fired at requests when aborting a transaction
\ No newline at end of file
+1 Pass
+Pass Properties of error events fired at requests when aborting a transaction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.txt
index f4e6f747ca6..1376d7962a2 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Properties of error events fired at requests when aborting a transaction
\ No newline at end of file
+1 Pass
+Pass Properties of error events fired at requests when aborting a transaction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.worker.txt
index f4e6f747ca6..1376d7962a2 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-request-error.any.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Properties of error events fired at requests when aborting a transaction
\ No newline at end of file
+1 Pass
+Pass Properties of error events fired at requests when aborting a transaction
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.sharedworker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.sharedworker.txt
index d4505b2ffd9..539172f5918 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.sharedworker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.sharedworker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Capture and bubble
\ No newline at end of file
+1 Pass
+Pass Capture and bubble
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.txt
index d4505b2ffd9..539172f5918 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Capture and bubble
\ No newline at end of file
+1 Pass
+Pass Capture and bubble
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.worker.txt
index d4505b2ffd9..539172f5918 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.worker.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction_bubble-and-capture.any.worker.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Capture and bubble
\ No newline at end of file
+1 Pass
+Pass Capture and bubble
\ No newline at end of file