| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script> | 3 <script> |
| 4 if (window.testRunner) { | 4 if (window.testRunner) { |
| 5 testRunner.dumpAsText(); | 5 testRunner.dumpAsText(); |
| 6 testRunner.setCanOpenWindows(); | 6 testRunner.setCanOpenWindows(); |
| 7 testRunner.setCloseRemainingWindowsWhenComplete(true); | 7 testRunner.setCloseRemainingWindowsWhenComplete(true); |
| 8 testRunner.waitUntilDone(); | 8 testRunner.waitUntilDone(); |
| 9 } | 9 } |
| 10 | 10 |
| 11 var TEST_STARTED = 0; | 11 var TEST_STARTED = 0; |
| 12 var TEST_WITH_ENABLING_POPUP_BLOCKER = 1; | 12 var TEST_WITH_ENABLING_POPUP_BLOCKER = 1; |
| 13 var TEST_WITH_DISABLING_POPUP_BLOCKER = 2; | 13 var TEST_WITH_DISABLING_POPUP_BLOCKER = 2; |
| 14 var TEST_COMPLETED = 3; | 14 var TEST_COMPLETED = 3; |
| 15 | 15 |
| 16 function nextTestStage() { | 16 function nextTestStage() { |
| 17 window.testStage++; | 17 window.testStage++; |
| 18 if (TEST_WITH_ENABLING_POPUP_BLOCKER == window.testStage) { | 18 if (TEST_WITH_ENABLING_POPUP_BLOCKER == window.testStage) { |
| 19 window.popupBlockerIsEnabled = true; | 19 window.popupBlockerIsEnabled = true; |
| 20 doClick(); | 20 doClick(); |
| 21 } else if (TEST_WITH_DISABLING_POPUP_BLOCKER == window.testStage) { | 21 } else if (TEST_WITH_DISABLING_POPUP_BLOCKER == window.testStage) { |
| 22 window.popupBlockerIsEnabled = false; | 22 window.popupBlockerIsEnabled = false; |
| 23 doClick(); | 23 doClick(); |
| 24 } else { | 24 } else { |
| 25 document.getElementById("console").innerHTML = "PASSED"; | 25 document.getElementById("console").innerHTML = "PASSED"; |
| 26 testRunner.notifyDone(); | 26 testRunner.notifyDone(); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 function dispatchEvent(obj, evt) { | 30 function dispatchEvent(obj, evt) { |
| 31 return function() { | 31 return function() { |
| 32 return obj.dispatchEvent(evt); | 32 return obj.dispatchEvent(evt); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 function simulateClick() { | 36 function simulateClick() { |
| 37 var evt = document.createEvent("MouseEvents"); | 37 var evt = document.createEvent("MouseEvents"); |
| 38 evt.initMouseEvent("click", true, true, window, | 38 evt.initMouseEvent("click", true, true, window, |
| 39 0, 0, 0, 0, 0, false, false, false, false, 0, null); | 39 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
| 40 var cb = document.getElementById("anchor"); | 40 var cb = document.getElementById("anchor"); |
| 41 setTimeout(dispatchEvent(cb, evt), 100); | 41 setTimeout(dispatchEvent(cb, evt), 100); |
| 42 } | 42 } |
| 43 | 43 |
| 44 function openWindow(evt) { | 44 function openWindow(evt) { |
| 45 window.open("data:text/html\, try to open new window", "_blank"); | 45 // Try to open a new window. |
| 46 window.open("about:blank", "_blank"); |
| 46 // If we enabled the popup blocker, the new window should be blocked. | 47 // If we enabled the popup blocker, the new window should be blocked. |
| 47 // The windowCount should still be 1. | 48 // The windowCount should still be 1. |
| 48 var expectedWindowCount = 1; | 49 var expectedWindowCount = 1; |
| 49 // If we disabled the popup blocker, the new window should be created. | 50 // If we disabled the popup blocker, the new window should be created. |
| 50 // The windowCount should be 2. | 51 // The windowCount should be 2. |
| 51 if (!window.popupBlockerIsEnabled) | 52 if (!window.popupBlockerIsEnabled) |
| 52 expectedWindowCount = 2; | 53 expectedWindowCount = 2; |
| 53 // Encounter a failure, quit test. | 54 // Encounter a failure, quit test. |
| 54 if (testRunner.windowCount() != expectedWindowCount) { | 55 if (testRunner.windowCount() != expectedWindowCount) { |
| 55 testRunner.notifyDone(); | 56 testRunner.notifyDone(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 71 function test() { | 72 function test() { |
| 72 if (!window.testRunner) | 73 if (!window.testRunner) |
| 73 return; | 74 return; |
| 74 window.testStage = TEST_STARTED; | 75 window.testStage = TEST_STARTED; |
| 75 nextTestStage(); | 76 nextTestStage(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 </script> | 79 </script> |
| 79 <body onload="window.setTimeout(test, 0);"> | 80 <body onload="window.setTimeout(test, 0);"> |
| 80 <input type="button" onclick="simulateClick();" value="click me" id="btn"><br> | 81 <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 <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.webk
it.org/show_bug.cgi?id=50508. | 83 The JavaScript created (untrusted) event inside a user-initiated (trusted) event
should not cache the UserGesture status. This test is for bug https://bugs.webk
it.org/show_bug.cgi?id=50508. |
| 83 <div id="console">FAILED</div> | 84 <div id="console">FAILED</div> |
| OLD | NEW |