| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title> Event.bubbles attribute is set to false </title> | |
| 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"> | |
| 6 <script src="../../../../resources/testharness.js"></script> | |
| 7 <script src="../../../../resources/testharnessreport.js"></script> | |
| 8 <div id=log></div> | |
| 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 <script> | |
| 22 function targetsForDocumentChain(document) { | |
| 23 return [ | |
| 24 document, | |
| 25 document.documentElement, | |
| 26 document.getElementsByTagName("body")[0], | |
| 27 document.getElementById("table"), | |
| 28 document.getElementById("table-body"), | |
| 29 document.getElementById("parent") | |
| 30 ]; | |
| 31 } | |
| 32 | |
| 33 function testChain(document, targetParents, phases, event_type) { | |
| 34 var target = document.getElementById("target"); | |
| 35 var targets = targetParents.concat(target); | |
| 36 var expected_targets = targets.concat(target); | |
| 37 | |
| 38 var actual_targets = [], actual_phases = []; | |
| 39 var test_event = function(evt) { | |
| 40 actual_targets.push(evt.currentTarget); | |
| 41 actual_phases.push(evt.eventPhase); | |
| 42 } | |
| 43 | |
| 44 for (var i = 0; i < targets.length; i++) { | |
| 45 targets[i].addEventListener(event_type, test_event, true); | |
| 46 targets[i].addEventListener(event_type, test_event, false); | |
| 47 } | |
| 48 | |
| 49 var evt = document.createEvent("Event"); | |
| 50 evt.initEvent(event_type, false, true); | |
| 51 | |
| 52 target.dispatchEvent(evt); | |
| 53 | |
| 54 assert_array_equals(actual_targets, expected_targets, "targets"); | |
| 55 assert_array_equals(actual_phases, phases, "phases"); | |
| 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()"); | |
| 98 </script> | |
| OLD | NEW |