<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[231188] trunk/LayoutTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/231188">231188</a></dd>
<dt>Author</dt> <dd>megan_gardner@apple.com</dd>
<dt>Date</dt> <dd>2018-04-30 17:35:16 -0700 (Mon, 30 Apr 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add tests for selection in content editable
https://bugs.webkit.org/show_bug.cgi?id=185144

Reviewed by Wenson Hsieh.
        
Tests that should cover selection in content editable, both with and without a keyboard present. Also fixing two tests that had errors.

* fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text.html: Added.
* fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text.html: Added.
* fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text.html: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text.html: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text.html: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text.html: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text.html: Added.
* fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html:
* fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressthendragrighttochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressthendraguptochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendragdowntochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendragdowntochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraglefttochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraglefttochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraguptochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraguptochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragdowntochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragdowntochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraglefttochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraglefttochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragrighttochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragrighttochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text.html</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraguptochangeselectedtextexpectedtxt">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraguptochangeselectedtexthtml">trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (231187 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2018-05-01 00:23:24 UTC (rev 231187)
+++ trunk/LayoutTests/ChangeLog 2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2018-04-30  Megan Gardner  <megan_gardner@apple.com>
+
+        Add tests for selection in content editable
+        https://bugs.webkit.org/show_bug.cgi?id=185144
+
+        Reviewed by Wenson Hsieh.
+        
+        Tests that should cover selection in content editable, both with and without a keyboard present. Also fixing two tests that had errors.
+
+        * fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html:
+        * fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html:
+
</ins><span class="cx"> 2018-04-30  Jer Noble  <jer.noble@apple.com>
</span><span class="cx"> 
</span><span class="cx">         <img src=mp4> does not display on ios despite Accept: video/* advertisement
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendragdowntochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text-expected.txt                         (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text-expected.txt    2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+PASS: Has Caret Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendragdowntochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text.html                         (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-down-to-change-selected-text.html    2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,132 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').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 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + firstTargetRect.height + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x + firstTargetRect.width;
+            var dragY2 = secondTargetRect.y + secondTargetRect.height + noneditableToEditableOffset;
+            var dragY3 = thirdTargetRect.y + thirdTargetRect.height + noneditableToEditableOffset;
+            var dragY4 = firstTargetRect.y - firstTargetRect.height + noneditableToEditableOffset;
+        
+            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() == "s")
+                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="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="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="target">
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraglefttochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text-expected.txt                         (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text-expected.txt    2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+PASS: Has Caret Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraglefttochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text.html                         (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-left-to-change-selected-text.html    2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,132 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').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 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x;
+            var dragX2 = secondTargetRect.x;
+            var dragX3 = thirdTargetRect.x;
+            var dragX4 = firstTargetRect.x + firstTargetRect.width;
+        
+            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() == "magna")
+                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, dragX2, dragY);
+            if (document.getSelection().toString() == "aliqua magna")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX3, dragY);
+            if (document.getSelection().toString() == "dolore aliqua magna")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX3, dragY, dragX2, dragY);
+            if (document.getSelection().toString() == "aliqua magna")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY);
+            if (document.getSelection().toString() == "magna")
+                 output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX4, dragY);
+            if (document.getSelection().toString() == "a")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to reduce selection to a single character by dragging right. 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="noneditable">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et <span id="thirdSelection"></span>dolore <span id="secondSelection"></span>aliqua <span id="firstSelection">magna</span>. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
+    </div>
+    <div id="editable" contenteditable>
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore aliqua magna. 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>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraguptochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text-expected.txt                           (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text-expected.txt      2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+PASS: Has Caret Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchiosdoubletaponeditablecontentforselectionthendraguptochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text.html                           (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/double-tap-on-editable-content-for-selection-then-drag-up-to-change-selected-text.html      2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,132 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').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 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x;
+            var dragY2 = secondTargetRect.y + noneditableToEditableOffset;
+            var dragY3 = thirdTargetRect.y + noneditableToEditableOffset;
+            var dragY4 = firstTargetRect.y + firstTargetRect.height + noneditableToEditableOffset;
+        
+            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() == "at")
+                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() == "o eiusmod tempor incididunt at")
+                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() == " adipiscing elit, sed do eiusmod tempor incididunt at")
+                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() == "o eiusmod tempor incididunt at")
+                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() == "at")
+                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() == "t")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to reduce selection to a single character by dragging down. 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="initial-scale=1">
+</head>
+<body>
+    <div id="noneditable">
+        <p>Lorem ipsum dolor sit amet, consectetur<span id="thirdSelection"></span> adipiscing elit, sed d<span id="secondSelection"></span>o eiusmod tempor incididunt <span id="firstSelection">at</span> 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="editable" contenteditable>
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt at 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="target">
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragdowntochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text-expected.txt                               (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text-expected.txt  2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragdowntochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text.html                               (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-down-to-change-selected-text.html  2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').getBoundingClientRect().y;
+        
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + firstTargetRect.height + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x + firstTargetRect.width;
+            var dragY2 = secondTargetRect.y + secondTargetRect.height + noneditableToEditableOffset;
+            var dragY3 = thirdTargetRect.y + thirdTargetRect.height + noneditableToEditableOffset;
+            var dragY4 = firstTargetRect.y - firstTargetRect.height + noneditableToEditableOffset;
+
+            await longPressAtPoint(pressPointX, pressPointY);
+            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() == "s")
+                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="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="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="target">
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraglefttochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text-expected.txt                               (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text-expected.txt  2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraglefttochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text.html                               (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-left-to-change-selected-text.html  2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').getBoundingClientRect().y;
+        
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x;
+            var dragX2 = secondTargetRect.x;
+            var dragX3 = thirdTargetRect.x;
+            var dragX4 = firstTargetRect.x + firstTargetRect.width;
+
+            await longPressAtPoint(pressPointX, pressPointY);
+            if (document.getSelection().toString() == "aliqua")
+                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, dragX2, dragY);
+            if (document.getSelection().toString() == "magna aliqua")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX3, dragY);
+            if (document.getSelection().toString() == "dolore magna aliqua")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX3, dragY, dragX2, dragY);
+            if (document.getSelection().toString() == "magna aliqua")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY);
+            if (document.getSelection().toString() == "aliqua")
+                 output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX4, dragY);
+            if (document.getSelection().toString() == "a")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to reduce selection to a single character by dragging right. 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="noneditable">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et <span id="thirdSelection"></span>dolore <span id="secondSelection"></span>magna <span id="firstSelection">aliqua</span>. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
+    </div>
+    <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="target">
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragrighttochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text-expected.txt                              (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text-expected.txt 2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendragrighttochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text.html                              (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-right-to-change-selected-text.html 2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').getBoundingClientRect().y;
+
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + firstTargetRect.height + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x + firstTargetRect.width;
+            var dragX2 = secondTargetRect.x;
+            var dragX3 = thirdTargetRect.x;
+            var dragX4 = firstTargetRect.x - firstTargetRect.width;
+        
+            await longPressAtPoint(pressPointX, pressPointY);
+            if (document.getSelection().toString() == "magna")
+                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, dragX2, dragY);
+            if (document.getSelection().toString() == "magna aliqua.")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX3, dragY);
+            if (document.getSelection().toString() == "magna aliqua. Ut")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX3, dragY, dragX2, dragY);
+            if (document.getSelection().toString() == "magna aliqua.")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY);
+            if (document.getSelection().toString() == "magna")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
+            output += '<br>';
+
+            var result = await touchAndDragFromPointToPoint(dragX, dragY, dragX4, dragY);
+            if (document.getSelection().toString() == "m")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to reduce selection to a single character by dragging left. 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="noneditable">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore <span id="firstSelection">magna</span> aliqua.<span id="secondSelection"></span> Ut<span id="thirdSelection"></span> enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
+    </div>
+    <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="target">
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraguptochangeselectedtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text-expected.txt (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text-expected.txt                         (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text-expected.txt    2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressoneditablecontentthendraguptochangeselectedtexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text.html (0 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text.html                         (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-on-editable-content-then-drag-up-to-change-selected-text.html    2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+<!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 noneditableToEditableOffset = document.getElementById('editable').getBoundingClientRect().y - document.getElementById('noneditable').getBoundingClientRect().y;
+        
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2 + noneditableToEditableOffset;
+            var dragY = firstTargetRect.y + noneditableToEditableOffset;
+            var dragX = firstTargetRect.x;
+            var dragY2 = secondTargetRect.y + noneditableToEditableOffset;
+            var dragY3 = thirdTargetRect.y + noneditableToEditableOffset;
+            var dragY4 = firstTargetRect.y + firstTargetRect.height + noneditableToEditableOffset;
+        
+            await longPressAtPoint(pressPointX, pressPointY);
+            if (document.getSelection().toString() == "ut")
+                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() == "o eiusmod tempor incididunt ut")
+                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() == " adipiscing elit, sed do eiusmod tempor incididunt ut")
+                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() == "o eiusmod tempor incididunt ut")
+                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() == "ut")
+                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() == "t")
+                output += 'PASS: Correct Selection';
+            else
+                output += 'FAIL: failed to reduce selection to a single character by dragging down. 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="initial-scale=1">
+</head>
+<body>
+    <div id="noneditable">
+        <p>Lorem ipsum dolor sit amet, consectetur<span id="thirdSelection"></span> adipiscing elit, sed d<span id="secondSelection"></span>o eiusmod tempor incididunt <span id="firstSelection">ut</span> 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="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="target">
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressthendragrighttochangeselectedtexthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html (231187 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html  2018-05-01 00:23:24 UTC (rev 231187)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html     2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx">                 output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
</span><span class="cx">             output += '<br>';
</span><span class="cx"> 
</span><del>-            await(touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY);
</del><ins>+            await touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY);
</ins><span class="cx">             if (document.getSelection().toString() == "magna")
</span><span class="cx">                 output += 'PASS: Correct Selection';
</span><span class="cx">             else
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventstouchioslongpressthendraguptochangeselectedtexthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html (231187 => 231188)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html     2018-05-01 00:23:24 UTC (rev 231187)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html        2018-05-01 00:35:16 UTC (rev 231188)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">             var dragY4 = firstTargetRect.y + firstTargetRect.height;
</span><span class="cx">         
</span><span class="cx">             await longPressAtPoint(pressPointX, pressPointY);
</span><del>-            if (document.getSelection().toString() == "Ut")
</del><ins>+            if (document.getSelection().toString() == "ut")
</ins><span class="cx">                 output += 'PASS: Correct Selection';
</span><span class="cx">             else
</span><span class="cx">                 output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">             output += '<br>';
</span><span class="cx"> 
</span><span class="cx">             await touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY2);
</span><del>-            if (document.getSelection().toString() == "e et dolore magna aliqua. Ut")
</del><ins>+            if (document.getSelection().toString() == "o eiusmod tempor incididunt ut")
</ins><span class="cx">                 output += 'PASS: Correct Selection';
</span><span class="cx">             else
</span><span class="cx">                 output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">             output += '<br>';
</span><span class="cx"> 
</span><span class="cx">             await touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY3);
</span><del>-            if (document.getSelection().toString() == "mod tempor incididunt ut labore et dolore magna aliqua. Ut")
</del><ins>+            if (document.getSelection().toString() == " adipiscing elit, sed do eiusmod tempor incididunt ut")
</ins><span class="cx">                 output += 'PASS: Correct Selection';
</span><span class="cx">             else
</span><span class="cx">                 output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">             output += '<br>';
</span><span class="cx"> 
</span><span class="cx">             await touchAndDragFromPointToPoint(dragX, dragY3, dragX, dragY2);
</span><del>-            if (document.getSelection().toString() == "e et dolore magna aliqua. Ut")
</del><ins>+            if (document.getSelection().toString() == "o eiusmod tempor incididunt ut")
</ins><span class="cx">                 output += 'PASS: Correct Selection';
</span><span class="cx">             else
</span><span class="cx">                 output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx">             output += '<br>';
</span><span class="cx"> 
</span><span class="cx">             await touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY);
</span><del>-            if (document.getSelection().toString() == "Ut")
</del><ins>+            if (document.getSelection().toString() == "ut")
</ins><span class="cx">                 output += 'PASS: Correct Selection';
</span><span class="cx">             else
</span><span class="cx">                 output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
</span></span></pre>
</div>
</div>

</body>
</html>