diff options
author | Ms2ger <Ms2ger@gmail.com> | 2016-09-12 16:03:46 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-09-12 16:07:25 +0200 |
commit | 3eaf1c1b899f1626fc5672eb677d2ac148533790 (patch) | |
tree | 748036ec057eb08f95dd67e76bb453f4b7fc08fd | |
parent | 6cb43f213eb775fe2468b7ba41a8a93a0351b74c (diff) | |
download | servo-3eaf1c1b899f1626fc5672eb677d2ac148533790.tar.gz servo-3eaf1c1b899f1626fc5672eb677d2ac148533790.zip |
Correct an unsound optimization in event dispatch.
-rw-r--r-- | components/script/dom/eventdispatcher.rs | 14 | ||||
-rw-r--r-- | tests/wpt/metadata/dom/events/Event-propagation.html.ini | 8 | ||||
-rw-r--r-- | tests/wpt/web-platform-tests/dom/events/Event-propagation.html | 4 |
3 files changed, 12 insertions, 14 deletions
diff --git a/components/script/dom/eventdispatcher.rs b/components/script/dom/eventdispatcher.rs index 01973e7c916..e9525f17604 100644 --- a/components/script/dom/eventdispatcher.rs +++ b/components/script/dom/eventdispatcher.rs @@ -112,19 +112,23 @@ pub fn dispatch_event(target: &EventTarget, assert_eq!(event.phase(), EventPhase::None); assert!(event.GetCurrentTarget().is_none()); + // Step 1. + event.mark_as_dispatching(); + // Step 2. event.set_target(target_override.unwrap_or(target)); if event.stop_propagation() { // If the event's stop propagation flag is set, we can skip everything because - // it prevents the calls of the invoke algorithm in the spec and we asserted - // at the beginning that steps 10-12 don't need to be executed. + // it prevents the calls of the invoke algorithm in the spec. + + // Step 10-12. + event.clear_dispatching_flags(); + + // Step 14. return !event.DefaultPrevented(); } - // Step 1. Postponed here for the reason stated above. - event.mark_as_dispatching(); - // Step 3. The "invoke" algorithm is only used on `target` separately, // so we don't put it in the path. rooted_vec!(let mut event_path); diff --git a/tests/wpt/metadata/dom/events/Event-propagation.html.ini b/tests/wpt/metadata/dom/events/Event-propagation.html.ini deleted file mode 100644 index 3c2599077fc..00000000000 --- a/tests/wpt/metadata/dom/events/Event-propagation.html.ini +++ /dev/null @@ -1,8 +0,0 @@ -[Event-propagation.html] - type: testharness - [After stopPropagation()] - expected: FAIL - - [After stopImmediatePropagation()] - expected: FAIL - diff --git a/tests/wpt/web-platform-tests/dom/events/Event-propagation.html b/tests/wpt/web-platform-tests/dom/events/Event-propagation.html index 6fc9701012b..459d45c1886 100644 --- a/tests/wpt/web-platform-tests/dom/events/Event-propagation.html +++ b/tests/wpt/web-platform-tests/dom/events/Event-propagation.html @@ -11,6 +11,9 @@ function testPropagationFlag(ev, expected, desc) { test(function() { var called = false; var callback = function() { called = true }; + this.add_cleanup(function() { + document.head.removeEventListener("foo", callback) + }); document.head.addEventListener("foo", callback); document.head.dispatchEvent(ev); assert_equals(called, expected, "Propagation flag"); @@ -18,7 +21,6 @@ function testPropagationFlag(ev, expected, desc) { // the event the second time around. document.head.dispatchEvent(ev); assert_equals(called, true, "Propagation flag after first dispatch"); - document.head.removeEventListener("foo", callback); }, desc); } |