blob: a3f1162674b73859d13622fb731c574db17016fa [file] [log] [blame]
<head>
<script src="../js/resources/js-test-pre.js"></script>
<script>
var newWindow;
var intervalId;
var firstIntervalExecution = true;
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.setCanOpenWindows();
layoutTestController.waitUntilDone();
layoutTestController.setPopupBlockingEnabled(true);
}
function clickHandler() {
newWindow = window.open("about:blank");
self.focus();
debug("Test calling window.open() directly. A popup should be allowed.");
shouldBeNonNull("newWindow");
setTimeout(function() {
newWindow = window.open("about:blank");
self.focus();
debug("Test calling window.open() with a 0 ms delay. A popup should be allowed.")
shouldBeNonNull("newWindow");
}, 0);
setTimeout(function() {
newWindow = window.open("about:blank");
self.focus();
debug("Test calling window.open() with a 1000 ms delay. A popup should be allowed.")
shouldBeNonNull("newWindow");
}, 1000);
setTimeout(function() {
newWindow = window.open("about:blank");
self.focus();
debug("Test calling window.open() with a 1001 ms delay. A popup should not be allowed.")
shouldBeUndefined("newWindow");
if (window.layoutTestController)
layoutTestController.notifyDone();
}, 1001);
intervalId = setInterval(function() {
debug("Test calling window.open() in a 100 ms interval. A popup should only be allowed on the first execution of the interval.");
newWindow = window.open("about:blank");
self.focus();
if (firstIntervalExecution) {
shouldBeNonNull("newWindow");
firstIntervalExecution = false;
} else {
shouldBeUndefined("newWindow");
clearInterval(intervalId);
}
}, 100);
setTimeout(function() {
setTimeout(function() {
newWindow = window.open("about:blank");
self.focus();
debug("Test calling window.open() in a nested call to setTimeout(). A popup should not be allowed.")
shouldBeUndefined("newWindow");
}, 0);
}, 300);
if (window.eventSender)
eventSender.leapForward(1001);
}
function clickButton() {
var button = document.getElementById("test");
var buttonX = button.offsetLeft + button.offsetWidth / 2;
var buttonY = button.offsetTop + button.offsetHeight / 2;
if (window.eventSender) {
eventSender.mouseMoveTo(buttonX, buttonY);
eventSender.mouseDown();
eventSender.mouseUp();
}
}
</script>
</head>
<body onload="clickButton()">
<button id="test" onclick="clickHandler()">Click Here</button>
<div id="console"></div>
</body>