| <!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 editableTargetRect = document.getElementById('editable').getBoundingClientRect(); |
| var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect(); |
| var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect(); |
| var thirdTargetRect = document.getElementById('thirdSelection').getBoundingClientRect(); |
| var editableToNoneditableOffset = document.getElementById('noneditable').getBoundingClientRect().y - document.getElementById('editable').getBoundingClientRect().y; |
| |
| var tapPointX = editableTargetRect.x + editableTargetRect.width / 2; |
| var tapPointY = editableTargetRect.y + editableTargetRect.height / 2; |
| var doubleTapPointX = firstTargetRect.x + firstTargetRect.width / 2; |
| var doubleTapPointY = firstTargetRect.y + firstTargetRect.height / 2 - editableToNoneditableOffset; |
| var dragY = firstTargetRect.y + firstTargetRect.height - editableToNoneditableOffset; |
| var dragX = firstTargetRect.x + firstTargetRect.width; |
| var dragY2 = secondTargetRect.y + secondTargetRect.height - editableToNoneditableOffset; |
| var dragY3 = thirdTargetRect.y + thirdTargetRect.height - editableToNoneditableOffset; |
| var dragY4 = firstTargetRect.y - firstTargetRect.height - editableToNoneditableOffset; |
| |
| await tapAtPoint(tapPointX, tapPointY); |
| if (document.getSelection().type == "Caret") |
| output += 'PASS: Has Caret Selection'; |
| else |
| output += 'FAIL: failed to activate caret as a result of a tap. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| |
| await didShowKeyboard(); |
| |
| await doubleTapAtPoint(doubleTapPointX, doubleTapPointY); |
| if (document.getSelection().toString() == "sed") |
| 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 touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY2); |
| if (document.getSelection().toString() == "sed do eiusmod tempor incididun") |
| output += 'PASS: Correct Selection'; |
| else |
| output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| |
| await touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY3); |
| if (document.getSelection().toString() == "sed do eiusmod tempor incididunt ut labore et dolore ma") |
| output += 'PASS: Correct Selection'; |
| else |
| output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| |
| await touchAndDragFromPointToPoint(dragX, dragY3, dragX, dragY2); |
| if (document.getSelection().toString() == "sed do eiusmod tempor incididun") |
| output += 'PASS: Correct Selection'; |
| else |
| output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| |
| await touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY); |
| if (document.getSelection().toString() == "sed") |
| output += 'PASS: Correct Selection'; |
| else |
| output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| |
| var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY4); |
| if (document.getSelection().toString() == "sed") |
| output += 'PASS: Correct Selection'; |
| else |
| output += 'FAIL: failed to reduce selection to a single character by dragging up. Incorrect Selection: ' + document.getSelection().toString(); |
| output += '<br>'; |
| output += result; |
| |
| var noneditableElement = document.getElementById('noneditable'); |
| noneditableElement.parentNode.removeChild(noneditableElement); |
| var editableElement = document.getElementById('editable'); |
| editableElement.parentNode.removeChild(editableElement); |
| document.getElementById('target').innerHTML = output; |
| testRunner.notifyDone(); |
| } |
| |
| window.addEventListener('load', runTest, false); |
| </script> |
| <style> |
| #noneditable { |
| height: 200px; |
| width: 300px; |
| background-color: silver; |
| font-family: monospace; |
| font-size: 18px; |
| } |
| #editable { |
| height: 200px; |
| width: 300px; |
| background-color: silver; |
| font-family: monospace; |
| font-size: 18px; |
| } |
| #target { |
| height: 50px; |
| width: 300px; |
| background-color: silver; |
| font-family: monospace; |
| font-size: 18px; |
| } |
| </style> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| </head> |
| <body> |
| <div id="editable" contenteditable> |
| <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> |
| </div> |
| <div id="noneditable"> |
| <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, <span id="firstSelection">sed</span> do eiusmod tempor incididun<span id="secondSelection"></span>t ut labore et dolore mag<span id="thirdSelection"></span>na aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> |
| </div> |
| <div id="target"> |
| This test requires UIScriptController to run. |
| </div> |
| </body> |
| </html> |