@@ -134,30 +134,41 @@ describe("codeHighlight", () => {
134134 } ) ;
135135
136136 it ( "updates fallback styles while the shadow host is still detached" , ( ) => {
137- initHighlighting ( ) ;
138- const host = document . createElement ( "div" ) ;
139- const shadow = host . attachShadow ( { mode : "open" } ) ;
140- Object . defineProperty ( shadow , "adoptedStyleSheets" , {
141- configurable : true ,
142- get ( ) {
143- throw new Error ( "adoptedStyleSheets unavailable" ) ;
144- } ,
145- set ( ) {
146- throw new Error ( "adoptedStyleSheets unavailable" ) ;
147- } ,
148- } ) ;
149-
150- applyHighlightStyles ( shadow ) ;
151- const style = shadow . querySelector ( "#cm-static-highlight-styles" ) ;
152- expect ( style ) . toBeTruthy ( ) ;
153- expect ( style . isConnected ) . toBe ( false ) ;
154- expect ( style . textContent ) . toContain ( "#c678dd" ) ;
155-
156- settings . value . editorTheme = "githubLight" ;
157- for ( const listener of themeListeners ) listener ( ) ;
158-
159- expect ( style . parentNode ) . toBe ( shadow ) ;
160- expect ( style . textContent ) . toContain ( "#cf222e" ) ;
137+ const warn = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
138+ try {
139+ initHighlighting ( ) ;
140+ const host = document . createElement ( "div" ) ;
141+ const shadow = host . attachShadow ( { mode : "open" } ) ;
142+ Object . defineProperty ( shadow , "adoptedStyleSheets" , {
143+ configurable : true ,
144+ get ( ) {
145+ throw new Error ( "adoptedStyleSheets unavailable" ) ;
146+ } ,
147+ set ( ) {
148+ throw new Error ( "adoptedStyleSheets unavailable" ) ;
149+ } ,
150+ } ) ;
151+
152+ applyHighlightStyles ( shadow ) ;
153+ const style = shadow . querySelector ( "#cm-static-highlight-styles" ) ;
154+ expect ( style ) . toBeTruthy ( ) ;
155+ expect ( style . isConnected ) . toBe ( false ) ;
156+ expect ( style . textContent ) . toContain ( "#c678dd" ) ;
157+
158+ settings . value . editorTheme = "githubLight" ;
159+ for ( const listener of themeListeners ) listener ( ) ;
160+
161+ expect ( style . parentNode ) . toBe ( shadow ) ;
162+ expect ( style . textContent ) . toContain ( "#cf222e" ) ;
163+ expect ( warn ) . toHaveBeenCalledWith (
164+ "Failed to adopt highlight stylesheet" ,
165+ expect . objectContaining ( {
166+ message : "adoptedStyleSheets unavailable" ,
167+ } ) ,
168+ ) ;
169+ } finally {
170+ warn . mockRestore ( ) ;
171+ }
161172 } ) ;
162173
163174 it ( "updates adopted shadow styles when the editor theme changes" , ( ) => {
0 commit comments