| <!-- webkit-test-runner [ useFlexibleViewport=true, useCharacterSelectionGranularity=true ] --> |
| <meta name=viewport content="width=device-width, initial-scale=1"> |
| <div style="font-size: 125px;">WEB<br>KIT</div> |
| <div id="output" style="color: green; margin-top: 1em;"></div> |
| <script> |
| function selectUpperTextScript() |
| { |
| return ` |
| (() => { |
| uiController.longPressAtPoint(100, 100, () => { |
| uiController.uiScriptComplete(); |
| }); |
| })();` |
| } |
| |
| function tapLowerTextScript() |
| { |
| return ` |
| (() => { |
| uiController.singleTapAtPoint(100, 225, () => { |
| uiController.uiScriptComplete(); |
| }); |
| })();` |
| } |
| |
| function appendOutput(message) |
| { |
| let code = document.createElement("code"); |
| code.appendChild(document.createTextNode(message)); |
| output.appendChild(code); |
| output.appendChild(document.createElement("br")); |
| } |
| |
| (() => { |
| if (!window.testRunner) { |
| appendOutput(`This test cannot be run manually; character granularity selections must be enabled.`); |
| return; |
| } |
| |
| let selectedString = ""; |
| document.addEventListener("selectionchange", () => { |
| let currentSelectedString = getSelection().toString(); |
| if (selectedString === currentSelectedString) |
| return; |
| |
| selectedString = currentSelectedString; |
| appendOutput(`The selected content is now: "${selectedString}"`); |
| if (selectedString === "") |
| testRunner.notifyDone(); |
| }); |
| })(); |
| |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| testRunner.runUIScript(selectUpperTextScript(), () => { |
| testRunner.runUIScript(tapLowerTextScript(), () => { }); |
| }); |
| </script> |