blob: 79b350fdc4c58f86af8dd93f5f794fce5b98b7fc [file] [log] [blame]
<html>
<body>
<embed name="plg" type="application/x-webkit-test-netscape" test="url-redirect"></embed>
<div id="log">
<div id="syncallowreason">Sync allow, reason shouldn't be NPRES_USER_BREAK...</div>
<div id="syncallowurl">Sync allow, URL should be the final URL...</div>
<div id="syncdenyreason">Sync deny, reason should be NPRES_USER_BREAK...</div>
<div id="syncdenyurl">Sync deny, URL should be the previous URL...</div>
<div id="asyncallowreason">Async allow, reason shouldn't be NPRES_USER_BREAK...</div>
<div id="asyncallowurl">Async allow, URL should be the final URL...</div>
<div id="asyncdenyreason">Async deny, reason should be NPRES_USER_BREAK...</div>
<div id="asyncdenyurl">Async deny, URL should be the previous URL...</div>
<div id="asyncmultiallowreason">Async multiple allow, reason shouldn't be NPRES_USER_BREAK...</div>
<div id="asyncmultiallowurl">Async multiple allow, URL should be the final URL...</div>
<div id="asyncmultidenyreason">Async multiple deny, reason should be NPRES_USER_BREAK...</div>
<div id="asyncmultidenyurl">Async multiple deny, URL should be the previous URL...</div>
</div>
<script>
function log(node, message)
{
text = document.getElementById(node);
text.innerText += message;
}
function cleanup()
{
--testsRemaining;
if (!testsRemaining) {
clearInterval(timer);
if (window.testRunner)
testRunner.notifyDone();
}
}
function notifyTrue(reason, url)
{
log("syncallowreason", reason != 2);
log("syncallowurl", url == redirectURL);
cleanup();
}
function notifyFalse(reason, url)
{
log("syncdenyreason", reason == 2);
log("syncdenyurl", url == singleRedirect);
cleanup();
}
function notifyTrueAsync(reason, url)
{
log("asyncallowreason", reason != 2);
log("asyncallowurl", url == redirectURL);
cleanup();
}
function notifyFalseAsync(reason, url)
{
log("asyncdenyreason", reason == 2);
log("asyncdenyurl", url == singleRedirect);
cleanup();
}
function notifyMultiTrueAsync(reason, url)
{
log("asyncmultiallowreason", reason != 2);
log("asyncmultiallowurl", url == redirectURL);
cleanup();
}
function notifyMultiFalseAsync(reason, url)
{
log("asyncmultidenyreason", reason == 2);
log("asyncmultidenyurl", url == singleRedirect);
cleanup();
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var baseURL = "http://127.0.0.1:8000/resources/redirect.py";
var redirectURL = "http://127.0.0.1:8000/dummy";
var singleRedirect = baseURL + "?code=307&url=" + encodeURIComponent(redirectURL);
var doubleRedirect = baseURL + "?code=307&url=" + encodeURIComponent(singleRedirect);
var testsRemaining = 6;
plg.get(singleRedirect, 1, "notifyTrue");
plg.get(singleRedirect, 0, "notifyFalse");
plg.getAsync(singleRedirect, 1, "notifyTrueAsync");
plg.getAsync(singleRedirect, 0, "notifyFalseAsync");
plg.getAsync(doubleRedirect, 2, "notifyMultiTrueAsync");
plg.getAsync(doubleRedirect, 1, "notifyMultiFalseAsync");
var timer = setInterval(function() { plg.serviceAsync() }, 10);
</script>
</body>
</html>