| <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> |
| <html> |
| <head> |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| <script src="../../../resources/js-test.js"></script> |
| <script src="../../../resources/ui-helper.js"></script> |
| <style> |
| body { |
| width: 100%; |
| height: 100%; |
| margin: 0; |
| } |
| |
| #editor { |
| width: 100%; |
| height: 100%; |
| opacity: 0; |
| } |
| |
| #container { |
| width: 320px; |
| height: 100px; |
| border: 1px solid tomato; |
| } |
| |
| #target { |
| width: 1em; |
| height: 1em; |
| } |
| |
| input { |
| width: 320px; |
| height: 3em; |
| } |
| </style> |
| <script> |
| addEventListener("load", runTest); |
| jsTestIsAsync = true; |
| |
| async function runTest() { |
| description("Verifies that text selection is suppressed when the selected content is in a hidden editable root, even when focusing a different element. To manually run the test, tap the editable area in the red box, and then tap the button below it. Platform selection views should not become visible."); |
| |
| button = document.querySelector("input"); |
| editor = document.getElementById("editor"); |
| focusTarget = document.getElementById("focus-target"); |
| editor.addEventListener("focus", () => getSelection().selectAllChildren(editor)); |
| button.addEventListener("click", () => { |
| event.preventDefault(); |
| focusTarget.focus(); |
| }); |
| |
| if (!window.testRunner) |
| return; |
| |
| await UIHelper.activateElementAndWaitForInputSession(editor); |
| await UIHelper.activateElement(button); |
| await UIHelper.waitForKeyboardToHide(); |
| selectionRects = await UIHelper.getUISelectionViewRects(); |
| |
| shouldBe("selectionRects.length", "0"); |
| shouldBeEqualToString("getSelection().toString()", "Hello world"); |
| shouldBe("document.activeElement", "focusTarget"); |
| |
| finishJSTest(); |
| } |
| </script> |
| </head> |
| <body> |
| <div id="container"> |
| <div id="editor" contenteditable>Hello world</div> |
| </div> |
| <div tabindex="0" id="focus-target"></div> |
| <input type="button" value="Press me"> |
| <div id="description"></div> |
| <div id="console"></div> |
| </body> |
| </html> |