diff --git a/html/semantics/forms/the-input-element/selection-pointer.html b/html/semantics/forms/the-input-element/selection-pointer.html index 8cb0ead44148dfb..7f06ae24a2d5d86 100644 --- a/html/semantics/forms/the-input-element/selection-pointer.html +++ b/html/semantics/forms/the-input-element/selection-pointer.html @@ -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 should not cancel selection`); }