File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
testing/tests/DevExpress.ui Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ function readThemeMarker(): string | null {
6060 return null ;
6161 }
6262 return result . substr ( THEME_MARKER_PREFIX . length ) ;
63+ } catch ( e ) {
64+ return null ;
6365 } finally {
6466 element . remove ( ) ;
6567 }
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 = function ( ) { throw new Error ( 'getComputedStyle fails' ) ; } ;
834+
835+ try {
836+ themes . resetTheme ( ) ;
837+ const value = themes . current ( ) ;
838+ assert . strictEqual ( value , null , 'current() returns null on getComputedStyle error' ) ;
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 = function ( ) { throw new Error ( 'boom' ) ; } ;
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 with errors' ) ;
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