Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 444b9f5

Browse files
dbaronmoz-wptsync-bot
authored andcommitted
Bug 1856013 [wpt PR 42249] - Add test for insertion of new <details name> elements into a group., a=testonly
Automatic update from web-platform-tests Add test for insertion of new <details name> elements into a group. I realized this test was missing due to whatwg/html#9400 (comment) Bug: 1444057 Change-Id: I18d5b553d2ab20543b37e190c1768703b43ac843 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4903590 Auto-Submit: David Baron <[email protected]> Reviewed-by: Joey Arhar <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1203408} -- wpt-commits: 59cd10c8c3296f14addd02e7ad2c35da7b6afb1a wpt-pr: 42249
1 parent 8a3ebc1 commit 444b9f5

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

testing/web-platform/tests/html/semantics/interactive-elements/the-details-element/name-attribute.tentative.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,5 +359,61 @@
359359
assert_element_states(elements, [1, 0, 0], "states after insertion by parser");
360360
}, "closing as a result of parsing doesn't depend on attribute order");
361361

362+
promise_test(async t => {
363+
container.innerHTML = `
364+
<details name="a" id="e0" open></details>
365+
<details name="a" id="e1"></details>
366+
`;
367+
let elements = [ document.getElementById("e0"),
368+
document.getElementById("e1") ];
369+
370+
assert_element_states(elements, [1, 0], "states before first mutation");
371+
372+
let make_details = () => {
373+
let e = document.createElement("details");
374+
e.setAttribute("name", "a");
375+
return e;
376+
};
377+
378+
let watch_e0 = new EventWatcher(t, elements[0], ['toggle']);
379+
let watch_e1 = new EventWatcher(t, elements[1], ['toggle']);
380+
381+
let expect_opening = async (watcher) => {
382+
await watcher.wait_for(['toggle'], {record: 'all'}).then((events) => {
383+
assert_equals(events[0].oldState, "closed");
384+
assert_equals(events[0].newState, "open");
385+
});
386+
};
387+
388+
let expect_closing = async (watcher) => {
389+
await watcher.wait_for(['toggle'], {record: 'all'}).then((events) => {
390+
assert_equals(events[0].oldState, "open");
391+
assert_equals(events[0].newState, "closed");
392+
});
393+
};
394+
395+
await expect_opening(watch_e0);
396+
397+
// Test appending an open element in the group.
398+
let new1 = make_details();
399+
let watch_new1 = new EventWatcher(t, new1, ['toggle']);
400+
new1.open = true;
401+
await expect_opening(watch_new1);
402+
container.appendChild(new1);
403+
await expect_closing(watch_new1);
404+
405+
// Test appending a closed element in the group.
406+
let new2 = make_details();
407+
let watch_new2 = new EventWatcher(t, new2, ['toggle']);
408+
container.appendChild(new2);
409+
410+
// Test inserting an open element at the start of the group.
411+
let new3 = make_details();
412+
new3.open = true; // this time do this before creating the EventWatcher
413+
let watch_new3 = new EventWatcher(t, new3, ['toggle']);
414+
await expect_opening(watch_new3);
415+
container.insertBefore(new3, elements[0]);
416+
await expect_closing(watch_new3);
417+
}, "handling of insertion of elements into group");
362418

363419
</script>

0 commit comments

Comments
 (0)