aboutsummaryrefslogtreecommitdiff
path: root/nginx/t/js_fetch_objects.t
diff options
context:
space:
mode:
authorDmitry Volyntsev <xeioex@nginx.com>2024-06-14 20:54:28 -0700
committerDmitry Volyntsev <xeioexception@gmail.com>2024-09-17 18:05:57 -0700
commit201b127679e27fe63eff5c1b4356ec4ed9ec4611 (patch)
tree2477939f07f646ee6137a7d30ccc8e807206da61 /nginx/t/js_fetch_objects.t
parent9b6744129ce4c18e74b5e41cd1da66f2cbadcf36 (diff)
downloadnjs-201b127679e27fe63eff5c1b4356ec4ed9ec4611.tar.gz
njs-201b127679e27fe63eff5c1b4356ec4ed9ec4611.zip
Modules: introduced QuickJS engine.
"js_engine" directive is introduced which sets JavaScript engine. When the module is built with QuickJS library "js_engine qjs;" sets QuickJS engine for the current block. By default njs engine is used. For example, nginx.conf: location /a { js_engine qjs; # will be handled by QuickJS js_content main.handler; } location /b { # will be handled by njs js_content main.handler; } QuickJS engine implements drop-in replacement for nginx/njs objects with the following exceptions: * nginx module API to be added later: ngx.fetch(), ngx.shared.dict. * Built-in modules to be added later: fs, crypto, WebCrypto, xml. * NJS specific API: njs.dump(), njs.on(), console.dump(). * js_preload_object directive.
Diffstat (limited to 'nginx/t/js_fetch_objects.t')
-rw-r--r--nginx/t/js_fetch_objects.t18
1 files changed, 15 insertions, 3 deletions
diff --git a/nginx/t/js_fetch_objects.t b/nginx/t/js_fetch_objects.t
index d0f47630..1bc88a3d 100644
--- a/nginx/t/js_fetch_objects.t
+++ b/nginx/t/js_fetch_objects.t
@@ -45,6 +45,10 @@ http {
js_content test.njs;
}
+ location /engine {
+ js_content test.engine;
+ }
+
location /headers {
js_content test.headers;
}
@@ -88,6 +92,10 @@ $t->write_file('test.js', <<EOF);
r.return(200, njs.version);
}
+ function engine(r) {
+ r.return(200, njs.engine);
+ }
+
function header(r) {
r.return(200, r.headersIn.a);
}
@@ -501,11 +509,15 @@ $t->write_file('test.js', <<EOF);
run(r, tests);
}
- export default {njs: test_njs, body, headers, request, response, fetch,
- fetch_multi_header};
+ export default {njs: test_njs, engine, body, headers, request, response,
+ fetch, fetch_multi_header};
EOF
-$t->try_run('no njs')->plan(5);
+$t->try_run('no njs');
+
+plan(skip_all => 'not yet') if http_get('/engine') =~ /QuickJS$/m;
+
+$t->plan(5);
###############################################################################