summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/scrolling/scrolling-apis-nan-scroll-position.html
blob: 54875198ae4e5c8aa3d021f35e9524d6cc9b3bd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE HTML>
<style>

body {
  height: 30000px;
  width: 30000px;
}

.spacer {
  height: 1000px;
  width: 1000px;
}

#scroller {
  height: 100px;
  width: 100px;
  overflow: scroll;
}
</style>

<div id=scroller>
    <div class=spacer></div>
</div>

<script src="../../resources/js-test.js"></script>
<script>
description("Verifies that nan scroll position works correctly.");

function scrollToNonFinite(x, y)
{
    window.scrollTo(100, 100);
    window.scrollTo(x, y);
    shouldBe('window.scrollY', "0");
    shouldBe('window.scrollX', "0");

    window.scrollTo(100, 100);
    window.scrollTo({top: y, left: x});
    shouldBe('window.scrollY', "0");
    shouldBe('window.scrollX', "0");
}

function scrollByNonFinite(x, y)
{
    window.scrollTo(100, 100);
    window.scrollBy(x, y);
    shouldBe('window.scrollY', "100");
    shouldBe('window.scrollX', "100");

    window.scrollTo(100, 100);
    window.scrollBy({top: y, left: x});
    shouldBe('window.scrollY', "100");
    shouldBe('window.scrollX', "100");
}

function scrollTopNonFinite(y)
{
    scroller.scrollTop = 1;
    shouldBe("scroller.scrollTop", "1");
    scroller.scrollTop = y;
    shouldBe("scroller.scrollTop", "0");
}

function scrollLeftNonFinite(x)
{
    scroller.scrollLeft = 1;
    shouldBe("scroller.scrollLeft", "1");
    scroller.scrollLeft = x;
    shouldBe("scroller.scrollLeft", "0");
}

function scroll()
{
    window.scrollTo(1, 1);
    shouldBe('window.scrollY', "1");
    shouldBe('window.scrollX', "1");

    scrollToNonFinite(window.NaN, window.NaN);
    scrollToNonFinite(window.Infinity, window.Infinity);
    scrollToNonFinite(0, window.Infinity);
    scrollToNonFinite(-window.Infinity, -window.Infinity);

    scrollByNonFinite(window.NaN, window.NaN);
    scrollByNonFinite(window.Infinity, window.Infinity);
    scrollByNonFinite(0, window.Infinity);
    scrollByNonFinite(-window.Infinity, -window.Infinity);

    scrollTopNonFinite(window.NaN);
    scrollTopNonFinite(window.Infinity);
    scrollTopNonFinite(-window.Infinity);

    scrollLeftNonFinite(window.NaN);
    scrollLeftNonFinite(window.Infinity);
    scrollLeftNonFinite(-window.Infinity);
}

onload = function() {
    if (window.eventSender)
      scroll();
}

</script>