Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test bug 529119</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 7 | |
michael@0 | 8 | <script class="testbody" type="text/javascript"> |
michael@0 | 9 | |
michael@0 | 10 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 11 | |
michael@0 | 12 | var workingURL = "http://mochi.test:8888/tests/docshell/test/bug529119-window.html"; |
michael@0 | 13 | var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/"; |
michael@0 | 14 | |
michael@0 | 15 | var w = null; |
michael@0 | 16 | var phase = 0; |
michael@0 | 17 | var gotWrongPageOnTryAgainClick = false; |
michael@0 | 18 | |
michael@0 | 19 | function pollForPage(f, w) |
michael@0 | 20 | { |
michael@0 | 21 | // Start with polling after a delay, we might mistakenly take the current page |
michael@0 | 22 | // as an expected one. |
michael@0 | 23 | window.setTimeout(function() { |
michael@0 | 24 | var iterationsLeft = 200; |
michael@0 | 25 | var int = window.setInterval(function() { |
michael@0 | 26 | iterationsLeft--; |
michael@0 | 27 | |
michael@0 | 28 | var haveErrorPage = false; |
michael@0 | 29 | try { |
michael@0 | 30 | var title = w.document.title; |
michael@0 | 31 | } |
michael@0 | 32 | catch (ex) { |
michael@0 | 33 | haveErrorPage = true; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | if (iterationsLeft == 0 || haveErrorPage) { |
michael@0 | 37 | window.clearInterval(int); |
michael@0 | 38 | f(iterationsLeft > 0); |
michael@0 | 39 | } |
michael@0 | 40 | }, 100); |
michael@0 | 41 | }, 1000); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function windowLoaded() |
michael@0 | 45 | { |
michael@0 | 46 | switch (phase) |
michael@0 | 47 | { |
michael@0 | 48 | case 0: |
michael@0 | 49 | /* 2. We have succeededfully loaded a page, now go to a faulty URL */ |
michael@0 | 50 | window.setTimeout(function() { |
michael@0 | 51 | w.location.href = faultyURL; |
michael@0 | 52 | }, 0); |
michael@0 | 53 | |
michael@0 | 54 | phase = 1; |
michael@0 | 55 | |
michael@0 | 56 | pollForPage(function(succeeded) { |
michael@0 | 57 | ok(succeeded, "Waiting for error page succeeded"); |
michael@0 | 58 | |
michael@0 | 59 | /* 3. now, while we are on the error page, try to reload it, actually |
michael@0 | 60 | click the "Try Again" button */ |
michael@0 | 61 | SpecialPowers.wrap(w).location.reload(); |
michael@0 | 62 | |
michael@0 | 63 | pollForPage(function(succeeded) { |
michael@0 | 64 | ok(succeeded, "Waiting for error page succeeded"); |
michael@0 | 65 | |
michael@0 | 66 | /* 4-finish, check we are still on the error page */ |
michael@0 | 67 | is(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page"); |
michael@0 | 68 | isnot(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page"); |
michael@0 | 69 | is(gotWrongPageOnTryAgainClick, false, |
michael@0 | 70 | "Must not get www.example.com page on reload of an error page"); |
michael@0 | 71 | w.close(); |
michael@0 | 72 | SimpleTest.finish(); |
michael@0 | 73 | }, w); |
michael@0 | 74 | }, w); |
michael@0 | 75 | break; |
michael@0 | 76 | |
michael@0 | 77 | case 1: |
michael@0 | 78 | /* 4-check, we must not get here! */ |
michael@0 | 79 | gotWrongPageOnTryAgainClick = true; |
michael@0 | 80 | break; |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function startTest() |
michael@0 | 85 | { |
michael@0 | 86 | /* 1. load a URL that leads to an error page */ |
michael@0 | 87 | w = window.open(workingURL); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | </script> |
michael@0 | 91 | </head> |
michael@0 | 92 | <body onload="startTest();"> |
michael@0 | 93 | </body> |
michael@0 | 94 | </html> |