Skip to content

Commit

Permalink
Update test expectations for Element.focus change.
Browse files Browse the repository at this point in the history
Element.focus() now centers an element in the block and inline
directions when the element should be scrolled into view. Update tests
to account for this.

Differential Revision: https://phabricator.services.mozilla.com/D183541

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1842679
gecko-commit: 7ffbd7298f7b4d38aad4c5af4e08a00e626d2c09
gecko-reviewers: emilio, credential-management-reviewers, devtools-reviewers, sgalich, ochameau
  • Loading branch information
dlrobertson authored and pull[bot] committed Jul 26, 2023
1 parent e39b7c5 commit 1001378
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions css/css-scroll-snap/scroll-target-margin-005.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

<script>
promise_test(async function() {
document.scrollingElement.scrollTo(0, 20000);
await new Promise(resolve => {
document.addEventListener("scroll", resolve, { once: true });
document.getElementById("target").focus();
});
// Should be around 4900 (5000 - 200px of margin). Give some leeway to account for line height / borders / input padding / etc.
assert_between_exclusive(document.scrollingElement.scrollTop, 4600, 4850, "Should honor date input scroll-margin");
document.scrollingElement.scrollTo(0, 20000);
await new Promise(resolve => {
document.addEventListener("scroll", resolve, { once: true });
document.getElementById("target").focus();
});
// Should be around 5000 - 200px of margin - (window.innerHeight / 2)
const targetPos = 4900 - (window.innerHeight / 2);
assert_between_exclusive(document.scrollingElement.scrollTop, targetPos - 300,
targetPos + 300, "Should honor date input scroll-margin");
});
</script>

0 comments on commit 1001378

Please sign in to comment.