File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 8686 debug ( "Fetching policy for actual URL %s (was %s)" , url , document . URL ) ;
8787 }
8888
89- debug ( `Synchronously fetching policy for ${ url } .` ) ;
9089 if ( this . syncFetchPolicy ) {
9190 // extra hops to ensure that scripts don't run when CSP has not been set through HTTP headers
9291 this . syncFetchPolicy ( ) ;
9392 } else {
94- this . setup (
95- browser . runtime . sendSyncMessage ( { id : "fetchPolicy" , url, contextUrl : url } )
96- ) ;
93+ let msg = { id : "fetchPolicy" , url, contextUrl : url } ;
94+ if ( document . readyState === "complete" ) {
95+ // no point fetching synchronously, since the document is already loaded (hot extension update?)
96+ ( async ( ) => this . setup ( await browser . runtime . sendMessage ( msg ) ) ) ( ) ;
97+ } else {
98+ debug ( `Synchronously fetching policy for ${ url } .` ) ;
99+ this . setup ( browser . runtime . sendSyncMessage ( msg ) ) ;
100+ }
97101 }
98102 } ,
99103
You can’t perform that action at this time.
0 commit comments