2009-11-18 16:02:28 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test bug 529119</title>
|
2010-08-24 17:29:34 +00:00
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
2009-11-18 16:02:28 +00:00
|
|
|
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2014-12-11 18:34:40 +00:00
|
|
|
SimpleTest.requestFlakyTimeout("untriaged");
|
2009-11-18 16:02:28 +00:00
|
|
|
|
2010-03-12 21:53:36 +00:00
|
|
|
var workingURL = "http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
|
2010-05-23 19:26:15 +00:00
|
|
|
var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
|
2009-11-18 16:02:28 +00:00
|
|
|
|
|
|
|
var w = null;
|
|
|
|
var phase = 0;
|
2014-07-21 13:10:50 +00:00
|
|
|
var isWindowLoaded = false;
|
2009-11-18 16:02:28 +00:00
|
|
|
|
2009-11-20 01:42:00 +00:00
|
|
|
function pollForPage(expectErrorPage, f, w)
|
2009-11-18 16:02:28 +00:00
|
|
|
{
|
|
|
|
// Start with polling after a delay, we might mistakenly take the current page
|
|
|
|
// as an expected one.
|
|
|
|
window.setTimeout(function() {
|
2009-11-20 01:42:00 +00:00
|
|
|
var iterationsLeft = 200;
|
2009-11-18 16:02:28 +00:00
|
|
|
var int = window.setInterval(function() {
|
|
|
|
iterationsLeft--;
|
|
|
|
|
2009-11-20 01:42:00 +00:00
|
|
|
var haveErrorPage = false;
|
2009-11-18 16:02:28 +00:00
|
|
|
try {
|
|
|
|
var title = w.document.title;
|
|
|
|
}
|
|
|
|
catch (ex) {
|
2009-11-20 01:42:00 +00:00
|
|
|
haveErrorPage = true;
|
2009-11-18 16:02:28 +00:00
|
|
|
}
|
|
|
|
|
2009-11-20 01:42:00 +00:00
|
|
|
if (iterationsLeft == 0 || expectErrorPage == haveErrorPage) {
|
2009-11-18 16:02:28 +00:00
|
|
|
window.clearInterval(int);
|
|
|
|
f(iterationsLeft > 0);
|
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function windowLoaded()
|
|
|
|
{
|
2014-07-21 13:10:50 +00:00
|
|
|
// The code under here should only be run once
|
|
|
|
// The test popup window workingURL was already opened
|
|
|
|
if (isWindowLoaded)
|
|
|
|
return;
|
|
|
|
isWindowLoaded = true;
|
|
|
|
|
2009-11-18 16:02:28 +00:00
|
|
|
/* 2. We have successfully loaded a page, now go to a faulty URL */
|
|
|
|
// XXX The test fails when we change the location synchronously
|
|
|
|
window.setTimeout(function() {
|
|
|
|
w.location.href = faultyURL;
|
|
|
|
}, 0);
|
|
|
|
|
2009-11-20 01:42:00 +00:00
|
|
|
pollForPage(true, function(succeeded) {
|
2009-11-18 16:02:28 +00:00
|
|
|
ok(succeeded, "Waiting for error page succeeded");
|
|
|
|
/* 3. now, while we are on the error page, navigate back */
|
|
|
|
try {
|
2012-08-03 20:19:54 +00:00
|
|
|
SpecialPowers.wrap(w).back();
|
2009-11-18 16:02:28 +00:00
|
|
|
}
|
|
|
|
catch(ex) {
|
|
|
|
ok(false, "w.back() threw " + ex);
|
|
|
|
}
|
|
|
|
|
2009-11-20 01:42:00 +00:00
|
|
|
pollForPage(false, function(succeeded) {
|
2009-11-18 16:02:28 +00:00
|
|
|
ok(succeeded, "Waiting for original page succeeded");
|
|
|
|
/* 4-finish, check we are back at the original page */
|
2012-08-03 20:19:54 +00:00
|
|
|
isnot(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
|
|
|
|
is(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
|
2009-11-18 16:02:28 +00:00
|
|
|
w.close();
|
|
|
|
SimpleTest.finish();
|
|
|
|
}, w);
|
|
|
|
}, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
function startTest()
|
|
|
|
{
|
|
|
|
/* 1. load a URL that leads to an error page */
|
|
|
|
w = window.open(workingURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="startTest();">
|
|
|
|
</body>
|
|
|
|
</html>
|