Revision control

1
<body>
2
<script src="../resources/magnitude-perf.js"></script>
3
<style>
4
.outer {
5
position: relative;
6
margin: 0.25px;
7
padding: 0.25px;
8
}
9
.inner {
10
width: 100px;
11
height: 100px;
12
background: red;
13
}
14
</style>
15
<div id="test"></div>
16
<script>
17
18
var innerElement, reportedPosition;
19
var testElement = document.getElementById('test');
20
21
function setupFunction(magnitude)
22
{
23
testElement.innerHTML = '';
24
var element, parent = testElement;
25
for (var i = 0; i < magnitude; i++) {
26
element = document.createElement('div');
27
element.className = 'outer';
28
parent.appendChild(element);
29
parent = element;
30
}
31
element = document.createElement('div');
32
element.className = 'inner';
33
parent.appendChild(element);
34
element.onmouseover = function(e) {
35
reportedPosition = e.offsetX + ', ' + e.offsetY;
36
};
37
innerElement = element;
38
}
39
40
function test(magnitude)
41
{
42
if (window.eventSender) {
43
var rect = innerElement.getBoundingClientRect();
44
eventSender.mouseMoveTo(0, 0);
45
eventSender.mouseMoveTo(rect.left, rect.top);
46
eventSender.mouseMoveTo(0, 0);
47
}
48
}
49
50
Magnitude.description("Tests that mouse event dispatch is linear with respect to the number of parent elements.");
51
Magnitude.run(setupFunction, test, Magnitude.LINEAR);
52
</script>
53
</body>