<html>
<head>
  <script src="../imported/w3c/web-platform-tests/resources/testdriver.js"></script>
  <script src="../imported/w3c/web-platform-tests/resources/testdriver-vendor.js"></script>
  <script>
    var testFrame;
    var testDiv;

    function runTest() {
        testFrame = document.getElementById('fullscreenFrame');
        testDiv = testFrame.contentWindow.document.getElementById('testDiv');
        // 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 {
            // Test if the iframe expands full screen when max-width/max-height are set.
            waitForEventTestAndEnd(document, 'webkitfullscreenchange', "testFrame.getBoundingClientRect().right == document.body.getBoundingClientRect().right && testFrame.getBoundingClientRect().bottom == document.body.getBoundingClientRect().bottom");

            // Make sure iframe gets transient activation.
            test_driver.click(testFrame).then(() => {
              runWithKeyDown(() => { testDiv.webkitRequestFullScreen(); });
            });
        }
    }
  </script>
  <script src='full-screen-test.js'></script>
</head>
<body style="margin: 0px;">
    <iframe onload='runTest();' id='fullscreenFrame' src='data:text/html,<div id="testDiv">test</div>' style='max-width: 10px; max-height: 10px;' frameborder='0' webkitallowfullscreen></iframe>
</body>
