blob: edf918e800577254907be53ee748b6cb3d1ed6e4 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<div style="height: 1000px; width: 1000px; border: 1px solid black;">This box should force the window to have a scrollable area to test.</div>
<script language="JavaScript" type="text/javascript">
var resetX;
var resetY;
var x = 25;
var y = 50;
function reset()
{
window.scrollTo(0,0);
resetX = window.scrollX;
resetY = window.scrollY;
}
if (window.testRunner)
testRunner.dumpAsText();
reset();
description("This test makes sure that calling the window scrolling\
methods with a single non-dictionary argument or with a dictionary \
whose 'behavior' field is invalid throws an exception.");
// scrollTo /////////////////////////
debug('');
debug('window.scrollTo Tests');
debug('');
debug("Testing - scrollTo with 0 arguments");
shouldNotThrow('window.scrollTo()');
reset();
debug("Testing - scrollTo with 1 non-dictionary argument");
shouldThrow('window.scrollTo(x)');;
reset();
debug("Testing - scrollTo with a valid ScrollToOptions argument");
shouldNotThrow('window.scrollTo({ })');
shouldNotThrow('window.scrollTo({ left: x })');
shouldNotThrow('window.scrollTo({ top: y })');
shouldNotThrow('window.scrollTo({ behavior: "auto" })');
shouldNotThrow('window.scrollTo({ behavior: "instant" })');
shouldNotThrow('window.scrollTo({ behavior: "smooth" })');
shouldNotThrow('window.scrollTo({ left: x, top: y })');
shouldNotThrow('window.scrollTo({ left: x, top: y, behavior: "auto" })');
shouldNotThrow('window.scrollTo({ left: x, top: y, behavior: "instant" })');
shouldNotThrow('window.scrollTo({ left: x, top: y, behavior: "smooth" })');
debug("Testing - scrollTo with an invalid ScrollToOptions argument");
shouldThrow('window.scrollTo({ behavior: "" })');
shouldThrow('window.scrollTo({ left: x, top: y, behavior: "abcd" })');
shouldThrow('window.scrollTo({ left: x, top: y, behavior: 200 })');
// scroll /////////////////////////
debug('');
debug('window.scroll Tests');
debug('');
debug("Testing - scroll with 0 arguments");
shouldNotThrow('window.scroll()');;
reset();
debug("Testing - scroll with 1 argument");
shouldThrow('window.scroll(x)');
reset();
debug("Testing - scroll with a valid ScrollToOptions argument");
shouldNotThrow('window.scroll({ })');
shouldNotThrow('window.scroll({ left: x })');
shouldNotThrow('window.scroll({ top: y })');
shouldNotThrow('window.scroll({ behavior: "auto" })');
shouldNotThrow('window.scroll({ behavior: "instant" })');
shouldNotThrow('window.scroll({ behavior: "smooth" })');
shouldNotThrow('window.scroll({ left: x, top: y })');
shouldNotThrow('window.scroll({ left: x, top: y, behavior: "auto" })');
shouldNotThrow('window.scroll({ left: x, top: y, behavior: "instant" })');
shouldNotThrow('window.scroll({ left: x, top: y, behavior: "smooth" })');
debug("Testing - scroll with an invalid ScrollToOptions argument");
shouldThrow('window.scroll({ behavior: "" })');
shouldThrow('window.scroll({ left: x, top: y, behavior: "abcd" })');
shouldThrow('window.scroll({ left: x, top: y, behavior: 200 })');
// scrollBy /////////////////////////
debug('');
debug('window.scrollBy Tests');
debug('');
debug("Testing - scrollBy with 0 arguments");
shouldNotThrow('window.scrollBy()');;
reset();
debug("Testing - scrollBy with 1 argument");
shouldThrow('window.scrollBy(x)');
reset();
debug("Testing - scrollBy with a valid ScrollOptions argument");
shouldNotThrow('window.scrollBy({ })');
shouldNotThrow('window.scrollBy({ left: x })');
shouldNotThrow('window.scrollBy({ top: y })');
shouldNotThrow('window.scrollBy({ behavior: "auto" })');
shouldNotThrow('window.scrollBy({ behavior: "instant" })');
shouldNotThrow('window.scrollBy({ behavior: "smooth" })');
shouldNotThrow('window.scrollBy({ left: x, top: y })');
shouldNotThrow('window.scrollBy({ left: x, top: y, behavior: "auto" })');
shouldNotThrow('window.scrollBy({ left: x, top: y, behavior: "instant" })');
shouldNotThrow('window.scrollBy({ left: x, top: y, behavior: "smooth" })');
debug("Testing - scrollBy with an invalid ScrollOptions argument");
shouldThrow('window.scrollBy({ behavior: "" })');
shouldThrow('window.scrollBy({ left: x, top: y, behavior: "abcd" })');
shouldThrow('window.scrollBy({ left: x, top: y, behavior: 200 })');
</script>
</body>
</html>