Add tests for Range collapse ordering in deleteContents/extractContents#58008
Open
stevenobiajulu wants to merge 2 commits intoweb-platform-tests:masterfrom
Open
Add tests for Range collapse ordering in deleteContents/extractContents#58008stevenobiajulu wants to merge 2 commits intoweb-platform-tests:masterfrom
stevenobiajulu wants to merge 2 commits intoweb-platform-tests:masterfrom
Conversation
Verify that Range.deleteContents() and Range.extractContents() collapse the range to the correct position after the operation completes. Tests cover: - Element children fully contained (Case 1: start is ancestor of end) - Mixed ancestry with multiple contained nodes (Case 2) - CharacterData boundary nodes with partial text deletion - Same CharacterData node (early return path) These tests serve as conformance/non-regression tests for the spec fix that moves range collapse before mutations (whatwg/dom#1446).
5 tasks
smaug----
reviewed
Mar 9, 2026
Contributor
smaug----
left a comment
There was a problem hiding this comment.
How do these tests test possible mutation? Like having iframe and the page in it having pagehide and that listener trying to modify DOM
…tents Address smaug's review: the existing tests only verified final collapse position without exercising synchronous script during removal. Add a test to each file that uses a custom element whose disconnectedCallback removes an earlier sibling mid-operation, verifying the range adjusts correctly. Tested in Chrome, Firefox, and Safari — all pass (startOffset = 0).
stevenobiajulu
commented
Mar 11, 2026
Author
stevenobiajulu
left a comment
There was a problem hiding this comment.
You're right — the existing tests only check the final collapse position without exercising script during removal. I've pushed a test for each API that uses a custom element whose disconnectedCallback removes an earlier sibling mid-operation and verifies the range adjusts correctly (startOffset = 0). Passes in Chrome, Firefox, and Safari.
AtkinsSJ
added a commit
to AtkinsSJ/ladybird
that referenced
this pull request
Apr 16, 2026
The spec text has also changed since we implemented it, but moving when we collapse the range is the only actual behaviour change. Corresponds to: whatwg/dom@9363c6d Also imported a couple of tests for it, from this WPT PR which isn't yet merged: web-platform-tests/wpt#58008
|
I just tested these in Ladybird, and they pass with or without the changes to Range in whatwg/dom#1452 . (PR is LadybirdBrowser/ladybird#8944 for reference.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add conformance tests for Range collapse position after
deleteContents()andextractContents(), covering the spec fix in whatwg/dom#1446.New test files:
dom/ranges/Range-deleteContents-mutation-order.html— 4 testsdom/ranges/Range-extractContents-mutation-order.html— 4 testsTest scenarios
Related