Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1253)

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm.html

Issue 1854003004: Import web-platform-tests@5a8700479d98852455bee6117558897867eb278a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm.html
new file mode 100644
index 0000000000000000000000000000000000000000..4b2b2285158da2f5d2fa1187b2e8dbae45a44203
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/html/webappapis/scripting/events/event-handler-processing-algorithm.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<title>Event handlers processing algorithm</title>
+<script src="../../../../../../resources/testharness.js"></script>
+<script src="../../../../../../resources/testharnessreport.js"></script
+ <body>
+ <div id="foo" style="width: 100px; height: 100px; background-color: black"></div>
+ <script>
+ async_test(function(t) {
+ var ev = new Event('mouseover', {cancelable: true});
+ document.getElementById("foo").onmouseover = t.step_func(function() { return true });
+ document.getElementById("foo").dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, true)
+ t.done();
+ }, "mouseover listener returning true cancels event");
+
+ async_test(function(t) {
+ var ev = new Event('mouseover', {cancelable: true});
+ document.getElementById("foo").onmouseover = t.step_func(function() { return false; });
+ document.getElementById("foo").dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, false);
+ t.done();
+ }, "mouseover listener returning false doesn't cancel event");
+
+ async_test(function(t) {
+ var ev = new Event('beforeunload', {cancelable: true});
+ window.onbeforeunload = t.step_func(function() {return null});
+ window.dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, true);
+ t.done();
+ }, "beforeunload listener returning null cancels event");
+
+ async_test(function(t) {
+ var ev = new Event('beforeunload', {cancelable: true});
+ window.onbeforeunload = t.step_func(function() {return true});
+ window.dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, false);
+ t.done();
+ }, "beforeunload listener returning non-null doesn't cancel event");
+
+ async_test(function(t) {
+ var ev = new Event("click", {cancelable: true});
+ document.getElementById("foo").onclick = t.step_func(function() { return false; });
+ document.getElementById("foo").dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, true);
+ t.done();
+ }, "click listener returning false cancels event");
+
+ async_test(function(t) {
+ var ev = new Event("blur", {cancelable: true});
+ document.getElementById("foo").onblur = t.step_func(function() { return false; });
+ document.getElementById("foo").dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, true);
+ t.done();
+ }, "blur listener returning false cancels event");
+
+ async_test(function(t) {
+ var ev = new Event("dblclick", {cancelable: true});
+ document.getElementById("foo").ondblclick = t.step_func(function() { return false; });
+ document.getElementById("foo").dispatchEvent(ev);
+ assert_equals(ev.defaultPrevented, true);
+ t.done();
+ }, "dblclick listener returning false cancels event");
+</script>

Powered by Google App Engine
This is Rietveld 408576698