Bumping manifests a=b2g-bump
[gecko.git] / docshell / test / test_bug529119-1.html
blob573885dc0f01aac71b0559a69650bed97a251f56
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 gotWrongPageOnTryAgainClick = false;
20 function pollForPage(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 || haveErrorPage) {
38 window.clearInterval(int);
39 f(iterationsLeft > 0);
41 }, 100);
42 }, 1000);
45 function windowLoaded()
47 switch (phase)
49 case 0:
50 /* 2. We have succeededfully loaded a page, now go to a faulty URL */
51 window.setTimeout(function() {
52 w.location.href = faultyURL;
53 }, 0);
55 phase = 1;
57 pollForPage(function(succeeded) {
58 ok(succeeded, "Waiting for error page succeeded");
60 /* 3. now, while we are on the error page, try to reload it, actually
61 click the "Try Again" button */
62 SpecialPowers.wrap(w).location.reload();
64 pollForPage(function(succeeded) {
65 ok(succeeded, "Waiting for error page succeeded");
67 /* 4-finish, check we are still on the error page */
68 is(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
69 isnot(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
70 is(gotWrongPageOnTryAgainClick, false,
71 "Must not get www.example.com page on reload of an error page");
72 w.close();
73 SimpleTest.finish();
74 }, w);
75 }, w);
76 break;
78 case 1:
79 /* 4-check, we must not get here! */
80 gotWrongPageOnTryAgainClick = true;
81 break;
85 function startTest()
87 /* 1. load a URL that leads to an error page */
88 w = window.open(workingURL);
91 </script>
92 </head>
93 <body onload="startTest();">
94 </body>
95 </html>