Title: [269854] trunk/LayoutTests
Revision
269854
Author
wei...@apple.com
Date
2020-11-16 09:04:38 -0800 (Mon, 16 Nov 2020)

Log Message

Remove and re-add fast/forms/selection-direction.html without CRs
https://bugs.webkit.org/show_bug.cgi?id=218966

* fast/forms/selection-direction.html: 
Re add test back without the CRs.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (269853 => 269854)


--- trunk/LayoutTests/ChangeLog	2020-11-16 16:40:58 UTC (rev 269853)
+++ trunk/LayoutTests/ChangeLog	2020-11-16 17:04:38 UTC (rev 269854)
@@ -1,3 +1,11 @@
+2020-11-16  Sam Weinig  <wei...@apple.com>
+
+        Remove and re-add fast/forms/selection-direction.html without CRs
+        https://bugs.webkit.org/show_bug.cgi?id=218966
+
+        * fast/forms/selection-direction.html: 
+        Re add test back without the CRs.
+
 2020-11-16  Chris Dumez  <cdu...@apple.com>
 
         WebAudio tests may give slightly different outputs on different platforms

Added: trunk/LayoutTests/fast/forms/selection-direction.html (0 => 269854)


--- trunk/LayoutTests/fast/forms/selection-direction.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/selection-direction.html	2020-11-16 17:04:38 UTC (rev 269854)
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div><input id="dummy"></div>
+<div id="tests"><input value="hello"><textarea>hello</textarea></div>
+<div id="console"></div>
+<div>
+<script type="text/_javascript_">
+description('Tests for selectionDirection');
+
+var dummy = document.getElementById('dummy');
+
+function assertDirection(expectedDirection, element, description) {
+    var action = '' + element.selectionDirection
+        + '" after ' + description;
+
+    if (element.selectionDirection == expectedDirection)
+        testPassed(action);
+    else
+        testFailed(action + ', but expected "' + expectedDirection + '"');
+}
+
+function testCache(expectedDirection, element) {
+    dummy.focus();
+    assertDirection(expectedDirection, element, 'focusing on another element');
+
+    element.style.display = 'none';
+    assertDirection(expectedDirection, element, 'hiding the element');
+    element.style.display = null;
+}
+
+function runTest(element, platform) {
+    debug(element.localName + ' on ' + platform);
+    element.focus();
+
+    var noneOnMacAndForwardOnOthers = (platform == 'Mac') ? 'none' : 'forward';
+
+    element.setSelectionRange(1, 2);
+    assertDirection(noneOnMacAndForwardOnOthers, element, 'focusing and setting selection by setSelectionRange(1, 2)');
+    testCache(noneOnMacAndForwardOnOthers, element);
+
+    element.focus();
+    element.setSelectionRange(1, 2, 'forward');
+    assertDirection('forward', element, 'focusing and setting selection by setSelectionRange(1, 2, "forward")');
+    testCache('forward', element);
+
+    element.setSelectionRange(1, 2, 'backward');
+    assertDirection('backward', element, 'setting selection by setSelectionRange(1, 2, "backward") without focus');
+    testCache('backward', element);
+
+    element.selectionDirection = 'none';
+    assertDirection(noneOnMacAndForwardOnOthers, element, 'setting selection by selectionDirection = "none" without focus');
+    testCache(noneOnMacAndForwardOnOthers, element);
+
+    element.selectionDirection = 'forward';
+    assertDirection('forward', element, 'focusing and setting selection by selectionDirection = "forward" without focus');
+    testCache('forward', element);
+
+    element.focus();
+    element.selectionDirection = 'backward';
+    assertDirection('backward', element, 'focusing and setting selection by selectionDirection = "backward"');
+    testCache('backward', element);
+
+    element.focus();
+    element.setSelectionRange(1, 1);
+    window.getSelection().modify('extend', 'forward', 'character');
+    assertDirection('forward', element, 'extending selection forward by character');
+    testCache('forward', element);
+
+    element.focus();
+    element.setSelectionRange(1, 1);
+    window.getSelection().modify('extend', 'backward', 'character');
+    assertDirection('backward', element, 'extending selection backward by character');
+    testCache('backward', element);
+
+}
+
+function runTestFor(platform) {
+    if (window.internals)
+        internals.settings.setEditingBehavior(platform.toLowerCase());
+    var tests = document.getElementById('tests');
+    for (var i = 0; i < tests.childNodes.length; i++) {
+        runTest(tests.childNodes[i], platform);
+        debug('');
+    }
+}
+
+if (window.internals) {
+    runTestFor('Mac');
+    runTestFor('Win');
+    runTestFor('Unix');
+} else
+    runTestFor(navigator.platform.indexOf('Mac') >= 0 ? 'Mac' : 'Win');
+
+tests.style.display = 'none';
+dummy.parentNode.style.display = 'none';
+
+</script>
+<script src=""
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to