mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	LibWeb: Correctly categorize Fetch responses as network errors
The condition here is flipped. From the spec:
     A network error is a response whose ... body is null ...
			
			
This commit is contained in:
		
							parent
							
								
									b317620486
								
							
						
					
					
						commit
						2b22402c6a
					
				
					 3 changed files with 39 additions and 1 deletions
				
			
		
							
								
								
									
										3
									
								
								Tests/LibWeb/Text/expected/video-failed-load.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Tests/LibWeb/Text/expected/video-failed-load.txt
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| failed to load: "data:" | ||||
| failed to load: "file:///i-do-no-exist-i-swear" | ||||
| failed to load: "https://i-do-no-exist-i-swear.net.uk" | ||||
							
								
								
									
										35
									
								
								Tests/LibWeb/Text/input/video-failed-load.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								Tests/LibWeb/Text/input/video-failed-load.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| <script src="include.js"></script> | ||||
| <script type="text/javascript"> | ||||
|     const SOURCES = [ | ||||
|         "data:", | ||||
|         "file:///i-do-no-exist-i-swear", | ||||
|         "https://i-do-no-exist-i-swear.net.uk", | ||||
|     ]; | ||||
| 
 | ||||
|     const runTest = source => { | ||||
|         let video = document.createElement("video"); | ||||
| 
 | ||||
|         return new Promise((resolve, reject) => { | ||||
|             video.addEventListener("loadedmetadata", () => { | ||||
|                 reject(`successfully loaded: "${video.src}"`); | ||||
|             }); | ||||
| 
 | ||||
|             video.addEventListener("error", () => { | ||||
|                 resolve(`failed to load: "${video.src}"`); | ||||
|             }); | ||||
| 
 | ||||
|             video.src = source; | ||||
|         }); | ||||
|     }; | ||||
| 
 | ||||
|     asyncTest(done => { | ||||
|         let promises = SOURCES.map(source => runTest(source)); | ||||
| 
 | ||||
|         Promise.allSettled(promises) | ||||
|             .then(results => { | ||||
|                 const values = results.map(result => result.value); | ||||
|                 values.sort().forEach(println); | ||||
|             }) | ||||
|             .finally(done); | ||||
|     }); | ||||
| </script> | ||||
|  | @ -96,7 +96,7 @@ bool Response::is_network_error() const | |||
|         return false; | ||||
|     if (!header_list()->is_empty()) | ||||
|         return false; | ||||
|     if (!body()) | ||||
|     if (body()) | ||||
|         return false; | ||||
|     if (body_info() != BodyInfo {}) | ||||
|         return false; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn