Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Range / range-isPointInRange.html
blobd3480e0989cfca946ecadbc6722a3653f0cb2375
1 <html>
2 <head>
3 <title>Test for Range.isPointInRange()</title>
4 <script>
5 function test()
7 // isPointInRange( refNode, offset ) - This method returns Ð1, 0 or 1 depending on
8 // if the point described by the refNode node and an offset within the node is
9 // before, same as, or after the range respectively.
11 var range = document.createRange();
13 // test 1 - point before range, different node
14 var expectedResult = false;
15 range.selectNode(document.getElementById("a2"));
16 var result = range.isPointInRange(document.getElementById("b1"), 1);
17 if (result == expectedResult)
18 document.getElementById("test1").innerHTML = "test 1 passed";
20 // test 2 - point before range, same node
21 range.setStart(document.getElementById("b2"), 1);
22 result = range.isPointInRange(document.getElementById("b2"), 0);
23 if (result == expectedResult)
24 document.getElementById("test2").innerHTML = "test 2 passed";
26 // test 3 - point on range start boundary
27 expectedResult = true;
28 range.selectNode(document.getElementById("b2"));
29 result = range.isPointInRange(document.getElementById("b2"), 0);
30 if (result == expectedResult)
31 document.getElementById("test3").innerHTML = "test 3 passed";
33 // test 4 - point within range, same node
34 result = range.isPointInRange(document.getElementById("b2"), 1);
35 if (result == expectedResult)
36 document.getElementById("test4").innerHTML = "test 4 passed";
38 // test 5 - point within range, spans nodes
39 range.setStart(document.getElementById("b1"), 1);
40 range.setEnd(document.getElementById("c2"), 1);
41 result = range.isPointInRange( document.getElementById("c2"), 0);
42 if (result == expectedResult)
43 document.getElementById("test5").innerHTML = "test 5 passed";
45 // test 6 - point on range end boundary
46 result = range.isPointInRange(document.getElementById("c2"), 1);
47 if (result == expectedResult)
48 document.getElementById("test6").innerHTML = "test 6 passed";
50 // test 7 - point after range, same node
51 expectedResult = false;
52 range.setEnd(document.getElementById("c2"), 0);
53 result = range.isPointInRange(document.getElementById("c2"), 1);
54 if (result == expectedResult)
55 document.getElementById("test7").innerHTML = "test 7 passed";
57 // test 8 - point after range, different node
58 result = range.isPointInRange(document.getElementById("a3"), 1);
59 if (result == expectedResult)
60 document.getElementById("test8").innerHTML = "test 8 passed";
62 // test 9 - detached range, attached node
63 expectedResult = false;
64 var detachedRange = document.createRange();
65 detachedRange.detach(); // No-op.
66 result = detachedRange.isPointInRange(document.getElementById("a1"), 0);
67 if (result == expectedResult)
68 document.getElementById("test9").innerHTML = "test 9 passed";
70 // test 10 - attached range, detached node
71 // firefox does not throw an exception and returns false for this test
72 range.selectNode(document.getElementById("a1"));
73 var node = document.getElementById("b1");
74 node.parentNode.removeChild(node);
75 result = range.isPointInRange(node, 0);
76 if (result == expectedResult)
77 document.getElementById("test10").innerHTML = "test 10 passed";
79 if (window.testRunner)
80 testRunner.dumpAsText();
83 </script>
84 </head>
85 <body onload="test();">
87 <!-- visible area with test results -->
88 <div id=test1><span style="color: red;">test 1 failed</span></div><br>
89 <div id=test2><span style="color: red;">test 2 failed</span></div><br>
90 <div id=test3><span style="color: red;">test 3 failed</span></div><br>
91 <div id=test4><span style="color: red;">test 4 failed</span></div><br>
92 <div id=test5><span style="color: red;">test 5 failed</span></div><br>
93 <div id=test6><span style="color: red;">test 6 failed</span></div><br>
94 <div id=test7><span style="color: red;">test 7 failed</span></div><br>
95 <div id=test8><span style="color: red;">test 8 failed</span></div><br>
96 <div id=test9><span style="color: red;">test 9 failed</span></div><br>
97 <div id=test10><span style="color: red;">test 10 failed</span></div><br>
99 <!-- hidden area to create the ranges being tested -->
100 <div style="visibility: hidden">
101 <div id=a1>a1
102 <div id=b1>b1</div> <div id=c1>c1</div>
103 </div>
105 <div id=a2>a2
106 <div id=b2>b2</div> <div id=c2>c2</div>
107 </div>
109 <div id=a3>a3
110 <div id=b3>b3</div> <div id=c3>c3</div>
111 </div>
112 </div>
114 </body>
115 </html>