blob: 99facb969d4ecce0546e1bcc2fd8192522e69d4e [file] [log] [blame]
<!DOCTYPE html>
<title> Event.stopImmediatePropagation() immediate effect </title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<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>
<tr id="parent">
<td id="target">Over the river, Charlie</td>
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.";
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);
assert_array_equals(ActualResult, ExpectResult, "ActualResult");
assert_array_equals(ActualListeners, ExpectListeners, "ActualListeners");
}, description);
function TestEvent(evt, i)
if ((1 == evt.eventPhase) && (TABLE == evt.currentTarget) && (0 == i))