@@ -675,6 +675,39 @@ function createWindowPair(origin = 'https://app.test'): { hostWin: FakeWindow, p
675675const fastHello = { helloIntervalMs : 5 , heartbeat : false as const }
676676
677677describe ( 'in-page channel handshake' , ( ) => {
678+ it . each ( [ 0 , 1 , 2 ] ) ( 'connects through a popup opener with %i nested panel frames' , async ( depth ) => {
679+ const { hostWin, panelWin } = createWindowPair ( )
680+ let popupWin = panelWin
681+ for ( let i = 0 ; i < depth ; i ++ ) {
682+ const parent = createFakeWindow ( hostWin . location . origin )
683+ popupWin . parent = parent
684+ popupWin = parent
685+ }
686+ popupWin . parent = popupWin
687+ popupWin . opener = hostWin
688+ const pageScript = createPageScriptChannel < TestProtocol > ( {
689+ name : 'devframes:test' ,
690+ window : asWindow ( hostWin ) ,
691+ heartbeat : false ,
692+ functions : defaultPageScriptFunctions ,
693+ } )
694+ const panel = connectPanelChannel < TestProtocol > ( {
695+ name : 'devframes:test' ,
696+ window : asWindow ( panelWin ) ,
697+ ...fastHello ,
698+ functions : defaultPanelFunctions ,
699+ } )
700+ try {
701+ await panel . whenConnected ( 200 )
702+ expect ( panel . pageScript ?. instanceId ) . toBe ( pageScript . instanceId )
703+ await expect ( panel . call ( 'echo' , 'popup' ) ) . resolves . toBe ( 'popup' )
704+ }
705+ finally {
706+ panel . close ( )
707+ pageScript . close ( )
708+ }
709+ } )
710+
678711 it ( 'connects a panel to the page script and survives page-script restarts' , async ( ) => {
679712 const { hostWin, panelWin } = createWindowPair ( )
680713 const pageScript = createPageScriptChannel < TestProtocol > ( {
0 commit comments