summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fullscreen/full-screen-restrictions.html
blob: 366f5fbe6e6e66c9d1daee498f0b192d82d9e8b3 (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
<!DOCTYPE html>
<body onload="runTest();">
<div>This tests the restrictions to entering full screen mode laid out in section 4.1 of the W3C 
<a href="http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html">Full Screen API</a></div>
<script src="full-screen-test.js"></script>
<script>
    var runTest = function() {
        consoleWrite('"The context object is not in a document."');
        var div = document.createElement('div');
        waitForEventOnce(document, 'webkitfullscreenerror', step2);
        runWithKeyDown(function(){div.webkitRequestFullscreen()});
    };

    var step2 = function() {
        consoleWrite('"The context object\'s node document, or an ancestor browsing context\'s document does not have the fullscreen enabled flag set."')
        var iframe = document.documentElement.appendChild(document.createElement('iframe'));
        var div = iframe.contentDocument.documentElement.appendChild(iframe.contentDocument.createElement('div'));

        waitForEventOnce(iframe.contentDocument, 'webkitfullscreenerror', step3);
        runWithKeyDown(function(){div.webkitRequestFullscreen()});
    };

    var step3 = function() {
        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."');
        var div = document.documentElement.appendChild(document.createElement('div'));
        var div2 = document.documentElement.appendChild(document.createElement('div'));
        waitForEventOnce(document, 'webkitfullscreenchange', function() {
            waitForEventOnce(document, 'webkitfullscreenerror', function() {
               waitForEventOnce(document, 'webkitfullscreenchange', step4);
               document.webkitExitFullscreen();
            });
            runWithKeyDown(function(){div2.webkitRequestFullscreen()});
        });
        runWithKeyDown(function(){div.webkitRequestFullscreen()});
    };

    var step4 = function() {
        consoleWrite('"A descendant browsing context\'s document has a non-empty fullscreen element stack."');
        var iframe = document.documentElement.appendChild(document.createElement('iframe'));
        iframe.setAttribute('allowfullscreen', 'true');
        var div = iframe.contentDocument.documentElement.appendChild(iframe.contentDocument.createElement('div'));
        var div2 = document.documentElement.appendChild(document.createElement('div'));
        waitForEventOnce(iframe.contentDocument, 'webkitfullscreenchange', function() {
            waitForEventOnce(document, 'webkitfullscreenerror', function(){
                waitForEventOnce(iframe.contentDocument, 'webkitfullscreenchange', step5);
                iframe.contentDocument.webkitExitFullscreen();
            });
            runWithKeyDown(function(){div2.webkitRequestFullscreen()});
        });
        runWithKeyDown(function(){div.webkitRequestFullscreen()});
    };

    var step5 = function() {
        consoleWrite('"This algorithm is not allowed to show a pop-up."');
        var div = document.documentElement.appendChild(document.createElement('div'));
        waitForEventOnce(document, 'webkitfullscreenerror', endTest);
        div.webkitRequestFullscreen();
    };

    if (typeof(testRunner) != 'undefined')
        testRunner.setPopupBlockingEnabled(true);
</script>