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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/events/Event-dispatch-bubbles-false.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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta charset=utf-8> 2 <meta charset=utf-8>
3 <title> Event.bubbles attribute is set to false </title> 3 <title> Event.bubbles attribute is set to false </title>
4 <link rel="help" href="https://dom.spec.whatwg.org/#dom-event-initevent"> 4 <link rel="help" href="https://dom.spec.whatwg.org/#dom-event-initevent">
5 <link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch"> 5 <link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch">
6 <script src="../../../../resources/testharness.js"></script> 6 <script src="../../../../resources/testharness.js"></script>
7 <script src="../../../../resources/testharnessreport.js"></script> 7 <script src="../../../../resources/testharnessreport.js"></script>
8 <div id=log></div> 8 <div id=log></div>
9 <table id="table" border="1" style="display: none"> 9 <table id="table" border="1" style="display: none">
10 <tbody id="table-body"> 10 <tbody id="table-body">
11 <tr id="table-row"> 11 <tr id="table-row">
12 <td id="table-cell">Shady Grove</td> 12 <td id="table-cell">Shady Grove</td>
13 <td>Aeolian</td> 13 <td>Aeolian</td>
14 </tr> 14 </tr>
15 <tr id="parent"> 15 <tr id="parent">
16 <td id="target">Over the river, Charlie</td> 16 <td id="target">Over the river, Charlie</td>
17 <td>Dorian</td> 17 <td>Dorian</td>
18 </tr> 18 </tr>
19 </tbody> 19 </tbody>
20 </table> 20 </table>
21 <script> 21 <script>
22 test(function() { 22 function targetsForDocumentChain(document) {
23 var event_type = "click"; 23 return [
24 var target = document.getElementById("target");
25 var targets = [
26 window,
27 document, 24 document,
28 document.documentElement, 25 document.documentElement,
29 document.body, 26 document.getElementsByTagName("body")[0],
30 document.getElementById("table"), 27 document.getElementById("table"),
31 document.getElementById("table-body"), 28 document.getElementById("table-body"),
32 document.getElementById("parent"), 29 document.getElementById("parent")
33 target,
34 ]; 30 ];
31 }
32
33 function testChain(document, targetParents, phases, event_type) {
34 var target = document.getElementById("target");
35 var targets = targetParents.concat(target);
35 var expected_targets = targets.concat(target); 36 var expected_targets = targets.concat(target);
36 var phases = [
37 Event.CAPTURING_PHASE,
38 Event.CAPTURING_PHASE,
39 Event.CAPTURING_PHASE,
40 Event.CAPTURING_PHASE,
41 Event.CAPTURING_PHASE,
42 Event.CAPTURING_PHASE,
43 Event.CAPTURING_PHASE,
44 Event.AT_TARGET,
45 Event.AT_TARGET,
46 ];
47
48 37
49 var actual_targets = [], actual_phases = []; 38 var actual_targets = [], actual_phases = [];
50 var test_event = function(evt) { 39 var test_event = function(evt) {
51 actual_targets.push(evt.currentTarget); 40 actual_targets.push(evt.currentTarget);
52 actual_phases.push(evt.eventPhase); 41 actual_phases.push(evt.eventPhase);
53 } 42 }
54 43
55 for (var i = 0; i < targets.length; i++) { 44 for (var i = 0; i < targets.length; i++) {
56 targets[i].addEventListener(event_type, test_event, true); 45 targets[i].addEventListener(event_type, test_event, true);
57 targets[i].addEventListener(event_type, test_event, false); 46 targets[i].addEventListener(event_type, test_event, false);
58 } 47 }
59 48
60 var evt = document.createEvent("Event"); 49 var evt = document.createEvent("Event");
61 evt.initEvent(event_type, false, true); 50 evt.initEvent(event_type, false, true);
62 51
63 target.dispatchEvent(evt); 52 target.dispatchEvent(evt);
64 53
65 assert_array_equals(actual_targets, expected_targets, "targets"); 54 assert_array_equals(actual_targets, expected_targets, "targets");
66 assert_array_equals(actual_phases, phases, "phases"); 55 assert_array_equals(actual_phases, phases, "phases");
67 }, "Event.dispatchEvent with Event.bubbles set to false."); 56 }
57
58 var phasesForDocumentChain = [
59 Event.CAPTURING_PHASE,
60 Event.CAPTURING_PHASE,
61 Event.CAPTURING_PHASE,
62 Event.CAPTURING_PHASE,
63 Event.CAPTURING_PHASE,
64 Event.CAPTURING_PHASE,
65 Event.AT_TARGET,
66 Event.AT_TARGET,
67 ];
68
69 test(function () {
70 var chainWithWindow = [window].concat(targetsForDocumentChain(document));
71 testChain(
72 document, chainWithWindow, [Event.CAPTURING_PHASE].concat(phasesForDocum entChain), "click");
73 }, "In window.document with click event");
74
75 test(function () {
76 testChain(document, targetsForDocumentChain(document), phasesForDocumentChai n, "load");
77 }, "In window.document with load event")
78
79 test(function () {
80 var documentClone = document.cloneNode(true);
81 testChain(
82 documentClone, targetsForDocumentChain(documentClone), phasesForDocument Chain, "click");
83 }, "In window.document.cloneNode(true)");
84
85 test(function () {
86 var newDocument = new Document();
87 newDocument.appendChild(document.documentElement.cloneNode(true));
88 testChain(
89 newDocument, targetsForDocumentChain(newDocument), phasesForDocumentChai n, "click");
90 }, "In new Document()");
91
92 test(function () {
93 var HTMLDocument = document.implementation.createHTMLDocument();
94 HTMLDocument.body.appendChild(document.getElementById("table").cloneNode(tru e));
95 testChain(
96 HTMLDocument, targetsForDocumentChain(HTMLDocument), phasesForDocumentCh ain, "click");
97 }, "In DOMImplementation.createHTMLDocument()");
68 </script> 98 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698