Files
sousa-gecko/testing/web-platform/tests/selection/textcontrols/click-input-after-iframe-focus.html
T
Mason Freed ae784a98e2 Bug 2050995 [wpt PR 60934] - Fix selection collapse when setting selection to unchanged value, a=testonly
Automatic update from web-platform-tests
Fix selection collapse when setting selection to unchanged value

When FrameSelection::SetSelection is called with a selection that
matches the current selection, it returns early without notifying the
SelectionController. This causes SelectionController's
selection_state_ to remain out of sync (kHaveNotStartedSelection).

Fixed: 342383810
Change-Id: Ie9615d9a0550093725aed4fd253dcbe956f3c6ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7997284
Reviewed-by: Dan Clark <daniec@microsoft.com>
Commit-Queue: Dan Clark <daniec@microsoft.com>
Auto-Submit: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1653534}

--

wpt-commits: 1eb456f600fedad07c8cd6439796fb81db54faff
wpt-pr: 60934
2026-07-10 09:20:04 +00:00

36 lines
1.2 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" href="mailto:masonf@chromium.org">
<link rel="help" href="https://crbug.com/342383810">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<input type=text id=input value="Some text"><br>
<iframe id=iframe src="about:blank"></iframe>
<script>
function is_fully_selected(input) {
return input.selectionStart === 0 && input.selectionEnd === input.value.length;
}
promise_test(async (t) => {
input.addEventListener('focus', function() {
this.select();
}, {signal: t.get_signal()});
// 1. Click inside the input. Text is selected.
await test_driver.click(input);
assert_true(is_fully_selected(input), 'Initial click');
// 2. Click inside the iframe. The text loses focus.
await test_driver.click(iframe);
assert_not_equals(document.activeElement, input, 'Input should lose focus');
// 3. Click back inside the input. The text should still be selected.
await test_driver.click(input);
assert_true(is_fully_selected(input), 'Second click');
}, "Selection behavior when selection doesn't change");
</script>