| 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 <input id="input1"></input> | 8 <input id="input1"></input> |
| 9 <div id="sandbox"></div> | 9 <div id="sandbox"></div> |
| 10 <div id="console"></div> | 10 <div id="console"></div> |
| 11 <script> | 11 <script> |
| 12 var sandbox = document.getElementById('sandbox'); | 12 var sandbox = document.getElementById('sandbox'); |
| 13 | 13 |
| 14 // A test for a non-distributed node. | 14 // A test for a non-distributed node. |
| 15 sandbox.appendChild( | 15 sandbox.appendChild( |
| 16 createDOM('div', {'id': 'host'}, | 16 createDOM('div', {'id': 'host'}, |
| 17 createDOM('input', {'id': 'non-distributed-node'}), | 17 createDOM('input', {'id': 'non-distributed-node'}), |
| 18 createShadowRoot({'id': 'shadow-root'}))); | 18 createShadowRoot({'id': 'shadow-root'}))); |
| 19 sandbox.offsetLeft; | 19 sandbox.offsetLeft; |
| 20 | 20 |
| 21 document.getElementById('input1').focus(); | 21 document.getElementById('input1').focus(); |
| 22 shouldBeEqualToString('document.activeElement.id', 'input1'); | 22 shouldBeEqualToString('document.activeElement.id', 'input1'); |
| 23 | 23 |
| 24 document.getElementById('non-distributed-node').focus(); | 24 document.getElementById('non-distributed-node').focus(); |
| 25 // Focus doesn't change because non-distributed-node can't get focused. | 25 // Focus doesn't change because non-distributed-node can't get focused. |
| 26 shouldBeEqualToString('document.activeElement.id', 'input1'); | 26 shouldBeEqualToString('document.activeElement.id', 'input1'); |
| 27 | 27 |
| 28 var shadowRoot = getNodeInTreeOfTrees('host/'); | 28 var shadowRoot = getNodeInComposedTree('host/'); |
| 29 shouldBeNull('shadowRoot.activeElement'); | 29 shouldBeNull('shadowRoot.activeElement'); |
| 30 | 30 |
| 31 | 31 |
| 32 // A test for a distributed node. | 32 // A test for a distributed node. |
| 33 sandbox.innerHTML = ''; | 33 sandbox.innerHTML = ''; |
| 34 sandbox.appendChild( | 34 sandbox.appendChild( |
| 35 createDOM('div', {'id': 'host'}, | 35 createDOM('div', {'id': 'host'}, |
| 36 createDOM('input', {'id': 'distributed-node'}), | 36 createDOM('input', {'id': 'distributed-node'}), |
| 37 createShadowRoot({'id': 'shadow-root'}, | 37 createShadowRoot({'id': 'shadow-root'}, |
| 38 createDOM('div', {'id': 'content-parent'}, | 38 createDOM('div', {'id': 'content-parent'}, |
| 39 createDOM('content', {'id': 'content'})
)))); | 39 createDOM('content', {'id': 'content'})
)))); |
| 40 sandbox.offsetLeft; | 40 sandbox.offsetLeft; |
| 41 | 41 |
| 42 var distributedNode = document.getElementById('distributed-node'); | 42 var distributedNode = document.getElementById('distributed-node'); |
| 43 distributedNode.focus(); | 43 distributedNode.focus(); |
| 44 | 44 |
| 45 shouldBeEqualToString('document.activeElement.id', 'distributed-node'); | 45 shouldBeEqualToString('document.activeElement.id', 'distributed-node'); |
| 46 shadowRoot = getNodeInTreeOfTrees("host/"); | 46 shadowRoot = getNodeInComposedTree("host/"); |
| 47 shouldBeEqualToString('shadowRoot.activeElement.id', 'distributed-node'); | 47 shouldBeEqualToString('shadowRoot.activeElement.id', 'distributed-node'); |
| 48 | 48 |
| 49 var contentParent = getNodeInTreeOfTrees('host/content-parent'); | 49 var contentParent = getNodeInComposedTree('host/content-parent'); |
| 50 contentParent.parentNode.removeChild(contentParent); | 50 contentParent.parentNode.removeChild(contentParent); |
| 51 // This is a similar case where 'dispaly: none' is set to the focused element. W
e can't guarantee this case. | 51 // This is a similar case where 'dispaly: none' is set to the focused element. W
e can't guarantee this case. |
| 52 // The current implementation leaves the distributed node as document.activeElem
ent. | 52 // The current implementation leaves the distributed node as document.activeElem
ent. |
| 53 // See the discussion from https://code.google.com/p/chromium/issues/detail?id=3
18448#c21. | 53 // See the discussion from https://code.google.com/p/chromium/issues/detail?id=3
18448#c21. |
| 54 shouldBeEqualToString('document.activeElement.id', 'distributed-node'); | 54 shouldBeEqualToString('document.activeElement.id', 'distributed-node'); |
| 55 shouldBeNull('shadowRoot.activeElement'); | 55 shouldBeNull('shadowRoot.activeElement'); |
| 56 | 56 |
| 57 var successfullyParsed = true; | 57 var successfullyParsed = true; |
| 58 </script> | 58 </script> |
| 59 </body> | 59 </body> |
| 60 </html> | 60 </html> |
| OLD | NEW |