blob: 38f9a57b46fc5d07d5a5469e0e568b98cb178dcd [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCanOpenWindows();
layoutTestController.waitUntilDone();
}
var start;
var myInterval;
//This function should only be used with DRT and thus layoutTestController
function checkIfDone() {
var numOpenWindows = layoutTestController.windowCount();
var now = new Date();
if (numOpenWindows == 1) {
var span = document.createElement("span");
span.innerHTML = 'TEST PASSED <br>';
document.getElementById("console").appendChild(span);
clearInterval(myInterval);
layoutTestController.notifyDone();
} else if (now - start > 10000) {
var span = document.createElement("span");
span.innerHTML = 'TEST FAILED <br> Number of open windows: ' + numOpenWindows + '<br/>';
document.getElementById("console").appendChild(span);
clearInterval(myInterval);
layoutTestController.notifyDone();
}
}
function openNewWindow() {
var event = document.createEvent('MouseEvent');
event.initEvent( 'click', true, true );
document.getElementById('anchorLink').dispatchEvent(event);
if (window.layoutTestController) {
layoutTestController.setCloseRemainingWindowsWhenComplete();
start = new Date();
myInterval = setInterval(checkIfDone, 500);
}
}
</script>
</head>
<body onload="openNewWindow()">
This test checks that a window which has been opened by the DOM can also be closed
byt the DOM. The test will run automatically with popup blocking disabled.
To run the test manually click the link below.
<br/>
<div id="console" />
<br/>
<a href="resources/middle.html" id="anchorLink" target="_blank">Open new window that will close itself</a>
<br/><br/>
</body>
</html>