harrison | 5ac5c75 | 2007-09-05 20:46:41 +0000 | [diff] [blame] | 1 | <script> |
rniwa@webkit.org | 14f6b5b | 2012-06-13 08:51:53 +0000 | [diff] [blame] | 2 | if (window.testRunner) |
| 3 | testRunner.dumpEditingCallbacks(); |
harrison | 5ac5c75 | 2007-09-05 20:46:41 +0000 | [diff] [blame] | 4 | </script> |
| 5 | <script> |
| 6 | function log(str) { |
| 7 | var li = document.createElement("li"); |
| 8 | li.appendChild(document.createTextNode(str)); |
| 9 | var console = document.getElementById("console"); |
| 10 | console.appendChild(li); |
| 11 | } |
| 12 | |
| 13 | function runTest() { |
| 14 | try { |
rniwa@webkit.org | 14f6b5b | 2012-06-13 08:51:53 +0000 | [diff] [blame] | 15 | if (window.testRunner) |
| 16 | window.testRunner.dumpAsText(); |
harrison | 5ac5c75 | 2007-09-05 20:46:41 +0000 | [diff] [blame] | 17 | |
| 18 | var selection = window.getSelection(); |
| 19 | var bodyElement = document.getElementById("test"); |
| 20 | var htmlElement = bodyElement.parentNode; |
| 21 | |
| 22 | if (selection.setBaseAndExtent) |
| 23 | selection.setBaseAndExtent(bodyElement, 1, htmlElement, 3); |
| 24 | else |
| 25 | throw("Couldn't set a selection."); |
| 26 | |
| 27 | if (selection.toString) { |
| 28 | var string = selection.toString(); |
| 29 | if (string != "\nbbbb") |
| 30 | throw("toString returned unexpected result"); |
| 31 | log("success"); |
| 32 | } else |
| 33 | throw("Selection::toString() not supported"); |
| 34 | } catch(e) { |
| 35 | log("Test Failed. Error was: " + e); |
| 36 | } |
| 37 | } |
| 38 | </script> |
| 39 | <body id="test" contenteditable>aaaa<object></object><div>bbbb</div> |
| 40 | <ul id="console"></ul> |
| 41 | <script>runTest();</script> |
rniwa@webkit.org | 14f6b5b | 2012-06-13 08:51:53 +0000 | [diff] [blame] | 42 | </body> |