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

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

Issue 2030243004: Set Event.composed flag correctly for some of UA UIEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
index c93324769002bb67fbf475945a93ce38941cdc6e..f0f1cf843dee734c023d144208da91e2d32dbcfe 100644
--- a/third_party/WebKit/LayoutTests/shadow-dom/event-composed.html
+++ b/third_party/WebKit/LayoutTests/shadow-dom/event-composed.html
@@ -18,22 +18,62 @@ test(() => {
assert_equals(e.composed, true);
}, 'Users should be able to set a composed value.');
-test(() => {
+function assertScoped(event) {
let nodes = createTestTree(host);
- let log = dispatchEventWithLog(nodes, nodes.target, new Event('test', {bubbles: true}));
+ let log = dispatchEventWithLog(nodes, nodes.target, event);
let expectedPath = ['target', 'shadowRoot'];
assert_event_path_equals(log,
[['target', null, expectedPath],
['shadowRoot', null, expectedPath]]);
+}
+
+function assertComposed(event) {
+ let nodes = createTestTree(host);
+ let log = dispatchEventWithLog(nodes, nodes.target, event);
+ let expectedPath = ['target', 'shadowRoot', 'host'];
+ assert_event_path_equals(log,
+ [['target', null, expectedPath],
+ ['shadowRoot', null, expectedPath],
+ ['host', null, expectedPath]]);
+}
+
+test(() => {
+ assertScoped(new Event('test', { bubbles: true }));
}, 'An event should be scoped by default');
test(() => {
+ assertComposed(new Event('test', { bubbles: true, composed: true }));
+}, 'An event should not be scoped if composed is specified');
+
+test(() => {
+ assertScoped(new MouseEvent('click', { bubbles: true }));
+}, 'A synthetic MouseEvent should be scoped by default');
+
+test(() => {
+ assertComposed(new MouseEvent('click', { bubbles: true, composed: true }));
+}, 'A synthetic MouseEvent with composed=true should not be scoped');
+
+test(() => {
+ assertScoped(new FocusEvent('focus', { bubbles: true }));
+}, 'A synthetic FocusEvent should be scoped by default');
+
+test(() => {
+ assertComposed(new FocusEvent('focus', { bubbles: true, composed: true }));
+}, 'A synthetic FocusEvent with composed=true should not be scoped');
+
+function assertUAComposed(eventType, callback) {
let nodes = createTestTree(host);
- let log = dispatchEventWithLog(nodes, nodes.target, new Event('test', {bubbles: true, composed: true}));
+ let log = dispatchUAEventWithLog(nodes, nodes.target, eventType, callback);
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');
+}
+
+test(() => {
+ assertUAComposed('click', (target) => { target.click(); });
+}, 'An UA click event should not be scoped');
kochi 2016/06/03 08:45:57 nit: 'A UA click'
hayato 2016/06/03 09:03:04 Done
+
+// TODO(hayato): Test other UIEvents.
</script>

Powered by Google App Engine
This is Rietveld 408576698