diff options
author | Zhidao HONG <z.hong@f5.com> | 2025-04-22 10:56:27 +0800 |
---|---|---|
committer | hongzhidao <hongzhidao@gmail.com> | 2025-05-09 01:14:21 +0800 |
commit | b7f76b71f4a1511cd9d954e6da3b0da4c9de40fb (patch) | |
tree | 7e87027c23f8d0e6424fee3900b1432433f59377 /nginx/t/js_fetch_objects.t | |
parent | a1e3f15f0a580f7b9d465a5b2ed2287a1705dc84 (diff) | |
download | njs-b7f76b71f4a1511cd9d954e6da3b0da4c9de40fb.tar.gz njs-b7f76b71f4a1511cd9d954e6da3b0da4c9de40fb.zip |
Fetch: QuickJS support.
Diffstat (limited to 'nginx/t/js_fetch_objects.t')
-rw-r--r-- | nginx/t/js_fetch_objects.t | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/nginx/t/js_fetch_objects.t b/nginx/t/js_fetch_objects.t index 67cabdfc..bc5cc7ed 100644 --- a/nginx/t/js_fetch_objects.t +++ b/nginx/t/js_fetch_objects.t @@ -271,7 +271,9 @@ $t->write_file('test.js', <<EOF); }) } catch (e) { - if (!e.message.startsWith('Cannot assign to read-only p')) { + if (!e.message.startsWith('Cannot assign to read-only p') + && !e.message.startsWith('no setter for property')) + { throw e; } } @@ -386,6 +388,17 @@ $t->write_file('test.js', <<EOF); var body = await r.text(); return `\${body}: \${r.headers.get('Content-Type')}`; }, 'ABC: text/plain;charset=UTF-8'], + ['arrayBuffer()', async () => { + var r = new Request("http://nginx.org", {body: 'ABC'}); + var body = await r.arrayBuffer(); + body = new Uint8Array(body); + return new TextDecoder().decode(body); + }, 'ABC'], + ['json()', async () => { + var r = new Request("http://nginx.org", {body: '{"a": 42}'}); + var body = await r.json(); + return body.a; + }, 42], ['user content type', async () => { var r = new Request("http://nginx.org", {body: 'ABC', @@ -443,6 +456,12 @@ $t->write_file('test.js', <<EOF); var body = await r.text(); return `\${r.url}: \${body} \${r.headers.get('b')}`; }, ': Y'], + ['arrayBuffer', async () => { + var r = new Response('foo'); + var body = await r.arrayBuffer(); + body = new Uint8Array(body); + return new TextDecoder().decode(body); + }, 'foo'], ['json', async () => { var r = new Response('{"a": {"b": 42}}'); var json = await r.json(); @@ -515,8 +534,6 @@ EOF $t->try_run('no njs'); -plan(skip_all => 'not yet') if http_get('/engine') =~ /QuickJS$/m; - $t->plan(5); ############################################################################### |