2 <p>Test Range.comparePoint and Range.isPointInRange Firefox extensions.
</p>
6 testRunner
.dumpAsText();
9 function logError(message
)
11 document
.getElementById("log").innerHTML
+= message
+ "<br>";
15 function shouldThrow(expr
, exceptionName
)
19 logError('<code>' + expr
+ '</code> didn\'t raise an exception');
21 if (ex
.code
!= ex
[exceptionName
])
22 logError('<code>' + expr
+'</code> raised a wrong exception: ' + ex
.code
+ ' vs. ' + ex
[exceptionName
] + ' (' + exceptionName
+ ')');
26 function shouldBe(expr
, expected
)
29 var actual
= eval(expr
);
30 if (actual
!= expected
)
31 logError('<code>' + expr
+ '</code>: actual ' + actual
+ ", expected " + expected
);
33 logError('<code>' + expr
+'</code> raised an exception: ' + ex
);
37 var ra
= document
.createRange();
38 ra
.selectNode(document
.getElementsByTagName("p")[0]);
40 shouldThrow("ra.comparePoint(document.createElement('b'), 0)", "WRONG_DOCUMENT_ERR");
41 shouldThrow("ra.comparePoint(null, 0)", "HIERARCHY_REQUEST_ERR");
42 shouldBe("ra.comparePoint(document.body, 0)", -1);
43 shouldBe("ra.comparePoint(document.documentElement, 0)", -1);
44 shouldBe("ra.isPointInRange(document.createElement('b'), 0)", false);
45 shouldBe("ra.isPointInRange(document.documentElement, 0)", false);
46 shouldBe("ra.isPointInRange(document.body, 0)", false);
47 shouldThrow("ra.isPointInRange(null, 0)", "HIERARCHY_REQUEST_ERR");
50 document
.getElementById("log").innerHTML
= "PASS";