@@ -10,6 +10,7 @@ import {
1010 installGlobals , freshViewer , fireHostMessage , parentMessages , advanceClock ,
1111} from './stub-dom.mjs' ;
1212import { createMockRfb } from './mock-rfb.mjs' ;
13+ import { makeHostWindow } from './host-stub.mjs' ;
1314
1415installGlobals ( 'ios' , { embedded : true , search : '?parentOrigin=https://portal.test' } ) ;
1516
@@ -52,3 +53,21 @@ test('the RTT read obeys the fail-closed inbound gate (wrong origin ignored)', a
5253 fireHostMessage ( { type : 'POPCORN_RTT_REQUEST' } , { origin : 'https://evil.example' } ) ;
5354 assert . equal ( lastRttMsg ( ) , null , 'request from a non-configured origin is dropped' ) ;
5455} ) ;
56+
57+ // ---- host side (PopcornHost SDK) ----------------------------------------
58+
59+ test ( 'PopcornHost.requestRtt posts the request and surfaces the reply as .on(\'rtt\')' , async ( ) => {
60+ const h = makeHostWindow ( { top : true , iframeStyle : { position : 'fixed' } ,
61+ iframeRect : { left : 0 , top : 0 , width : 411 , height : 732 } } ) ;
62+ const host = h . PopcornHost . attach ( h . iframe , { childOrigin : 'https://pod.test' } ) ;
63+
64+ const got = [ ] ;
65+ host . on ( 'rtt' , ( d ) => got . push ( d ) ) ;
66+ host . requestRtt ( ) ;
67+ assert . ok ( h . posted . some ( ( m ) => m . type === 'POPCORN_RTT_REQUEST' ) , 'request posted to the frame' ) ;
68+
69+ h . fromChild ( { type : 'POPCORN_RTT' , rttMs : 86 , avgMs : 92 , samples : 41 } ) ;
70+ assert . equal ( got . length , 1 , 'rtt event emitted' ) ;
71+ assert . equal ( got [ 0 ] . rttMs , 86 ) ;
72+ assert . equal ( got [ 0 ] . samples , 41 ) ;
73+ } ) ;
0 commit comments