OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <title>Range.commonAncestorContainer</title> |
| 3 <script src=../../../../resources/testharness.js></script> |
| 4 <script src=../../../../resources/testharnessreport.js></script> |
| 5 <div id=log></div> |
| 6 <script> |
| 7 test(function() { |
| 8 var range = document.createRange(); |
| 9 range.detach(); |
| 10 assert_equals(range.commonAncestorContainer, document); |
| 11 }, "Detached Range") |
| 12 test(function() { |
| 13 var df = document.createDocumentFragment(); |
| 14 var foo = df.appendChild(document.createElement("foo")); |
| 15 foo.appendChild(document.createTextNode("Foo")); |
| 16 var bar = df.appendChild(document.createElement("bar")); |
| 17 bar.appendChild(document.createComment("Bar")); |
| 18 [ |
| 19 // start node, start offset, end node, end offset, expected cAC |
| 20 [foo, 0, bar, 0, df], |
| 21 [foo, 0, foo.firstChild, 3, foo], |
| 22 [foo.firstChild, 0, bar, 0, df], |
| 23 [foo.firstChild, 3, bar.firstChild, 2, df] |
| 24 ].forEach(function(t) { |
| 25 test(function() { |
| 26 var range = document.createRange(); |
| 27 range.setStart(t[0], t[1]); |
| 28 range.setEnd(t[2], t[3]); |
| 29 assert_equals(range.commonAncestorContainer, t[4]); |
| 30 }) |
| 31 }); |
| 32 }, "Normal Ranges") |
| 33 </script> |
OLD | NEW |