<html>
<head>
<script>
var theFrame, theImage;

function log(msg)
{
    var console = document.getElementById('console');
    console.appendChild(document.createTextNode(msg));
    console.appendChild(document.createElement('br'));
}

function resizeAndCheck(newSize)
{
    theFrame.height = newSize;

    log("New frame height is " + theFrame.height);
    log("New image height is " + theImage.height);

    if (theImage.height == newSize)
        log("PASSED: Image size is correct");
    else
        log("FAILED: Image size is not correct");
}

function run()
{
    if (window.testRunner)
        testRunner.dumpAsText();

    theFrame = document.getElementById('frame');
    var frContents = theFrame.contentWindow.document;
    theImage = frContents.getElementById('img');

    log("Original frame height was " + theFrame.height);
    log("Original image height was " + theImage.height);
    
    log("Vertically resizing the frame to be larger");
    resizeAndCheck(600);

    log("Vertically resizing the frame to be smaller");
    resizeAndCheck(450);
}

</script>
</head>

<body onload="run()">
<iframe height="500" width="500" id="frame" src="resources/vertical-resize-100percent-contents.html"></iframe> 
<p>Layout test for https://bugs.webkit.org/show_bug.cgi?id=43022. Checks to see if an image having a percentage height is resized when its containing iframe is vertically resized. This test only works in DumpRenderTree since it involves accessing the internal elements of an iframe.</p>
<p id="console"></p>
</body>

</html>
