reload-subresource-when-type-changes.html 1.25 KB
Newer Older
1 2
<div id="logDiv">FAILED</div>
<script>
3 4
if (window.testRunner)
    testRunner.dumpAsText();
5 6 7 8 9 10 11 12 13 14 15 16 17 18

var logDiv = document.getElementById("logDiv");

function clearLog()
{
    logDiv.innerHTML = "";
}

function log(string)
{
    logDiv.appendChild(document.createTextNode(string));
    logDiv.appendChild(document.createElement("br"));
}

19 20 21
var loaded = 0;
var messages = [];

22 23 24
function checkLoadedImage(event, testNumber) {
    var imageWidth = event.target.width;
    if (imageWidth == 25)
25
        resourceLoaded("PASS ", testNumber);
26
    else
27 28 29 30 31 32 33 34 35
        resourceLoaded("IMAGE SIZE " + imageWidth + " FAIL - ", testNumber);
}

function resourceLoaded(message, testNumber) {
    messages[testNumber] = message + testNumber + " of 3";
    if (++loaded == 3) {
        for (var i = 1; i <= 3; i++)
            log(messages[i]);
    }
36 37 38 39 40 41 42 43 44 45 46
}
</script>

<img src="resources/reload-subresource-when-type-changes.js">
<script src="resources/reload-subresource-when-type-changes.js"></script>

<link rel="prefetch" href="resources/image1.png">
<img src="resources/image1.png" onerror="log('LOAD ERROR - FAIL 2 of 3)" onload="checkLoadedImage(event, 2)">

<script src="resources/image2.png"></script>
<img src="resources/image2.png" onerror="log('LOAD ERROR - FAIL 2 of 3)" onload="checkLoadedImage(event, 3)">