<!DOCTYPE html>
<!-- Explicitly use manifest resource that does not end in .manifest so that its Content-Type is not text/cached-manifest. -->
<html manifest="resources/fallback-namespace-outside-manifest-path.txt">
<head>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
</script>
</head>
<body>
<p>Tests that we do not load the fallback entry when the manifest does not have Content-Type text/cached-manifest and the fallback namespace is outside the manifest path.</p>
<pre id="console"></pre>
<script>
window.applicationCache.onnoupdate = runTests;
window.applicationCache.oncached = runTests;

window.applicationCache.onupdateready = () => logMessage("FAIL received unexpected updateready event");
window.applicationCache.onerror = () => logMessage("FAIL received unexpected error event");

function loadURL(url)
{
    var xhr = new XMLHttpRequest;
    xhr.open("GET", url, false /* synchronous */);
    xhr.send("");
    return xhr.responseText;
}

function logMessage(message)
{
    document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
}

function runTests()
{
    logMessage("Fallback namespace under the manifest path:");
    try {
        var responseText = loadURL("resources/non-existent-file-under-manifest-path.html");
        console.assert(responseText === "Hello, World!");
        logMessage("PASS did load fallback entry with fallback namespace under manifest path.");
    } catch (e) {
        logMessage("FAIL did load fallback entry with fallback namespace under manifest path.");
    }

    logMessage("Fallback namespace outside of manifest path:");
    try {
        loadURL("/non-existent-file-outside-manifest-path.html");
        logMessage("FAIL did load fallback entry with fallback namespace outside manifest path.");
    } catch (e) {
        logMessage("PASS did not load fallback entry with fallback namespace outside manifest path.");
    }

    if (window.testRunner)
        testRunner.notifyDone();
}
</script>
</body>
</html>
