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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/shadow/slotchange-event.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/v1-slots-api-dynamic.html b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotchange-event.html
similarity index 55%
copy from third_party/WebKit/LayoutTests/fast/dom/shadow/v1-slots-api-dynamic.html
copy to third_party/WebKit/LayoutTests/fast/dom/shadow/slotchange-event.html
index 5d51a088946ff107b36b221d01c36441d1d0a86f..424c0c402c7b1ada63c526462ee1aa996e1e026e 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/shadow/v1-slots-api-dynamic.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/slotchange-event.html
@@ -18,7 +18,9 @@
convertTemplatesToShadowRootsWithin(d1);
removeWhiteSpaceOnlyTextNodes(d1);
-test(() => {
+async_test((test) => {
+ var count = 0;
+
const d1_s1 = d1_shadow.querySelector('slot');
const d1_d1_s1 = d1_d1_shadow.querySelector('slot');
@@ -28,15 +30,34 @@ test(() => {
assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]);
assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2]);
+ d1_s1.addEventListener('slotchange', (e) => {
+ test.step(() => {
+ assert_equals(e.target, d1_s1);
+ assert_array_equals(d1_s1.getAssignedNodes(), [d2, d3]);
+ assert_array_equals(d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
+ assert_array_equals(e.scoped, true);
+ count++;
+ // The order when a slotchange event is dispatched in the slots is not guranteed.
+ if (count == 2)
+ test.done();
+ });
+ });
+
+ d1_d1_s1.addEventListener('slotchange', (e) => {
+ test.step(() => {
+ assert_equals(e.target, d1_d1_s1);
+ assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]);
+ assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
+ assert_array_equals(e.scoped, true);
+ count++;
+ if (count == 2)
+ test.done();
+ });
+ });
+
const d3 = document.createElement('div');
d3.setAttribute('id', 'd3');
d3.setAttribute('slot', 'd1-s1');
d1.appendChild(d3);
-
- assert_array_equals(d1_s1.getAssignedNodes(), [d2, d3]);
- assert_array_equals(d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
-
- assert_array_equals(d1_d1_s1.getAssignedNodes(), [d1_s1]);
- assert_array_equals(d1_d1_s1.getAssignedNodes({'flatten': true}), [d2, d3]);
-}, "Distribution should be re-calcualted when assigned nodes of a slot in the parent tree is changed");
+}, "slotchange event should be dispatched.");
</script>
« 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