-<!DOCTYPE html>\r
-<html>\r
-<head>\r
-<script src="../../resources/js-test.js"></script>\r
-</head>\r
-<body>\r
-<p id="description"></p>\r
-<div><input id="dummy"></div>\r
-<div id="tests"><input value="hello"><textarea>hello</textarea></div>\r
-<div id="console"></div>\r
-<div>\r
-<script type="text/javascript">\r
-description('Tests for selectionDirection');\r
-\r
-var dummy = document.getElementById('dummy');\r
-\r
-function assertDirection(expectedDirection, element, description) {\r
- var action = 'selectionDirection was "' + element.selectionDirection\r
- + '" after ' + description;\r
-\r
- if (element.selectionDirection == expectedDirection)\r
- testPassed(action);\r
- else\r
- testFailed(action + ', but expected "' + expectedDirection + '"');\r
-}\r
-\r
-function testCache(expectedDirection, element) {\r
- dummy.focus();\r
- assertDirection(expectedDirection, element, 'focusing on another element');\r
-\r
- element.style.display = 'none';\r
- assertDirection(expectedDirection, element, 'hiding the element');\r
- element.style.display = null;\r
-}\r
-\r
-function runTest(element, platform) {\r
- debug(element.localName + ' on ' + platform);\r
- element.focus();\r
-\r
- var noneOnMacAndForwardOnOthers = (platform == 'Mac') ? 'none' : 'forward';\r
-\r
- element.setSelectionRange(1, 2);\r
- assertDirection(noneOnMacAndForwardOnOthers, element, 'focusing and setting selection by setSelectionRange(1, 2)');\r
- testCache(noneOnMacAndForwardOnOthers, element);\r
-\r
- element.focus();\r
- element.setSelectionRange(1, 2, 'forward');\r
- assertDirection('forward', element, 'focusing and setting selection by setSelectionRange(1, 2, "forward")');\r
- testCache('forward', element);\r
-\r
- element.setSelectionRange(1, 2, 'backward');\r
- assertDirection('backward', element, 'setting selection by setSelectionRange(1, 2, "backward") without focus');\r
- testCache('backward', element);\r
-\r
- element.selectionDirection = 'none';\r
- assertDirection(noneOnMacAndForwardOnOthers, element, 'setting selection by selectionDirection = "none" without focus');\r
- testCache(noneOnMacAndForwardOnOthers, element);\r
-\r
- element.selectionDirection = 'forward';\r
- assertDirection('forward', element, 'focusing and setting selection by selectionDirection = "forward" without focus');\r
- testCache('forward', element);\r
-\r
- element.focus();\r
- element.selectionDirection = 'backward';\r
- assertDirection('backward', element, 'focusing and setting selection by selectionDirection = "backward"');\r
- testCache('backward', element);\r
-\r
- element.focus();\r
- element.setSelectionRange(1, 1);\r
- window.getSelection().modify('extend', 'forward', 'character');\r
- assertDirection('forward', element, 'extending selection forward by character');\r
- testCache('forward', element);\r
-\r
- element.focus();\r
- element.setSelectionRange(1, 1);\r
- window.getSelection().modify('extend', 'backward', 'character');\r
- assertDirection('backward', element, 'extending selection backward by character');\r
- testCache('backward', element);\r
-\r
-}\r
-\r
-function runTestFor(platform) {\r
- if (window.internals)\r
- internals.settings.setEditingBehavior(platform.toLowerCase());\r
- var tests = document.getElementById('tests');\r
- for (var i = 0; i < tests.childNodes.length; i++) {\r
- runTest(tests.childNodes[i], platform);\r
- debug('');\r
- }\r
-}\r
-\r
-if (window.internals) {\r
- runTestFor('Mac');\r
- runTestFor('Win');\r
- runTestFor('Unix');\r
-} else\r
- runTestFor(navigator.platform.indexOf('Mac') >= 0 ? 'Mac' : 'Win');\r
-\r
-tests.style.display = 'none';\r
-dummy.parentNode.style.display = 'none';\r
-\r
-</script>\r
-</body>\r
-</html>\r
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</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 = 'selectionDirection was "' + 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>
+</body>
+</html>