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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/uievents/order-of-events/init-event-while-dispatching.html

Issue 1999243002: Import wpt@5df9b57edb3307a87d5187804b29c8ddd2aa14e1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add expectations files (using run-webkit-tests --new-baseline) Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <title>Re-initializing events while dispatching them</title>
4 <link rel="author" title="Josh Matthews" href="mailto:josh@joshmatthews.net">
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <div id="log"></div>
8 <script>
9 var events = {
10 'KeyboardEvent': {
11 'constructor': function() { return new KeyboardEvent("type", {key: "A"}); },
12 'init': function(ev) { ev.initKeyboardEvent("type2", true, true, null, "a", 1, "", true, "") },
13 'check': function(ev) {
14 assert_equals(ev.key, "A", "initKeyboardEvent key setter should short-cir cuit");
15 assert_false(ev.repeat, "initKeyboardEvent repeat setter should short-cir cuit");
16 assert_equals(ev.location, 0, "initKeyboardEvent location setter should s hort-circuit");
17 }
18 },
19 'MouseEvent': {
20 'constructor': function() { return new MouseEvent("type"); },
21 'init': function(ev) { ev.initMouseEvent("type2", true, true, null, 0, 1, 1, 1, 1, true, true, true, true, 1, null) },
22 'check': function(ev) {
23 assert_equals(ev.screenX, 0, "initMouseEvent screenX setter should short-c ircuit");
24 assert_equals(ev.screenY, 0, "initMouseEvent screenY setter should short-c ircuit");
25 assert_equals(ev.clientX, 0, "initMouseEvent clientX setter should short-c ircuit");
26 assert_equals(ev.clientY, 0, "initMouseEvent clientY setter should short-c ircuit");
27 assert_false(ev.ctrlKey, "initMouseEvent ctrlKey setter should short-circu it");
28 assert_false(ev.altKey, "initMouseEvent altKey setter should short-circuit ");
29 assert_false(ev.shiftKey, "initMouseEvent shiftKey setter should short-cir cuit");
30 assert_false(ev.metaKey, "initMouseEvent metaKey setter should short-circu it");
31 assert_equals(ev.button, 0, "initMouseEvent button setter should short-cir cuit");
32 }
33 },
34 'CustomEvent': {
35 'constructor': function() { return new CustomEvent("type") },
36 'init': function(ev) { ev.initCustomEvent("type2", true, true, 1) },
37 'check': function(ev) {
38 assert_equals(ev.detail, null, "initCustomEvent detail setter should short -circuit");
39 }
40 },
41 'UIEvent': {
42 'constructor': function() { return new UIEvent("type") },
43 'init': function(ev) { ev.initUIEvent("type2", true, true, window, 1) },
44 'check': function(ev) {
45 assert_equals(ev.view, null, "initUIEvent view setter should short-circuit ");
46 assert_equals(ev.detail, 0, "initUIEvent detail setter should short-circui t");
47 }
48 },
49 'Event': {
50 'constructor': function() { return new Event("type") },
51 'init': function(ev) { ev.initEvent("type2", true, true) },
52 'check': function(ev) {
53 assert_equals(ev.bubbles, false, "initEvent bubbles setter should short-ci rcuit");
54 assert_equals(ev.cancelable, false, "initEvent cancelable setter should sh ort-circuit");
55 assert_equals(ev.type, "type", "initEvent type setter should short-circuit ");
56 }
57 }
58 };
59
60 var names = Object.keys(events);
61 for (var i = 0; i < names.length; i++) {
62 var t = async_test("Calling init" + names[i] + " while dispatching.");
63 t.step(function() {
64 var e = events[names[i]].constructor();
65
66 var target = document.createElement("div")
67 target.addEventListener("type", t.step_func(function() {
68 events[names[i]].init(e);
69
70 var o = e;
71 while ((o = Object.getPrototypeOf(o))) {
72 if (!(o.constructor.name in events)) {
73 break;
74 }
75 events[o.constructor.name].check(e);
76 }
77 }), false);
78
79 assert_equals(target.dispatchEvent(e), true, "dispatchEvent must return true ")
80 });
81 t.done();
82 }
83 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698