summaryrefslogtreecommitdiffstats
path: root/docshell/test/test_bug529119-2.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /docshell/test/test_bug529119-2.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'docshell/test/test_bug529119-2.html')
-rw-r--r--docshell/test/test_bug529119-2.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/docshell/test/test_bug529119-2.html b/docshell/test/test_bug529119-2.html
new file mode 100644
index 000000000..fb3d19119
--- /dev/null
+++ b/docshell/test/test_bug529119-2.html
@@ -0,0 +1,90 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Test bug 529119</title>
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
+
+var workingURL = "http://mochi.test:8888/tests/docshell/test/bug529119-window.html";
+var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
+
+var w = null;
+var phase = 0;
+var isWindowLoaded = false;
+
+function pollForPage(expectErrorPage, f, w)
+{
+ // Start with polling after a delay, we might mistakenly take the current page
+ // as an expected one.
+ window.setTimeout(function() {
+ var iterationsLeft = 200;
+ var int = window.setInterval(function() {
+ iterationsLeft--;
+
+ var haveErrorPage = false;
+ try {
+ var title = w.document.title;
+ }
+ catch (ex) {
+ haveErrorPage = true;
+ }
+
+ if (iterationsLeft == 0 || expectErrorPage == haveErrorPage) {
+ window.clearInterval(int);
+ f(iterationsLeft > 0);
+ }
+ }, 100);
+ }, 1000);
+}
+
+function windowLoaded()
+{
+ // The code under here should only be run once
+ // The test popup window workingURL was already opened
+ if (isWindowLoaded)
+ return;
+ isWindowLoaded = true;
+
+ /* 2. We have successfully loaded a page, now go to a faulty URL */
+ // XXX The test fails when we change the location synchronously
+ window.setTimeout(function() {
+ w.location.href = faultyURL;
+ }, 0);
+
+ pollForPage(true, function(succeeded) {
+ ok(succeeded, "Waiting for error page succeeded");
+ /* 3. now, while we are on the error page, navigate back */
+ try {
+ SpecialPowers.wrap(w).back();
+ }
+ catch(ex) {
+ ok(false, "w.back() threw " + ex);
+ }
+
+ pollForPage(false, function(succeeded) {
+ ok(succeeded, "Waiting for original page succeeded");
+ /* 4-finish, check we are back at the original page */
+ isnot(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
+ is(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
+ w.close();
+ SimpleTest.finish();
+ }, w);
+ }, w);
+}
+
+function startTest()
+{
+ /* 1. load a URL that leads to an error page */
+ w = window.open(workingURL);
+}
+
+</script>
+</head>
+<body onload="startTest();">
+</body>
+</html>