blob: b8f4fc7edbf8b8fcd22eb2d479532a82004a38a1 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="resources/shadow-dom.js"></script>
<input id="input"></input>
<div id="sandbox">
<div id = "host">
<template>
<input id="target" value="test"></div>
</template>
</div>
</div>
<script>
var e;
test(function() {
e = new Event('test');
assert_equals(e.composed, false);
}, 'A new events composed value should be set to false by default.');
test(function() {
e = new Event('test', { composed: true });
assert_equals(e.composed, true);
}, 'Users should be able to set a composed value.');
var input = document.getElementById('input');
async_test(function(t) {
input.onselect = function(e) {
t.step(function() { assert_false(e.composed); t.done(); });
};
}, 'UA select events composed should be set to false.');
input.select();
var sandbox = document.getElementById('sandbox');
convertTemplatesToShadowRootsWithin(sandbox);
var target = getNodeInComposedTree('host/target');
var host = getNodeInComposedTree('host');
async_test(function(t) {
target.onselect = function(e) {
t.step(function() {
assert_true(e.composedPath().includes(target));
assert_false(e.composedPath().includes(host));
t.done();
});
}
}, 'Select events should stop if created by UA.');
async_test(function(t) {
target.onerror = function(e) {
t.step(function() {
assert_true(e.composedPath().includes(target));
assert_true(e.composedPath().includes(host));
t.done();
});
}
}, 'Only certain trusted events should stop in bubbling.');
target.select();
var userError = new Event('error');
target.dispatchEvent(userError);
</script>