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

Unified Diff: third_party/WebKit/LayoutTests/shadow-dom/slotchange-event.html

Issue 1899653002: Support slotchange event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Element.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/shadow-dom/slotchange-event.html
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/slotchange-event.html b/third_party/WebKit/LayoutTests/shadow-dom/slotchange-event.html
index c16889d5a5f70cbeeb7ed26933a39e1cea9db447..0f2e9ca3f9217ec387a637d41f7b68d7590af809 100644
--- a/third_party/WebKit/LayoutTests/shadow-dom/slotchange-event.html
+++ b/third_party/WebKit/LayoutTests/shadow-dom/slotchange-event.html
@@ -19,7 +19,8 @@ convertTemplatesToShadowRootsWithin(d1);
removeWhiteSpaceOnlyTextNodes(d1);
async_test((test) => {
- var count = 0;
+ var count_for_d1_s1 = 0;
+ var count_for_d1_d1_s1 = 0;
const d1_s1 = d1_shadow.querySelector('slot');
const d1_d1_s1 = d1_d1_shadow.querySelector('slot');
@@ -32,26 +33,37 @@ async_test((test) => {
d1_s1.addEventListener('slotchange', (e) => {
test.step(() => {
- assert_equals(e.target, d1_s1);
- assert_array_equals(d1_s1.assignedNodes(), [d2, d3]);
- assert_array_equals(d1_s1.assignedNodes({'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)
+ count_for_d1_s1++;
+ if (count_for_d1_s1 == 1) {
+ assert_equals(e.target, d1_s1);
+ assert_array_equals(d1_s1.assignedNodes(), [d2, d3]);
+ assert_array_equals(d1_s1.assignedNodes({'flatten': true}), [d2, d3]);
+ assert_array_equals(e.scoped, true);
+ } else if (count_for_d1_s1 == 2) {
+ assert_equals(e.target, d1_s1);
+ assert_array_equals(d1_s1.assignedNodes(), [d2]);
+ assert_array_equals(d1_s1.assignedNodes({'flatten': true}), [d2]);
+ assert_array_equals(e.scoped, true);
test.done();
+ }
});
});
d1_d1_s1.addEventListener('slotchange', (e) => {
test.step(() => {
- assert_equals(e.target, d1_d1_s1);
- assert_array_equals(d1_d1_s1.assignedNodes(), [d1_s1]);
- assert_array_equals(d1_d1_s1.assignedNodes({'flatten': true}), [d2, d3]);
- assert_array_equals(e.scoped, true);
- count++;
- if (count == 2)
+ count_for_d1_d1_s1++;
+ if (count_for_d1_d1_s1 == 1) {
+ assert_equals(e.target, d1_d1_s1);
+ assert_array_equals(d1_d1_s1.assignedNodes(), [d1_s1]);
+ assert_array_equals(d1_d1_s1.assignedNodes({'flatten': true}), [d2, d3]);
+ assert_array_equals(e.scoped, true);
+ } else if (count_for_d1_d1_s1 == 2){
+ assert_equals(e.target, d1_d1_s1);
+ assert_array_equals(d1_d1_s1.assignedNodes(), [d1_s1]);
+ assert_array_equals(d1_d1_s1.assignedNodes({'flatten': true}), [d2]);
+ assert_array_equals(e.scoped, true);
test.done();
+ }
});
});
@@ -59,5 +71,10 @@ async_test((test) => {
d3.setAttribute('id', 'd3');
d3.setAttribute('slot', 'd1-s1');
d1.appendChild(d3);
-}, "slotchange event should be dispatched.");
+ // Different microtask.
+ setTimeout(function(){
+ d3.remove();
+ }, 0);
+
+}, "slotchange event should be dispatched for a slot at most once per microtask.");
</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Element.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698