@@ -1336,16 +1336,55 @@ describe('ModeBar', function() {
13361336 . then ( done ) ;
13371337 } ) ;
13381338
1339- it ( 'changes background color' , function ( done ) {
1339+ it ( 'changes background color (displayModeBar: hover)' , function ( done ) {
1340+ function getStyleRule ( ) {
1341+ var uid = gd . _fullLayout . _uid ;
1342+ var ownerNode = document . getElementById ( 'plotly.js-style-modebar-' + uid ) ;
1343+ var styleSheets = document . styleSheets ;
1344+ for ( var i = 0 ; i < styleSheets . length ; i ++ ) {
1345+ var ss = styleSheets [ i ] ;
1346+ if ( ss . ownerNode === ownerNode ) return ss ;
1347+ }
1348+ }
1349+
13401350 Plotly . plot ( gd , [ ] , { modebar : { bgcolor : colors [ 0 ] } } )
1351+ . then ( function ( ) {
1352+ style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1353+ expect ( style . backgroundColor ) . toBe ( 'rgba(0, 0, 0, 0)' ) ;
1354+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1355+ } )
1356+ . then ( function ( ) { Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
1357+ . then ( function ( ) {
1358+ style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
1359+ expect ( style . backgroundColor ) . toBe ( 'rgba(0, 0, 0, 0)' ) ;
1360+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1361+ } )
1362+ . catch ( failTest )
1363+ . then ( done ) ;
1364+ } ) ;
1365+
1366+ it ( 'changes background color (displayModeBar: true)' , function ( done ) {
1367+ function getStyleRule ( ) {
1368+ var uid = gd . _fullLayout . _uid ;
1369+ var ownerNode = document . getElementById ( 'plotly.js-style-modebar-' + uid ) ;
1370+ var styleSheets = document . styleSheets ;
1371+ for ( var i = 0 ; i < styleSheets . length ; i ++ ) {
1372+ var ss = styleSheets [ i ] ;
1373+ if ( ss . ownerNode === ownerNode ) return ss ;
1374+ }
1375+ }
1376+
1377+ Plotly . plot ( gd , [ ] , { modebar : { bgcolor : colors [ 0 ] } } , { displayModeBar : true } )
13411378 . then ( function ( ) {
13421379 style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
13431380 expect ( style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
1381+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 0 ] ) ;
13441382 } )
13451383 . then ( function ( ) { Plotly . relayout ( gd , 'modebar.bgcolor' , colors [ 1 ] ) ; } )
13461384 . then ( function ( ) {
13471385 style = window . getComputedStyle ( gd . _fullLayout . _modeBar . element ) ;
13481386 expect ( style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
1387+ expect ( getStyleRule ( ) . rules [ 3 ] . style . backgroundColor ) . toBe ( colors [ 1 ] ) ;
13491388 } )
13501389 . catch ( failTest )
13511390 . then ( done ) ;
0 commit comments