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=366944
4 -->
5 <title>Test for Bug 366944</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=366944">Mozilla Bug 366944</a>
9 <script>
11 /** Test for Bug 366944 **/
12 var testNodes = [document, document.doctype, document.createDocumentFragment()];
13 for (var i = 0; i < testNodes.length; i++) {
14 var range = document.createRange();
15 // If a non-Text node is partially contained, we expect to throw for that
16 // first
17 range.setStart(document.head, 0);
18 range.setEnd(document.body, 0);
19 var threw = false;
20 var desc = " (surrounding a range with partially-contained Element "
21 + "with " + (i == 0 ? "document" : i == 1 ? "doctype" : "docfrag") + ")";
22 try {
23 range.surroundContents(testNodes[i]);
24 } catch(e) {
25 threw = true;
26 is(Object.getPrototypeOf(e), DOMException.prototype,
27 "Must throw DOMException" + desc);
28 is(e.name, "InvalidStateError", "Must throw InvalidStateError" + desc);
29 }
30 ok(threw, "Must throw" + desc);
32 range.setStart(document.body, 0);
33 range.setEnd(document.body, 1);
34 threw = false;
35 desc = " (surrounding a regular range "
36 + "with " + (i == 0 ? "document" : i == 1 ? "doctype" : "docfrag") + ")";
37 try {
38 range.surroundContents(testNodes[i]);
39 } catch(e) {
40 threw = true;
41 is(Object.getPrototypeOf(e), DOMException.prototype,
42 "Must throw DOMException" + desc);
43 is(e.name, "InvalidNodeTypeError",
44 "Must throw InvalidNodeTypeError" + desc);
45 }
46 ok(threw, "Must throw" + desc);
47 }
49 </script>