@@ -371,6 +371,9 @@ describe("shadow reload readiness and failure", () => {
371371 expect ( getApi ( ) . iframeRef . current ) . toBe ( live ) ;
372372 expect ( live . style . visibility ) . toBe ( "" ) ;
373373 expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith ( expect . stringContaining ( "too long" ) ) ;
374+ expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith (
375+ expect . stringContaining ( "still waiting for the page and its runtime to load" ) ,
376+ ) ;
374377 expect ( consoleError ) . toHaveBeenCalled ( ) ;
375378 unmount ( root ) ;
376379 } ) ;
@@ -395,6 +398,48 @@ describe("shadow reload readiness and failure", () => {
395398 act ( ( ) => void vi . advanceTimersByTime ( 1 ) ) ;
396399 expect ( getApi ( ) . previewSlots ) . toEqual ( [ { gen : 0 , role : "live" } ] ) ;
397400 expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith ( expect . stringContaining ( "too long" ) ) ;
401+ expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith (
402+ expect . stringContaining ( "still waiting for the page and its runtime to load" ) ,
403+ ) ;
404+ unmount ( root ) ;
405+ } ) ;
406+
407+ it ( "names the timeline when a shadow's runtime runs but never reports a length" , ( ) => {
408+ vi . useFakeTimers ( ) ;
409+ vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
410+ const onPreviewReloadFailed = vi . fn ( ) ;
411+ const { getApi, gen, root } = beginReload ( { onPreviewReloadFailed } ) ;
412+ const lengthless = makeFakeIframe ( makeAdapterWindow ( { duration : 0 } ) . win ) ;
413+ act ( ( ) => {
414+ getApi ( ) . setShadowIframeNode ( lengthless ) ;
415+ getApi ( ) . onShadowIframeLoad ( gen ) ;
416+ getApi ( ) . onShadowReadyChange ( gen , true ) ;
417+ } ) ;
418+
419+ act ( ( ) => void vi . advanceTimersByTime ( FULL_WAIT_MS ) ) ;
420+
421+ expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith (
422+ expect . stringContaining ( "still waiting for its timeline to be ready" ) ,
423+ ) ;
424+ unmount ( root ) ;
425+ } ) ;
426+
427+ it ( "names the loaders when a shadow with a ready timeline never clears them" , ( ) => {
428+ vi . useFakeTimers ( ) ;
429+ vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
430+ const onPreviewReloadFailed = vi . fn ( ) ;
431+ const { getApi, gen, root } = beginReload ( { onPreviewReloadFailed } ) ;
432+ const shadow = makeShadowWithSpies ( ) ;
433+ act ( ( ) => {
434+ getApi ( ) . setShadowIframeNode ( shadow . iframe ) ;
435+ getApi ( ) . onShadowIframeLoad ( gen ) ;
436+ } ) ;
437+
438+ act ( ( ) => void vi . advanceTimersByTime ( FULL_WAIT_MS ) ) ;
439+
440+ expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith (
441+ expect . stringContaining ( "still waiting for its loaders to clear" ) ,
442+ ) ;
398443 unmount ( root ) ;
399444 } ) ;
400445
@@ -475,6 +520,31 @@ describe("shadow reload readiness and failure", () => {
475520 unmount ( root ) ;
476521 } ) ;
477522
523+ it ( "still drops and reports a shadow whose window throws on access" , ( ) => {
524+ vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
525+ const onPreviewReloadFailed = vi . fn ( ) ;
526+ const { getApi, live, gen, root } = beginReload ( { onPreviewReloadFailed } ) ;
527+ const crossOrigin = makeFakeIframe (
528+ Object . defineProperty ( { } , "__player" , {
529+ get : ( ) => {
530+ throw new DOMException ( "Blocked a frame" , "SecurityError" ) ;
531+ } ,
532+ } ) ,
533+ ) ;
534+ act ( ( ) => getApi ( ) . setShadowIframeNode ( crossOrigin ) ) ;
535+
536+ act ( ( ) => getApi ( ) . onShadowError ( gen , "Composition timeline not found after 8s" ) ) ;
537+
538+ expect ( getApi ( ) . previewSlots ) . toEqual ( [ { gen : 0 , role : "live" } ] ) ;
539+ expect ( getApi ( ) . iframeRef . current ) . toBe ( live ) ;
540+ expect ( isPreviewChanging ( ) ) . toBe ( false ) ;
541+ expect ( onPreviewReloadFailed ) . toHaveBeenCalledTimes ( 1 ) ;
542+ expect ( onPreviewReloadFailed ) . toHaveBeenCalledWith (
543+ expect . stringContaining ( "still waiting for the page and its runtime to load" ) ,
544+ ) ;
545+ unmount ( root ) ;
546+ } ) ;
547+
478548 it ( "drops a shadow whose document reports an error and reports the cause" , ( ) => {
479549 vi . spyOn ( console , "error" ) . mockImplementation ( ( ) => { } ) ;
480550 const onPreviewReloadFailed = vi . fn ( ) ;
0 commit comments