Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / Range / bug-19527.html
1 <body>
2 <p>Test Range.comparePoint and Range.isPointInRange Firefox extensions.</p>
3 <div id=log></div>
4 <script>
5 if (window.testRunner)
6     testRunner.dumpAsText();
7
8 var hadError = false;
9 function logError(message)
10 {
11     document.getElementById("log").innerHTML += message + "<br>";
12     hadError = true;
13 }
14
15 function shouldThrow(expr, exceptionName)
16 {
17     try {
18         eval(expr);
19         logError('<code>' + expr + '</code> didn\'t raise an exception');
20     } catch (ex) {
21         if (ex.code != ex[exceptionName])
22             logError('<code>' + expr +'</code> raised a wrong exception: ' + ex.code + ' vs. ' + ex[exceptionName] + ' (' + exceptionName + ')');
23     }
24 }
25
26 function shouldBe(expr, expected)
27 {
28     try {
29         var actual = eval(expr);
30         if (actual != expected)
31             logError('<code>' + expr + '</code>: actual ' + actual + ", expected " + expected);
32     } catch (ex) {
33         logError('<code>' + expr +'</code> raised an exception: ' + ex);
34     }
35 }
36
37 var ra = document.createRange();
38 ra.selectNode(document.getElementsByTagName("p")[0]);
39
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");
48
49 if (!hadError)
50     document.getElementById("log").innerHTML = "PASS";
51
52 </script>