fix(zone.js): should not try to patch fetch if it is not writable (#36311)
Close #36142 In Firefox extensions, the `window.fetch` is not configurable, that means ``` const desc = Object.getOwnPropertyDescriptor(window, 'fetch'); desc.writable === false; ``` So in this case, we should not try to patch `fetch`, otherwise, it will throw error ('fetch is ReadOnly`) PR Close #36311
This commit is contained in:
		
							parent
							
								
									93302b7fb8
								
							
						
					
					
						commit
						416c786774
					
				| @ -1,3 +1,5 @@ | ||||
| import {patchMethod} from './utils'; | ||||
| 
 | ||||
| /** | ||||
|  * @license | ||||
|  * Copyright Google Inc. All Rights Reserved. | ||||
| @ -500,8 +502,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr | ||||
|   api.patchThen = patchThen; | ||||
| 
 | ||||
|   function zoneify(fn: Function) { | ||||
|     return function(this: unknown) { | ||||
|       let resultPromise = fn.apply(this, arguments); | ||||
|     return function(self: any, args: any[]) { | ||||
|       let resultPromise = fn.apply(self, args); | ||||
|       if (resultPromise instanceof ZoneAwarePromise) { | ||||
|         return resultPromise; | ||||
|       } | ||||
| @ -515,11 +517,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr | ||||
| 
 | ||||
|   if (NativePromise) { | ||||
|     patchThen(NativePromise); | ||||
|     const fetch = global['fetch']; | ||||
|     if (typeof fetch == 'function') { | ||||
|       global[api.symbol('fetch')] = fetch; | ||||
|       global['fetch'] = zoneify(fetch); | ||||
|     } | ||||
|     patchMethod(global, 'fetch', delegate => zoneify(delegate)); | ||||
|   } | ||||
| 
 | ||||
|   // This is not part of public API, but it is useful for tests, so we expose it.
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user