Lightpanda: the headless browser designed for AI and automation
update tests
Halil Durak34de819acac8
diff --git a/src/browser/tests/net/response.html b/src/browser/tests/net/response.htmlindex eb7acf4aa..082f1741d 100644--- a/src/browser/tests/net/response.html+++ b/src/browser/tests/net/response.html@@ -86,6 +86,57 @@});</script>+<script id=form_data type=module>+ const state = await testing.async();++ // An urlencoded body parses into a FormData.+ const res1 = new Response('a=1&b=hello+world&c=%26%3D&no_value', {+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },+ });+ const fd1 = await res1.formData();++ // A FormData body round-trips through the multipart encoding.+ const src = new FormData();+ src.append('username', 'alice');+ src.append('note', 'two\r\nlines');+ src.append('username', 'bob');+ const res2 = new Response(src);+ const fd2 = await res2.formData();++ // A URLSearchParams body parses back (urlencoded default Content-Type).+ const res3 = new Response(new URLSearchParams({ x: 'y z' }));+ const fd3 = await res3.formData();++ // A non-form Content-Type rejects with a TypeError.+ let rejected4 = false;+ const res4 = new Response('plain');+ try { await res4.formData(); } catch (e) { rejected4 = e instanceof TypeError; }++ // So does re-consuming an already-used body.+ let rejected5 = false;+ try { await res1.formData(); } catch (e) { rejected5 = e instanceof TypeError; }++ state.resolve();+ await state.done(() => {+ testing.expectEqual(true, fd1 instanceof FormData);+ testing.expectEqual('1', fd1.get('a'));+ testing.expectEqual('hello world', fd1.get('b'));+ testing.expectEqual('&=', fd1.get('c'));+ testing.expectEqual('', fd1.get('no_value'));++ testing.expectEqual(true, fd2 instanceof FormData);+ testing.expectEqual(2, fd2.getAll('username').length);+ testing.expectEqual('alice', fd2.getAll('username')[0]);+ testing.expectEqual('bob', fd2.getAll('username')[1]);+ testing.expectEqual('two\r\nlines', fd2.get('note'));++ testing.expectEqual('y z', fd3.get('x'));++ testing.expectEqual(true, rejected4);+ testing.expectEqual(true, rejected5);+ });+</script>+<script id=clone type=module>const state = await testing.async();