Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1739)

Unified Diff: third_party/WebKit/LayoutTests/shadow-dom/active-element.html

Issue 1870583002: Update the behavior of ShadowRoot.activeElement to match the latest spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/shadow-dom/active-element.html
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/active-element.html b/third_party/WebKit/LayoutTests/shadow-dom/active-element.html
new file mode 100644
index 0000000000000000000000000000000000000000..1e448b37d8c862e8e7edc39a456e86dac984d89a
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shadow-dom/active-element.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<script src='../resources/testharness.js'></script>
+<script src='../resources/testharnessreport.js'></script>
+<script src="resources/shadow-dom.js"></script>
+<div id='wrapper'>
+ <div id='node-in-document' tabindex=1></div>
+ <div id='shadow-host-1'>
+ <template data-mode='open'>
+ <div id='shadow-host-2'>
+ <template data-mode='open'>
+ <div id='child-in-shadow-root-2' tabindex=1></div>
+ </template>
+ </div>
+ <div id='child-in-shadow-root-1' tabindex=1></div>
+ <slot></slot>
+ </template>
+ <div id='slotted-child' tabindex=1></div>
+ </div>
+</div>
+<script>
+'use strict';
+convertTemplatesToShadowRootsWithin(wrapper);
+
+const nodeInDocument = document.querySelector('#node-in-document');
+const slottedChild = document.querySelector('#slotted-child');
+
+const shadowHost1 = document.querySelector('#shadow-host-1');
+const shadowRoot1 = shadowHost1.shadowRoot;
+const childInShadowRoot1 = shadowRoot1.querySelector('#child-in-shadow-root-1');
+
+const shadowHost2 = shadowRoot1.querySelector('#shadow-host-2');
+const shadowRoot2 = shadowHost2.shadowRoot;
+const childInShadowRoot2 = shadowRoot2.querySelector('#child-in-shadow-root-2');
+
+test(() => {
+ nodeInDocument.focus();
+ assert_equals(document.activeElement, nodeInDocument);
+ assert_equals(shadowRoot1.activeElement, null);
+ assert_equals(shadowRoot2.activeElement, null);
+}, "activeElement for a node in a document");
+
+test(() => {
+ slottedChild.focus();
+ assert_equals(document.activeElement, slottedChild);
+ assert_equals(shadowRoot1.activeElement, null);
+ assert_equals(shadowRoot2.activeElement, null);
+}, "activeElement for a slotted child");
+
+test(() => {
+ childInShadowRoot1.focus();
+ assert_equals(document.activeElement, shadowHost1);
+ assert_equals(shadowRoot1.activeElement, childInShadowRoot1);
+ assert_equals(shadowRoot2.activeElement, null);
+}, "activeElement for a node in a shadow tree");
+
+test(() => {
+ childInShadowRoot2.focus();
+ assert_equals(document.activeElement, shadowHost1);
+ assert_equals(shadowRoot1.activeElement, shadowHost2);
+ assert_equals(shadowRoot2.activeElement, childInShadowRoot2);
+}, "activeElement for a node in a nested shadow tree");
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698