Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / shadow / getRangeAt-end-of-text-node.html
blob4cc77d1b35777f6b26f56f94064ad9bde1ef9429
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <div id="shadowHost"></div>
5 <script>
6 (function () {
7 var shadowRoot = shadowHost.createShadowRoot();
8 shadowRoot.innerHTML = '<div id="editable" contenteditable>Test</div>';
9 var textNode = shadowRoot.querySelector("#editable").firstChild;
10 var selection = shadowRoot.getSelection();
11 selection.collapse(textNode, textNode.textContent.length);
12 test(function () {
13 var range = selection.getRangeAt(0);
14 assert_equals(range.startContainer, textNode);
15 assert_equals(range.startOffset, textNode.textContent.length);
16 assert_true(range.collapsed);
17 }, "collapsed");
19 selection.collapse(textNode, 0);
20 selection.extend(textNode, 2);
21 test(function () {
22 var range = selection.getRangeAt(0);
23 assert_equals(range.startContainer, textNode);
24 assert_equals(range.startOffset, 0);
25 assert_equals(range.endContainer, textNode);
26 assert_equals(range.endOffset, 2);
27 assert_false(range.collapsed);
28 }, "range");
30 test(function () {
31 assert_not_equals(window.getSelection().getRangeAt(0).anchorNode, textNode);
32 }, "Nodes in Shadow should not be exposed to window.getSelection()");
33 })();
34 </script>