@@ -91,6 +91,7 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
9191 const normalizedError = createNormalizedError ( Native ) ;
9292 const {
9393 nativeFunctionSource,
94+ nativeAccessorSource,
9495 maskNativeFunction,
9596 maskMethods,
9697 define,
@@ -112,6 +113,23 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
112113 return define ( obj , key , value ) ;
113114 }
114115 }
116+ function defineReplacingAccessor ( obj , key , get , set ) {
117+ if ( ! obj ) return false ;
118+ const d = Object . getOwnPropertyDescriptor ( obj , key ) ;
119+ try {
120+ Object . defineProperty ( obj , key , {
121+ get,
122+ set,
123+ enumerable : d ? d . enumerable : true ,
124+ configurable : d ? d . configurable : true
125+ } ) ;
126+ if ( typeof get === 'function' ) toStringMap . set ( get , nativeAccessorSource ( 'get' , key ) ) ;
127+ if ( typeof set === 'function' ) toStringMap . set ( set , nativeAccessorSource ( 'set' , key ) ) ;
128+ return true ;
129+ } catch {
130+ return defineAccessor ( obj , key , get , set ) ;
131+ }
132+ }
115133 const {
116134 installCanvasAntiFingerprinting,
117135 installAudioAntiFingerprinting,
@@ -136,6 +154,7 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
136154 boot,
137155 Native,
138156 defineAccessor,
157+ defineReplacingAccessor,
139158 getVirtualURL : ( ) => virtualURL ,
140159 getBaseURL : ( ) => baseURL ,
141160 postMessageToSW,
@@ -660,6 +679,18 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
660679 catch { return false ; }
661680 }
662681
682+ function isInitialAboutBlankFrame ( frame , childWin ) {
683+ if ( ! frame || isSrcdocFrame ( frame ) ) return false ;
684+ try {
685+ if ( Native . getAttribute . call ( frame , 'data-zp-target-url' ) || Native . getAttribute . call ( frame , 'data-zp-blocked-url' ) ) return false ;
686+ const rawSrc = String ( Native . getAttribute . call ( frame , 'src' ) || '' ) . trim ( ) . toLowerCase ( ) ;
687+ if ( rawSrc && rawSrc !== 'about:blank' ) return false ;
688+ return true ;
689+ } catch {
690+ return false ;
691+ }
692+ }
693+
663694 function frameLocationFacadeFor ( frame , childDoc , childWin ) {
664695 const current = ( ) => {
665696 try { return new URL ( frameDocumentURL ( frame , childDoc , childWin ) ) ; }
@@ -695,7 +726,7 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
695726 if ( prop === Symbol . toStringTag ) return 'Window' ;
696727 if ( prop === 'window' || prop === 'self' || prop === 'globalThis' || prop === 'frames' ) return proxy ;
697728 if ( prop === 'location' ) return locationFacade ;
698- if ( prop === 'origin' ) return locationFacade . origin ;
729+ if ( prop === 'origin' ) return isInitialAboutBlankFrame ( frame , childWin ) ? virtualURL . origin : locationFacade . origin ;
699730 if ( prop === 'postMessage' ) return postMessageWrapperFor ( childWin ) ;
700731 if ( prop === 'document' ) {
701732 try { return frameDocumentFacadeFor ( frame , childWin . document , childWin ) ; } catch { return undefined ; }
@@ -778,6 +809,14 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
778809 if ( prop === Symbol . toStringTag ) return 'HTMLDocument' ;
779810 if ( prop === 'defaultView' ) return windowFacade ;
780811 if ( prop === 'location' ) return locationFacade ;
812+ if ( isInitialAboutBlankFrame ( frame , childWin ) ) {
813+ if ( prop === 'URL' || prop === 'documentURI' ) return 'about:blank' ;
814+ if ( prop === 'referrer' ) return virtualURL . href ;
815+ if ( prop === 'domain' ) return virtualURL . hostname ;
816+ if ( prop === 'cookie' ) {
817+ try { return document . cookie ; } catch { return '' ; }
818+ }
819+ }
781820 if ( prop === 'URL' || prop === 'documentURI' ) return locationFacade . href ;
782821 const value = childDoc [ prop ] ;
783822 return typeof value === 'function' ? value . bind ( childDoc ) : value ;
@@ -1164,6 +1203,7 @@ import { createWorkerFacades } from './runtime/workers/facades.mjs';
11641203 installDynamicCodeHooks ( ) ;
11651204 installDocumentWriteHooks ( root ) ;
11661205 }
1206+
11671207 function fireEvent ( target , type ) {
11681208 let ev ;
11691209 try { ev = new Event ( type ) ; } catch { ev = { type } ; }
0 commit comments