| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="resources/shadow-dom.js"></script> |
| <div id=host label=host> |
| <template label=shadowRoot data-mode=open> |
| <div label=target></div> |
| </template> |
| </div> |
| <script> |
| test(() => { |
| const e = new Event('test'); |
| assert_equals(e.composed, false); |
| }, 'A new events composed value should be set to false by default.'); |
| |
| test(() => { |
| const e = new Event('test', { composed: true }); |
| assert_equals(e.composed, true); |
| }, 'Users should be able to set a composed value.'); |
| |
| test(() => { |
| let nodes = createTestTree(host); |
| let log = dispatchEventWithLog(nodes, nodes.target, new Event('test', {bubbles: true})); |
| let expectedPath = ['target', 'shadowRoot']; |
| assert_event_path_equals(log, |
| [['target', null, expectedPath], |
| ['shadowRoot', null, expectedPath]]); |
| }, 'An event should be scoped by default'); |
| |
| test(() => { |
| let nodes = createTestTree(host); |
| let log = dispatchEventWithLog(nodes, nodes.target, new Event('test', {bubbles: true, composed: true})); |
| let expectedPath = ['target', 'shadowRoot', 'host']; |
| assert_event_path_equals(log, |
| [['target', null, expectedPath], |
| ['shadowRoot', null, expectedPath], |
| ['host', null, expectedPath]]); |
| }, 'An event should not be scoped if composed is specified'); |
| </script> |