Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 6 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /dom/ranges/tentative/FormControlRange-supported-elements.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body></body>
<script>
test(() => {
[
{ html: '<textarea>Hello world</textarea>', name: 'textarea' },
{ html: '<input type="text" value="Sample text">', name: 'input[type=text]' },
{ html: '<input type="search" value="search query">', name: 'input[type=search]' },
{ html: '<input type="password" value="secret123">', name: 'input[type=password]' },
{ html: '<input type="tel" value="+1-555-123-4567">', name: 'input[type=tel]' }
].forEach(({ html, name }) => {
test(() => {
document.body.innerHTML = html;
const element = document.body.firstElementChild;
const range = new FormControlRange();
const value = element.value || element.textContent;
range.setFormControlRange(element, 0, value.length);
assert_equals(range.startContainer, element);
assert_equals(range.endContainer, element);
assert_equals(range.toString(), value);
}, `FormControlRange should support ${name}.`);
});
}, "FormControlRange supported elements.");
</script>