| <body> |
| <p>This tests that keydown events aren't sent to the main frame for command key presses that occur when a subframe is first responder. To run it manually, click inside the subframe, type a few characters, then do Command-A to Select All. Only the subframe should report a keydown event.</p> |
| <iframe id="iframe" style="border: 1px solid black;" src="../../editing/resources/contenteditable-iframe-src.html"></iframe> |
| <ul id="console"></ul> |
| |
| <script> |
| function log(str) { |
| var console = document.getElementById("console"); |
| var li = document.createElement("li"); |
| li.appendChild(document.createTextNode(str)); |
| console.appendChild(li); |
| } |
| |
| function addEventListeners() { |
| window.addEventListener("keydown", |
| function(e) { |
| log("keydown in mainframe: " + e); |
| }, |
| false); |
| |
| window.frames[0].addEventListener("keydown", |
| function(e) { |
| log("keydown in subframe: " + e); |
| }, |
| false); |
| } |
| |
| function step2() { |
| addEventListeners(); |
| |
| if (!window.layoutTestController) |
| return; |
| |
| var iframe = document.getElementById("iframe"); |
| var x = iframe.offsetParent.offsetLeft + iframe.offsetLeft + iframe.offsetWidth / 2; |
| var y = iframe.offsetParent.offsetTop + iframe.offsetTop + iframe.offsetHeight / 2; |
| |
| eventSender.mouseMoveTo(x, y); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| |
| window.frames[0].document.execCommand("InsertText", false, "This sentence should not end with a period."); |
| // Move backward by one character. |
| eventSender.keyDown("b", Array("ctrlKey")); |
| // Delete forward by one character. |
| eventSender.keyDown("d", Array("ctrlKey")); |
| window.layoutTestController.notifyDone(); |
| } |
| |
| function runTest() { |
| if (window.layoutTestController) |
| window.layoutTestController.waitUntilDone(); |
| |
| window.setTimeout(step2, 200); |
| } |
| |
| runTest(); |
| </script> |
| </body> |