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