2011-04-18 Andrew Scherkus <scherkus@chromium.org>
[WebKit-https.git] / LayoutTests / fullscreen / full-screen-cancel.html
1 <body>
2 <script src="full-screen-test.js"></script>
3 <span></span>
4 <script>
5     // Bail out early if the full screen API is not enabled or is missing:
6     if (Element.prototype.webkitRequestFullScreen == undefined) {
7         logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
8         endTest();
9     } else {
10         var callback;
11         var fullscreenChanged = function(event)
12         {
13             if (callback)
14                 callback(event)
15         };
16         waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
17
18         var span = document.getElementsByTagName('span')[0];
19
20         var spanEnteredFullScreen = function() {
21             testExpected("document.webkitIsFullScreen", true);
22             testExpected("document.webkitCurrentFullScreenElement", span);
23             callback = cancelledFullScreen;
24             document.webkitCancelFullScreen();
25         };
26
27         var cancelledFullScreen = function() {
28             testExpected("document.webkitIsFullScreen", false);
29             testExpected("document.webkitCurrentFullScreenElement", undefined);
30             callback = failFullScreenTest;
31             document.webkitCancelFullScreen();
32             setTimeout(endTest, 0);
33         };
34
35         var failFullScreenTest = function() {
36             consoleWrite("Should not have received a webkitfullscreenchange event.");
37             endTest();
38         };
39
40         callback = spanEnteredFullScreen;
41         runWithKeyDown(function(){span.webkitRequestFullScreen()});
42     }
43 </script>