<body>
<script src="full-screen-test.js"></script>
<span></span>
<script>
    // Bail out early if the full screen API is not enabled or is missing:
    if (Element.prototype.webkitRequestFullScreen == undefined) {
        logResult(false, "Element.prototype.webkitRequestFullScreen == undefined");
        endTest();
    } else {
        var callback;
        var fullscreenChanged = function(event)
        {
            if (callback)
                callback(event)
        };
        waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
    
        var span = document.getElementsByTagName('span')[0];

        var spanEnteredFullScreen = function() {
            testExpected("document.webkitCurrentFullScreenElement", span);
            callback = documentEnteredFullScreen;
            endTest();
        };
    
        var documentEnteredFullScreen = function() {
            testExpected("document.webkitCurrentFullScreenElement", document.documentElement);
            callback = spanEnteredFullScreen;
            runWithKeyDown(function(){span.webkitRequestFullScreen()});
        };

        callback = documentEnteredFullScreen;
        runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()});
    }
</script>
