OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <title>Test for Range.isPointInRange()</title> | 3 <title>Test for Range.isPointInRange()</title> |
4 <script> | 4 <script> |
5 function test() | 5 function test() |
6 { | 6 { |
7 // isPointInRange( refNode, offset ) - This method returns Ð1, 0 or 1 depend
ing on | 7 // isPointInRange( refNode, offset ) - This method returns Ð1, 0 or 1 depend
ing on |
8 // if the point described by the refNode node and an offset within the node
is | 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. | 9 // before, same as, or after the range respectively. |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 result = range.isPointInRange(document.getElementById("c2"), 1); | 53 result = range.isPointInRange(document.getElementById("c2"), 1); |
54 if (result == expectedResult) | 54 if (result == expectedResult) |
55 document.getElementById("test7").innerHTML = "test 7 passed"; | 55 document.getElementById("test7").innerHTML = "test 7 passed"; |
56 | 56 |
57 // test 8 - point after range, different node | 57 // test 8 - point after range, different node |
58 result = range.isPointInRange(document.getElementById("a3"), 1); | 58 result = range.isPointInRange(document.getElementById("a3"), 1); |
59 if (result == expectedResult) | 59 if (result == expectedResult) |
60 document.getElementById("test8").innerHTML = "test 8 passed"; | 60 document.getElementById("test8").innerHTML = "test 8 passed"; |
61 | 61 |
62 // test 9 - detached range, attached node | 62 // test 9 - detached range, attached node |
63 // firefox throws an exception and does not return a value | 63 expectedResult = false; |
64 var detachedRange = document.createRange(); | 64 var detachedRange = document.createRange(); |
65 detachedRange.detach(); | 65 detachedRange.detach(); // No-op. |
66 try { | 66 result = detachedRange.isPointInRange(document.getElementById("a1"), 0); |
67 result = detachedRange.isPointInRange(document.getElementById("a1"), 0); | 67 if (result == expectedResult) |
68 } catch (e) { | |
69 document.getElementById("test9").innerHTML = "test 9 passed"; | 68 document.getElementById("test9").innerHTML = "test 9 passed"; |
70 } | |
71 | 69 |
72 // test 10 - attached range, detached node | 70 // test 10 - attached range, detached node |
73 // firefox does not throw an exception and returns false for this test | 71 // firefox does not throw an exception and returns false for this test |
74 range.selectNode(document.getElementById("a1")); | 72 range.selectNode(document.getElementById("a1")); |
75 var node = document.getElementById("b1"); | 73 var node = document.getElementById("b1"); |
76 node.parentNode.removeChild(node); | 74 node.parentNode.removeChild(node); |
77 result = range.isPointInRange(node, 0); | 75 result = range.isPointInRange(node, 0); |
78 if (result == expectedResult) | 76 if (result == expectedResult) |
79 document.getElementById("test10").innerHTML = "test 10 passed"; | 77 document.getElementById("test10").innerHTML = "test 10 passed"; |
80 | 78 |
(...skipping 27 matching lines...) Expand all Loading... |
108 <div id=b2>b2</div> <div id=c2>c2</div> | 106 <div id=b2>b2</div> <div id=c2>c2</div> |
109 </div> | 107 </div> |
110 | 108 |
111 <div id=a3>a3 | 109 <div id=a3>a3 |
112 <div id=b3>b3</div> <div id=c3>c3</div> | 110 <div id=b3>b3</div> <div id=c3>c3</div> |
113 </div> | 111 </div> |
114 </div> | 112 </div> |
115 | 113 |
116 </body> | 114 </body> |
117 </html> | 115 </html> |
OLD | NEW |