JS Test Harness: Make successfullyParsed optional
[WebKit-https.git] / LayoutTests / fast / dom / shadow / get-element-by-id-in-shadow-root.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 <script src="resources/create-dom.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Tests to ensure that internals.getElementByIdInTreeScope can get an element in TreeScope by its id. Can only run within DRT");
10
11 function getElementInShadow(path)
12 {
13     var ids = path.split('/');
14     var element = document.getElementById(ids[0]);
15     for (var i = 1; element != null && i < ids.length; ++i) {
16         var shadowRoot = internals.shadowRoot(element);
17         element = internals.getElementByIdInShadowRoot(shadowRoot, ids[i]);
18     }
19     return element;
20 }
21
22 function prepareDomTree(parent)
23 {
24     parent.appendChild(
25         createShadow('div', {'id': 'divA'},
26                      createDom('input', {'id': 'inputB'}),
27                      createShadow('div', {'id': 'divC'},
28                                   createDom('input', {'id': 'inputD'}))));
29 }
30
31 function test()
32 {
33     if (window.layoutTestController)
34         layoutTestController.dumpAsText();
35     prepareDomTree(document.body);
36     shouldBeEqualToString("getElementInShadow('divA/inputB').id", 'inputB');
37     shouldBeEqualToString("getElementInShadow('divA/divC').id", 'divC');
38     shouldBeEqualToString("getElementInShadow('divA/divC/inputD').id", 'inputD');
39 }
40
41 test();
42 </script>
43 <script src="../../js/resources/js-test-post.js"></script>
44 </body>
45 </html>