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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/shadow-dom/event-composed.html
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/event-composed.html b/third_party/WebKit/LayoutTests/shadow-dom/event-composed.html
new file mode 100644
index 0000000000000000000000000000000000000000..891b684ea93d8dc2a2fccf5b07ce8e8a33f8be97
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shadow-dom/event-composed.html
@@ -0,0 +1,48 @@
+<!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>
+function assert_event_path_equals(actual, expected) {
+ assert_equals(actual.length, expected.length);
+ for (let i = 0; i < actual.length; ++i) {
+ assert_equals(actual[i][0], expected[i][0], 'currentTarget at ' + i + ' should be same');
+ assert_equals(actual[i][1], expected[i][1], 'relatedTarget at ' + i + ' should be same');
+ assert_array_equals(actual[i][2], expected[i][2], 'composedPath at ' + i + ' should be same');
+ }
+}
+
+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>

Powered by Google App Engine
This is Rietveld 408576698