Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / selection / document-mutation.html
index 0dfee78..7345f72 100644 (file)
@@ -1,91 +1,91 @@
-<!DOCTYPE html>\r
-<html>\r
-<body>\r
-<p>This test ensures WebKit adjusts the selection under document mutation.</p>\r
-<p> Examples are from:<br> http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Mutation</p>\r
-<div id="test" contenteditable></div>\r
-<pre>\r
-<script>\r
-\r
-var test = document.getElementById('test');\r
-test.focus();\r
-\r
-if (window.testRunner)\r
-    testRunner.dumpAsText();\r
-\r
-var baseIsFirst = true;\r
-var selection = window.getSelection();\r
-\r
-function checkResult(expectedStartOffset, expectedEndOffset) {\r
-    var actualStartOffset = selection.getRangeAt(0).startOffset;\r
-    var actualEndOffset = selection.getRangeAt(0).endOffset;\r
-    if (actualStartOffset == expectedStartOffset && actualEndOffset == expectedEndOffset)\r
-        document.write('PASS: selection is (' + expectedStartOffset + ', ' + expectedEndOffset + ') "' + selection + '"\n');\r
-    else\r
-        document.write('FAIL: selection is (' + actualStartOffset + ', ' + actualEndOffset + ') "' + selection +\r
-            '" and expected selection is ' + '(' + expectedStartOffset + ', ' + expectedEndOffset + ')\n');\r
-}\r
-\r
-function setSelectionRange(startContainer, startOffset, endContainer, endOffset) {\r
-    if (baseIsFirst)\r
-        selection.setBaseAndExtent(startContainer, startOffset, endContainer, endOffset);\r
-    else\r
-        selection.setBaseAndExtent(endContainer, endOffset, startContainer, startOffset);\r
-}\r
-\r
-function runInsertionTest(actor, expectedStartOffset, expectedEndOffset) {\r
-    test.innerHTML = '<p>Abcd efgh XY blah ijkl</p>';\r
-\r
-    // Select "Y blah i"\r
-    setSelectionRange(test.firstChild.firstChild, 11, test.firstChild.firstChild, 19);\r
-    actor(test.firstChild.firstChild);\r
-    checkResult(expectedStartOffset, expectedEndOffset);\r
-}\r
-\r
-function runDeletionTest(actor, expectedStartOffset, expectedEndOffset) {\r
-    test.innerHTML = '<p>Abcd efgh The Range ijkl</p>';\r
-\r
-    // Select "he Range i"\r
-    setSelectionRange(test.firstChild.firstChild, 11, test.firstChild.firstChild, 21);\r
-    actor(test.firstChild.firstChild);\r
-    checkResult(expectedStartOffset, expectedEndOffset);\r
-}\r
-\r
-function deleteNodeContainingSelection(expectedStartOffset, expectedEndOffset) {\r
-    test.innerHTML = '<p>Abcd <em>efgh The Range ij</em>kl</p>';\r
-\r
-    // Select "he Range i"\r
-    setSelectionRange(test.firstChild.firstChild.nextSibling.firstChild, 6, test.firstChild.firstChild.nextSibling.firstChild, 16);\r
-    test.firstChild.removeChild(test.firstChild.firstChild.nextSibling);\r
-    checkResult(expectedStartOffset, expectedEndOffset);\r
-}\r
-\r
-function runTests() {\r
-    document.write('Insertion tests:\n');\r
-    runInsertionTest(function(node) { node.insertData(10, 'inserted text'); }, 24, 32);\r
-    runInsertionTest(function(node) { node.insertData(11, 'inserted text'); }, 11, 32);\r
-    runInsertionTest(function(node) { node.insertData(12, 'inserted text'); }, 11, 32);\r
-    runInsertionTest(function(node) { node.insertData(17, 'inserted text'); }, 11, 32);\r
-    runInsertionTest(function(node) { node.insertData(19, 'inserted text'); }, 11, 19);\r
-\r
-    document.write('\nDeletion tests:\n');\r
-    runDeletionTest(function(node) { node.deleteData(5, 8); }, 5, 13);\r
-    runDeletionTest(function(node) { node.deleteData(5, 17); }, 5, 5);\r
-    runDeletionTest(function(node) { node.deleteData(5, 6); }, 5, 15);\r
-    deleteNodeContainingSelection(1, 1);\r
-}\r
-\r
-document.write('Base is first\n\n');\r
-runTests();\r
-\r
-baseIsFirst = false;\r
-\r
-document.write('\n\nExtent is first\n\n');\r
-runTests();\r
-\r
-test.style.display = 'none';\r
-document.write('\nDONE');\r
-</script>\r
-</pre>\r
-</body>\r
-</html>\r
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test ensures WebKit adjusts the selection under document mutation.</p>
+<p> Examples are from:<br> http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Mutation</p>
+<div id="test" contenteditable></div>
+<pre>
+<script>
+
+var test = document.getElementById('test');
+test.focus();
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var baseIsFirst = true;
+var selection = window.getSelection();
+
+function checkResult(expectedStartOffset, expectedEndOffset) {
+    var actualStartOffset = selection.getRangeAt(0).startOffset;
+    var actualEndOffset = selection.getRangeAt(0).endOffset;
+    if (actualStartOffset == expectedStartOffset && actualEndOffset == expectedEndOffset)
+        document.write('PASS: selection is (' + expectedStartOffset + ', ' + expectedEndOffset + ') "' + selection + '"\n');
+    else
+        document.write('FAIL: selection is (' + actualStartOffset + ', ' + actualEndOffset + ') "' + selection +
+            '" and expected selection is ' + '(' + expectedStartOffset + ', ' + expectedEndOffset + ')\n');
+}
+
+function setSelectionRange(startContainer, startOffset, endContainer, endOffset) {
+    if (baseIsFirst)
+        selection.setBaseAndExtent(startContainer, startOffset, endContainer, endOffset);
+    else
+        selection.setBaseAndExtent(endContainer, endOffset, startContainer, startOffset);
+}
+
+function runInsertionTest(actor, expectedStartOffset, expectedEndOffset) {
+    test.innerHTML = '<p>Abcd efgh XY blah ijkl</p>';
+
+    // Select "Y blah i"
+    setSelectionRange(test.firstChild.firstChild, 11, test.firstChild.firstChild, 19);
+    actor(test.firstChild.firstChild);
+    checkResult(expectedStartOffset, expectedEndOffset);
+}
+
+function runDeletionTest(actor, expectedStartOffset, expectedEndOffset) {
+    test.innerHTML = '<p>Abcd efgh The Range ijkl</p>';
+
+    // Select "he Range i"
+    setSelectionRange(test.firstChild.firstChild, 11, test.firstChild.firstChild, 21);
+    actor(test.firstChild.firstChild);
+    checkResult(expectedStartOffset, expectedEndOffset);
+}
+
+function deleteNodeContainingSelection(expectedStartOffset, expectedEndOffset) {
+    test.innerHTML = '<p>Abcd <em>efgh The Range ij</em>kl</p>';
+
+    // Select "he Range i"
+    setSelectionRange(test.firstChild.firstChild.nextSibling.firstChild, 6, test.firstChild.firstChild.nextSibling.firstChild, 16);
+    test.firstChild.removeChild(test.firstChild.firstChild.nextSibling);
+    checkResult(expectedStartOffset, expectedEndOffset);
+}
+
+function runTests() {
+    document.write('Insertion tests:\n');
+    runInsertionTest(function(node) { node.insertData(10, 'inserted text'); }, 24, 32);
+    runInsertionTest(function(node) { node.insertData(11, 'inserted text'); }, 11, 32);
+    runInsertionTest(function(node) { node.insertData(12, 'inserted text'); }, 11, 32);
+    runInsertionTest(function(node) { node.insertData(17, 'inserted text'); }, 11, 32);
+    runInsertionTest(function(node) { node.insertData(19, 'inserted text'); }, 11, 19);
+
+    document.write('\nDeletion tests:\n');
+    runDeletionTest(function(node) { node.deleteData(5, 8); }, 5, 13);
+    runDeletionTest(function(node) { node.deleteData(5, 17); }, 5, 5);
+    runDeletionTest(function(node) { node.deleteData(5, 6); }, 5, 15);
+    deleteNodeContainingSelection(1, 1);
+}
+
+document.write('Base is first\n\n');
+runTests();
+
+baseIsFirst = false;
+
+document.write('\n\nExtent is first\n\n');
+runTests();
+
+test.style.display = 'none';
+document.write('\nDONE');
+</script>
+</pre>
+</body>
+</html>