blob: 1498586a88cca70de3e5a518cc7b0d6a1d463d83 [file] [log] [blame]
<html manifest="resources/online-whitelist.manifest">
<body>
<p>Test online whitelist functionality. Should say PASS:</p>
<div id="result"></div>
<script>
if (window.testRunner) {
testRunner.dumpAsText()
testRunner.waitUntilDone();
}
function log(message)
{
document.getElementById("result").innerHTML += message + "<br>";
}
var hadError = false;
function canLoad(url)
{
try {
var req = new XMLHttpRequest();
req.open("GET", url, false);
req.send("");
return true;
} catch (e) {
return false;
}
}
function load(url)
{
try {
var req = new XMLHttpRequest();
req.open("GET", url, false);
req.send("");
return req.responseText;
} catch (ex) {
alert("Unexpected error loading " + url + ": " + ex);
hadError = true;
}
}
function test()
{
if (load("resources/online-whitelist.php?cached") != load("resources/online-whitelist.php?cached")) {
log("FAIL: Explicit entry didn't override online whitelist.");
hadError = true;
}
if (load("resources/online-whitelist.php?uncached") == load("resources/online-whitelist.php?uncached")) {
log("FAIL: Online whitelist resource wasn't reloaded from network.");
hadError = true;
}
if (load("resources/online-whitelist.php?uncachedxxx") == load("resources/online-whitelist.php?uncachedxxx")) {
log("FAIL: Online whitelist resource wasn't reloaded from network (prefix matching).");
hadError = true;
}
if (canLoad("resources/online-whitelist.php?foobar")) {
log("FAIL: Uncached resource was successfully loaded.");
hadError = true;
}
log(hadError ? "FAIL" : "PASS");
if (window.testRunner)
testRunner.notifyDone();
}
applicationCache.addEventListener('cached', test, false);
applicationCache.addEventListener('noupdate', test, false);
</script>
</body>
</html>