-
Notifications
You must be signed in to change notification settings - Fork 54
/
layout_change_should_fire_mouseover-manual.html
83 lines (79 loc) · 2.97 KB
/
layout_change_should_fire_mouseover-manual.html
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
<!doctype html>
<html>
<head>
<title>Mouseover/enter is sent on layout change</title>
<meta name="viewport" content="width=device-width">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#spacer {
height: 100px;
width: 100px;
}
#red {
background-color: rgb(255, 0, 0);
position: absolute;
z-index: 0;
left: 0px;
top: 0px;
height: 100px;
width: 100px;
}
#blue {
background-color: rgb(0, 0, 255);
position: absolute;
z-index: 1;
left: 0px;
top: 0px;
height: 100px;
width: 100px;
}
#blue:hover {
background-color: rgb(255, 255, 0);
}
</style>
</head>
<body onload="run();">
<div id="spacer"></div>
<div id="red"></div>
<h4>Test Description: Tests that the mouseover event is fired and the element has a hover effect when the element underneath the mouse cursor is changed.
<ol>
<li>Put your mouse over the red rectangle</li>
<li>Click the primary mouse button</li>
</ol>
</h4>
<script type="text/javascript">
var testMouseOver = async_test('Tests that the mouseover event is fired and the element has a hover effect when the element underneath the mouse cursor is changed.');
var eventList = [];
function addBlue() {
document.body.innerHTML += '<div id="blue"></div>';
var blue = document.getElementById("blue");
var events = ['mouseover', 'mousemove', 'mouseout', 'mouseenter', 'mouseleave'];
events.forEach(function (event) {
blue.addEventListener(event, checkHoverEffect);
});
testMouseOver.step_timeout(function () {
checkEventSequence();
}, 2500);
}
function checkEventSequence() {
var result = eventList.join();
assert_true(result == 'mouseover,mouseenter');
testMouseOver.done();
}
function run() {
document.addEventListener('click', addBlue);
}
function checkHoverEffect(event) {
eventList.push(event.type);
testMouseOver.step(function () {
assert_equals(event.target.id, "blue");
assert_equals(getComputedStyle(event.target).backgroundColor, "rgb(255, 255, 0)");
if (event.type == "mouseenter") {
checkEventSequence();
}
});
}
</script>
</body>
</html>