2009-11-18 08:02:28 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test bug 529119</title>
|
|
|
|
<script type="text/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
|
|
|
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2010-03-12 13:53:36 -08:00
|
|
|
var workingURL = "http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
|
2010-05-23 12:26:15 -07:00
|
|
|
var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
|
2009-11-18 08:02:28 -08:00
|
|
|
|
|
|
|
var w = null;
|
|
|
|
var phase = 0;
|
|
|
|
var gotWrongPageOnTryAgainClick = false;
|
|
|
|
|
2009-11-19 17:42:00 -08:00
|
|
|
function pollForPage(f, w)
|
2009-11-18 08:02:28 -08:00
|
|
|
{
|
|
|
|
// Start with polling after a delay, we might mistakenly take the current page
|
|
|
|
// as an expected one.
|
|
|
|
window.setTimeout(function() {
|
2009-11-19 17:42:00 -08:00
|
|
|
var iterationsLeft = 200;
|
2009-11-18 08:02:28 -08:00
|
|
|
var int = window.setInterval(function() {
|
|
|
|
iterationsLeft--;
|
2009-11-19 17:42:00 -08:00
|
|
|
|
|
|
|
var haveErrorPage = false;
|
2009-11-18 08:02:28 -08:00
|
|
|
try {
|
|
|
|
var title = w.document.title;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
2009-11-19 17:42:00 -08:00
|
|
|
haveErrorPage = true;
|
2009-11-18 08:02:28 -08:00
|
|
|
}
|
|
|
|
|
2009-11-19 17:42:00 -08:00
|
|
|
if (iterationsLeft == 0 || haveErrorPage) {
|
2009-11-18 08:02:28 -08:00
|
|
|
window.clearInterval(int);
|
|
|
|
f(iterationsLeft > 0);
|
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function windowLoaded()
|
|
|
|
{
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
switch (phase)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
/* 2. We have succeededfully loaded a page, now go to a faulty URL */
|
|
|
|
window.setTimeout(function() {
|
|
|
|
w.location.href = faultyURL;
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
phase = 1;
|
|
|
|
|
2009-11-19 17:42:00 -08:00
|
|
|
pollForPage(function(succeeded) {
|
2009-11-18 08:02:28 -08:00
|
|
|
ok(succeeded, "Waiting for error page succeeded");
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
/* 3. now, while we are on the error page, try to reload it, actually
|
|
|
|
click the "Try Again" button */
|
|
|
|
w.location.reload();
|
|
|
|
|
2009-11-19 17:42:00 -08:00
|
|
|
pollForPage(function(succeeded) {
|
2009-11-18 08:02:28 -08:00
|
|
|
ok(succeeded, "Waiting for error page succeeded");
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
/* 4-finish, check we are still on the error page */
|
|
|
|
is(w.location.href, faultyURL, "Is on an error page");
|
|
|
|
isnot(w.location.href, workingURL, "Is not on the previous page");
|
|
|
|
is(gotWrongPageOnTryAgainClick, false,
|
|
|
|
"Must not get www.example.com page on reload of an error page");
|
|
|
|
w.close();
|
|
|
|
SimpleTest.finish();
|
|
|
|
}, w);
|
|
|
|
}, w);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
/* 4-check, we must not get here! */
|
|
|
|
gotWrongPageOnTryAgainClick = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function startTest()
|
|
|
|
{
|
|
|
|
/* 1. load a URL that leads to an error page */
|
|
|
|
w = window.open(workingURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="startTest();">
|
|
|
|
</body>
|
|
|
|
</html>
|