@@ -433,6 +433,51 @@ suite('Utils', function () {
433433 Blockly . utils . dom . removeClass ( p , 'zero' ) ;
434434 assert . equal ( p . className , '' , 'Removing "zero"' ) ;
435435 } ) ;
436+
437+ suite ( 'createSvgElement' , function ( ) {
438+ test ( 'svg elements of type g have the generic role by default' , function ( ) {
439+ const svgG = Blockly . utils . dom . createSvgElement (
440+ Blockly . utils . Svg . G ,
441+ { } ,
442+ ) ;
443+ const g = Blockly . utils . dom . createSvgElement ( 'g' , { } ) ;
444+ assert . equal ( svgG . getAttribute ( 'role' ) , 'generic' ) ;
445+ assert . equal ( g . getAttribute ( 'role' ) , 'generic' ) ;
446+ } ) ;
447+ test ( 'svg elements of type svg have the generic role by default' , function ( ) {
448+ const svgSvg = Blockly . utils . dom . createSvgElement (
449+ Blockly . utils . Svg . SVG ,
450+ { } ,
451+ ) ;
452+ const svg = Blockly . utils . dom . createSvgElement ( 'svg' , { } ) ;
453+ assert . equal ( svgSvg . getAttribute ( 'role' ) , 'generic' ) ;
454+ assert . equal ( svg . getAttribute ( 'role' ) , 'generic' ) ;
455+ } ) ;
456+ test ( 'svg elements of type g reflect the role passed in when created' , function ( ) {
457+ const svgG = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . G , {
458+ role : 'button' ,
459+ } ) ;
460+ const g = Blockly . utils . dom . createSvgElement ( 'g' , { role : 'button' } ) ;
461+ assert . equal ( svgG . getAttribute ( 'role' ) , 'button' ) ;
462+ assert . equal ( g . getAttribute ( 'role' ) , 'button' ) ;
463+ } ) ;
464+ test ( 'svg elements of type svg reflect the role passed in when created' , function ( ) {
465+ const svgSvg = Blockly . utils . dom . createSvgElement (
466+ Blockly . utils . Svg . SVG ,
467+ { role : 'button' } ,
468+ ) ;
469+ const svg = Blockly . utils . dom . createSvgElement ( 'svg' , { role : 'button' } ) ;
470+ assert . equal ( svgSvg . getAttribute ( 'role' ) , 'button' ) ;
471+ assert . equal ( svg . getAttribute ( 'role' ) , 'button' ) ;
472+ } ) ;
473+ test ( 'other svg elements do not default to generic role' , function ( ) {
474+ const textElement = Blockly . utils . dom . createSvgElement (
475+ Blockly . utils . Svg . TEXT ,
476+ { } ,
477+ ) ;
478+ assert . equal ( textElement . getAttribute ( 'role' ) , null ) ;
479+ } ) ;
480+ } ) ;
436481 } ) ;
437482
438483 suite ( 'String' , function ( ) {
0 commit comments