<script src="/js-test-resources/js-test-pre.js"></script>
<script>
description("Tests speculative revalidation of authenticated resources.");
jsTestIsAsync = true;

testRunner.setHandlesAuthenticationChallenges(true);
testRunner.setAuthenticationUsername("testUsername");
testRunner.setAuthenticationPassword("testPassword");

state = "warmup";

function clearCredentialStorage()
{
    xhr = new XMLHttpRequest();
    xhr.open("GET", "resources/resource-with-auth.py?other", false, "badUsername", "badPassword");
    xhr.send();
    shouldBe("xhr.status", "401");
}

function frameLoaded()
{
    if (state == "warmup") {
        // Navigate frame to 'about:blank' to flush to subresource loads metadata to disk.
        state = "flushingMetadata";
        testRunner.setHandlesAuthenticationChallenges(false);
        document.getElementById("testFrame").src = "about:blank";
        return;
    }
    if (state == "flushingMetadata") {
        clearCredentialStorage();

        internals.clearMemoryCache();
        testRunner.setHandlesAuthenticationChallenges(false);

        // Navigate frame to its original location again. This time it should speculatively
        // validate subresources as we have subresource loads metadata in the disk cache.
        state = "speculativeRevalidation";
        document.getElementById("testFrame").src = "resources/frame-with-authenticated-resource.py";
        return;
    }
    if (state == "speculativeRevalidation") {
        testPassed("Successfuly loaded.");

        finishJSTest();
        return;
    }
}

</script>
<iframe id="testFrame" src="resources/frame-with-authenticated-resource.py" onload="frameLoaded()"></iframe>
<script src="/js-test-resources/js-test-post.js"></script>
