@@ -7,7 +7,7 @@ describe("inert", () => {
77 document . body . innerHTML = "" ;
88 } ) ;
99
10- it ( "should hide inert elements from the tree unless they are modal dialog (non-native)" , async ( ) => {
10+ it ( "should hide inert elements from the tree unless they are modal dialog (non-native dialog )" , async ( ) => {
1111 document . body . innerHTML = `<p>visible paragraph</p>
1212<p inert>hidden paragraph</p>
1313
@@ -116,4 +116,59 @@ describe("inert", () => {
116116 "end of dialog, visible dialog heading 5" ,
117117 ] ) ;
118118 } ) ;
119+
120+ it ( "should hide inert elements from the tree unless they are modal dialog (alertdialog)" , async ( ) => {
121+ document . body . innerHTML = `<p>visible paragraph</p>
122+ <p inert>hidden paragraph</p>
123+
124+ <!-- Explicitly inert modal dialog should be inert -->
125+ <div aria-labelledby="dialog-heading-1" aria-modal="true" inert role="alertdialog">
126+ <h1 id="dialog-heading-1">hidden dialog heading 1</h1>
127+ </div>
128+
129+ <!-- Explicitly inert dialog should be inert -->
130+ <div aria-labelledby="dialog-heading-2" inert role="alertdialog">
131+ <h1 id="dialog-heading-2">hidden dialog heading 2</h1>
132+ </div>
133+
134+ <div inert>
135+ <p>hidden paragraph</p>
136+
137+ <!-- Explicitly inert modal dialog should be inert -->
138+ <div aria-labelledby="dialog-heading-3" aria-modal="true" inert role="alertdialog">
139+ <h1 id="dialog-heading-3">hidden dialog heading 3</h1>
140+ </div>
141+
142+ <!-- Non-modal dialog should inherit inert -->
143+ <div aria-labelledby="dialog-heading-4" role="alertdialog">
144+ <h1 id="dialog-heading-4">hidden dialog heading 4</h1>
145+ </div>
146+
147+ <!-- Modal dialog should not inherit inert -->
148+ <div aria-labelledby="dialog-heading-5" aria-modal="true" role="alertdialog">
149+ <h1 id="dialog-heading-5">visible dialog heading 5</h1>
150+ </div>
151+ </div>
152+ ` ;
153+
154+ await virtual . start ( { container : document . body } ) ;
155+
156+ while (
157+ ( await virtual . lastSpokenPhrase ( ) ) !==
158+ "end of alertdialog, visible dialog heading 5, modal"
159+ ) {
160+ await virtual . next ( ) ;
161+ }
162+
163+ expect ( await virtual . spokenPhraseLog ( ) ) . toEqual ( [
164+ "document" ,
165+ "paragraph" ,
166+ "visible paragraph" ,
167+ "end of paragraph" ,
168+ "alertdialog, visible dialog heading 5, modal" ,
169+ "alertdialog, visible dialog heading 5, modal" ,
170+ "heading, visible dialog heading 5, level 1" ,
171+ "end of alertdialog, visible dialog heading 5, modal" ,
172+ ] ) ;
173+ } ) ;
119174} ) ;
0 commit comments