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

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

Issue 1695163003: Support slotchange events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor Created 4 years, 10 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src='../../../resources/testharness.js'></script> 2 <script src='../../../resources/testharness.js'></script>
3 <script src='../../../resources/testharnessreport.js'></script> 3 <script src='../../../resources/testharnessreport.js'></script>
4 <script src='resources/shadow-dom.js'></script> 4 <script src='resources/shadow-dom.js'></script>
5 <div id='d1'> 5 <div id='d1'>
6 <template data-mode='open' data-expose-as='d1_shadow'> 6 <template data-mode='open' data-expose-as='d1_shadow'>
7 <div id='d1-d1'> 7 <div id='d1-d1'>
8 <template data-mode='open' data-expose-as='d1_d1_shadow'> 8 <template data-mode='open' data-expose-as='d1_d1_shadow'>
9 <slot name='d1-d1-s1'></slot> 9 <slot name='d1-d1-s1'></slot>
10 </template> 10 </template>
11 <slot name='d1-s1' slot='d1-d1-s1'></slot> 11 <slot name='d1-s1' slot='d1-d1-s1'></slot>
12 </div> 12 </div>
13 </template> 13 </template>
14 <div id='d2' slot='d1-s1'></div> 14 <div id='d2' slot='d1-s1'></div>
15 </div> 15 </div>
16 <script> 16 <script>
17 'use strict'; 17 'use strict';
18 convertTemplatesToShadowRootsWithin(d1); 18 convertTemplatesToShadowRootsWithin(d1);
19 removeWhiteSpaceOnlyTextNodes(d1); 19 removeWhiteSpaceOnlyTextNodes(d1);
20 20
21 test(() => { 21 async_test((test) => {
22 var count = 0;
23
22 const d1_s1 = d1_shadow.querySelector('slot'); 24 const d1_s1 = d1_shadow.querySelector('slot');
23 const d1_d1_s1 = d1_d1_shadow.querySelector('slot'); 25 const d1_d1_s1 = d1_d1_shadow.querySelector('slot');
24 26
25 assert_array_equals(d1_s1.getAssignedNodes(), [d2]); 27 assert_array_equals(d1_s1.getAssignedNodes(), [d2]);
26 assert_array_equals(d1_s1.getAssignedNodes({'flatten': true}), [d2]); 28 assert_array_equals(d1_s1.getAssignedNodes({'flatten': true}), [d2]);
27 29
28 assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]); 30 assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]);
29 assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2]); 31 assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2]);
30 32
33 d1_s1.addEventListener('slotchange', (e) => {
34 test.step(() => {
35 assert_equals(e.target, d1_s1);
36 assert_array_equals(d1_s1.getAssignedNodes(), [d2, d3]);
37 assert_array_equals(d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
38 assert_array_equals(e.scoped, true);
39 count++;
40 // The order when a slotchange event is dispatched in the slots is not gur anteed.
41 if (count == 2)
42 test.done();
43 });
44 });
45
46 d1_d1_s1.addEventListener('slotchange', (e) => {
47 test.step(() => {
48 assert_equals(e.target, d1_d1_s1);
49 assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]);
50 assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2, d3] );
51 assert_array_equals(e.scoped, true);
52 count++;
53 if (count == 2)
54 test.done();
55 });
56 });
57
31 const d3 = document.createElement('div'); 58 const d3 = document.createElement('div');
32 d3.setAttribute('id', 'd3'); 59 d3.setAttribute('id', 'd3');
33 d3.setAttribute('slot', 'd1-s1'); 60 d3.setAttribute('slot', 'd1-s1');
34 d1.appendChild(d3); 61 d1.appendChild(d3);
35 62 }, "slotchange event should be dispatched.");
36 assert_array_equals(d1_s1.getAssignedNodes(), [d2, d3]);
37 assert_array_equals(d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
38
39 assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]);
40 assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
41 }, "Distribution should be re-calcualted when assigned nodes of a slot in the pa rent tree is changed");
42 </script> 63 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | third_party/WebKit/Source/core/dom/Node.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698