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

Unified Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/uievents/order-of-events/init-event-while-dispatching.html

Issue 1933203002: Import web-platform-tests@343606cdf8f6c7442d1a0309a9fcdd47d6244eca (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against web-platform tests to pick up my whitespace fix upstream 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/uievents/order-of-events/init-event-while-dispatching.html
diff --git a/third_party/WebKit/LayoutTests/imported/web-platform-tests/uievents/order-of-events/init-event-while-dispatching.html b/third_party/WebKit/LayoutTests/imported/web-platform-tests/uievents/order-of-events/init-event-while-dispatching.html
new file mode 100644
index 0000000000000000000000000000000000000000..9306e082f656b83b8584c0ff2f0c8929475500ca
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/web-platform-tests/uievents/order-of-events/init-event-while-dispatching.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Re-initializing events while dispatching them</title>
+<link rel="author" title="Josh Matthews" href="mailto:josh@joshmatthews.net">
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+var events = {
+ 'KeyboardEvent': {
+ 'constructor': function() { return new KeyboardEvent("type", {key: "A"}); },
+ 'init': function(ev) { ev.initKeyboardEvent("type2", true, true, null, "a", 1, "", true, "") },
+ 'check': function(ev) {
+ assert_equals(ev.key, "A", "initKeyboardEvent key setter should short-circuit");
+ assert_false(ev.repeat, "initKeyboardEvent repeat setter should short-circuit");
+ assert_equals(ev.location, 0, "initKeyboardEvent location setter should short-circuit");
+ }
+ },
+ 'MouseEvent': {
+ 'constructor': function() { return new MouseEvent("type"); },
+ 'init': function(ev) { ev.initMouseEvent("type2", true, true, null, 0, 1, 1, 1, 1, true, true, true, true, 1, null) },
+ 'check': function(ev) {
+ assert_equals(ev.screenX, 0, "initMouseEvent screenX setter should short-circuit");
+ assert_equals(ev.screenY, 0, "initMouseEvent screenY setter should short-circuit");
+ assert_equals(ev.clientX, 0, "initMouseEvent clientX setter should short-circuit");
+ assert_equals(ev.clientY, 0, "initMouseEvent clientY setter should short-circuit");
+ assert_false(ev.ctrlKey, "initMouseEvent ctrlKey setter should short-circuit");
+ assert_false(ev.altKey, "initMouseEvent altKey setter should short-circuit");
+ assert_false(ev.shiftKey, "initMouseEvent shiftKey setter should short-circuit");
+ assert_false(ev.metaKey, "initMouseEvent metaKey setter should short-circuit");
+ assert_equals(ev.button, 0, "initMouseEvent button setter should short-circuit");
+ }
+ },
+ 'CustomEvent': {
+ 'constructor': function() { return new CustomEvent("type") },
+ 'init': function(ev) { ev.initCustomEvent("type2", true, true, 1) },
+ 'check': function(ev) {
+ assert_equals(ev.detail, null, "initCustomEvent detail setter should short-circuit");
+ }
+ },
+ 'UIEvent': {
+ 'constructor': function() { return new UIEvent("type") },
+ 'init': function(ev) { ev.initUIEvent("type2", true, true, window, 1) },
+ 'check': function(ev) {
+ assert_equals(ev.view, null, "initUIEvent view setter should short-circuit");
+ assert_equals(ev.detail, 0, "initUIEvent detail setter should short-circuit");
+ }
+ },
+ 'Event': {
+ 'constructor': function() { return new Event("type") },
+ 'init': function(ev) { ev.initEvent("type2", true, true) },
+ 'check': function(ev) {
+ assert_equals(ev.bubbles, false, "initEvent bubbles setter should short-circuit");
+ assert_equals(ev.cancelable, false, "initEvent cancelable setter should short-circuit");
+ assert_equals(ev.type, "type", "initEvent type setter should short-circuit");
+ }
+ }
+};
+
+var names = Object.keys(events);
+for (var i = 0; i < names.length; i++) {
+ var t = async_test("Calling init" + names[i] + " while dispatching.");
+ t.step(function() {
+ var e = events[names[i]].constructor();
+
+ var target = document.createElement("div")
+ target.addEventListener("type", t.step_func(function() {
+ events[names[i]].init(e);
+
+ var o = e;
+ while ((o = Object.getPrototypeOf(o))) {
+ if (!(o.constructor.name in events)) {
+ break;
+ }
+ events[o.constructor.name].check(e);
+ }
+ }), false);
+
+ assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true")
+ });
+ t.done();
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698