| <!DOCTYPE html> |
| |
| <html> |
| <head> |
| <script src="../../../../resources/basic-gestures.js"></script> |
| <script> |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| testRunner.waitUntilDone(); |
| } |
| |
| async function runTest() |
| { |
| if (!testRunner.runUIScript) |
| return; |
| |
| var output = ''; |
| var targetRect = document.getElementById('selection').getBoundingClientRect(); |
| |
| var pressPointX = targetRect.x + targetRect.width / 2; |
| var pressPointY = targetRect.y + targetRect.height / 2; |
| |
| await longPressAtPoint(pressPointX, pressPointY); |
| if (document.getSelection().toString() == "PressMe") |
| output += 'PASS: Correct Selection'; |
| else |
| output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| await tapAtPoint(100, 100); |
| if (document.getSelection().toString() == "") |
| output += 'PASS: Cleared selection'; |
| else |
| output += 'FAIL: failed to clear selection after tap.' + document.getSelection().toString(); |
| output += '<br>'; |
| document.getElementById('target').innerHTML = output; |
| testRunner.notifyDone(); |
| } |
| |
| window.addEventListener('load', runTest, false); |
| </script> |
| <style> |
| #target { |
| height: 100px; |
| width: 200px; |
| background-color: silver; |
| } |
| </style> |
| <meta name="viewport" content="initial-scale=1"> |
| </head> |
| <body> |
| <div id="target"> |
| <p><span id="selection">PressMe</span></p> |
| This test requires UIScriptController to run. |
| </div> |
| </body> |
| </html> |