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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html

Issue 1606153002: Implement v1 slot logic in EventPath (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test case in layout test Created 4 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/events/EventPath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html
new file mode 100644
index 0000000000000000000000000000000000000000..c0e7335e81992934e7d459bd31ebe34428a4ab6b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/event-path-with-slot.html
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<script src='../../../resources/testharness.js'></script>
+<script src='../../../resources/testharnessreport.js'></script>
+<script src='resources/shadow-dom.js'></script>
+<div id='host1'>
+ <input id='input1' slot='slot1'>
+ <template data-mode='open'>
+ <slot name='slot1'></slot>
+ </template>
+</div>
+
+<div id='host2'>
+ <input id='input2' slot='slot2'>
+ <template data-mode='open'>
+ <div id='host3'>
+ <div id='slot2-parent'>
+ <slot name='slot2'></slot>
+ </div>
+ <template data-mode='v0'>
+ <content select='#slot2-parent'></content>
+ </template>
+ </div>
+ </template>
+</div>
+
+<div id='host4'>
+ <template data-mode='open'>
+ <slot name='slot3'></slot>
+ </template>
+ <div id='input-parent' slot='slot3'>
+ <input id='input3'>
+ </div>
+</div>
+<script>
+
+var host1 = document.getElementById('host1');
kochi 2016/01/21 01:26:33 nit: if an element with ID "host1" (in this file,
yuzuchan 2016/01/21 05:10:22 Done.
+convertTemplatesToShadowRootsWithin(host1);
+removeWhiteSpaceOnlyTextNodes(host1);
+document.body.offsetLeft;
+
+var input1 = document.getElementById('input1');
+var slot1 = host1.shadowRoot.querySelector('slot');
+var shadowRoot = host1.shadowRoot;
+
+input1.onfocus = function(e) {
+ var expected_array1 = [input1, slot1, shadowRoot, host1, document.body, document.documentElement, document, window];
+ test(function() {
kochi 2016/01/21 01:26:33 If the event doesn't happen accidentally, this tes
kochi 2016/01/21 04:55:47 The "focus" event is synchronous (i.e. when such e
yuzuchan 2016/01/21 05:10:22 Thanks for pointing out the issue. How about addin
kochi 2016/01/21 05:22:58 One setup() can only check one "done();"? So if y
yuzuchan 2016/01/21 07:18:12 Done.
+ assert_array_equals(e.path, expected_array1);
+ }, 'Triggered in a slotted element, eventPath should go through shadow tree.');
+};
+
+var input2 = document.getElementById('input2');
+var host2 = document.getElementById('host2');
+convertTemplatesToShadowRootsWithin(host2);
+var shadowRootV1 = host2.shadowRoot;
+var host3 = shadowRootV1.querySelector('#host3');
+convertTemplatesToShadowRootsWithin(host3);
+var slotParent = host3.querySelector('div');
+var slot2 = host3.querySelector('slot');
+var shadowRootV0 = host3.shadowRoot;
+var content = shadowRootV0.querySelector('content');
+
+input2.onfocus = function(e) {
+ var expected_array2 = [input2, slot2, slotParent, content, shadowRootV0, host3, shadowRootV1, host2, document.body, document.documentElement, document, window];
+ test(function() {
+ assert_array_equals(e.path, expected_array2);
+ }, 'EventPath works fine with v0 insertion points & v1 slots.');
+};
+
+var host4 = document.getElementById('host4');
+convertTemplatesToShadowRootsWithin(host4);
+var shadowRoot2 = host4.shadowRoot;
+var slot3 = shadowRoot2.querySelector('slot');
+var input3 = document.getElementById('input3')
+var inputParent = document.getElementById('input-parent');
+
+input3.onfocus = function(e) {
+ var expected_array3 = [input3, inputParent, slot3, shadowRoot2, host4, document.body, document.documentElement, document, window];
+ test(function() {
+ assert_array_equals(e.path, expected_array3);
+ }, 'EventPath works fine when event happens to a descendant of a slotted element.');
+};
+
+var focusEvent = document.createEvent('MouseEvents');
+focusEvent.initMouseEvent('focus');
+input1.dispatchEvent(focusEvent);
+input2.dispatchEvent(focusEvent);
+input3.dispatchEvent(focusEvent);
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/events/EventPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698