Layout Test imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionSta...
[WebKit-https.git] / LayoutTests / pointer-lock / lock-already-locked.html
index 281d53b..986af23 100644 (file)
@@ -1,7 +1,8 @@
 <!DOCTYPE HTML>
 <html>
 <head>
-<script src="../fast/js/resources/js-test-pre.js"></script>
+<script src="../http/tests/resources/js-test-pre.js"></script>
+<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
 </head>
 <body>
 <div>
     targetdiv2 = document.getElementById("target2");
 
     // Expect change event only for all transitions below.
-    document.onwebkitpointerlockchange =
-        function () { testPassed("document.onwebkitpointerlockchange event received."); };
-    document.onwebkitpointerlockerror =
-        function () { testFailed("document.onwebkitpointerlockerror event received."); finishJSTest(); };
+    expectedTargetToBeLockedString = "";
+    document.onpointerlockchange = function ()
+        {
+            testPassed("document.onpointerlockchange event received.");
+            shouldBe("document.pointerLockElement", expectedTargetToBeLockedString);
+            doNextStepWithUserGesture();
+        };
+    document.onpointerlockerror =
+        function () { testFailed("document.onpointerlockerror event received."); finishJSTest(); };
 
     var expectTarget1Unlock = false;
-    targetdiv1.addEventListener("webkitpointerlocklost",
+    targetdiv1.addEventListener("pointerlocklost",
         function () { shouldBe("expectTarget1Unlock", "true"); });
 
-    targetdiv2.addEventListener("webkitpointerlocklost",
-        function () { testFailed("Unexpected targetdiv2 pointerlocklost."); });
+    var expectTarget2Unlock = false;
+    targetdiv2.addEventListener("pointerlocklost",
+        function () { shouldBe("expectTarget2Unlock", "true"); });
 
-    currentStep = 0;
-    function doNextStep() {
-      setTimeout(function () { todo[currentStep++](); }, 0);
-    }
     todo = [
         function () {
-            shouldBe("navigator.webkitPointer.isLocked", "false");
-            navigator.webkitPointer.lock(targetdiv1,
-                function () {
-                    testPassed("Lock target1 succeeded.");
-                    shouldBe("navigator.webkitPointer.isLocked", "true");
-                    doNextStep();
-                },
-                function () {
-                    testFailed("Lock failed.");
-                    finishJSTest();
-                });
+            shouldBe("document.pointerLockElement", "null");
+            debug("     Locking targetdiv1.")
+            targetdiv1.requestPointerLock();
+            expectedTargetToBeLockedString = "targetdiv1";
+            // doNextStep() called by onpointerlockchange handler.
         },
         function () {
-            navigator.webkitPointer.lock(targetdiv1,
-                function () {
-                    testPassed("Lock target1 succeeded again.");
-                    shouldBe("navigator.webkitPointer.isLocked", "true");
-                    doNextStep();
-                },
-                function () {
-                    testFailed("Lock failed.");
-                    finishJSTest();
-                });
-
+            debug("     Locking targetdiv1, again.")
+            targetdiv1.requestPointerLock();
+            expectedTargetToBeLockedString = "targetdiv1";
+            // doNextStep() called by onpointerlockchange handler.
         },
         function () {
+            debug("     Locking targetdiv2.")
             expectTarget1Unlock = true;
-            navigator.webkitPointer.lock(targetdiv2,
-                function () {
-                    testPassed("Lock target2 succeeded.");
-                    shouldBe("navigator.webkitPointer.isLocked", "true");
-                    doNextStep();
-                },
-                function () {
-                    testFailed("Lock failed.");
-                    finishJSTest();
-                });
-
+            targetdiv2.requestPointerLock();
+            expectedTargetToBeLockedString = "targetdiv2";
+            // doNextStep() called by onpointerlockchange handler.
         },
-        finishJSTest
     ];
-    doNextStep();
+    doNextStepWithUserGesture();
 </script>
-<script src="../fast/js/resources/js-test-post.js"></script>
+<script src="../http/tests/resources/js-test-post.js"></script>
 </body>
 </html>