diff options
Diffstat (limited to 'testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html')
-rw-r--r-- | testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html new file mode 100644 index 0000000000..93489c63b4 --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html> +<head> +<title> Event.stopPropagation() deferred effect </title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id=log></div> + +<table id="table" border="1" style="display: none"> + <tbody id="table-body"> + <tr id="table-row"> + <td id="table-cell">Shady Grove</td> + <td>Aeolian</td> + </tr> + <tr id="parent"> + <td id="target">Over the river, Charlie</td> + <td>Dorian</td> + </tr> + </tbody> +</table> + +<script> + var EVENT = "foo"; + var TARGET = document.getElementById("target"); + var PARENT = document.getElementById("parent"); + var TBODY = document.getElementById("table-body"); + var TABLE = document.getElementById("table"); + var BODY = document.body; + var HTML = document.documentElement; + var CurrentTargets = [window, document, HTML, BODY, TABLE, TBODY, PARENT, TARGET]; + var ExpectResult = [window, window, document, document, HTML, HTML, BODY, BODY, TABLE, TABLE]; + var ActualResult = []; + var ExpectListeners = [0,1,0,1,0,1,0,1,0,1]; + var ActualListeners = []; + + var description = "Test Description: " + + "stopPropagation() prevents other event listeners from being triggered but its effect must be " + + "deferred until all event listeners attached on the Event.currentTarget have been triggered."; + + test(function() + { + for (var i=0; i < CurrentTargets.length; i++) + { + CurrentTargets[i].addEventListener(EVENT, function(e){TestEvent(e, 0)}, true); + CurrentTargets[i].addEventListener(EVENT, function(e){TestEvent(e, 1)}, true); + } + + var evt = document.createEvent("Event"); + evt.initEvent(EVENT, true, true); + TARGET.dispatchEvent(evt); + + assert_array_equals(ActualResult, ExpectResult, "ActualResult"); + assert_array_equals(ActualListeners, ExpectListeners, "ActualListeners"); + + }, description); + + function TestEvent(evt, i) + { + ActualResult.push(evt.currentTarget); + ActualListeners.push(i); + if ((1 == evt.eventPhase) && (TABLE == evt.currentTarget) && (0 == i)) + { + evt.stopPropagation(); + } + } +</script> +</body> +</html> |