Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix clamping of scroll position in window.scrollBy
For rightward and downward overflow the spec says: Let x be max(0, min(x, viewport scrolling area width - viewport width)). Let y be max(0, min(y, viewport scrolling area height - viewport height)). Previously, those operations were reversed, which created negative overflow even when the overflow direction was downward. This change ensures that Servo matches spec behavior.
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>Ensure that the window.scrollBy function affects scroll position as expected</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<body> | ||
<a id="link" href="http://mozilla.org">This is some link text.</a> | ||
<div style="width: 10000px; height: 10000px; background: pink; z-index: -1;"></div> | ||
<script> | ||
test(function() { | ||
scrollBy(0, 5000); | ||
assert_equals(scrollX, 0); | ||
assert_equals(pageXOffset, 0); | ||
assert_equals(scrollY, 5000); | ||
assert_equals(pageYOffset, 5000); | ||
|
||
scrollTo(0, 0); | ||
|
||
var link = document.getElementById("link"); | ||
var linkRect = link.getBoundingClientRect(); | ||
assert_equals(link, document.elementFromPoint(linkRect.left, linkRect.top)); | ||
window.scrollBy(0, 1); | ||
assert_equals(link, document.elementFromPoint(linkRect.left, linkRect.top - 1)); | ||
}); | ||
</script> | ||
</body> |