Rollup of bug 786631: Get processes with non-default permissions on the prelaunch...
[gecko.git] / docshell / test / test_bug529119-2.html
blob67d30307585252995b12d3f5b21e88302dc11f60
1 <!DOCTYPE HTML>
2 <html>
3 <head>
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/";
15 var w = null;
16 var phase = 0;
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() {
25 iterationsLeft--;
27 var haveErrorPage = false;
28 try {
29 var title = w.document.title;
31 catch (ex) {
32 haveErrorPage = true;
35 if (iterationsLeft == 0 || expectErrorPage == haveErrorPage) {
36 window.clearInterval(int);
37 f(iterationsLeft > 0);
39 }, 100);
40 }, 1000);
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;
49 }, 0);
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 */
54 try {
55 SpecialPowers.wrap(w).back();
57 catch(ex) {
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");
66 w.close();
67 SimpleTest.finish();
68 }, w);
69 }, w);
72 function startTest()
74 /* 1. load a URL that leads to an error page */
75 w = window.open(workingURL);
78 </script>
79 </head>
80 <body onload="startTest();">
81 </body>
82 </html>