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 isWindowLoaded = false;
20 function pollForPage(expectErrorPage, 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 || expectErrorPage == haveErrorPage) {
38 window.clearInterval(int);
39 f(iterationsLeft
> 0);
45 function windowLoaded()
47 // The code under here should only be run once
48 // The test popup window workingURL was already opened
51 isWindowLoaded = true;
53 /*
2. We have successfully loaded a page, now go to a faulty URL */
54 // XXX The test fails when we change the location synchronously
55 window.setTimeout(function() {
56 w.location.href = faultyURL;
59 pollForPage(true, function(succeeded) {
60 ok(succeeded,
"Waiting for error page succeeded");
61 /*
3. now, while we are on the error page, navigate back */
63 SpecialPowers.wrap(w).back();
66 ok(false,
"w.back() threw " + ex);
69 pollForPage(false, function(succeeded) {
70 ok(succeeded,
"Waiting for original page succeeded");
71 /*
4-finish, check we are back at the original page */
72 isnot(SpecialPowers.wrap(w).location.href, faultyURL,
"Is on an error page");
73 is(SpecialPowers.wrap(w).location.href, workingURL,
"Is not on the previous page");
82 /*
1. load a URL that leads to an error page */
83 w = window.open(workingURL);
88 <body onload=
"startTest();">