Skip to content

Commit 1038655

Browse files
janewmanchromium-wpt-export-bot
authored andcommitted
[focusgroup] Use HTML auto-globals in shadow and tentative-root WPTs
Replace document.getElementById('x') with the bare HTML auto-global x in the focusgroup shadow WPT suite and the remaining loose tests at the focusgroup/tentative/ root. Inspired by Mason's comment here: https://chromium-review.googlesource.com/c/chromium/src/+/7681875/comment/8353cb43_450159ed/ Test only, no behavior change Bug: 4021071 Change-Id: I6bc0b684b905d71710e2539f48723c968ce88a7a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7834833 Reviewed-by: Stephanie Zhang <stephanie.zhang@microsoft.com> Commit-Queue: Jacques Newman <janewman@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1637305}
1 parent 857ec50 commit 1038655

11 files changed

Lines changed: 39 additions & 70 deletions

html/interaction/focus/focusgroup/tentative/ax-role-inference-top-layer.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
}, 'Sibling outside the popover still infers the implied tab role');
3232

3333
promise_test(async t => {
34-
const pop = document.getElementById('pop');
3534
assert_false(pop.matches(':popover-open'),
3635
'precondition: popover starts closed');
3736
pop.showPopover();

html/interaction/focus/focusgroup/tentative/behavior-first-requirement.html

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,49 +46,37 @@
4646
<script>
4747
promise_test(async t => {
4848
// Valid behavior-first syntax should enable focusgroup navigation
49-
var item1 = document.getElementById("item1");
50-
var item2 = document.getElementById("item2");
5149

5250
await focusAndSendDirectionalInput(item1, kRight);
5351
assert_equals(document.activeElement, item2, "Valid 'toolbar' behavior should enable navigation");
5452
}, "Valid behavior-first token 'toolbar' enables focusgroup navigation");
5553

5654
promise_test(async t => {
57-
var item3 = document.getElementById("item3");
58-
var item4 = document.getElementById("item4");
5955

6056
await focusAndSendDirectionalInput(item3, kRight);
6157
assert_equals(document.activeElement, item4, "Valid 'tablist inline' behavior should enable navigation");
6258
}, "Valid behavior-first token 'tablist' with modifier enables focusgroup navigation");
6359

6460
promise_test(async t => {
65-
var item5 = document.getElementById("item5");
66-
var item6 = document.getElementById("item6");
6761

6862
await focusAndSendDirectionalInput(item5, kRight);
6963
assert_equals(document.activeElement, item6, "Valid 'radiogroup wrap' behavior should enable navigation");
7064
}, "Valid behavior-first token 'radiogroup' with modifier enables focusgroup navigation");
7165

7266
promise_test(async t => {
7367
// Invalid behavior-first syntax should NOT enable focusgroup navigation
74-
var item7 = document.getElementById("item7");
75-
var item8 = document.getElementById("item8");
7668

7769
await focusAndSendDirectionalInput(item7, kRight);
7870
assert_equals(document.activeElement, item7, "Empty focusgroup attribute should not enable navigation");
7971
}, "Empty focusgroup attribute is rejected and does not enable navigation");
8072

8173
promise_test(async t => {
82-
var item9 = document.getElementById("item9");
83-
var item10 = document.getElementById("item10");
8474

8575
await focusAndSendDirectionalInput(item9, kRight);
8676
assert_equals(document.activeElement, item9, "Invalid first token 'inline' should not enable navigation");
8777
}, "Invalid first token 'inline' is rejected and does not enable navigation");
8878

8979
promise_test(async t => {
90-
var item11 = document.getElementById("item11");
91-
var item12 = document.getElementById("item12");
9280

9381
await focusAndSendDirectionalInput(item11, kRight);
9482
assert_equals(document.activeElement, item11, "Invalid first token 'wrap' should not enable navigation");

html/interaction/focus/focusgroup/tentative/home-end-keys.optional.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,128 +83,128 @@
8383
// --- Basic Home/End in toolbar (inline, no wrap) ---
8484

8585
promise_test(async t => {
86-
await focusAndSendHomeInput(document.getElementById('tb2'));
86+
await focusAndSendHomeInput(tb2);
8787
assert_equals(document.activeElement.id, 'tb1');
8888
}, "Home moves focus to first item in toolbar");
8989

9090
promise_test(async t => {
91-
await focusAndSendEndInput(document.getElementById('tb2'));
91+
await focusAndSendEndInput(tb2);
9292
assert_equals(document.activeElement.id, 'tb3');
9393
}, "End moves focus to last item in toolbar");
9494

9595
promise_test(async t => {
96-
await focusAndSendHomeInput(document.getElementById('tb1'));
96+
await focusAndSendHomeInput(tb1);
9797
assert_equals(document.activeElement.id, 'tb1');
9898
}, "Home on first item stays on first item");
9999

100100
promise_test(async t => {
101-
await focusAndSendEndInput(document.getElementById('tb3'));
101+
await focusAndSendEndInput(tb3);
102102
assert_equals(document.activeElement.id, 'tb3');
103103
}, "End on last item stays on last item");
104104

105105
// --- Home/End in wrapping tablist ---
106106

107107
promise_test(async t => {
108-
await focusAndSendHomeInput(document.getElementById('tl3'));
108+
await focusAndSendHomeInput(tl3);
109109
assert_equals(document.activeElement.id, 'tl1');
110110
}, "Home in tablist moves to first item");
111111

112112
promise_test(async t => {
113-
await focusAndSendEndInput(document.getElementById('tl1'));
113+
await focusAndSendEndInput(tl1);
114114
assert_equals(document.activeElement.id, 'tl3');
115115
}, "End in tablist moves to last item");
116116

117117
// --- Home/End in block-only menu ---
118118

119119
promise_test(async t => {
120-
await focusAndSendHomeInput(document.getElementById('m3'));
120+
await focusAndSendHomeInput(m3);
121121
assert_equals(document.activeElement.id, 'm1');
122122
}, "Home in block-only menu moves to first item");
123123

124124
promise_test(async t => {
125-
await focusAndSendEndInput(document.getElementById('m1'));
125+
await focusAndSendEndInput(m1);
126126
assert_equals(document.activeElement.id, 'm3');
127127
}, "End in block-only menu moves to last item");
128128

129129
// --- Home/End in nested focusgroups ---
130130

131131
promise_test(async t => {
132-
await focusAndSendHomeInput(document.getElementById('i3'));
132+
await focusAndSendHomeInput(i3);
133133
assert_equals(document.activeElement.id, 'i1');
134134
}, "Home in nested focusgroup moves to first item of inner group");
135135

136136
promise_test(async t => {
137-
await focusAndSendEndInput(document.getElementById('i1'));
137+
await focusAndSendEndInput(i1);
138138
assert_equals(document.activeElement.id, 'i3');
139139
}, "End in nested focusgroup moves to last item of inner group");
140140

141141
// --- Home/End ignores focusgroupstart ---
142142

143143
promise_test(async t => {
144-
await focusAndSendHomeInput(document.getElementById('fs3'));
144+
await focusAndSendHomeInput(fs3);
145145
assert_equals(document.activeElement.id, 'fs1');
146146
}, "Home goes to first item, not focusgroupstart item");
147147

148148
promise_test(async t => {
149-
await focusAndSendEndInput(document.getElementById('fs1'));
149+
await focusAndSendEndInput(fs1);
150150
assert_equals(document.activeElement.id, 'fs3');
151151
}, "End goes to last item, not focusgroupstart item");
152152

153153
// --- Home/End with opted-out elements ---
154154

155155
promise_test(async t => {
156-
await focusAndSendHomeInput(document.getElementById('oo4'));
156+
await focusAndSendHomeInput(oo4);
157157
assert_equals(document.activeElement.id, 'oo1');
158158
}, "Home skips opted-out elements and reaches first item");
159159

160160
promise_test(async t => {
161-
await focusAndSendEndInput(document.getElementById('oo1'));
161+
await focusAndSendEndInput(oo1);
162162
assert_equals(document.activeElement.id, 'oo4');
163163
}, "End skips opted-out elements and reaches last item");
164164

165165
// --- Home/End blocked inside key conflict elements ---
166166

167167
promise_test(async t => {
168-
await focusAndSendHomeInput(document.getElementById('kc2'));
168+
await focusAndSendHomeInput(kc2);
169169
assert_equals(document.activeElement.id, 'kc2');
170170
}, "Home inside text input does not navigate focusgroup");
171171

172172
promise_test(async t => {
173-
await focusAndSendEndInput(document.getElementById('kc2'));
173+
await focusAndSendEndInput(kc2);
174174
assert_equals(document.activeElement.id, 'kc2');
175175
}, "End inside text input does not navigate focusgroup");
176176

177177
// --- Home/End from a non-key-conflict element works ---
178178

179179
promise_test(async t => {
180-
await focusAndSendHomeInput(document.getElementById('kc3'));
180+
await focusAndSendHomeInput(kc3);
181181
assert_equals(document.activeElement.id, 'kc1');
182182
}, "Home from button navigates past key conflict element to first item");
183183

184184
promise_test(async t => {
185-
await focusAndSendEndInput(document.getElementById('kc1'));
185+
await focusAndSendEndInput(kc1);
186186
assert_equals(document.activeElement.id, 'kc3');
187187
}, "End from button navigates past key conflict element to last item");
188188

189189
// --- Home/End blocked inside other key conflict element types ---
190190

191191
promise_test(async t => {
192-
await focusAndSendHomeInput(document.getElementById('hc2'));
192+
await focusAndSendHomeInput(hc2);
193193
assert_equals(document.activeElement.id, 'hc2');
194194
}, "Home inside select does not navigate focusgroup");
195195

196196
promise_test(async t => {
197-
await focusAndSendEndInput(document.getElementById('hc2'));
197+
await focusAndSendEndInput(hc2);
198198
assert_equals(document.activeElement.id, 'hc2');
199199
}, "End inside select does not navigate focusgroup");
200200

201201
promise_test(async t => {
202-
await focusAndSendHomeInput(document.getElementById('hc3'));
202+
await focusAndSendHomeInput(hc3);
203203
assert_equals(document.activeElement.id, 'hc3');
204204
}, "Home inside textarea does not navigate focusgroup");
205205

206206
promise_test(async t => {
207-
await focusAndSendEndInput(document.getElementById('hc3'));
207+
await focusAndSendEndInput(hc3);
208208
assert_equals(document.activeElement.id, 'hc3');
209209
}, "End inside textarea does not navigate focusgroup");
210210
</script>

html/interaction/focus/focusgroup/tentative/shadow/shadow-items-basic.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
return a;
2727
}
2828
promise_test(async t => {
29-
const host = document.getElementById('host');
3029
const sr = host.attachShadow({mode: 'open'});
3130
sr.innerHTML = `
3231
<button id=item1 tabindex=0>One</button>

html/interaction/focus/focusgroup/tentative/shadow/shadow-nested-scope.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
return a;
2727
}
2828
promise_test(async t => {
29-
const host = document.getElementById('shadow_host');
29+
const host = shadow_host;
3030
const sr = host.attachShadow({mode: 'open'});
3131
sr.innerHTML = `
3232
<div id=inner_fg focusgroup="toolbar inline">
3333
<button id=inner1 tabindex=0>Inner 1</button>
3434
<button id=inner2 tabindex=0>Inner 2</button>
3535
</div>`;
36-
const outer1 = document.getElementById('outer1');
37-
const outer2 = document.getElementById('outer2');
3836
const inner1 = sr.getElementById('inner1');
3937
const inner2 = sr.getElementById('inner2');
4038

html/interaction/focus/focusgroup/tentative/top-layer-dialog-excluded.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
// still operates normally").
3333

3434
promise_test(async t => {
35-
const dlg = document.getElementById("dlg");
3635
dlg.showModal();
3736
t.add_cleanup(() => dlg.close());
3837

html/interaction/focus/focusgroup/tentative/top-layer-dynamic-exclusion.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<script>
4343

4444
promise_test(async t => {
45-
const pop = document.getElementById("pop");
4645
t.add_cleanup(() => pop.hidePopover());
4746

4847
// Hidden popover: items not rendered, naturally skipped. Guard against
@@ -72,7 +71,6 @@
7271
}, "Top-layer exclusion is dynamic: show and hide cycles");
7372

7473
promise_test(async t => {
75-
const pop = document.getElementById("pop");
7674
pop.showPopover();
7775
t.add_cleanup(() => pop.hidePopover());
7876

@@ -81,7 +79,6 @@
8179
}, "Wrapping navigation skips shown popover subtree");
8280

8381
promise_test(async t => {
84-
const pop = document.getElementById("pop");
8582
pop.showPopover();
8683
t.add_cleanup(() => pop.hidePopover());
8784

@@ -99,7 +96,7 @@
9996
}, "Home and End keys skip shown popover subtree");
10097

10198
promise_test(async t => {
102-
const pop_b = document.getElementById("pop_block");
99+
const pop_b = pop_block;
103100
pop_b.showPopover();
104101
t.add_cleanup(() => pop_b.hidePopover());
105102

@@ -113,8 +110,8 @@
113110
}, "Block-axis navigation skips shown popover subtree");
114111

115112
promise_test(async t => {
116-
const p1 = document.getElementById("pop_m1");
117-
const p2 = document.getElementById("pop_m2");
113+
const p1 = pop_m1;
114+
const p2 = pop_m2;
118115
p1.showPopover();
119116
p2.showPopover();
120117
t.add_cleanup(() => {

html/interaction/focus/focusgroup/tentative/top-layer-inner-focusgroup.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<script>
2424

2525
promise_test(async t => {
26-
const pop = document.getElementById("popover_fg");
26+
const pop = popover_fg;
2727
pop.showPopover();
2828
t.add_cleanup(() => pop.hidePopover());
2929

@@ -33,7 +33,7 @@
3333
}, "Popover with own focusgroup is excluded from ancestor arrow navigation");
3434

3535
promise_test(async t => {
36-
const pop = document.getElementById("popover_fg");
36+
const pop = popover_fg;
3737
pop.showPopover();
3838
t.add_cleanup(() => pop.hidePopover());
3939

@@ -59,7 +59,7 @@
5959
<script>
6060

6161
promise_test(async t => {
62-
const pop = document.getElementById("focusable_pop");
62+
const pop = focusable_pop;
6363
pop.showPopover();
6464
t.add_cleanup(() => pop.hidePopover());
6565

html/interaction/focus/focusgroup/tentative/top-layer-popover-excluded.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
<script>
2323

2424
promise_test(async t => {
25-
const pop = document.getElementById("popover_simple");
25+
const pop = popover_simple;
2626
pop.showPopover();
2727
t.add_cleanup(() => pop.hidePopover());
2828

2929
await assert_directional_navigation_bidirectional([before_pop, after_pop]);
3030
}, "Arrow navigation skips a shown popover in ancestor focusgroup");
3131

3232
promise_test(async t => {
33-
const pop = document.getElementById("popover_simple");
33+
const pop = popover_simple;
3434
pop.showPopover();
3535
t.add_cleanup(() => pop.hidePopover());
3636

@@ -59,7 +59,7 @@
5959
<script>
6060

6161
promise_test(async t => {
62-
const pop = document.getElementById("first_pop");
62+
const pop = first_pop;
6363
pop.showPopover();
6464
t.add_cleanup(() => pop.hidePopover());
6565

@@ -95,7 +95,7 @@
9595
<script>
9696

9797
promise_test(async t => {
98-
const pop = document.getElementById("seg_pop");
98+
const pop = seg_pop;
9999
pop.showPopover();
100100
t.add_cleanup(() => pop.hidePopover());
101101

@@ -125,7 +125,7 @@
125125
<script>
126126

127127
promise_test(async t => {
128-
const pop = document.getElementById("sib_pop");
128+
const pop = sib_pop;
129129
pop.showPopover();
130130
t.add_cleanup(() => pop.hidePopover());
131131

@@ -157,7 +157,7 @@
157157
<script>
158158

159159
promise_test(async t => {
160-
const pop = document.getElementById("none_pop");
160+
const pop = none_pop;
161161
pop.showPopover();
162162
t.add_cleanup(() => pop.hidePopover());
163163

0 commit comments

Comments
 (0)