summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/http/tests/pointer-lock/pointerlockelement-same-origin.html
blob: 641b78b6ea7267768c3477978cf3113b6adacc96 (plain)
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
<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="../resources/pointer-lock/pointer-lock-test-harness.js"></script>
</head>
<body>
<div>
  <div id="target1"></div>
  <iframe src="../resources/pointer-lock/inner-iframe.html" onload="doNextStepWithUserGesture()"></iframe>
</div>
<script>
    description("Test iframe from same origin can not access pointerLockElement.")
    window.jsTestIsAsync = true;

    targetDiv1 = document.getElementById("target1");
    iframe = document.getElementsByTagName("iframe")[0];

    todo = [
      function () {
          expectOnlyChangeEvent("Lock targetDiv1.");
          targetDiv1.requestPointerLock();
          // doNextStep called by event handler.
      },
      function () {
          shouldBe("document.pointerLockElement", "targetDiv1");
          doNextStep();
      },
      function () {
          iframe.contentWindow.postMessage(["eval", 'parent.postMessage(thisFileName() + " document.pointerLockElement = " + document.pointerLockElement, "*")'], "*");
          window.onmessage = function (messageEvent) {
              message = messageEvent.data;
              shouldBeEqualToString("message", "inner-iframe.html document.pointerLockElement = null");
              window.onmessage = null;
              doNextStep();
          }
      },
    ];
    // doNextStep() called by iframe onload handler.
</script>
</body>
</html>