4 if (window
.testRunner
) {
5 testRunner
.dumpAsText();
6 testRunner
.setCanOpenWindows();
7 testRunner
.setCloseRemainingWindowsWhenComplete(true);
8 testRunner
.waitUntilDone();
12 var TEST_WITH_ENABLING_POPUP_BLOCKER
= 1;
13 var TEST_WITH_DISABLING_POPUP_BLOCKER
= 2;
14 var TEST_COMPLETED
= 3;
16 function nextTestStage() {
18 if (TEST_WITH_ENABLING_POPUP_BLOCKER
== window
.testStage
) {
19 window
.popupBlockerIsEnabled
= true;
21 } else if (TEST_WITH_DISABLING_POPUP_BLOCKER
== window
.testStage
) {
22 window
.popupBlockerIsEnabled
= false;
25 document
.getElementById("console").innerHTML
= "PASSED";
26 testRunner
.notifyDone();
30 function dispatchEvent(obj
, evt
) {
32 return obj
.dispatchEvent(evt
);
36 function simulateClick() {
37 var evt
= document
.createEvent("MouseEvents");
38 evt
.initMouseEvent("click", true, true, window
,
39 0, 0, 0, 0, 0, false, false, false, false, 0, null);
40 var cb
= document
.getElementById("anchor");
41 setTimeout(dispatchEvent(cb
, evt
), 100);
44 function openWindow(evt
) {
45 window
.open("data:text/html\, try to open new window", "_blank");
46 // If we enabled the popup blocker, the new window should be blocked.
47 // The windowCount should still be 1.
48 var expectedWindowCount
= 1;
49 // If we disabled the popup blocker, the new window should be created.
50 // The windowCount should be 2.
51 if (!window
.popupBlockerIsEnabled
)
52 expectedWindowCount
= 2;
53 // Encounter a failure, quit test.
54 if (testRunner
.windowCount() != expectedWindowCount
) {
55 testRunner
.notifyDone();
58 // Go to next test stage.
59 window
.setTimeout(nextTestStage
, 0);
63 testRunner
.setPopupBlockingEnabled(window
.popupBlockerIsEnabled
);
64 // Send a mouse-click event to click the button.
65 eventSender
.mouseMoveTo(0, 0);
66 eventSender
.mouseMoveTo(20, 20);
67 eventSender
.mouseDown();
68 eventSender
.mouseUp();
72 if (!window
.testRunner
)
74 window
.testStage
= TEST_STARTED
;
79 <body onload=
"window.setTimeout(test, 0);">
80 <input type=
"button" onclick=
"simulateClick();" value=
"click me" id=
"btn"><br>
81 <a onclick=
"openWindow(event)" id=
"anchor"> open a new window
</a><br>
82 The JavaScript created (untrusted) event inside a user-initiated (trusted) event should not cache the UserGesture status. This test is for bug https://bugs.webkit.org/show_bug.cgi?id=
50508.
83 <div id=
"console">FAILED
</div>