chromium/third_party/blink/web_tests/http/tests/cache/loaded-from-cache-after-reload.html

<body>
<h1></h1>
<script>
// Test that a subresource fetched after onload, following a reload, is still
// loaded from the cache.

if (!sessionStorage.lastRandom) {
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }
}

function done(result)
{
    delete sessionStorage.lastRandom;

    document.body.innerText = result;

    if (window.testRunner)
        testRunner.notifyDone();
}

function scriptLoaded()
{
    setTimeout(function()
    {
        if (!window.randomNumber)
            done('FAIL: window.randomNumber not defined!');
        else if (sessionStorage.lastRandom) {
            if ((sessionStorage.lastRandom - 0) == (randomNumber - 0))
                done('PASS');
            else
                done('FAIL');
        } else {
            sessionStorage.lastRandom = randomNumber;
            location.reload();
        }
    }, 0);
}

onload = function()
{
    // After onload, add a script tag that should always load from the cache.
    setTimeout(function()
    {
        var s = document.createElement("script");
        s.src = "resources/random-cached.cgi";
        s.onload = scriptLoaded;
        document.body.appendChild(s);
    }, 0);
};
</script>
</body>