chromium/third_party/blink/web_tests/fast/css/percent-width-img-src-change.html

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var completed = 0, failures = 0, failuresDetail = ""; 
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
function printResult() {
    document.getElementById("result").innerText = failures ? "FAIL: " + failures + " cases failed\n" + failuresDetail : "PASS";
    if (window.testRunner)
        testRunner.notifyDone();
}
function imageCheckForMax(image) {
    if (image.src.match("greenbox.png")  != null)
        image.src = "resources/greenbox-100px.png";
    else {
        ++completed;
        if (image.width != 100) {
            ++failures; 
            failuresDetail +=  image.id + ": " + image.width + " (expected: " + 100 + ")\n";
        }
        if (completed == 4)
             printResult();
    }
}
</script>
</head>

<body>
<div id="result"></div>
<table>
<tbody>
<tr>
<td>
<img id="percentWidthInTable" style="width:100%;" src="resources/greenbox.png" onload="imageCheckForMax(this)">
</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td>
<img id="percentMaxWidthInTable" style="max-width:100%;" src="resources/greenbox.png" onload="imageCheckForMax(this)">
</td>
</tr>
</tbody>
</table>
<div style="position:absolute;top:110px;left:110px">
<img id="percentWidthInAbsolute" style="width:100%;" src="resources/greenbox.png" onload="imageCheckForMax(this)">
</div>
<div style="position:absolute;top:220px;left:110px">
<img id="percentMaxWidthInAbsolute" style="max-width:100%;" src="resources/greenbox.png" onload="imageCheckForMax(this)">
</div>
</body>
</html>