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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
<!DOCTYPE HTML>
<html>
<!--
Open one window, focus it and enter fullscreen, then exit fullscreen.
-->
<head>
<title>Simple Fullscreen Enter and Exit Test</title>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="file_fullscreen-utils.js"></script>
</head>
<body>
<div id="fullscreen-div"><p>Fullscreen div</p></div>
<script type="application/javascript">
function ok(condition, msg) {
opener.ok(condition, "[single] " + msg);
}
function is(value, expected, msg) {
opener.is(value, expected, "[single] " + msg);
}
function isnot(value, unexpected, msg) {
opener.isnot(value, unexpected, "[single] " + msg);
}
function info(msg) {
opener.info("[single] " + msg);
}
function windowResized() {
info(`Window resized to width: ${window.innerWidth}, height: ${window.innerHeight}.`);
}
async function begin() {
window.addEventListener('resize', windowResized);
info(`Starting window width: ${window.innerWidth}, height: ${window.innerHeight}.`);
let windowedWidth = window.innerWidth;
let windowedHeight = window.innerHeight;
info("Requesting fullscreen.");
let entryPromise = document.getElementById('fullscreen-div').requestFullscreen()
info("Fullscreen requested, waiting for promise to resolve.");
await entryPromise;
info("element.requestFullscreen() promise resolved.");
info(`Fullscreen window width: ${window.innerWidth}, height: ${window.innerHeight}.`);
isnot(document.fullscreenElement, null, "document.fullscreenElement should exist.");
ok(window.fullScreen, "window.fullScreen");
isnot(windowedWidth, window.innerWidth, "window width should be changed.");
isnot(windowedHeight, window.innerHeight, "window height should be changed.");
info("Requesting fullscreen exit.");
let exitPromise = document.exitFullscreen()
info("Fullscreen exit requested, waiting for promise to resolve.");
await exitPromise;
info("document.exitFullscreen() promise resolved.");
info(`Restored window width: ${window.innerWidth}, height: ${window.innerHeight}.`);
is(document.fullscreenElement, null, "document.fullscreenElement should be null.");
ok(!window.fullScreen, "window.fullScreen should be false.");
is(window.innerWidth, windowedWidth, "window width should be restored.");
is(window.innerHeight, windowedHeight, "window height should be restored.");
opener.nextTest();
}
</script>
</pre>
</body>
</html>
|