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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/events/Event-dispatch-bubbles-true.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, 7 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 function concatReverse(a) {
23 return a.concat(a.map(function(x) { return x }).reverse());
24 }
25
22 function targetsForDocumentChain(document) { 26 function targetsForDocumentChain(document) {
23 return [ 27 return [
24 document, 28 document,
25 document.documentElement, 29 document.documentElement,
26 document.getElementsByTagName("body")[0], 30 document.getElementsByTagName("body")[0],
27 document.getElementById("table"), 31 document.getElementById("table"),
28 document.getElementById("table-body"), 32 document.getElementById("table-body"),
29 document.getElementById("parent") 33 document.getElementById("parent")
30 ]; 34 ];
31 } 35 }
32 36
33 function testChain(document, targetParents, phases, event_type) { 37 function testChain(document, targetParents, phases, event_type) {
34 var target = document.getElementById("target"); 38 var target = document.getElementById("target");
35 var targets = targetParents.concat(target); 39 var targets = targetParents.concat(target);
36 var expected_targets = targets.concat(target); 40 var expected_targets = concatReverse(targets);
37 41
38 var actual_targets = [], actual_phases = []; 42 var actual_targets = [], actual_phases = [];
39 var test_event = function(evt) { 43 var test_event = function(evt) {
40 actual_targets.push(evt.currentTarget); 44 actual_targets.push(evt.currentTarget);
41 actual_phases.push(evt.eventPhase); 45 actual_phases.push(evt.eventPhase);
42 } 46 }
43 47
44 for (var i = 0; i < targets.length; i++) { 48 for (var i = 0; i < targets.length; i++) {
45 targets[i].addEventListener(event_type, test_event, true); 49 targets[i].addEventListener(event_type, test_event, true);
46 targets[i].addEventListener(event_type, test_event, false); 50 targets[i].addEventListener(event_type, test_event, false);
47 } 51 }
48 52
49 var evt = document.createEvent("Event"); 53 var evt = document.createEvent("Event");
50 evt.initEvent(event_type, false, true); 54 evt.initEvent(event_type, true, true);
51 55
52 target.dispatchEvent(evt); 56 target.dispatchEvent(evt);
53 57
54 assert_array_equals(actual_targets, expected_targets, "targets"); 58 assert_array_equals(actual_targets, expected_targets, "targets");
55 assert_array_equals(actual_phases, phases, "phases"); 59 assert_array_equals(actual_phases, phases, "phases");
56 } 60 }
57 61
58 var phasesForDocumentChain = [ 62 var phasesForDocumentChain = [
59 Event.CAPTURING_PHASE, 63 Event.CAPTURING_PHASE,
60 Event.CAPTURING_PHASE, 64 Event.CAPTURING_PHASE,
61 Event.CAPTURING_PHASE, 65 Event.CAPTURING_PHASE,
62 Event.CAPTURING_PHASE, 66 Event.CAPTURING_PHASE,
63 Event.CAPTURING_PHASE, 67 Event.CAPTURING_PHASE,
64 Event.CAPTURING_PHASE, 68 Event.CAPTURING_PHASE,
65 Event.AT_TARGET, 69 Event.AT_TARGET,
66 Event.AT_TARGET, 70 Event.AT_TARGET,
71 Event.BUBBLING_PHASE,
72 Event.BUBBLING_PHASE,
73 Event.BUBBLING_PHASE,
74 Event.BUBBLING_PHASE,
75 Event.BUBBLING_PHASE,
76 Event.BUBBLING_PHASE,
67 ]; 77 ];
68 78
69 test(function () { 79 test(function () {
70 var chainWithWindow = [window].concat(targetsForDocumentChain(document)); 80 var chainWithWindow = [window].concat(targetsForDocumentChain(document));
71 testChain( 81 var phases = [Event.CAPTURING_PHASE].concat(phasesForDocumentChain, Event.BU BBLING_PHASE);
72 document, chainWithWindow, [Event.CAPTURING_PHASE].concat(phasesForDocum entChain), "click"); 82 testChain(document, chainWithWindow, phases, "click");
73 }, "In window.document with click event"); 83 }, "In window.document with click event");
74 84
75 test(function () { 85 test(function () {
76 testChain(document, targetsForDocumentChain(document), phasesForDocumentChai n, "load"); 86 testChain(document, targetsForDocumentChain(document), phasesForDocumentChai n, "load");
77 }, "In window.document with load event") 87 }, "In window.document with load event")
78 88
79 test(function () { 89 test(function () {
80 var documentClone = document.cloneNode(true); 90 var documentClone = document.cloneNode(true);
81 testChain( 91 testChain(
82 documentClone, targetsForDocumentChain(documentClone), phasesForDocument Chain, "click"); 92 documentClone, targetsForDocumentChain(documentClone), phasesForDocument Chain, "click");
83 }, "In window.document.cloneNode(true)"); 93 }, "In window.document.cloneNode(true)");
84 94
85 test(function () { 95 test(function () {
86 var newDocument = new Document(); 96 var newDocument = new Document();
87 newDocument.appendChild(document.documentElement.cloneNode(true)); 97 newDocument.appendChild(document.documentElement.cloneNode(true));
88 testChain( 98 testChain(
89 newDocument, targetsForDocumentChain(newDocument), phasesForDocumentChai n, "click"); 99 newDocument, targetsForDocumentChain(newDocument), phasesForDocumentChai n, "click");
90 }, "In new Document()"); 100 }, "In new Document()");
91 101
92 test(function () { 102 test(function () {
93 var HTMLDocument = document.implementation.createHTMLDocument(); 103 var HTMLDocument = document.implementation.createHTMLDocument();
94 HTMLDocument.body.appendChild(document.getElementById("table").cloneNode(tru e)); 104 HTMLDocument.body.appendChild(document.getElementById("table").cloneNode(tru e));
95 testChain( 105 testChain(
96 HTMLDocument, targetsForDocumentChain(HTMLDocument), phasesForDocumentCh ain, "click"); 106 HTMLDocument, targetsForDocumentChain(HTMLDocument), phasesForDocumentCh ain, "click");
97 }, "In DOMImplementation.createHTMLDocument()"); 107 }, "In DOMImplementation.createHTMLDocument()");
98 </script> 108 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698