summaryrefslogtreecommitdiffstats
path: root/dom/html/test/file_fullscreen-esc-exit.html
blob: beb52f9263718054e83d79e21aefc7e81f04bc23 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=700764

Verify that an ESC key press in a subdoc of a full-screen doc causes us to
exit DOM full-screen mode.

-->
<head>
  <title>Test for Bug 700764</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <script type="application/javascript" src="file_fullscreen-utils.js"></script>
  <style>
  body:fullscreen, div:fullscreen {
    background-color: red;
  }
  </style>
</head>
<body>

<script type="application/javascript">

function ok(condition, msg) {
  opener.ok(condition, "[esc-exit] " + msg);
}

function is(a, b, msg) {
  opener.is(a, b, "[esc-exit] " + msg);
}

function finish() {
  opener.nextTest();
}

function fullscreenchange1(event) {
  is(document.fullscreenElement, document.body, "FSE should be doc");
  addFullscreenChangeContinuation("exit", fullscreenchange2);
  ok(!document.getElementById("subdoc").contentWindow.escKeySent, "Should not yet have sent ESC key press.");
  document.getElementById("subdoc").contentWindow.startTest();
}

function fullscreenchange2(event) {
  ok(document.getElementById("subdoc").contentWindow.escKeySent, "Should have sent ESC key press.");
  ok(!document.getElementById("subdoc").contentWindow.escKeyReceived, "ESC key press to exit should not be delivered.");
  ok(!document.fullscreenElement, "Should have left full-screen mode on ESC key press");
  finish();
}

function begin() {
  addFullscreenChangeContinuation("enter", fullscreenchange1);
  document.body.requestFullscreen();
}

</script>

<!-- This subframe conducts the test. -->
<iframe id="subdoc" src="file_fullscreen-esc-exit-inner.html"></iframe>

</pre>
</body>
</html>