1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug366944.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +<!doctype html> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=366944 1.7 +--> 1.8 +<title>Test for Bug 366944</title> 1.9 +<script src="/tests/SimpleTest/SimpleTest.js"></script> 1.10 +<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 1.11 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366944">Mozilla Bug 366944</a> 1.12 +<script> 1.13 + 1.14 +/** Test for Bug 366944 **/ 1.15 +var testNodes = [document, document.doctype, document.createDocumentFragment()]; 1.16 +for (var i = 0; i < testNodes.length; i++) { 1.17 + var range = document.createRange(); 1.18 + // If a non-Text node is partially contained, we expect to throw for that 1.19 + // first 1.20 + range.setStart(document.head, 0); 1.21 + range.setEnd(document.body, 0); 1.22 + var threw = false; 1.23 + var desc = " (surrounding a range with partially-contained Element " 1.24 + + "with " + (i == 0 ? "document" : i == 1 ? "doctype" : "docfrag") + ")"; 1.25 + try { 1.26 + range.surroundContents(testNodes[i]); 1.27 + } catch(e) { 1.28 + threw = true; 1.29 + is(Object.getPrototypeOf(e), DOMException.prototype, 1.30 + "Must throw DOMException" + desc); 1.31 + is(e.name, "InvalidStateError", "Must throw InvalidStateError" + desc); 1.32 + } 1.33 + ok(threw, "Must throw" + desc); 1.34 + 1.35 + range.setStart(document.body, 0); 1.36 + range.setEnd(document.body, 1); 1.37 + threw = false; 1.38 + desc = " (surrounding a regular range " 1.39 + + "with " + (i == 0 ? "document" : i == 1 ? "doctype" : "docfrag") + ")"; 1.40 + try { 1.41 + range.surroundContents(testNodes[i]); 1.42 + } catch(e) { 1.43 + threw = true; 1.44 + is(Object.getPrototypeOf(e), DOMException.prototype, 1.45 + "Must throw DOMException" + desc); 1.46 + is(e.name, "InvalidNodeTypeError", 1.47 + "Must throw InvalidNodeTypeError" + desc); 1.48 + } 1.49 + ok(threw, "Must throw" + desc); 1.50 +} 1.51 + 1.52 +</script>