| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../js/resources/js-test-pre.js"></script> |
| <script src="resources/shadow-dom.js"></script> |
| </head> |
| <body> |
| <div id="console"></div> |
| <div id="sandbox"> |
| </div> |
| <script> |
| description("This tests the activeElement property of a ShadowRoot."); |
| |
| if (!window.internals) |
| debug('This test runs on DRT only'); |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| document.getElementById('sandbox').appendChild( |
| createDOM('div', {}, |
| createDOM('div', {'id': 'node-in-document', 'tabindex': 1}), |
| createDOM('div', {'id': 'shadow-host-1'}, |
| createShadowRoot( |
| createDOM('div', {'id': 'shadow-host-2'}, |
| createShadowRoot( |
| createDOM('div', {'id': 'child-in-shadow-root-2', 'tabindex': 1}))), |
| createDOM('div', {'id': 'child-in-shadow-root-1', 'tabindex': 1}), |
| createDOM('content', {'select': '#distributed-light-child'})), |
| createDOM('div', {'id': 'distributed-light-child', 'tabindex': 1})))); |
| |
| var shadowHost1 = getNodeInShadowTreeStack('shadow-host-1'); |
| var shadowHost2 = getNodeInShadowTreeStack('shadow-host-1/shadow-host-2'); |
| var shadowRoot1 = getNodeInShadowTreeStack('shadow-host-1/'); |
| var shadowRoot2 = getNodeInShadowTreeStack('shadow-host-1/shadow-host-2/'); |
| |
| var nodeInDocument = document.getElementById('node-in-document'); |
| var distributedLightChild = document.getElementById('distributed-light-child'); |
| var childInShadowRoot1 = getNodeInShadowTreeStack('shadow-host-1/child-in-shadow-root-1'); |
| var childInShadowRoot2 = getNodeInShadowTreeStack('shadow-host-1/shadow-host-2/child-in-shadow-root-2'); |
| |
| shouldBeDefined("shadowRoot1.activeElement"); |
| shouldBeDefined("shadowRoot2.activeElement"); |
| |
| shouldBe("nodeInDocument.focus(); document.activeElement", "nodeInDocument"); |
| shouldBe("nodeInDocument.focus(); shadowRoot1.activeElement", "null"); |
| shouldBe("nodeInDocument.focus(); shadowRoot2.activeElement", "null"); |
| |
| shouldBe("distributedLightChild.focus(); document.activeElement", "distributedLightChild"); |
| shouldBe("distributedLightChild.focus(); shadowRoot1.activeElement", "distributedLightChild"); |
| shouldBe("distributedLightChild.focus(); shadowRoot2.activeElement", "null"); |
| |
| shouldBe("childInShadowRoot1.focus(); document.activeElement", "shadowHost1"); |
| shouldBe("childInShadowRoot1.focus(); shadowRoot1.activeElement", "childInShadowRoot1"); |
| shouldBe("childInShadowRoot1.focus(); shadowRoot2.activeElement", "null"); |
| |
| shouldBe("childInShadowRoot2.focus(); document.activeElement", "shadowHost1"); |
| shouldBe("childInShadowRoot2.focus(); shadowRoot1.activeElement", "shadowHost2"); |
| shouldBe("childInShadowRoot2.focus(); shadowRoot2.activeElement", "childInShadowRoot2"); |
| |
| evalAndLog("childInShadowRoot2.blur();"); |
| shouldBe("document.activeElement", "document.body"); |
| shouldBe("shadowRoot1.activeElement", "null"); |
| shouldBe("shadowRoot2.activeElement", "null"); |
| |
| var successfullyParsed = true; |
| </script> |
| <script src="../../js/resources/js-test-post.js"></script> |
| </body> |
| </html> |