4 <title>Test bug
529119</title>
5 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
8 <script class=
"testbody" type=
"text/javascript">
10 SimpleTest.waitForExplicitFinish();
11 SimpleTest.requestFlakyTimeout(
"untriaged");
13 var workingURL =
"http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
14 var faultyURL =
"http://some-nonexistent-domain-27489274c892748217cn2384.com/";
18 var gotWrongPageOnTryAgainClick = false;
20 function pollForPage(f, w)
22 // Start with polling after a delay, we might mistakenly take the current page
23 // as an expected one.
24 window.setTimeout(function() {
25 var iterationsLeft =
200;
26 var int = window.setInterval(function() {
29 var haveErrorPage = false;
31 var title = w.document.title;
37 if (iterationsLeft ==
0 || haveErrorPage) {
38 window.clearInterval(int);
39 f(iterationsLeft
> 0);
45 function windowLoaded()
50 /*
2. We have succeededfully loaded a page, now go to a faulty URL */
51 window.setTimeout(function() {
52 w.location.href = faultyURL;
57 pollForPage(function(succeeded) {
58 ok(succeeded,
"Waiting for error page succeeded");
60 /*
3. now, while we are on the error page, try to reload it, actually
61 click the
"Try Again" button */
62 SpecialPowers.wrap(w).location.reload();
64 pollForPage(function(succeeded) {
65 ok(succeeded,
"Waiting for error page succeeded");
67 /*
4-finish, check we are still on the error page */
68 is(SpecialPowers.wrap(w).location.href, faultyURL,
"Is on an error page");
69 isnot(SpecialPowers.wrap(w).location.href, workingURL,
"Is not on the previous page");
70 is(gotWrongPageOnTryAgainClick, false,
71 "Must not get www.example.com page on reload of an error page");
79 /*
4-check, we must not get here! */
80 gotWrongPageOnTryAgainClick = true;
87 /*
1. load a URL that leads to an error page */
88 w = window.open(workingURL);
93 <body onload=
"startTest();">