93370f95f3ac9626f0d1763955b9dbed44f33d3c
[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/shadow-dom.js"></script>
6 </head>
7 <body>
8 <script>
9 description("Tests to ensure that internals.getElementByIdInShadowRoot can get an element in ShadowRoot by its id. Can only run within DRT");
10
11 function prepareDomTree(parent)
12 {
13     parent.appendChild(
14         createDOM('div', {'id': 'divA'},
15                   createShadowRoot(
16                       createDOM('input', {'id': 'inputB'}),
17                       createDOM('div', {'id': 'divC'},
18                                 createShadowRoot(
19                                     createDOM('input', {'id': 'inputD'})),
20                                 createShadowRoot(
21                                     createDOM('input', {'id': 'inputE'})),
22                                 createShadowRoot(
23                                     createDOM('input', {'id': 'inputF'}))))));
24 }
25
26 function test()
27 {
28     if (window.layoutTestController)
29         layoutTestController.dumpAsText();
30
31     prepareDomTree(document.body);
32     shouldBeEqualToString("getElementInShadowTreeStack('divA/inputB').id", 'inputB');
33     shouldBeEqualToString("getElementInShadowTreeStack('divA/divC').id", 'divC');
34     shouldBeEqualToString("getElementInShadowTreeStack('divA/divC/inputD').id", 'inputD');
35     shouldBeEqualToString("getElementInShadowTreeStack('divA/divC//inputE').id", 'inputE');
36     shouldBeEqualToString("getElementInShadowTreeStack('divA/divC///inputF').id", 'inputF');
37 }
38
39 test();
40 </script>
41 <script src="../../js/resources/js-test-post.js"></script>
42 </body>
43 </html>