diff options
author | Tobias Nießen <tniessen@tnie.de> | 2022-04-26 00:46:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-26 00:46:42 +0300 |
commit | 4f9bc41f1ef325f43b96c5cfacd493c853034315 (patch) | |
tree | 13adb61a4d06ae2bd70384cfe54c9e466760813e /src | |
parent | f54bf2839baee1ac354a19b7167f9854be3b0db0 (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.cc | 12 | ||||
-rw-r--r-- | src/node_wasm_web_api.h | 1 |
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); |