5 /* relative positioning ensures underlying RenderLayer */
11 function appendShadow(target, select) {
12 var root = internals.ensureShadowRoot(target);
14 var child0 = document.createElement("span");
15 child0.innerHTML = "Hello,";
16 root.appendChild(child0);
18 var content = internals.createContentElement();
19 content.setAttribute('select', select);
20 root.appendChild(content);
22 var child1 = document.createElement("span");
23 child1.innerHTML = "World.";
24 root.appendChild(child1);
27 function testSelectIsNull() {
28 var target = document.createElement('div');
29 target.innerHTML = "<span>content</span>";
31 appendShadow(target, "");
33 document.getElementById('container').appendChild(target);
36 function testSelectIsId() {
37 var target = document.createElement('div');
38 target.innerHTML = "<span id='foo'>content</span><span id='azunyan'>peropero</span>";
40 appendShadow(target, "#foo");
42 document.getElementById('container').appendChild(target);
45 function testSelectIsIdButNotMatched() {
46 var target = document.createElement('div');
47 target.innerHTML = "<span id='foo'>content</span><span id='azunyan'>peropero</span>";
49 appendShadow(target, "#foobar");
51 document.getElementById('container').appendChild(target);
54 function testSelectIsIdButNotChild() {
55 var target = document.createElement('div');
56 target.innerHTML = "<span><span id='foo'>content</span><span id='azunyan'>peropero</span></span>";
58 appendShadow(target, "#foo");
60 document.getElementById('container').appendChild(target);
63 function testSelectIsMultiId() {
64 var target = document.createElement('div');
65 target.innerHTML = "<span id='foo'>content</span><span id='azunyan'>peropero</span><span id='foo'>content</span>";
67 appendShadow(target, "#foo");
69 // All matched elements will be selected.
70 document.getElementById('container').appendChild(target);
73 function testSelectIsType() {
74 var target = document.createElement('div');
75 target.innerHTML = "<div>azunyan</div><span>content</span><div>peropero</div>";
77 appendShadow(target, "span");
79 document.getElementById('container').appendChild(target);
82 function testSelectIsTypeWithAttribute() {
83 var target = document.createElement('div');
84 target.innerHTML = "<span>azunyan</span><span title='content'>content</span><span>peropero</span>";
86 appendShadow(target, "span[title='content']");
88 document.getElementById('container').appendChild(target);
91 function testSelectIsTypeWithFirstOfType() {
92 var target = document.createElement('div');
93 target.innerHTML = "<div>azunyan</div><span>content</span><span>peropero</span>";
95 appendShadow(target, "span:first-of-type");
97 document.getElementById('container').appendChild(target);
100 function testSelectIsTypeWithFirstOfType2() {
101 var target = document.createElement('div');
102 target.innerHTML = "<div><span>azunyan</span></div><span>content</span><span>peropero</span>";
104 appendShadow(target, "span:first-of-type");
106 document.getElementById('container').appendChild(target);
109 function testSelectIsTypeWithLastOfType() {
110 var target = document.createElement('div');
111 target.innerHTML = "<span>azunyan</span><span>content</span><div>peropero</div>";
113 appendShadow(target, "span:last-of-type");
115 document.getElementById('container').appendChild(target);
118 function testSelectIsDetails() {
119 var target = document.createElement('div');
120 target.innerHTML = "<details>content</details>";
122 appendShadow(target, "details");
124 document.getElementById('container').appendChild(target);
127 function testSelectIsDetails2() {
128 var target = document.createElement('div');
129 target.innerHTML = "<details><summary>content</summary></details>";
131 appendShadow(target, "details");
133 document.getElementById('container').appendChild(target);
136 function testSelectWhenDynamicallyChildrenChanged() {
137 var target = document.createElement('div');
138 target.innerHTML = "<span>content</span><span id='toberemoved'>anunyan peropero</span>";
140 appendShadow(target, "span");
142 document.getElementById('container').appendChild(target);
144 var elem = document.getElementById('toberemoved');
145 elem.parentNode.removeChild(elem);
151 testSelectIsIdButNotMatched,
152 testSelectIsIdButNotChild,
155 testSelectIsTypeWithAttribute,
156 testSelectIsTypeWithFirstOfType,
157 testSelectIsTypeWithFirstOfType2,
158 testSelectIsTypeWithLastOfType,
160 testSelectIsDetails2,
161 testSelectWhenDynamicallyChildrenChanged,
165 for (var i = 0; i < testFuncs.length; ++i) {
171 <body onload="doTest()">
172 <div id="container"></div>