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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
<!DOCTYPE html>
<html>
<body>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style type="text/css">
#status-log {
margin: 10px 0;
color: green;
color: green;
}
</style>
</head>
<body onload="run_test()">
<h2>Description</h2>
<p>This test if movementX/Y can provide the change in position of the pointer, as if movementX/Y = eNow.screenX/Y-ePrevious.screenX/Y</p>
<hr/>
<h2>Manual Test Steps:</h2>
<p>
<ol>
<li>Click to start Test1.</li>
<li>Move the mouse within the window, slow and fast, like a scribble.</li>
<li>Click again to end test.</li>
</ol>
</p>
<hr/>
<div id="status-log">Waiting... Click to start loging.</div>
<div class="data-log">
<table>
<tr><td></td><td>X</td><td>Y</td></tr>
<tr><td>screen_init:</td><td id="screenX_init-log">X</td><td id="screenY_init-log">Y</td></tr>
<tr><td>screen_last:</td><td id="screenX_last-log">X</td><td id="screenY_last-log">Y</td></tr>
<tr><td>screen_delta:</td><td id="screenX_delta-log">X</td><td id="screenY_delta-log">Y</td></tr>
<tr><td>movement_sum:</td><td id="movementX_sum-log">X</td><td id="movementY_sum-log">Y</td></tr>
<tr><td>movement:</td><td id="movementX-log">X</td><td id="movementY-log">Y</td></tr>
</table>
</div>
<hr/>
<div id="log"></div>
<script type="text/javascript" >
var status_log = document.querySelector('#status-log'),
movementX_log = document.querySelector('#movementX-log'),
movementY_log = document.querySelector('#movementY-log'),
movementX_sum_log = document.querySelector('#movementX_sum-log'),
movementY_sum_log = document.querySelector('#movementY_sum-log'),
screenX_init_log = document.querySelector('#screenX_init-log'),
screenY_init_log = document.querySelector('#screenY_init-log'),
screenX_last_log = document.querySelector('#screenX_last-log'),
screenY_last_log = document.querySelector('#screenY_last-log');
screenX_delta_log = document.querySelector('#screenX_delta-log'),
screenY_delta_log = document.querySelector('#screenY_delta-log');
var click_counter = 0;
var screenX_init, screenY_init, movementX, movementY, movementX_sum, movementY_sum, screenX_last, screenY_last;
var movementX_Y_inside_window_Test = async_test("Test that movementX/Y = eNow.screenX/Y-ePrevious.screenX/Y.");
document.addEventListener("click", function (e) {
click_counter++;
switch(click_counter) {
case 1:
status_log.innerHTML = "inside window: logging...";
break;
case 2:
status_log.innerHTML = "inside window: done";
movementX_Y_inside_window_Test.step(function() {
assert_equals(movementX_sum, screenX_last - screenX_init, "sum of movementX = screenX_last - screenX_init");
assert_equals(movementY_sum, screenY_last - screenY_init, "sum of movementY = screenY_last - screenY_init");
});
movementX_Y_inside_window_Test.done();
break;
}
});
document.addEventListener("mousemove", function (e) {
movementX = e.movementX;
movementY = e.movementY;
if(click_counter === 1) {
if(!screenX_init) {
screenX_init = screenX_last = e.screenX;
screenY_init = screenY_last = e.screenY;
movementX_sum = 0;
movementY_sum = 0;
}
else {
movementX_sum += movementX;
movementY_sum += movementY;
screenX_delta = e.screenX - screenX_last;
screenY_delta = e.screenY - screenY_last;
movementX_Y_inside_window_Test.step(function() {
assert_equals(movementX, screenX_delta, "movementX = screen_delta");
assert_equals(movementY, screenY_delta, "movementY = screen_delta");
});
screenX_last = e.screenX;
screenY_last = e.screenY;
updateData();
}
}
});
function updateData() {
screenX_init_log.innerHTML = screenX_init;
screenY_init_log.innerHTML = screenY_init;
screenX_last_log.innerHTML = screenX_last;
screenY_last_log.innerHTML = screenY_last;
screenX_delta_log.innerHTML = screenX_delta;
screenY_delta_log.innerHTML = screenY_delta;
movementX_log.innerHTML = movementX;
movementY_log.innerHTML = movementY;
movementX_sum_log.innerHTML = movementX_sum;
movementY_sum_log.innerHTML = movementY_sum;
}
function run_test() {
x = Math.round(window.innerWidth / 2);
y = Math.round(window.innerHeight / 2);
var actions = new test_driver.Actions();
actions.pointerMove(x, y)
.pointerDown()
.pointerUp();
for (var i = 0; i < 10; i++) {
// Alternatively move left/right and up/down.
x += ((-1)**i) * i * 10;
y -= ((-1)**i) * i * 10;
actions.pointerMove(x, y);
}
actions.pointerMove(x, y)
.pointerDown()
.pointerUp()
.send();
}
</script>
</body>
</html>
|