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();
12 var workingURL =
"http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
13 var faultyURL =
"http://some-nonexistent-domain-27489274c892748217cn2384.com/";
18 function pollForPage(expectErrorPage, f, w)
20 // Start with polling after a delay, we might mistakenly take the current page
21 // as an expected one.
22 window.setTimeout(function() {
23 var iterationsLeft =
200;
24 var int = window.setInterval(function() {
27 var haveErrorPage = false;
29 var title = w.document.title;
35 if (iterationsLeft ==
0 || expectErrorPage == haveErrorPage) {
36 window.clearInterval(int);
37 f(iterationsLeft
> 0);
43 function windowLoaded()
45 /*
2. We have successfully loaded a page, now go to a faulty URL */
46 // XXX The test fails when we change the location synchronously
47 window.setTimeout(function() {
48 w.location.href = faultyURL;
51 pollForPage(true, function(succeeded) {
52 ok(succeeded,
"Waiting for error page succeeded");
53 /*
3. now, while we are on the error page, navigate back */
55 SpecialPowers.wrap(w).back();
58 ok(false,
"w.back() threw " + ex);
61 pollForPage(false, function(succeeded) {
62 ok(succeeded,
"Waiting for original page succeeded");
63 /*
4-finish, check we are back at the original page */
64 isnot(SpecialPowers.wrap(w).location.href, faultyURL,
"Is on an error page");
65 is(SpecialPowers.wrap(w).location.href, workingURL,
"Is not on the previous page");
74 /*
1. load a URL that leads to an error page */
75 w = window.open(workingURL);
80 <body onload=
"startTest();">