mirror of
				https://github.com/lightpanda-io/browser.git
				synced 2025-10-30 15:41:48 +00:00 
			
		
		
		
	fix arena, add fetch test
This commit is contained in:
		 Karl Seguin
					Karl Seguin
				
			
				
					committed by
					
						 Muki Kiboigo
						Muki Kiboigo
					
				
			
			
				
	
			
			
			 Muki Kiboigo
						Muki Kiboigo
					
				
			
						parent
						
							31335fc4fb
						
					
				
				
					commit
					af916dea1d
				
			| @@ -111,7 +111,7 @@ pub fn fetch(input: RequestInput, options: ?RequestInit, page: *Page) !Env.Promi | ||||
|     while (header_iter.next()) |entry| { | ||||
|         // This is fine because curl/headers copies it internally. | ||||
|         const combined = try std.fmt.allocPrintSentinel( | ||||
|             page.call_arena, | ||||
|             page.arena, | ||||
|             "{s}: {s}", | ||||
|             .{ entry.key_ptr.*, entry.value_ptr.* }, | ||||
|             0, | ||||
| @@ -229,3 +229,8 @@ pub fn fetch(input: RequestInput, options: ?RequestInit, page: *Page) !Env.Promi | ||||
|  | ||||
|     return resolver.promise(); | ||||
| } | ||||
|  | ||||
| const testing = @import("../../testing.zig"); | ||||
| test "fetch: fetch" { | ||||
|     try testing.htmlRunner("fetch/fetch.html"); | ||||
| } | ||||
|   | ||||
							
								
								
									
										16
									
								
								src/tests/fetch/fetch.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/tests/fetch/fetch.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| <script src="../testing.js"></script> | ||||
| <script id=fetch type=module> | ||||
|   const promise1 = new Promise((resolve) => { | ||||
|     fetch('http://127.0.0.1:9582/xhr/json') | ||||
|     .then((res) => { | ||||
|       return res.json() | ||||
|     }) | ||||
|     .then((json) => { | ||||
|       resolve(json); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   testing.async(promise1, (json) => { | ||||
|     testing.expectEqual({over: '9000!!!'}, json); | ||||
|   }); | ||||
| </script> | ||||
| @@ -36,3 +36,14 @@ | ||||
|   let emptyResponse = new Response(""); | ||||
|   testing.expectEqual(200, emptyResponse.status); | ||||
| </script> | ||||
|  | ||||
| <script id=json type=module> | ||||
|   const promise1 = new Promise((resolve) => { | ||||
|     let response = new Response('[]'); | ||||
|     response.json().then(resolve) | ||||
|   }); | ||||
|  | ||||
|   testing.async(promise1, (json) => { | ||||
|     testing.expectEqual([], json); | ||||
|   }); | ||||
| </script>ref | ||||
|   | ||||
		Reference in New Issue
	
	Block a user