Skip to content

Commit

Permalink
Bug 1830579 [wpt PR 39753] - Update the-input-element/selection-point…
Browse files Browse the repository at this point in the history
…er.html to support multi-range, a=testonly

Automatic update from web-platform-tests
Update the-input-element/selection-pointer.html to support multi-range

See [1] for context. This CL makes this test pass in the case that
multiple range support is present *and* selecting across an `<input>`
creates multiple ranges. Note that in my local testing, only a single
range is created on all rendering engines (Blink, WebKit, and Gecko)
when the user selects across an `<input>`. Thus, I was not able to test
the newly added code here. I did attempt to verify that it would work
correctly, however, and I believe it will.

[1] web-platform-tests/interop#313

Change-Id: I88c88fcca47da627a0be9de518b76bbbcc07964b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4492089
Reviewed-by: Di Zhang <dizhangg@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1137412}

--

wpt-commits: 655997d590b0d2c50a08e565e0cbab272b4b00e4
wpt-pr: 39753
  • Loading branch information
Mason Freed authored and moz-wptsync-bot committed May 21, 2023
1 parent a9f546a commit 33ae9ec
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,20 @@
.pointerMove(0, 0, {origin: bar})
.pointerUp()
.send();
assert_equals(selection.anchorNode, foo.childNodes[0], "anchorNode");
assert_equals(selection.focusNode, bar.childNodes[0], "focusNode");
const nRanges = selection.rangeCount;
assert_true(nRanges > 0);
const expectedStart = foo.childNodes[0];
const expectedEnd = bar.childNodes[0];
if (nRanges === 1) {
assert_equals(selection.anchorNode, expectedStart, "anchorNode");
assert_equals(selection.focusNode, expectedEnd, "focusNode");
} else {
// In case multiple ranges are supported, make sure the set of ranges
// spans the full selection, across the input.
const ranges = [...Array(nRanges).keys()].map(n => selection.getRangeAt(n));
assert_true(ranges.some(r => r.startContainer === expectedStart),"startContainer");
assert_true(ranges.some(r => r.endContainer === expectedEnd),"endContainer");
}
}, `Selecting texts across <input type=${inputType}> should not cancel selection`);
}
</script>

0 comments on commit 33ae9ec

Please sign in to comment.