2 <p id=
"description"></p>
3 <div id=
"sample">0123<b>45</b>6789</div>
5 <div id=
"console"></div>
6 <script src=
"../../../resources/js-test.js"></script>
8 description('Range on detached node should not throw exception.');
9 function $(id
) { return document
.getElementById(id
); }
11 function invalidNodeMessage(methodName
)
13 return '"InvalidNodeTypeError: Failed to execute \'' + methodName
+ '\' on \'Range\': the given Node has no parent."'
16 var sample
= $('sample').cloneNode(true);
17 var range
= document
.createRange();
19 shouldBe('range.selectNode(sample.firstChild); range.startContainer', 'sample');
20 shouldBe('range.setEndBefore(sample.firstChild); range.startContainer', 'sample');
21 shouldBe('range.setEndAfter(sample.firstChild); range.startContainer', 'sample');
22 shouldBe('range.setStartAfter(sample.firstChild); range.startContainer', 'sample');
23 shouldBe('range.setStartBefore(sample.firstChild); range.startContainer', 'sample');
25 shouldThrow('range.selectNode(sample); range.startContainer', invalidNodeMessage('selectNode'));
26 shouldThrow('range.setEndAfter(sample); range.startContainer', invalidNodeMessage('setEndAfter'));
27 shouldThrow('range.setEndBefore(sample); range.startContainer', invalidNodeMessage('setEndBefore'));
28 shouldThrow('range.setStartAfter(sample); range.startContainer', invalidNodeMessage('setStartAfter'));
29 shouldThrow('range.setStartBefore(sample); range.startContainer', invalidNodeMessage('setStartBefore'));
31 if (window
.testRunner
)
32 $('container').outerHTML
= '';