pointerlockchange-pointerlockerror-events.html 4.17 KB
Newer Older
1 2 3
<!DOCTYPE HTML>
<html>
<head>
4 5
<script src="../http/tests/resources/js-test-pre.js"></script>
<script src="../http/tests/resources/pointer-lock/pointer-lock-test-harness.js"></script>
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
</head>
<body>
<div>
  <div id="target1"></div>
  <div id="target2"></div>
  <iframe id="iframe1"></iframe>
  <iframe id="iframe2"></iframe>
</div>
<script>
    description("Test expected pointerlockchange and pointerlockerror events.")
    window.jsTestIsAsync = true;

    targetDiv1 = document.getElementById("target1");
    targetDiv2 = document.getElementById("target2");
    targetIframe1 = document.getElementById("iframe1");
    targetIframe2 = document.getElementById("iframe2");

    todo = [
        function () {
            expectNoEvents("Unlock.");
26
            document.webkitExitPointerLock();
27
            doNextStepWithUserGesture();
28 29 30
        },
        function () {
            expectOnlyChangeEvent("Lock targetDiv1.");
31
            targetDiv1.webkitRequestPointerLock();
32 33 34
        },
        function () {
            expectOnlyChangeEvent("Unlock again.");
35
            document.webkitExitPointerLock();
36 37 38
        },
        function () {
            expectOnlyChangeEvent("Lock targetDiv1 again.");
39
            targetDiv1.webkitRequestPointerLock();
40 41
        },
        function () {
42
            expectOnlyChangeEvent("Lock targetDiv2.");
43
            targetDiv2.webkitRequestPointerLock();
44 45 46
        },
        function () {
            expectOnlyChangeEvent("Lock targetDiv2 again.");
47
            targetDiv2.webkitRequestPointerLock();
48
        },
49 50 51 52
        function () {
            expectOnlyChangeEvent("Unlock targetDiv2.");
            document.webkitExitPointerLock();
        },
53 54 55 56 57 58 59 60 61
        function () {
            targetIframe1.src = "about:blank";
            targetIframe1.onload = function () { doNextStep(); }
        },
        function () {
            targetIframe2.src = "about:blank";
            targetIframe2.onload = function () { doNextStep(); }
        },
        function () {
62
            expectNoEvents("Lock targetIframe1.");
63
            expectOnlyChangeEvent("Lock targetIframe1 (handler for iframe1).", targetIframe1.contentDocument);
64
            targetIframe1.contentDocument.body.webkitRequestPointerLock();
65 66 67
        },
        function () {
            expectNoEvents("Lock targetIframe2.");
68 69
            expectNoEvents("Lock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
            expectOnlyErrorEvent("Lock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
70
            targetIframe2.contentDocument.body.webkitRequestPointerLock();
71 72 73
        },
        function () {
            expectNoEvents("Unlock targetIframe2.");
74 75 76
            expectOnlyChangeEvent("Unlock targetIframe2 (handler for iframe1).", targetIframe1.contentDocument);
            expectNoEvents("Unlock targetIframe2 (handler for iframe2).", targetIframe2.contentDocument);
            targetIframe1.contentDocument.webkitExitPointerLock();
77 78
        },
        function () {
79 80
            shouldBeDefined("testRunner.setPointerLockWillFailSynchronously");
            testRunner.setPointerLockWillFailSynchronously();
81
            expectOnlyErrorEvent("Lock with synchronous failure.");
82
            targetDiv1.webkitRequestPointerLock();
83 84
        },
        function () {
85 86 87 88
            shouldBeDefined("testRunner.setPointerLockWillRespondAsynchronously");
            shouldBeDefined("testRunner.didAcquirePointerLock");
            shouldBeDefined("testRunner.didNotAcquirePointerLock");
            testRunner.setPointerLockWillRespondAsynchronously();
89
            expectOnlyErrorEvent("Lock with asynchronous failure.");
90
            targetDiv1.webkitRequestPointerLock();
91 92 93 94 95 96 97 98 99 100 101 102 103
            doNextStep();
        },
        function () {
            testRunner.didNotAcquirePointerLock();
        },
        function () {
            testRunner.setPointerLockWillRespondAsynchronously();
            expectOnlyChangeEvent("Lock with asynchronous success.");
            targetDiv1.webkitRequestPointerLock();
            doNextStep();
        },
        function () {
            testRunner.didAcquirePointerLock();
104 105 106 107
        },
    ];
    doNextStep();
</script>
108
<script src="../http/tests/resources/js-test-post.js"></script>
109 110
</body>
</html>