Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / selection / rangeCount.html
1 <p>This tests Selection::rangeCount.  You should see "Hello World" selected below.  You should not see any failures below.</p>
2 <div id="div" contenteditable="true">Hello World</div>
3 <ul id="console"></ul>
4 <script>
5 function log(str) {
6     var li = document.createElement("li");
7     li.appendChild(document.createTextNode(str));
8     var console = document.getElementById("console");
9     console.appendChild(li);
10 }
11
12 function runTest() {
13     
14     try {
15         if (window.testRunner)
16             window.testRunner.dumpAsText();
17             
18         var div = document.getElementById("div");
19         var text = div.firstChild;
20         var sel = window.getSelection();
21             
22         if (sel.rangeCount == undefined) {
23             log("Selection::rangeCount not implemented.");
24             return;
25         }
26         
27         if (sel.rangeCount != 0)
28             log("Failure.  Expected: rangeCount == 0, Found: " + sel.rangeCount);
29         
30         sel.collapse(text, 0);
31         if (sel.rangeCount != 1)
32             log("Failure.  Expected: rangeCount == 1, Found: " + sel.rangeCount);
33         
34         document.execCommand("SelectAll");
35         if (sel.rangeCount != 1)
36             log("Failure.  Expected: rangeCount == 1, Found: " + sel.rangeCount);
37         
38     } catch(e) {
39         log(e);
40     }
41 }
42
43 runTest();
44 </script>