Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
isolate->SetModifyCodeGenerationFromStringsCallback(
modify_code_generation_from_strings_callback);

isolate->SetWasmStreamingCallback(wasm_web_api::StartStreamingCompilation);
if ((s.flags & SHOULD_NOT_SET_WASM_STREAMING_CALLBACK) == 0) {
isolate->SetWasmStreamingCallback(wasm_web_api::StartStreamingCompilation);
}

Mutex::ScopedLock lock(node::per_process::cli_options_mutex);
if (per_process::cli_options->get_per_isolate_options()
Expand Down
1 change: 1 addition & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ enum IsolateSettingsFlags {
DETAILED_SOURCE_POSITIONS_FOR_PROFILING = 1 << 1,
SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK = 1 << 2,
SHOULD_NOT_SET_PREPARE_STACK_TRACE_CALLBACK = 1 << 3,
SHOULD_NOT_SET_WASM_STREAMING_CALLBACK = 1 << 4,
ALLOW_MODIFY_CODE_GENERATION_FROM_STRINGS_CALLBACK = 0, /* legacy no-op */
};

Expand Down
33 changes: 33 additions & 0 deletions test/cctest/test_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,39 @@ TEST_F(EnvironmentTest, ManagedBufferCache) {
(*env)->release_managed_buffer(buffer);
}

static int embedder_wasm_streaming_calls = 0;
static void EmbedderWasmStreaming(const v8::FunctionCallbackInfo<v8::Value>&) {
embedder_wasm_streaming_calls++;
}

TEST_F(EnvironmentTest, KeepsEmbedderWasmStreamingCallbackWhenAsked) {
const v8::HandleScope handle_scope(isolate_);
const Argv argv;
Env env{handle_scope, argv};

auto compile_streaming = [&]() {
v8::Local<v8::Context> context = isolate_->GetCurrentContext();
v8::Script::Compile(context,
v8::String::NewFromUtf8Literal(
isolate_, "WebAssembly.compileStreaming(0); 0"))
.ToLocalChecked()
->Run(context)
.ToLocalChecked();
isolate_->PerformMicrotaskCheckpoint();
};

node::IsolateSettings settings;
settings.flags |= node::SHOULD_NOT_SET_WASM_STREAMING_CALLBACK;
isolate_->SetWasmStreamingCallback(EmbedderWasmStreaming);
node::SetIsolateUpForNode(isolate_, settings);
compile_streaming();
EXPECT_EQ(embedder_wasm_streaming_calls, 1);

node::SetIsolateUpForNode(isolate_);
compile_streaming();
EXPECT_EQ(embedder_wasm_streaming_calls, 1);
}

TEST_F(EnvironmentTest, EnvironmentWithoutBrowserGlobals) {
const v8::HandleScope handle_scope(isolate_);
Argv argv;
Expand Down
Loading