@@ -14,6 +14,7 @@ suite('Toasts', function () {
1414 setup ( function ( ) {
1515 sharedTestSetup . call ( this ) ;
1616 this . workspace = Blockly . inject ( 'blocklyDiv' , { } ) ;
17+ this . liveRegion = document . getElementById ( 'blocklyAriaAnnounce' ) ;
1718 this . toastIsVisible = ( message ) => {
1819 const toast = this . workspace
1920 . getInjectionDiv ( )
@@ -97,16 +98,20 @@ suite('Toasts', function () {
9798 clock . restore ( ) ;
9899 } ) ;
99100
100- test ( 'default to polite assertiveness' , function ( ) {
101+ test ( 'toast announces message with status role and polite assertiveness' , function ( ) {
101102 const message = 'texas toast' ;
102103 Blockly . Toast . show ( this . workspace , { message, id : 'test' } ) ;
103- const toast = this . workspace
104- . getInjectionDiv ( )
105- . querySelector ( '.blocklyToast' ) ;
106104
105+ this . clock . tick ( 11 ) ;
106+
107+ assert . include ( this . liveRegion . textContent , message ) ;
107108 assert . equal (
108- toast . getAttribute ( 'aria-live' ) ,
109- Blockly . Toast . Assertiveness . POLITE ,
109+ this . liveRegion . getAttribute ( 'role' ) ,
110+ Blockly . utils . aria . Role . STATUS ,
111+ ) ;
112+ assert . equal (
113+ this . liveRegion . getAttribute ( 'aria-live' ) ,
114+ Blockly . utils . aria . LiveRegionAssertiveness . POLITE ,
110115 ) ;
111116 } ) ;
112117
@@ -115,15 +120,26 @@ suite('Toasts', function () {
115120 Blockly . Toast . show ( this . workspace , {
116121 message,
117122 id : 'test' ,
118- assertiveness : Blockly . Toast . Assertiveness . ASSERTIVE ,
123+ assertiveness : Blockly . utils . aria . LiveRegionAssertiveness . ASSERTIVE ,
119124 } ) ;
125+
126+ this . clock . tick ( 11 ) ;
127+
128+ assert . equal (
129+ this . liveRegion . getAttribute ( 'aria-live' ) ,
130+ Blockly . utils . aria . LiveRegionAssertiveness . ASSERTIVE ,
131+ ) ;
132+ } ) ;
133+
134+ test ( 'toast is not itself a live region' , function ( ) {
135+ const message = 'texas toast' ;
136+ Blockly . Toast . show ( this . workspace , { message, id : 'test' } ) ;
137+
120138 const toast = this . workspace
121139 . getInjectionDiv ( )
122140 . querySelector ( '.blocklyToast' ) ;
123141
124- assert . equal (
125- toast . getAttribute ( 'aria-live' ) ,
126- Blockly . Toast . Assertiveness . ASSERTIVE ,
127- ) ;
142+ assert . isNull ( toast . getAttribute ( 'aria-live' ) ) ;
143+ assert . notEqual ( toast . getAttribute ( 'role' ) , Blockly . utils . aria . Role . STATUS ) ;
128144 } ) ;
129145} ) ;
0 commit comments