content/base/test/test_bug737565.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial