Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2022-04-26 00:46:42 +0300
committerGitHub <noreply@github.com>2022-04-26 00:46:42 +0300
commit4f9bc41f1ef325f43b96c5cfacd493c853034315 (patch)
tree13adb61a4d06ae2bd70384cfe54c9e466760813e /src
parentf54bf2839baee1ac354a19b7167f9854be3b0db0 (diff)
lib,src: use Response URL as WebAssembly location
As per Section 3 of the WebAssembly Web API spec. PR-URL: https://github.com/nodejs/node/pull/42842 Refs: https://github.com/nodejs/node/pull/42701 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_wasm_web_api.cc12
-rw-r--r--src/node_wasm_web_api.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/node_wasm_web_api.cc b/src/node_wasm_web_api.cc
index b23096120b1..fcb845d08b0 100644
--- a/src/node_wasm_web_api.cc
+++ b/src/node_wasm_web_api.cc
@@ -29,6 +29,7 @@ Local<Function> WasmStreamingObject::Initialize(Environment* env) {
t->InstanceTemplate()->SetInternalFieldCount(
WasmStreamingObject::kInternalFieldCount);
+ env->SetProtoMethod(t, "setURL", SetURL);
env->SetProtoMethod(t, "push", Push);
env->SetProtoMethod(t, "finish", Finish);
env->SetProtoMethod(t, "abort", Abort);
@@ -75,6 +76,17 @@ void WasmStreamingObject::New(const FunctionCallbackInfo<Value>& args) {
new WasmStreamingObject(env, args.This());
}
+void WasmStreamingObject::SetURL(const FunctionCallbackInfo<Value>& args) {
+ WasmStreamingObject* obj;
+ ASSIGN_OR_RETURN_UNWRAP(&obj, args.Holder());
+ CHECK(obj->streaming_);
+
+ CHECK_EQ(args.Length(), 1);
+ CHECK(args[0]->IsString());
+ Utf8Value url(Environment::GetCurrent(args)->isolate(), args[0]);
+ obj->streaming_->SetUrl(url.out(), url.length());
+}
+
void WasmStreamingObject::Push(const FunctionCallbackInfo<Value>& args) {
WasmStreamingObject* obj;
ASSIGN_OR_RETURN_UNWRAP(&obj, args.Holder());
diff --git a/src/node_wasm_web_api.h b/src/node_wasm_web_api.h
index 9f5fe868167..da584be1592 100644
--- a/src/node_wasm_web_api.h
+++ b/src/node_wasm_web_api.h
@@ -33,6 +33,7 @@ class WasmStreamingObject final : public BaseObject {
private:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void SetURL(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Push(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Finish(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Abort(const v8::FunctionCallbackInfo<v8::Value>& args);