blob: f9d1bbf4561a263991537a6c48828cab60c4bef2 [file] [log] [blame]
harrison5ac5c752007-09-05 20:46:41 +00001<script>
rniwa@webkit.org14f6b5b2012-06-13 08:51:53 +00002if (window.testRunner)
3 testRunner.dumpEditingCallbacks();
harrison5ac5c752007-09-05 20:46:41 +00004</script>
5<script>
6function 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
13function runTest() {
14 try {
rniwa@webkit.org14f6b5b2012-06-13 08:51:53 +000015 if (window.testRunner)
16 window.testRunner.dumpAsText();
harrison5ac5c752007-09-05 20:46:41 +000017
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.org14f6b5b2012-06-13 08:51:53 +000042</body>