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

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

Issue 2060793002: Rewrite tests for slots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@events-related
Patch Set: fixed Created 4 years, 6 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
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/shadow-dom.js"></script>
5 <div id="host">
6 <template data-mode="open">
7 <slot id="slot1" name="slot1">
8 <div id="fallback1"></div>
9 </slot>
10 <slot id="slot2" name="slot2">
11 <div id="fallback2"></div>
12 </slot>
13 </template>
14 <div id="child1" slot="slot1"></div>
15 </div>
16 <script>
17 'use strict';
18
19 let n = createTestTree(host);
20 removeWhiteSpaceOnlyTextNodes(n.host);
21
22 test(() => {
23 assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.child1]);
24 assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
25 }, "Slot's distributed nodes");
26
27 test(() => {
28 // Insert
29 const slot0 = document.createElement('slot');
30 slot0.setAttribute('name', 'slot1');
31 n.host.shadowRoot.insertBefore(slot0, n.slot1);
32
33 assert_array_equals(slot0.assignedNodes({ flatten: true }), [n.child1]);
34 assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.fallback1]);
35 assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
36
37 // Remove
38 n.host.shadowRoot.removeChild(slot0);
39 assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.child1]);
40 assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
41 }, "Slot's distributed nodes after inserting/removeing a slot.");
42
43 test(() => {
44 // Attribute change
45 n.slot1.setAttribute('name', 'slot-foo');
46 assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.fallback1]);
47 assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
48
49 n.child1.setAttribute('slot', 'slot-foo');
50 assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.child1]);
51 assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
52 }, "Slot's distributed nodes after the attribute is changed.");
53 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698