fafd74c43e20ab70e10079f69626a903807f9761
[WebKit-https.git] / LayoutTests / fast / events / popup-blocking-timers3.html
1 <!DOCTYPE html>
2 <head>
3     <script src="../js/resources/js-test-pre.js"></script>
4     <script>
5         var newWindow;
6         var intervalId;
7         var firstIntervalExecution = true;
8         
9         if (window.testRunner) {
10             testRunner.dumpAsText();
11             testRunner.setCanOpenWindows();
12             testRunner.waitUntilDone();
13             testRunner.setPopupBlockingEnabled(true);
14         }
15     
16         function clickHandler() {
17             intervalId = setInterval(function() {
18                 debug("Test calling window.open() in a 100 ms interval. A popup should only be allowed on the first execution of the interval.");
19                 newWindow = window.open("about:blank");
20                 self.focus();
21                 if (firstIntervalExecution) {
22                     shouldBeNonNull("newWindow");
23                     firstIntervalExecution = false;
24                 } else {
25                     shouldBeUndefined("newWindow");
26                     clearInterval(intervalId);
27                     if (window.testRunner)
28                         testRunner.notifyDone();
29                 }
30             }, 100);
31         }
32         
33         function clickButton() {
34             var button = document.getElementById("test");
35             var buttonX = button.offsetLeft + button.offsetWidth / 2;
36             var buttonY = button.offsetTop + button.offsetHeight / 2;
37             if (window.eventSender) {
38                 eventSender.mouseMoveTo(buttonX, buttonY);
39                 eventSender.mouseDown();
40                 eventSender.mouseUp();
41             }
42         }        
43     </script>
44 </head>
45 <body onload="clickButton()">
46     <button id="test" onclick="clickHandler()">Click Here</button>
47     <div id="console"></div>
48 </body>