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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-handlers-changed.html

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years 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> Dispatch additional events inside an event listener </title>
4 <link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch">
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <div id=log></div>
8
9 <table id="table" border="1" style="display: none">
10 <tbody id="table-body">
11 <tr id="table-row">
12 <td id="table-cell">Shady Grove</td>
13 <td>Aeolian</td>
14 </tr>
15 <tr id="parent">
16 <td id="target">Over the river, Charlie</td>
17 <td>Dorian</td>
18 </tr>
19 </tbody>
20 </table>
21
22 <script>
23 async_test(function() {
24 var event_type = "bar";
25 var target = document.getElementById("target");
26 var parent = document.getElementById("parent");
27 var tbody = document.getElementById("table-body");
28 var table = document.getElementById("table");
29 var body = document.body;
30 var html = document.documentElement;
31 var targets = [window, document, html, body, table, tbody, parent, target];
32 var expected_targets = [
33 window,
34 document,
35 html,
36 body,
37 table,
38 tbody,
39 parent,
40 target,
41 target,
42 parent,
43 tbody,
44 table,
45 body,
46 html,
47 document,
48 window
49 ];
50 var expected_listeners = [0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1];
51
52 var actual_targets = [], actual_listeners = [];
53 var test_event_function = function(i) {
54 return this.step_func(function(evt) {
55 actual_targets.push(evt.currentTarget);
56 actual_listeners.push(i);
57
58 if (evt.eventPhase != evt.BUBBLING_PHASE && evt.currentTarget.foo != 1) {
59 evt.currentTarget.removeEventListener(event_type, event_handlers[0], tru e);
60 evt.currentTarget.addEventListener(event_type, event_handlers[2], true);
61 evt.currentTarget.foo = 1;
62 }
63
64 if (evt.eventPhase != evt.CAPTURING_PHASE && evt.currentTarget.foo != 3) {
65 evt.currentTarget.removeEventListener(event_type, event_handlers[0], fal se);
66 evt.currentTarget.addEventListener(event_type, event_handlers[3], false) ;
67 evt.currentTarget.foo = 3;
68 }
69 });
70 }.bind(this);
71 var event_handlers = [
72 test_event_function(0),
73 test_event_function(1),
74 test_event_function(2),
75 test_event_function(3),
76 ];
77
78 for (var i = 0; i < targets.length; ++i) {
79 targets[i].addEventListener(event_type, event_handlers[0], true);
80 targets[i].addEventListener(event_type, event_handlers[1], false);
81 }
82
83 var evt = document.createEvent("Event");
84 evt.initEvent(event_type, true, true);
85 target.dispatchEvent(evt);
86
87 assert_array_equals(actual_targets, expected_targets, "actual_targets");
88 assert_array_equals(actual_listeners, expected_listeners, "actual_listeners");
89
90 this.done();
91 });
92 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698