| <!DOCTYPE html> |
| <html> |
| <head> |
| <script> |
| function runTest() { |
| window.onfocus = windowFocused; |
| window.onblur = windowBlurred; |
| |
| if (window.testRunner) { |
| testRunner.setWindowIsKey(false); |
| window.open('javascript:window.focus()', '_self', ''); |
| setTimeout(function() { testRunner.notifyDone(); }, 0); |
| } |
| } |
| |
| function log(message) { |
| var console = document.getElementById("console"); |
| var li = document.createElement("li"); |
| var text = document.createTextNode(message); |
| |
| console.appendChild(li); |
| li.appendChild(text); |
| } |
| |
| function windowFocused() { |
| log("FAIL: Window was focused"); |
| } |
| |
| function windowBlurred() { |
| log("Window was blurred"); |
| } |
| </script> |
| </head> |
| <body> |
| This tests that a window cannot focus itself by using javascript: urls. |
| <ul id="console"></ul> |
| <script> |
| if (window.testRunner) { |
| testRunner.waitUntilDone(); |
| testRunner.dumpAsText(); |
| // If this test is run on a fresh content shell, its initial focus |
| // may deliver a focus event which can race with runTest() above, |
| // and result in false failure. Add some delay to avoid the initial |
| // focus event. See crbug.com/863067 for more background. |
| setTimeout(runTest, 100); |
| } |
| </script> |
| </body> |
| </html> |