Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<meta charset="utf-8">
<meta name="timeout" content="long">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
<title>Test: used 'user-select' is always 'contain' on editable elements</title>
<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 value="I should be selectable">
<input type=search value="I should be selectable">
<input type=url value="">
<input type=tel value="555-555-5555">
<input type=password value="I should be selectable">
<textarea>I should be selectable</textarea>
<div contenteditable="true">I should be selectable</div>
const valuesToTest = ["auto", "text", "none", "contain", "all"];
for (let value of valuesToTest) {
promise_test(async function () {
for (let element of document.querySelectorAll("input,textarea")) { = value;
let start = element.selectionStart;
assert_not_equals(element.selectionStart, start, "Selection should've moved on click.");
element.selectionStart = 0;
let div = document.querySelector("div"); = value;
let oldOffset = getSelection().focusOffset;
assert_not_equals(oldOffset, getSelection().focusOffset, "Selection should've moved on click.");
getSelection().focusOffet = 0;
}, `selection for ${value}`);