|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602 |
|
5 --> |
|
6 <head> |
|
7 <title>Bug 633602 - file_childIframe.html</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> |
|
9 </script> |
|
10 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
11 <script type="application/javascript" src="pointerlock_utils.js"></script> |
|
12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
13 <style> |
|
14 #parent, #childDiv, #iframe, #table, #table td { |
|
15 margin: 0; |
|
16 padding: 0; |
|
17 border: none; |
|
18 } |
|
19 #iframe, #table { |
|
20 background-color: red; |
|
21 width: 100%; |
|
22 height: 100%; |
|
23 } |
|
24 #childDiv, #table td { |
|
25 background-color: blue; |
|
26 width: 50%; |
|
27 height: 50%; |
|
28 } |
|
29 </style> |
|
30 </head> |
|
31 <body> |
|
32 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> |
|
33 Mozilla Bug 633602 |
|
34 </a> |
|
35 |
|
36 <div id="parent"> |
|
37 <table id="childTable"> |
|
38 <tr> |
|
39 <td> |
|
40 <iframe id="iframe" src="iframe_differentDOM.html" onload="start();"> |
|
41 </iframe> |
|
42 </td> |
|
43 <td> |
|
44 <div id="childDiv"> |
|
45 </div> |
|
46 </td> |
|
47 </tr> |
|
48 </table> |
|
49 </div> |
|
50 |
|
51 <pre id="test"> |
|
52 <script type="application/javascript"> |
|
53 /* |
|
54 * Test for Bug 633602 |
|
55 * Check if pointer is locked when over a child iframe of |
|
56 * the locked element |
|
57 * Check if pointer is being repositioned back to center of |
|
58 * the locked element even when pointer goes over a child ifame |
|
59 */ |
|
60 |
|
61 SimpleTest.waitForExplicitFinish(); |
|
62 |
|
63 var parent = document.getElementById("parent") |
|
64 , childDiv = document.getElementById("childDiv") |
|
65 , iframe = document.getElementById("iframe"); |
|
66 |
|
67 function MozMovementStats() { |
|
68 this.mozMovementX = false; |
|
69 this.mozMovementY = false; |
|
70 } |
|
71 |
|
72 var firstMove = new MozMovementStats() |
|
73 , secondMove = new MozMovementStats() |
|
74 , hoverIframe = false; |
|
75 |
|
76 function runTests () { |
|
77 ok(hoverIframe, "Pointer should be locked even when pointer " + |
|
78 "hovers over a child iframe"); |
|
79 is(firstMove.mozMovementX, secondMove.mozMovementX, "MovementX of first " + |
|
80 "move to childDiv should be equal to movementX of second move " + |
|
81 "to child div"); |
|
82 is(firstMove.mozMovementY, secondMove.mozMovementY, "MovementY of first " + |
|
83 "move to childDiv should be equal to movementY of second move " + |
|
84 "to child div"); |
|
85 } |
|
86 |
|
87 var firstMoveChild = function (e) { |
|
88 firstMove.mozMovementX = e.mozMovementX; |
|
89 firstMove.mozMovementY = e.mozMovementY; |
|
90 |
|
91 parent.removeEventListener("mousemove", firstMoveChild); |
|
92 parent.addEventListener("mousemove", moveIframe); |
|
93 |
|
94 synthesizeMouseAtCenter(iframe, {type: "mousemove"}, window); |
|
95 }; |
|
96 |
|
97 var moveIframe = function (e) { |
|
98 hoverIframe = !!document.mozPointerLockElement; |
|
99 |
|
100 parent.removeEventListener("mousemove", moveIframe); |
|
101 parent.addEventListener("mousemove", secondMoveChild); |
|
102 |
|
103 synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window); |
|
104 }; |
|
105 |
|
106 var secondMoveChild = function (e) { |
|
107 secondMove.mozMovementX = e.mozMovementX; |
|
108 secondMove.mozMovementY = e.mozMovementY; |
|
109 parent.removeEventListener("mousemove", secondMoveChild); |
|
110 |
|
111 document.mozCancelFullScreen(); |
|
112 }; |
|
113 |
|
114 document.addEventListener("mozpointerlockchange", function () { |
|
115 if (document.mozPointerLockElement === parent) { |
|
116 parent.addEventListener("mousemove", firstMoveChild); |
|
117 synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window); |
|
118 } |
|
119 }, false); |
|
120 |
|
121 document.addEventListener("mozpointerlockerror", function () { |
|
122 document.mozCancelFullScreen(); |
|
123 }, false); |
|
124 |
|
125 document.addEventListener("mozfullscreenchange", function (e) { |
|
126 if (document.mozFullScreenElement === parent) { |
|
127 parent.mozRequestPointerLock(); |
|
128 } |
|
129 else { |
|
130 runTests(); |
|
131 SimpleTest.finish(); |
|
132 } |
|
133 }, false); |
|
134 |
|
135 function start() { |
|
136 parent.mozRequestFullScreen(); |
|
137 } |
|
138 </script> |
|
139 </pre> |
|
140 </body> |
|
141 </html> |