4 <title>Test bug
529119</title>
5 <script type=
"text/javascript" src=
"/MochiKit/packed.js"></script>
6 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
9 <script class=
"testbody" type=
"text/javascript">
11 SimpleTest.waitForExplicitFinish();
13 var workingURL =
"http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
14 var faultyURL =
"http://some-nonexistent-domain-27489274c892748217cn2384.com/";
19 function pollForPage(expectErrorPage, f, w)
21 // Start with polling after a delay, we might mistakenly take the current page
22 // as an expected one.
23 window.setTimeout(function() {
24 var iterationsLeft =
200;
25 var int = window.setInterval(function() {
28 var haveErrorPage = false;
30 var title = w.document.title;
36 if (iterationsLeft ==
0 || expectErrorPage == haveErrorPage) {
37 window.clearInterval(int);
38 f(iterationsLeft
> 0);
44 function windowLoaded()
46 netscape.security.PrivilegeManager.enablePrivilege(
"UniversalXPConnect");
48 /*
2. We have successfully loaded a page, now go to a faulty URL */
49 // XXX The test fails when we change the location synchronously
50 window.setTimeout(function() {
51 w.location.href = faultyURL;
54 pollForPage(true, function(succeeded) {
55 ok(succeeded,
"Waiting for error page succeeded");
57 netscape.security.PrivilegeManager.enablePrivilege(
"UniversalXPConnect");
58 /*
3. now, while we are on the error page, navigate back */
63 ok(false,
"w.back() threw " + ex);
66 pollForPage(false, function(succeeded) {
67 ok(succeeded,
"Waiting for original page succeeded");
69 netscape.security.PrivilegeManager.enablePrivilege(
"UniversalXPConnect");
70 /*
4-finish, check we are back at the original page */
71 isnot(w.location.href, faultyURL,
"Is on an error page");
72 is(w.location.href, workingURL,
"Is not on the previous page");
81 /*
1. load a URL that leads to an error page */
82 w = window.open(workingURL);
87 <body onload=
"startTest();">