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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src='../resources/testharness.js'></script>
3 <script src='../resources/testharnessreport.js'></script>
4 <script src="resources/shadow-dom.js"></script>
5 <div id='wrapper'>
6 <div id='node-in-document' tabindex=1></div>
7 <div id='shadow-host-1'>
8 <template data-mode='open'>
9 <div id='shadow-host-2'>
10 <template data-mode='open'>
11 <div id='child-in-shadow-root-2' tabindex=1></div>
12 </template>
13 </div>
14 <div id='child-in-shadow-root-1' tabindex=1></div>
15 <slot></slot>
16 </template>
17 <div id='slotted-child' tabindex=1></div>
18 </div>
19 </div>
20 <script>
21 'use strict';
22 convertTemplatesToShadowRootsWithin(wrapper);
23
24 const nodeInDocument = document.querySelector('#node-in-document');
25 const slottedChild = document.querySelector('#slotted-child');
26
27 const shadowHost1 = document.querySelector('#shadow-host-1');
28 const shadowRoot1 = shadowHost1.shadowRoot;
29 const childInShadowRoot1 = shadowRoot1.querySelector('#child-in-shadow-root-1');
30
31 const shadowHost2 = shadowRoot1.querySelector('#shadow-host-2');
32 const shadowRoot2 = shadowHost2.shadowRoot;
33 const childInShadowRoot2 = shadowRoot2.querySelector('#child-in-shadow-root-2');
34
35 test(() => {
36 nodeInDocument.focus();
37 assert_equals(document.activeElement, nodeInDocument);
38 assert_equals(shadowRoot1.activeElement, null);
39 assert_equals(shadowRoot2.activeElement, null);
40 }, "activeElement for a node in a document");
41
42 test(() => {
43 slottedChild.focus();
44 assert_equals(document.activeElement, slottedChild);
45 assert_equals(shadowRoot1.activeElement, null);
46 assert_equals(shadowRoot2.activeElement, null);
47 }, "activeElement for a slotted child");
48
49 test(() => {
50 childInShadowRoot1.focus();
51 assert_equals(document.activeElement, shadowHost1);
52 assert_equals(shadowRoot1.activeElement, childInShadowRoot1);
53 assert_equals(shadowRoot2.activeElement, null);
54 }, "activeElement for a node in a shadow tree");
55
56 test(() => {
57 childInShadowRoot2.focus();
58 assert_equals(document.activeElement, shadowHost1);
59 assert_equals(shadowRoot1.activeElement, shadowHost2);
60 assert_equals(shadowRoot2.activeElement, childInShadowRoot2);
61 }, "activeElement for a node in a nested shadwo tree");
kochi 2016/04/08 01:23:58 nit: s/shadwo/shadow/
hayato 2016/04/08 04:46:28 Done
62 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/Node.h » ('j') | third_party/WebKit/Source/core/dom/TreeScope.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698