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

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

Issue 2053503003: Clean up layout tests in LayoutTests/shadow-dom/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/shadow-dom/slots-dom-mutation.html
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/slots-dom-mutation.html b/third_party/WebKit/LayoutTests/shadow-dom/slots-dom-mutation.html
new file mode 100644
index 0000000000000000000000000000000000000000..0f7f390ec3c88943886316422bc75942d686956e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shadow-dom/slots-dom-mutation.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/shadow-dom.js"></script>
+<div id="host">
+ <template data-mode="open">
+ <slot id="slot1" name="slot1">
+ <div id="fallback1"></div>
+ </slot>
+ <slot id="slot2" name="slot2">
+ <div id="fallback2"></div>
+ </slot>
+ </template>
+ <div id="child1" slot="slot1"></div>
+</div>
+<script>
+'use strict';
+
+let n = createTestTree(host);
+removeWhiteSpaceOnlyTextNodes(n.host);
+
+test(() => {
+ assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.child1]);
+ assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
+}, "Slot's distributed nodes");
+
+test(() => {
+ // Insert
+ const slot0 = document.createElement('slot');
+ slot0.setAttribute('name', 'slot1');
+ n.host.shadowRoot.insertBefore(slot0, n.slot1);
+
+ assert_array_equals(slot0.assignedNodes({ flatten: true }), [n.child1]);
+ assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.fallback1]);
+ assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
+
+ // Remove
+ n.host.shadowRoot.removeChild(slot0);
+ assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.child1]);
+ assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
+}, "Slot's distributed nodes after inserting/removeing a slot.");
+
+test(() => {
+ // Attribute change
+ n.slot1.setAttribute('name', 'slot-foo');
+ assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.fallback1]);
+ assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
+
+ n.child1.setAttribute('slot', 'slot-foo');
+ assert_array_equals(n.slot1.assignedNodes({ flatten: true }), [n.child1]);
+ assert_array_equals(n.slot2.assignedNodes({ flatten: true }), [n.fallback2]);
+}, "Slot's distributed nodes after the attribute is changed.");
+</script>

Powered by Google App Engine
This is Rietveld 408576698