Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: third_party/WebKit/LayoutTests/shadow-dom/event-composed.html

Issue 2012423004: Rename Event.scoped to Event.composed and invert its meaning (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@event-composed-path
Patch Set: rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/shadow-dom.js"></script>
5 <div id=host label=host>
6 <template label=shadowRoot data-mode=open>
7 <div label=target></div>
8 </template>
9 </div>
10 <script>
11 function assert_event_path_equals(actual, expected) {
12 assert_equals(actual.length, expected.length);
13 for (let i = 0; i < actual.length; ++i) {
14 assert_equals(actual[i][0], expected[i][0], 'currentTarget at ' + i + ' shou ld be same');
15 assert_equals(actual[i][1], expected[i][1], 'relatedTarget at ' + i + ' shou ld be same');
16 assert_array_equals(actual[i][2], expected[i][2], 'composedPath at ' + i + ' should be same');
17 }
18 }
19
20 test(() => {
21 const e = new Event('test');
22 assert_equals(e.composed, false);
23 }, 'A new events composed value should be set to false by default.');
24
25 test(() => {
26 const e = new Event('test', { composed: true });
27 assert_equals(e.composed, true);
28 }, 'Users should be able to set a composed value.');
29
30 test(() => {
31 let nodes = createTestTree(host);
32 let log = dispatchEventWithLog(nodes, nodes.target, new Event('test', {bubbles : true}));
33 let expectedPath = ['target', 'shadowRoot'];
34 assert_event_path_equals(log,
35 [['target', null, expectedPath],
36 ['shadowRoot', null, expectedPath]]);
37 }, 'An event should be scoped by default');
38
39 test(() => {
40 let nodes = createTestTree(host);
41 let log = dispatchEventWithLog(nodes, nodes.target, new Event('test', {bubbles : true, composed: true}));
42 let expectedPath = ['target', 'shadowRoot', 'host'];
43 assert_event_path_equals(log,
44 [['target', null, expectedPath],
45 ['shadowRoot', null, expectedPath],
46 ['host', null, expectedPath]]);
47 }, 'An event should not be scoped if composed is specified');
48 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698