OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 <script src="resources/shadow-dom.js"></script> | 5 <script src="resources/shadow-dom.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <div id="console"></div> | 8 <div id="console"></div> |
9 <div id="sandbox"> | 9 <div id="sandbox"> |
10 </div> | 10 </div> |
11 <script> | 11 <script> |
12 description("This tests the activeElement property of a ShadowRoot."); | 12 description("This tests the activeElement property of a ShadowRoot."); |
13 | 13 |
14 if (!window.internals) | 14 if (!window.internals) |
15 debug('This test runs on DRT only'); | 15 debug('This test runs on DRT only'); |
16 | 16 |
17 document.getElementById('sandbox').appendChild( | 17 document.getElementById('sandbox').appendChild( |
18 createDOM('div', {}, | 18 createDOM('div', {}, |
19 createDOM('div', {'id': 'node-in-document', 'tabindex': 1}), | 19 createDOM('div', {'id': 'node-in-document', 'tabindex': 1}), |
20 createDOM('div', {'id': 'shadow-host-1'}, | 20 createDOM('div', {'id': 'shadow-host-1'}, |
21 createShadowRoot( | 21 createShadowRoot( |
22 createDOM('div', {'id': 'shadow-host-2'}, | 22 createDOM('div', {'id': 'shadow-host-2'}, |
23 createShadowRoot( | 23 createShadowRoot( |
24 createDOM('div', {'id': 'child-in-shad
ow-root-2', 'tabindex': 1}))), | 24 createDOM('div', {'id': 'child-in-shad
ow-root-2', 'tabindex': 1}))), |
25 createDOM('div', {'id': 'child-in-shadow-root-1', 't
abindex': 1}), | 25 createDOM('div', {'id': 'child-in-shadow-root-1', 't
abindex': 1}), |
26 createDOM('content', {'select': '#distributed-light-
child'})), | 26 createDOM('content', {'select': '#distributed-light-
child'})), |
27 createDOM('div', {'id': 'distributed-light-child', 'tabi
ndex': 1})))); | 27 createDOM('div', {'id': 'distributed-light-child', 'tabi
ndex': 1})))); |
28 | 28 |
29 var shadowHost1 = getNodeInTreeOfTrees('shadow-host-1'); | 29 var shadowHost1 = getNodeInComposedTree('shadow-host-1'); |
30 var shadowHost2 = getNodeInTreeOfTrees('shadow-host-1/shadow-host-2'); | 30 var shadowHost2 = getNodeInComposedTree('shadow-host-1/shadow-host-2'); |
31 var shadowRoot1 = getNodeInTreeOfTrees('shadow-host-1/'); | 31 var shadowRoot1 = getNodeInComposedTree('shadow-host-1/'); |
32 var shadowRoot2 = getNodeInTreeOfTrees('shadow-host-1/shadow-host-2/'); | 32 var shadowRoot2 = getNodeInComposedTree('shadow-host-1/shadow-host-2/'); |
33 | 33 |
34 var nodeInDocument = document.getElementById('node-in-document'); | 34 var nodeInDocument = document.getElementById('node-in-document'); |
35 var distributedLightChild = document.getElementById('distributed-light-child'); | 35 var distributedLightChild = document.getElementById('distributed-light-child'); |
36 var childInShadowRoot1 = getNodeInTreeOfTrees('shadow-host-1/child-in-shadow-roo
t-1'); | 36 var childInShadowRoot1 = getNodeInComposedTree('shadow-host-1/child-in-shadow-ro
ot-1'); |
37 var childInShadowRoot2 = getNodeInTreeOfTrees('shadow-host-1/shadow-host-2/child
-in-shadow-root-2'); | 37 var childInShadowRoot2 = getNodeInComposedTree('shadow-host-1/shadow-host-2/chil
d-in-shadow-root-2'); |
38 | 38 |
39 shouldBeDefined("shadowRoot1.activeElement"); | 39 shouldBeDefined("shadowRoot1.activeElement"); |
40 shouldBeDefined("shadowRoot2.activeElement"); | 40 shouldBeDefined("shadowRoot2.activeElement"); |
41 | 41 |
42 shouldBe("nodeInDocument.focus(); document.activeElement", "nodeInDocument"); | 42 shouldBe("nodeInDocument.focus(); document.activeElement", "nodeInDocument"); |
43 shouldBe("nodeInDocument.focus(); shadowRoot1.activeElement", "null"); | 43 shouldBe("nodeInDocument.focus(); shadowRoot1.activeElement", "null"); |
44 shouldBe("nodeInDocument.focus(); shadowRoot2.activeElement", "null"); | 44 shouldBe("nodeInDocument.focus(); shadowRoot2.activeElement", "null"); |
45 | 45 |
46 shouldBe("distributedLightChild.focus(); document.activeElement", "distributedLi
ghtChild"); | 46 shouldBe("distributedLightChild.focus(); document.activeElement", "distributedLi
ghtChild"); |
47 shouldBe("distributedLightChild.focus(); shadowRoot1.activeElement", "distribute
dLightChild"); | 47 shouldBe("distributedLightChild.focus(); shadowRoot1.activeElement", "distribute
dLightChild"); |
48 shouldBe("distributedLightChild.focus(); shadowRoot2.activeElement", "null"); | 48 shouldBe("distributedLightChild.focus(); shadowRoot2.activeElement", "null"); |
49 | 49 |
50 shouldBe("childInShadowRoot1.focus(); document.activeElement", "shadowHost1"); | 50 shouldBe("childInShadowRoot1.focus(); document.activeElement", "shadowHost1"); |
51 shouldBe("childInShadowRoot1.focus(); shadowRoot1.activeElement", "childInShadow
Root1"); | 51 shouldBe("childInShadowRoot1.focus(); shadowRoot1.activeElement", "childInShadow
Root1"); |
52 shouldBe("childInShadowRoot1.focus(); shadowRoot2.activeElement", "null"); | 52 shouldBe("childInShadowRoot1.focus(); shadowRoot2.activeElement", "null"); |
53 | 53 |
54 shouldBe("childInShadowRoot2.focus(); document.activeElement", "shadowHost1"); | 54 shouldBe("childInShadowRoot2.focus(); document.activeElement", "shadowHost1"); |
55 shouldBe("childInShadowRoot2.focus(); shadowRoot1.activeElement", "shadowHost2")
; | 55 shouldBe("childInShadowRoot2.focus(); shadowRoot1.activeElement", "shadowHost2")
; |
56 shouldBe("childInShadowRoot2.focus(); shadowRoot2.activeElement", "childInShadow
Root2"); | 56 shouldBe("childInShadowRoot2.focus(); shadowRoot2.activeElement", "childInShadow
Root2"); |
57 | 57 |
58 evalAndLog("childInShadowRoot2.blur();"); | 58 evalAndLog("childInShadowRoot2.blur();"); |
59 shouldBe("document.activeElement", "document.body"); | 59 shouldBe("document.activeElement", "document.body"); |
60 shouldBe("shadowRoot1.activeElement", "null"); | 60 shouldBe("shadowRoot1.activeElement", "null"); |
61 shouldBe("shadowRoot2.activeElement", "null"); | 61 shouldBe("shadowRoot2.activeElement", "null"); |
62 | 62 |
63 var successfullyParsed = true; | 63 var successfullyParsed = true; |
64 </script> | 64 </script> |
65 </body> | 65 </body> |
66 </html> | 66 </html> |
OLD | NEW |