Bumping manifests a=b2g-bump
[gecko.git] / docshell / test / test_bug529119-2.html
blobfb3d1911933dc1206a26adb5349c01305bde1519
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();
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/";
16 var w = null;
17 var phase = 0;
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() {
27 iterationsLeft--;
29 var haveErrorPage = false;
30 try {
31 var title = w.document.title;
33 catch (ex) {
34 haveErrorPage = true;
37 if (iterationsLeft == 0 || expectErrorPage == haveErrorPage) {
38 window.clearInterval(int);
39 f(iterationsLeft > 0);
41 }, 100);
42 }, 1000);
45 function windowLoaded()
47 // The code under here should only be run once
48 // The test popup window workingURL was already opened
49 if (isWindowLoaded)
50 return;
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;
57 }, 0);
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 */
62 try {
63 SpecialPowers.wrap(w).back();
65 catch(ex) {
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");
74 w.close();
75 SimpleTest.finish();
76 }, w);
77 }, w);
80 function startTest()
82 /* 1. load a URL that leads to an error page */
83 w = window.open(workingURL);
86 </script>
87 </head>
88 <body onload="startTest();">
89 </body>
90 </html>