Skip to content

Conversation

@keithamus
Copy link
Member

This attempts to write some tests for w3c/csswg-drafts#12362

/cc @mfreed7 can I get a reviewer from the Chrome side please? Some of these tests will fail and impl may need adjusting as I think all browsers are inconsistent (caretRangeFromPoint.tentative.html passes but others don't - reporting the wrong node).

/cc @annevk likewise - if I can get a suitable WebKit reviewer, as some of these will fail in WebKit.

/cc @gregorypappas

Copy link
Contributor

@mfreed7 mfreed7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look ok, and despite the failures, I'm ok to land this. But I'd love to make sure the Blink failures are actual bugs, per the new spec PR.

assert_true(range instanceof Range);
assert_equals(range.startOffset, 1);
assert_equals(range.endOffset, 1);
assert_equals(range.startContainer, textarea);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blink returns the document as the container. Not sure if that's correct?

assert_true(range instanceof Range);
assert_equals(range.startOffset, 0);
assert_equals(range.endOffset, 0);
assert_equals(range.startContainer, textarea);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, Blink returns <body>. Again, not sure what's correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebKit returns the <textarea> here. That makes sense to me since if a user clicked at (0, 0), the selection would be in the textarea.

<script>
test(() => {
const textarea = document.createElement("textarea");
document.replaceChild(textarea, document.documentElement);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In WebKit this line replaces the entire test content with <textarea></textarea> so nothing actually gets tested.

assert_equals(range.startOffset, characterIndex);
assert_equals(range.endOffset, characterIndex);
assert_true(range.collapsed);
}, "document.caretRangeFromPoint() on a shadow should return a Range pointing at document.body");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why body and not the shadow host?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent here is that it should match caretPositionFromPoint, so I've changed it to do that exactly.

@keithamus keithamus enabled auto-merge (squash) September 16, 2025 12:05
@keithamus keithamus merged commit 3de8a89 into web-platform-tests:master Sep 16, 2025
23 checks passed
mertcanaltin pushed a commit to mertcanaltin/wpt that referenced this pull request Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants