@@ -358,6 +358,72 @@ describe('color.getBackgroundColor', function() {
358
358
assert . deepEqual ( bgNodes , [ parent ] ) ;
359
359
} ) ;
360
360
361
+ it ( 'should count a THEAD as a background element for a child element' , function ( ) {
362
+ fixture . innerHTML =
363
+ '<div style="background-color:#007acc;">' +
364
+ '<table style="width:100%">' +
365
+ '<thead style="background-color:#f3f3f3; height:40px;" id="parent">' +
366
+ '<td>' +
367
+ '<span style="color:#007acc" id="target">Cell content</span>' +
368
+ '</td></thead>' +
369
+ '</table></div>' ;
370
+ var target = fixture . querySelector ( '#target' ) ,
371
+ parent = fixture . querySelector ( '#parent' ) ;
372
+ var bgNodes = [ ] ;
373
+ axe . testUtils . flatTreeSetup ( fixture . firstChild ) ;
374
+ var actual = axe . commons . color . getBackgroundColor ( target , bgNodes ) ;
375
+ var expected = new axe . commons . color . Color ( 243 , 243 , 243 , 1 ) ;
376
+ assert . equal ( actual . red , expected . red ) ;
377
+ assert . equal ( actual . green , expected . green ) ;
378
+ assert . equal ( actual . blue , expected . blue ) ;
379
+ assert . equal ( actual . alpha , expected . alpha ) ;
380
+ assert . deepEqual ( bgNodes , [ parent ] ) ;
381
+ } ) ;
382
+
383
+ it ( 'should count a TBODY as a background element for a child element' , function ( ) {
384
+ fixture . innerHTML =
385
+ '<div style="background-color:#007acc;">' +
386
+ '<table style="width:100%">' +
387
+ '<tbody style="background-color:#f3f3f3; height:40px;" id="parent">' +
388
+ '<td>' +
389
+ '<span style="color:#007acc" id="target">Cell content</span>' +
390
+ '</td></tbody>' +
391
+ '</table></div>' ;
392
+ var target = fixture . querySelector ( '#target' ) ,
393
+ parent = fixture . querySelector ( '#parent' ) ;
394
+ var bgNodes = [ ] ;
395
+ axe . testUtils . flatTreeSetup ( fixture . firstChild ) ;
396
+ var actual = axe . commons . color . getBackgroundColor ( target , bgNodes ) ;
397
+ var expected = new axe . commons . color . Color ( 243 , 243 , 243 , 1 ) ;
398
+ assert . equal ( actual . red , expected . red ) ;
399
+ assert . equal ( actual . green , expected . green ) ;
400
+ assert . equal ( actual . blue , expected . blue ) ;
401
+ assert . equal ( actual . alpha , expected . alpha ) ;
402
+ assert . deepEqual ( bgNodes , [ parent ] ) ;
403
+ } ) ;
404
+
405
+ it ( 'should count a TFOOT as a background element for a child element' , function ( ) {
406
+ fixture . innerHTML =
407
+ '<div style="background-color:#007acc;">' +
408
+ '<table style="width:100%">' +
409
+ '<tfoot style="background-color:#f3f3f3; height:40px;" id="parent">' +
410
+ '<td>' +
411
+ '<span style="color:#007acc" id="target">Cell content</span>' +
412
+ '</td></tfoot>' +
413
+ '</table></div>' ;
414
+ var target = fixture . querySelector ( '#target' ) ,
415
+ parent = fixture . querySelector ( '#parent' ) ;
416
+ var bgNodes = [ ] ;
417
+ axe . testUtils . flatTreeSetup ( fixture . firstChild ) ;
418
+ var actual = axe . commons . color . getBackgroundColor ( target , bgNodes ) ;
419
+ var expected = new axe . commons . color . Color ( 243 , 243 , 243 , 1 ) ;
420
+ assert . equal ( actual . red , expected . red ) ;
421
+ assert . equal ( actual . green , expected . green ) ;
422
+ assert . equal ( actual . blue , expected . blue ) ;
423
+ assert . equal ( actual . alpha , expected . alpha ) ;
424
+ assert . deepEqual ( bgNodes , [ parent ] ) ;
425
+ } ) ;
426
+
361
427
it ( "should ignore TR elements that don't overlap" , function ( ) {
362
428
fixture . innerHTML =
363
429
'<table style="position:relative; width:100%;">' +
0 commit comments