Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!doctype html>
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi?id=737565
4 -->
5 <title>Test for Bug 737565</title>
6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
8 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=737565">Mozilla Bug 737565</a>
9 <script>
11 /** Test for Bug 737565 **/
12 var offsets = [-1, 0, 1, 2, 3, 65536, 1 << 31];
13 // This is supposed to be an unsigned long, so adding or subtracting 1 << 32
14 // should have no effect
15 var offsetOffsets = [0, -Math.pow(2, 32), Math.pow(2, 32)];
17 for (var i = 0; i < offsets.length; i++) {
18 for (var j = 0; j < offsetOffsets.length; j++) {
19 var offset = offsets[i] + offsetOffsets[j];
21 // Doctype always needs to throw
22 var threw = false;
23 try {
24 var range = document.createRange();
25 range.comparePoint(document.doctype, offset);
26 } catch(e) {
27 threw = true;
28 is(e.name, "InvalidNodeTypeError",
29 "comparePoint(document.doctype, " + offset
30 + ") must throw InvalidNodeTypeError");
31 is(Object.getPrototypeOf(e), DOMException.prototype,
32 "comparePoint(document.doctype, " + offset
33 + ") must throw DOMException");
34 is(e.code, DOMException.INVALID_NODE_TYPE_ERR,
35 "comparePoint(document.doctype, " + offset
36 + ") must throw INVALID_NODE_TYPE_ERR");
37 }
38 ok(threw, "comparePoint(document.doctype, " + offset + ") must throw");
40 threw = false;
41 // document.documentElement has two children, head and body
42 var expectedThrew = offsets[i] < 0 || offsets[i] > 2;
43 try {
44 var range = document.createRange();
45 range.comparePoint(document.documentElement, offset);
46 } catch(e) {
47 threw = true;
48 is(e.name, "IndexSizeError",
49 "comparePoint(document.documentElement, " + offset
50 + ") must throw IndexSizeError");
51 is(Object.getPrototypeOf(e), DOMException.prototype,
52 "comparePoint(document.documentElement, " + offset
53 + ") must throw DOMException");
54 is(e.code, DOMException.INDEX_SIZE_ERR,
55 "comparePoint(document.documentElement, " + offset
56 + ") must throw INDEX_SIZE_ERR");
57 }
58 is(threw, expectedThrew,
59 "comparePoint(document.documentElement, " + offset
60 + ") must " + (expectedThrew ? "" : "not ") + "throw");
61 }
62 }
64 </script>