mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
91 lines
2.6 KiB
HTML
91 lines
2.6 KiB
HTML
|
<!DOCTYPE HTML>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Test bug 529119</title>
|
||
|
<script type="text/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||
|
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||
|
|
||
|
<script class="testbody" type="text/javascript">
|
||
|
|
||
|
SimpleTest.waitForExplicitFinish();
|
||
|
|
||
|
var workingURL = "http://localhost:8888/tests/docshell/test/bug529119-window.html";
|
||
|
var faultyURL = "http://some-non-existent-domain-27489274c892748217cn2384.com/";
|
||
|
|
||
|
var w = null;
|
||
|
var phase = 0;
|
||
|
|
||
|
function pollForPage(expected_title, f, w)
|
||
|
{
|
||
|
// Start with polling after a delay, we might mistakenly take the current page
|
||
|
// as an expected one.
|
||
|
window.setTimeout(function() {
|
||
|
var iterationsLeft = 20;
|
||
|
var int = window.setInterval(function() {
|
||
|
iterationsLeft--;
|
||
|
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
try {
|
||
|
var title = w.document.title;
|
||
|
}
|
||
|
catch (ex) {
|
||
|
alert(ex);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (iterationsLeft == 0 || title.match(expected_title)) {
|
||
|
window.clearInterval(int);
|
||
|
f(iterationsLeft > 0);
|
||
|
}
|
||
|
}, 100);
|
||
|
}, 1000);
|
||
|
}
|
||
|
|
||
|
function windowLoaded()
|
||
|
{
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
|
||
|
/* 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("Problem loading page", function(succeeded) {
|
||
|
ok(succeeded, "Waiting for error page succeeded");
|
||
|
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
/* 3. now, while we are on the error page, navigate back */
|
||
|
try {
|
||
|
w.back();
|
||
|
}
|
||
|
catch(ex) {
|
||
|
ok(false, "w.back() threw " + ex);
|
||
|
}
|
||
|
|
||
|
pollForPage("Test bug 529119, sub-window", function(succeeded) {
|
||
|
ok(succeeded, "Waiting for original page succeeded");
|
||
|
|
||
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||
|
/* 4-finish, check we are back at the original page */
|
||
|
isnot(w.location.href, faultyURL, "Is on an error page");
|
||
|
is(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>
|