Bug 1332699 - Don't check handler of legacy version if the event is not trusted. r?smaug
MozReview-Commit-ID: A7G4bkyNsOe
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -1309,19 +1309,20 @@ EventListenerManager::HandleEventInterna
}
}
}
}
// If we didn't find any matching listeners, and our event has a legacy
// version, we'll now switch to looking for that legacy version and we'll
// recheck our listeners.
- if (hasListenerForCurrentGroup || usingLegacyMessage) {
- // (No need to recheck listeners, because we already found a match, or we
- // already rechecked them.)
+ if (hasListenerForCurrentGroup ||
+ usingLegacyMessage || !aEvent->IsTrusted()) {
+ // No need to recheck listeners, because we already found a match, we
+ // already rechecked them, or it is not a trusted event.
break;
}
EventMessage legacyEventMessage = GetLegacyEventMessage(eventMessage);
if (legacyEventMessage == eventMessage) {
break; // There's no legacy version of our event; no need to recheck.
}
MOZ_ASSERT(GetLegacyEventMessage(legacyEventMessage) == legacyEventMessage,
"Legacy event messages should not themselves have legacy versions");
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -168,8 +168,9 @@ skip-if = toolkit == 'android' #CRASH_DU
[test_onerror_handler_args.html]
[test_passive_listeners.html]
[test_paste_image.html]
[test_wheel_default_action.html]
[test_bug687787.html]
[test_bug1305458.html]
[test_bug1298970.html]
[test_bug1304044.html]
+[test_bug1332699.html]
new file mode 100644
--- /dev/null
+++ b/dom/events/test/test_bug1332699.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for bug 1332699</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+<style>
+#test {
+ color: red;
+ transition: color 100ms;
+}
+#test.changed {
+ color: green;
+}
+</style>
+<div id="test"></div>
+<script>
+SimpleTest.waitForExplicitFinish();
+
+window.onload = function () {
+ let $test = document.getElementById('test');
+ is(getComputedStyle($test).color, 'rgb(255, 0, 0)',
+ 'color should be red before transition');
+ let numEvents = 0;
+ $test.addEventListener('webkittransitionend', function() {
+ ++numEvents;
+ if (numEvents == 1) {
+ is(getComputedStyle($test).color, 'rgb(0, 128, 0)',
+ 'color should be green after transition');
+ $test.dispatchEvent(new TransitionEvent('transitionend'));
+ is(numEvents, 1, "Shouldn't receive the prefixed event again");
+ SimpleTest.finish();
+ }
+ });
+ $test.className = 'changed';
+};
+</script>