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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ScrollState constructor behaves correctly</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function() {
assert_true('ScrollState' in window, "'ScrollState' in window");
}, "These tests only work with scroll customization enabled.");
if ('ScrollState' in window) {
test(function() {
var scrollState = new ScrollState();
assert_equals(scrollState.deltaX, 0);
assert_equals(scrollState.deltaY, 0);
assert_equals(scrollState.deltaGranularity, 0);
assert_equals(scrollState.velocityX, 0);
assert_equals(scrollState.velocityY, 0);
assert_equals(scrollState.inInertialPhase, false);
assert_equals(scrollState.isBeginning, false);
assert_equals(scrollState.isEnding, false);
assert_equals(scrollState.fromUserInput, false);
assert_equals(scrollState.shouldPropagate, true);
}, "Empty constructor behaves correctly.");
test(function() {
var init = {
deltaX: 12.5,
deltaY: 14.9,
startPositionX: 16.82,
startPositionY: 82.17,
velocityX: 23.7,
velocityY: 2.5,
isBeginning: true,
isInInertialPhase: true,
isEnding: true,
shouldPropagate: false,
fromUserInput: true,
isDirectManipulation: true,
deltaGranularity: 148.3
};
var scrollState = new ScrollState(init);
assert_equals(scrollState.deltaX, init.deltaX);
assert_equals(scrollState.deltaY, init.deltaY);
assert_equals(scrollState.startPositionX, Math.floor(init.startPositionX));
assert_equals(scrollState.startPositionY, Math.floor(init.startPositionY));
assert_equals(scrollState.velocityX, init.velocityX);
assert_equals(scrollState.velocityY, init.velocityY);
assert_equals(scrollState.isBeginning, init.isBeginning);
assert_equals(scrollState.inInertialPhase, init.isInInertialPhase);
assert_equals(scrollState.isEnding, init.isEnding);
assert_equals(scrollState.shouldPropagate, init.shouldPropagate);
assert_equals(scrollState.fromUserInput, init.fromUserInput);
assert_equals(scrollState.isDirectManipulation, init.isDirectManipulation);
assert_equals(scrollState.deltaGranularity, init.deltaGranularity);
}, "Constructor behaves correctly.");
test(function() {
var scrollState = new ScrollState();
scrollState.isBeginning = true;
assert_equals(scrollState.isBeginning, false);
scrollState.fromUserInput = true;
assert_equals(scrollState.fromUserInput, false);
}, "attributes are read only");
}
</script>
</body>
</html>
|