dom/tests/mochitest/pointerlock/file_childIframe.html

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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

mercurial