Skip to content

Commit

Permalink
Bug 1899600 [wpt PR 46538] - Add a new options argument to `document.…
Browse files Browse the repository at this point in the history
…caretPositionFromPoint` API., a=testonly

Automatic update from web-platform-tests
Add a new options argument to `document.caretPositionFromPoint` API.

Per w3c/csswg-drafts#10345, we should change
`shadowRoots` parameter from a rest parameter to a dictionary which
contains an array of shadow roots.

Bug: 41487363
Change-Id: I0686d1eae75797ae07cad215a71a24ab54c7398d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5553027
Reviewed-by: Mason Freed <[email protected]>
Reviewed-by: Koji Ishii <[email protected]>
Reviewed-by: Sanket Joshi <[email protected]>
Commit-Queue: Siye Liu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1308173}

--

wpt-commits: acce6678c90d675dbe7a797666737376b16073b8
wpt-pr: 46538
  • Loading branch information
siliu1 authored and moz-wptsync-bot committed Jun 5, 2024
1 parent 0aa4315 commit 10bb0c3
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Get x and y coordinate at `he|llo, world`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y);
const caretPosition = document.caretPositionFromPoint(x, y, {});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -68,7 +68,7 @@
// Get x and y coordinate at `he|llo, world`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, shadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [shadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand All @@ -92,7 +92,7 @@
// Get x and y coordinate at `ab|cd`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, shadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [shadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand All @@ -113,7 +113,7 @@
// Get x and y coordinate at left-most location inside input element.
const x = rect.left + 1;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, shadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [shadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Node);
assert_equals(typeof(caretPosition.offset), "number");
Expand All @@ -134,7 +134,7 @@
// Get x and y coordinate at left-most location inside input element.
const x = rect.left + 1;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: []});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Node);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -215,7 +215,7 @@
// Get x and y coordinate at `so|me text`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, innerShadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [innerShadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -244,7 +244,7 @@
// Get x and y coordinate at `so|me text`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, outerShadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [outerShadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Node);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down Expand Up @@ -274,7 +274,7 @@
// Get x and y coordinate at `so|me text`.
const x = rect.left + characterWidth * characterIndex;
const y = rect.top + rect.height / 2;
const caretPosition = document.caretPositionFromPoint(x, y, outerShadowRoot, innerShadowRoot);
const caretPosition = document.caretPositionFromPoint(x, y, {shadowRoots: [innerShadowRoot, outerShadowRoot]});
assert_true(caretPosition instanceof CaretPosition);
assert_true(caretPosition.offsetNode instanceof Text);
assert_equals(typeof(caretPosition.offset), "number");
Expand Down

0 comments on commit 10bb0c3

Please sign in to comment.