1 <body onload="runTest();">
2 <div>This tests the restrictions to entering full screen mode laid out in section 4.1 of the W3C
3 <a href="http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html">Full Screen API</a></div>
4 <script src="full-screen-test.js"></script>
6 // Bail out early if the full screen API is not enabled or is missing:
7 if (Element.prototype.webkitRequestFullScreen == undefined) {
8 logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
11 var runTest = function() {
12 consoleWrite('"The context object is not in a document."');
13 var div = document.createElement('div');
14 waitForEventOnce(document, 'webkitfullscreenerror', step2);
15 runWithKeyDown(function(){div.webkitRequestFullscreen()});
18 var step2 = function() {
19 consoleWrite('"The context object\'s node document, or an ancestor browsing context\'s document does not have the fullscreen enabled flag set."')
20 var iframe = document.documentElement.appendChild(document.createElement('iframe'));
21 var div = iframe.contentDocument.documentElement.appendChild(iframe.contentDocument.createElement('div'));
23 waitForEventOnce(iframe.contentDocument, 'webkitfullscreenerror', step3);
24 runWithKeyDown(function(){div.webkitRequestFullscreen()});
27 var step3 = function() {
28 consoleWrite('"The context object\'s node document fullscreen element stack is not empty and its top element is not an ancestor of the context object."');
29 var div = document.documentElement.appendChild(document.createElement('div'));
30 var div2 = document.documentElement.appendChild(document.createElement('div'));
31 waitForEventOnce(document, 'webkitfullscreenchange', function() {
32 waitForEventOnce(document, 'webkitfullscreenerror', function() {
33 waitForEventOnce(document, 'webkitfullscreenchange', step4);
34 document.webkitExitFullscreen();
36 runWithKeyDown(function(){div2.webkitRequestFullscreen()});
38 runWithKeyDown(function(){div.webkitRequestFullscreen()});
41 var step4 = function() {
42 consoleWrite('"A descendant browsing context\'s document has a non-empty fullscreen element stack."');
43 var iframe = document.documentElement.appendChild(document.createElement('iframe'));
44 iframe.setAttribute('webkitallowfullscreen', 'true');
45 var div = iframe.contentDocument.documentElement.appendChild(iframe.contentDocument.createElement('div'));
46 var div2 = document.documentElement.appendChild(document.createElement('div'));
47 waitForEventOnce(iframe.contentDocument, 'webkitfullscreenchange', function() {
48 waitForEventOnce(document, 'webkitfullscreenerror', function(){
49 waitForEventOnce(iframe.contentDocument, 'webkitfullscreenchange', step5);
50 iframe.contentDocument.webkitExitFullscreen();
52 runWithKeyDown(function(){div2.webkitRequestFullscreen()});
54 runWithKeyDown(function(){div.webkitRequestFullscreen()});
57 var step5 = function() {
58 consoleWrite('"This algorithm is not allowed to show a pop-up."');
59 var div = document.documentElement.appendChild(document.createElement('div'));
60 waitForEventOnce(document, 'webkitfullscreenerror', endTest);
61 div.webkitRequestFullscreen();
64 if (typeof(testRunner) != 'undefined')
65 testRunner.setPopupBlockingEnabled(true);