gecko-dev/docshell/test/mochitest/test_bug529119-1.html
Brian Grinstead ede8c44ef2 Bug 1544322 - Part 2.1 - Remove the [type] attribute for one-liner <script> tags loading files in /tests/SimpleTest/ in everything except for dom/ r=bzbarsky
This excludes dom/, otherwise the file size is too large for phabricator to handle.

This is an autogenerated commit to handle scripts loading mochitest harness files, in
the simple case where the script src is on the same line as the tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 2` argument.

Differential Revision: https://phabricator.services.mozilla.com/D27456

--HG--
extra : moz-landing-system : lando
2019-04-16 03:50:44 +00:00

91 lines
2.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test bug 529119</title>
<script 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/mochitest/bug529119-window.html";
var faultyURL = "http://some-nonexistent-domain-27489274c892748217cn2384.com/";
var w = null;
var phase = 0;
var gotWrongPageOnTryAgainClick = false;
function pollForPage(f, win) {
// 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 {
win.document.title;
} catch (ex) {
haveErrorPage = true;
}
if (iterationsLeft == 0 || haveErrorPage) {
window.clearInterval(int);
f(iterationsLeft > 0);
}
}, 100);
}, 1000);
}
function windowLoaded() {
switch (phase) {
case 0:
/* 2. We have succeededfully loaded a page, now go to a faulty URL */
window.setTimeout(function() {
w.location.href = faultyURL;
}, 0);
phase = 1;
pollForPage(function(enterErrorSucceeded) {
ok(enterErrorSucceeded, "Waiting for error page succeeded");
/* 3. now, while we are on the error page, try to reload it, actually
click the "Try Again" button */
SpecialPowers.wrap(w).location.reload();
pollForPage(function(continueErrorSucceeded) {
ok(continueErrorSucceeded, "Waiting for error page succeeded");
/* 4-finish, check we are still on the error page */
is(SpecialPowers.wrap(w).location.href, faultyURL, "Is on an error page");
isnot(SpecialPowers.wrap(w).location.href, workingURL, "Is not on the previous page");
is(gotWrongPageOnTryAgainClick, false,
"Must not get www.example.com page on reload of an error page");
w.close();
SimpleTest.finish();
}, w);
}, w);
break;
case 1:
/* 4-check, we must not get here! */
gotWrongPageOnTryAgainClick = true;
break;
}
}
function startTest() {
/* 1. load a URL that leads to an error page */
w = window.open(workingURL);
}
</script>
</head>
<body onload="startTest();">
</body>
</html>