2 <script src="../js/resources/js-test-pre.js"></script>
6 var firstIntervalExecution = true;
8 if (window.layoutTestController) {
9 layoutTestController.dumpAsText();
10 layoutTestController.setCanOpenWindows();
11 layoutTestController.waitUntilDone();
12 layoutTestController.setPopupBlockingEnabled(true);
15 function clickHandler() {
16 newWindow = window.open("about:blank");
18 debug("Test calling window.open() directly. A popup should be allowed.");
19 shouldBeNonNull("newWindow");
21 setTimeout(function() {
22 newWindow = window.open("about:blank");
24 debug("Test calling window.open() with a 0 ms delay. A popup should be allowed.")
25 shouldBeNonNull("newWindow");
28 setTimeout(function() {
29 newWindow = window.open("about:blank");
31 debug("Test calling window.open() with a 1000 ms delay. A popup should be allowed.")
32 shouldBeNonNull("newWindow");
35 setTimeout(function() {
36 newWindow = window.open("about:blank");
38 debug("Test calling window.open() with a 1001 ms delay. A popup should not be allowed.")
39 shouldBeUndefined("newWindow");
41 if (window.layoutTestController)
42 layoutTestController.notifyDone();
45 intervalId = setInterval(function() {
46 debug("Test calling window.open() in a 100 ms interval. A popup should only be allowed on the first execution of the interval.");
47 newWindow = window.open("about:blank");
49 if (firstIntervalExecution) {
50 shouldBeNonNull("newWindow");
51 firstIntervalExecution = false;
53 shouldBeUndefined("newWindow");
54 clearInterval(intervalId);
58 setTimeout(function() {
59 setTimeout(function() {
60 newWindow = window.open("about:blank");
62 debug("Test calling window.open() in a nested call to setTimeout(). A popup should not be allowed.")
63 shouldBeUndefined("newWindow");
67 if (window.eventSender)
68 eventSender.leapForward(1001);
71 function clickButton() {
72 var button = document.getElementById("test");
73 var buttonX = button.offsetLeft + button.offsetWidth / 2;
74 var buttonY = button.offsetTop + button.offsetHeight / 2;
75 if (window.eventSender) {
76 eventSender.mouseMoveTo(buttonX, buttonY);
77 eventSender.mouseDown();
78 eventSender.mouseUp();
83 <body onload="clickButton()">
84 <button id="test" onclick="clickHandler()">Click Here</button>
85 <div id="console"></div>