3 Distributed under both the W3C Test Suite License [1] and the W3C
4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
5 policies and contribution forms [3].
7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
9 [3] http://www.w3.org/2004/10/27-testcases
13 <title>Shadow DOM Test: A_07_01_02</title>
14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
15 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#ranges-and-selection">
16 <meta name="assert" content="User Interaction: The getSelection() method of the shadow root object must return the current selection in this shadow tree.">
17 <script src="../../../../../resources/testharness.js"></script>
18 <script src="../../../../../resources/testharnessreport.js"></script>
19 <script src="../../testcommon.js"></script>
20 <link rel="stylesheet" href="../../../../../resources/testharness.css">
25 test(unit(function (ctx) {
26 var d = newRenderedHTMLDocument(ctx);
28 var host = d.createElement('div');
29 d.body.appendChild(host);
30 var s = host.createShadowRoot();
32 var span = d.createElement('span');
33 span.innerHTML = 'Some text';
36 var range = d.createRange();
37 range.setStart(span.firstChild, 0);
38 range.setEnd(span.firstChild, 3);
40 var selection = window.getSelection();
41 selection.removeAllRanges();
42 selection.addRange(range);
44 var sl = s.getSelection();
45 assert_equals(sl.toString(), 'Som', 'The getSelection() method of the shadow root object must return ' +
46 'the current selection in this shadow tree');
48 }), 'A_07_01_02_T01');
51 //test distributed nodes
52 test(unit(function (ctx) {
53 var d = newRenderedHTMLDocument(ctx);
55 var host = d.createElement('div');
56 d.body.appendChild(host);
58 var span = d.createElement('span');
59 span.innerHTML = 'Some text';
60 host.appendChild(span);
62 var s = host.createShadowRoot();
63 s.innerHTML = '<content select="span"></content>';
65 var range = d.createRange();
66 range.setStart(span.firstChild, 0);
67 range.setEnd(span.firstChild, 3);
69 var selection = window.getSelection();
70 selection.removeAllRanges();
71 selection.addRange(range);
73 var sl = s.getSelection();
74 assert_equals(sl.toString(), 'Som', 'The getSelection() method of the shadow root object must return ' +
75 'the current selection in this shadow tree');
77 }), 'A_07_07_02_T02');