File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636
3737 fetchPolicy ( ) {
3838 let url = document . URL ;
39+
40+ let syncFetch = callback => {
41+ browser . runtime . sendSyncMessage (
42+ { id : "fetchPolicy" , url, contextUrl : url } ,
43+ callback ) ;
44+ } ;
45+
3946 debug ( `Fetching policy from document %s, readyState %s` ,
4047 url , document . readyState
4148 , document . documentElement . outerHTML , // DEV_ONLY
102109 // because it needs to be reparsed (e.g. broken / late charset declaration)
103110 // see https://forums.informaction.com/viewtopic.php?p=102850
104111 documentCSP . apply ( new Set ( ) ) ; // block everything to prevent leaks from page's event handlers
112+ try {
113+ syncFetch ( p => policy = p ) ; // user might have changed the permissions in the meanwhile...
114+ } catch ( e ) {
115+ error ( e ) ;
116+ }
105117 addEventListener ( "pagehide" , e => localPolicy . write ( policy ) , false ) ;
106118 } ;
107119 addEventListener ( "beforeunload" , onEarlyReload , false ) ;
137149
138150 for ( let attempts = 3 ; attempts -- > 0 ; ) {
139151 try {
140- browser . runtime . sendSyncMessage (
141- { id : "fetchPolicy" , url, contextUrl : url } ,
142- setup ) ;
152+ syncFetch ( setup ) ;
143153 break ;
144154 } catch ( e ) {
145155 if ( ! Messages . isMissingEndpoint ( e ) || document . readyState === "complete" ) {
You can’t perform that action at this time.
0 commit comments