Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / extend.html
blobfd5ccc42f8059a15c55af8b699a92b017beafa28
1 <html>
2 <body>
3 <div id="test"><span id="span1">foo<span id="span2">bar</span></span><span id="span3">baz</span></div>
4 <div id="console"></div>
5 <script>
6 var s = window.getSelection();
7 var testDiv = document.getElementById("test");
8 var span1 = document.getElementById("span1");
9 var span2 = document.getElementById("span2");
10 var span3 = document.getElementById("span3");
12 function log(str) {
13 var li = document.createElement("li");
14 li.appendChild(document.createTextNode(str));
15 document.getElementById("console").appendChild(li);
18 function shouldBe(expr, expected) {
19 var actual = eval(expr);
20 if (actual != expected)
21 log("Failure: " + expr + " should be " + expected + ", was " + actual + ".");
22 else
23 log("Success: " + expr + " is " + expected + ".");
26 function shouldThrow(expr) {
27 try {
28 eval(expr);
29 log("Failure: " + expr + " didn't raise an exception" + ".");
30 } catch (ex) {
31 log("Success: " + expr + " raised " + ex + ".");
35 if (window.testRunner)
36 testRunner.dumpAsText();
38 var r = document.createRange();
41 r.setStart(span2.firstChild, 1);
42 r.setEnd(span2.firstChild, 1);
43 s.addRange(r);
45 s.extend(span2.firstChild, 3);
46 shouldBe('window.getSelection()', 'ar');
48 shouldThrow('s.extend(span2.firstChild, 4)');
50 shouldThrow('s.extend(span2.firstChild, -1)');
52 s.extend(span2.firstChild, 0);
53 shouldBe('window.getSelection()', 'b');
55 s.extend(span3, 1);
56 shouldBe('window.getSelection()', 'arbaz');
58 shouldThrow('s.extend()');
59 shouldThrow('s.extend(null, 0)');
61 </script>
62 </body>
63 </html>