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

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

Issue 2306873002: Make slotchange events bubble (Closed)
Patch Set: fix Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLSlotElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5
6 <div id="test1"> 6 <div id="test1">
7 <div id="host1"> 7 <div id="host1">
8 <template data-mode="open"> 8 <template id="shadowroot" data-mode="open">
9 <slot id="s1" name="slot1"></slot> 9 <slot id="s1" name="slot1"></slot>
10 </template> 10 </template>
11 <div id="c1" slot="slot1"></div> 11 <div id="c1" slot="slot1"></div>
12 </div> 12 </div>
13 </div> 13 </div>
14 14
15 <script> 15 <script>
16 function doneIfSlotChange(slots, test) { 16 function doneIfSlotChange(slots, test) {
17 let fired = new Set(); 17 let fired = new Set();
18 for (let slot of slots) { 18 for (let slot of slots) {
19 slot.addEventListener('slotchange', test.step_func((e) => { 19 slot.addEventListener('slotchange', test.step_func((e) => {
20 assert_false(fired.has(slot.id)); 20 assert_false(fired.has(slot.id));
21 fired.add(slot.id); 21 fired.add(slot.id);
22 if (fired.size == slots.length) { 22 if (fired.size == slots.length) {
23 test.done(); 23 test.done();
24 } 24 }
25 })) 25 }))
26 } 26 }
27 } 27 }
28 28
29 async_test((test) => { 29 async_test((test) => {
30 let n = createTestTree(test1); 30 let n = createTestTree(test1);
31 removeWhiteSpaceOnlyTextNodes(n.test1); 31 removeWhiteSpaceOnlyTextNodes(n.test1);
32 32
33 n.shadowroot.addEventListener('slotchange', test.step_func((e) => {
kochi 2016/09/02 02:57:06 nit: you can use test.step_func_done(...) and remo
hayato 2016/09/02 04:08:10 Done.
34 assert_true(event.bubbles, 'A slotchange should be a bubble event');
35 assert_false(event.composed, 'A slotchange should be a non-composed event')
36 assert_equals(event.target, n.s1);
37 test.done();
38 }))
39
40 let d1 = document.createElement('div');
41 d1.setAttribute('slot', 'slot1');
42 n.host1.appendChild(d1);
43 }, 'A slotchange event shoud be a bubble, non-composed event.');
kochi 2016/09/02 02:57:06 nit: s/bubble/bubbling/
hayato 2016/09/02 04:08:10 Done
44
45 async_test((test) => {
46 let n = createTestTree(test1);
47 removeWhiteSpaceOnlyTextNodes(n.test1);
48
33 doneIfSlotChange([n.s1], test); 49 doneIfSlotChange([n.s1], test);
34 50
35 let d1 = document.createElement('div'); 51 let d1 = document.createElement('div');
36 d1.setAttribute('slot', 'slot1'); 52 d1.setAttribute('slot', 'slot1');
37 n.host1.appendChild(d1); 53 n.host1.appendChild(d1);
38 }, 'slotchange event: Append a child to a host.'); 54 }, 'slotchange event: Append a child to a host.');
39 55
40 async_test((test) => { 56 async_test((test) => {
41 let n = createTestTree(test1); 57 let n = createTestTree(test1);
42 removeWhiteSpaceOnlyTextNodes(n.test1); 58 removeWhiteSpaceOnlyTextNodes(n.test1);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 <script> 275 <script>
260 async_test((test) => { 276 async_test((test) => {
261 let n = createTestTree(test6); 277 let n = createTestTree(test6);
262 removeWhiteSpaceOnlyTextNodes(n.test6); 278 removeWhiteSpaceOnlyTextNodes(n.test6);
263 279
264 doneIfSlotChange([n.s2], test); 280 doneIfSlotChange([n.s2], test);
265 281
266 n.s1.remove(); 282 n.s1.remove();
267 }, "slotchange event: Even if distributed nodes do not change, slotchange should be fired if assigned nodes are changed."); 283 }, "slotchange event: Even if distributed nodes do not change, slotchange should be fired if assigned nodes are changed.");
268 </script> 284 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLSlotElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698