Test event dispatching in documents without a browsing context

This commit is contained in:
Anthony Ramine 2016-02-24 12:38:11 +01:00
parent d85ee09bc7
commit 0455b0b301
2 changed files with 48 additions and 35 deletions

View file

@ -1,5 +1,5 @@
[Event-dispatch-bubbles-false.html]
type: testharness
[Event.dispatchEvent with Event.bubbles set to false.]
[In document with a browsing context: Event.dispatchEvent with Event.bubbles set to false.]
expected: FAIL

View file

@ -19,32 +19,23 @@
</tbody>
</table>
<script>
test(function() {
var event_type = "click";
var target = document.getElementById("target");
var targets = [
window,
function targetsForDocumentChain(document) {
return [
document,
document.documentElement,
document.body,
document.getElementById("table"),
document.getElementById("table-body"),
document.getElementById("parent"),
target,
];
var expected_targets = targets.concat(target);
var phases = [
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.AT_TARGET,
Event.AT_TARGET,
document.getElementById("parent")
];
}
function testChain(document, targetParents, phases, label) {
test(function() {
var event_type = "click";
var target = document.getElementById("target");
var targets = targetParents.concat(target);
var expected_targets = targets.concat(target);
var actual_targets = [], actual_phases = [];
var test_event = function(evt) {
@ -64,5 +55,27 @@ test(function() {
assert_array_equals(actual_targets, expected_targets, "targets");
assert_array_equals(actual_phases, phases, "phases");
}, "Event.dispatchEvent with Event.bubbles set to false.");
}, label + ": Event.dispatchEvent with Event.bubbles set to false.");
}
var phasesForDocumentChain = [
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.AT_TARGET,
Event.AT_TARGET,
];
chainWithWindow = [window].concat(targetsForDocumentChain(document));
testChain(
document, chainWithWindow, [Event.CAPTURING_PHASE].concat(phasesForDocumentChain),
"In document with a browsing context");
var documentClone = document.cloneNode(true);
testChain(
documentClone, targetsForDocumentChain(documentClone), phasesForDocumentChain,
"In document without a browsing context");
</script>