diff options
Diffstat (limited to 'testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html')
-rw-r--r-- | testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html new file mode 100644 index 0000000000..a414d60298 --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> +<head> +<title> Event.stopImmediatePropagation() immediate 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]; + var ActualResult = []; + var ExpectListeners = [0,1,0,1,0,1,0,1,0]; + var ActualListeners = []; + + var description = "Test Description: " + + "stopImmediatePropagation() prevents other event listeners from being triggered and, unlike " + + "Event.stopPropagation(), its effect must be immediate. Once it has been called, further calls " + + "to this method have no additional effect."; + + 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.stopImmediatePropagation(); + } + } +</script> +</body> +</html> |