Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test all input types with scrollTo and onscroll #20172

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions html/rendering/widgets/input-all-scrollable.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<title>Text controls are scroll containers</title>
<link rel=help href="https://html.spec.whatwg.org/multipage/rendering.html#the-input-element-as-a-text-entry-widget">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
input { width: 2em; }
</style>
<body>
<script>
// Test all input types and expect a 'scroll' event for
// - "text entry widgets"
// - image-alt with non-visible overflow
// This matches what whatwg/html#4840 requires
// (if we take the "overflow doesn't apply" +
// no statement to allow or require a scroll container
// to mean that scrolling shouldn't be supported).
// TODO(zcorpan) https://github.com/whatwg/html/issues/5099
function setExpectation(el, t) {
if ((el.type === 'text' ||
el.type === 'search' ||
el.type === 'password' ||
el.type === 'tel' ||
el.type === 'email' ||
el.type === 'url') ||
(el.type === 'image' && el.style.overflow !== 'visible')) {
el.onscroll = t.step_func_done();
t.step_timeout(t.unreached_func("No event"), 4000);
} else {
el.onscroll = t.unreached_func("Unexpected event");
t.step_timeout(t.step_func_done(), 4000);
}
}
for (var inputType of ['text', 'search', 'password', 'tel', 'email', 'url', 'date', 'month', 'week', 'time', 'datetime-local', 'number', 'range', 'color', 'checkbox', 'radio', 'file', 'button', 'submit', 'reset', 'image']) {
for (var overflowValue of ['visible', 'hidden', 'scroll']) {
for (var appearanceValue of ['auto', 'none']) {
async_test(t => {
var el = document.createElement('input');
el.type = inputType;
var longValue = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab';
if (inputType === 'image') {
el.alt = longValue;
} else if (inputType !== 'file') {
el.value = longValue;
}
el.style.overflow = overflowValue;
el.style.WebkitAppearance = appearanceValue;
el.style.appearance = appearanceValue;
document.body.appendChild(el);
setExpectation(el, t);
el.scrollTo(1000, 0);
}, `scrolling <input type=${inputType}> with overflow:${overflowValue}; appearance: ${appearanceValue}`);
}
}
}
</script>