File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
testing/tests/DevExpress.ui Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ function readThemeMarker(): string | null {
5050 let result : string ;
5151
5252 try {
53+ if ( ! window ?. getComputedStyle ) {
54+ return null ;
55+ }
5356 result = window . getComputedStyle ( element . get ( 0 ) ) . fontFamily ;
5457 if ( ! result ) {
5558 return null ;
Original file line number Diff line number Diff line change @@ -825,3 +825,39 @@ QUnit.module('initialized method', (hooks) => {
825825 } ) ;
826826 } ) ;
827827} ) ;
828+
829+ QUnit . module ( 'readThemeMarker error handling' , ( ) => {
830+ test ( 'readThemeMarker returns null when getComputedStyle throws an error' , function ( assert ) {
831+ const done = assert . async ( ) ;
832+ const originalGetComputedStyle = window . getComputedStyle ;
833+ window . getComputedStyle = undefined ;
834+
835+ try {
836+ themes . resetTheme ( ) ;
837+ const value = themes . current ( ) ;
838+ assert . strictEqual ( value , null , 'current() returns null on getComputedStyle being undefined' ) ;
839+ } finally {
840+ window . getComputedStyle = originalGetComputedStyle ;
841+ done ( ) ;
842+ }
843+ } ) ;
844+
845+ test ( 'waitForThemeLoad resolves even if getComputedStyle continuously throws' , function ( assert ) {
846+ const done = assert . async ( ) ;
847+ const originalGetComputedStyle = window . getComputedStyle ;
848+ window . getComputedStyle = undefined ;
849+
850+ const TEST_TIMEOUT = 30 ;
851+ themes . resetTheme ( ) ;
852+ themes . setDefaultTimeout ( TEST_TIMEOUT ) ;
853+
854+ themes . ready ( ( ) => {
855+ assert . strictEqual ( themes . current ( ) , null , 'theme remains null after timeout' ) ;
856+ window . getComputedStyle = originalGetComputedStyle ;
857+ themes . setDefaultTimeout ( defaultTimeout ) ;
858+ done ( ) ;
859+ } ) ;
860+
861+ themes . waitForThemeLoad ( 'some.nonexistent.theme' ) ;
862+ } ) ;
863+ } ) ;
You can’t perform that action at this time.
0 commit comments