Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ struct v8_dom_runtime::implementation final {
{
prune_persistent_compilation_cache();
initialize_v8_process();
{
std::lock_guard lock(message_port_wake->mutex);
message_port_wake->notify = runtime_work_available;
}
if (!force_dedicated_isolate && std::getenv("WEBSCENE_V8_SHARED_ISOLATE") != nullptr) {
try {
shared_isolate = acquire_shared_isolate();
Expand Down Expand Up @@ -3752,6 +3756,7 @@ struct v8_dom_runtime::implementation final {
install_clipboard_api(local_context);
install_websocket_globals(local_context);
install_editor_web_platform_globals(local_context);
install_message_channel(local_context);
install_tree_walker_platform(local_context);
install_custom_elements_platform(local_context);
local_context->Global()->Set(local_context,js_string(isolate,"__webSceneRevokeObjectUrl"),v8::Function::New(local_context,revoke_object_url).ToLocalChecked()).Check();
Expand Down Expand Up @@ -5137,6 +5142,7 @@ bool v8_dom_runtime::has_pending_tasks() const noexcept
|| impl_->websocket_transport.has_pending_events()
|| !impl_->pending_window_messages.empty()
|| impl_->has_worker_messages()
|| impl_->has_message_port_messages()
|| impl_->has_ready_fetch_task()
|| !impl_->pending_dialog_close_events.empty()
|| !impl_->pending_programmatic_scroll_events.empty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,53 @@
if (target_context.IsEmpty()) return;
if (source_context.IsEmpty()) source_context = target_context;

if (self->pending_window_messages.size()
>= maximum_pending_window_messages
|| self->pending_window_message_bytes
>= maximum_pending_window_message_bytes) {
throw_dom_exception(
info,
"Window message queue capacity exhausted",
"QuotaExceededError");
return;
}

auto target_origin = std::string("*");
v8::Local<v8::Value> transfer = v8::Undefined(isolate);
if (info.Length() > 1 && info[1]->IsObject() && !info[1]->IsArray()) {
v8::Local<v8::Value> target_origin_value;
if (!info[1].As<v8::Object>()->Get(
isolate->GetCurrentContext(),
js_string(isolate, "targetOrigin")).ToLocal(&target_origin_value)) {
return;
}
if (!target_origin_value->IsUndefined()) {
target_origin = to_utf8(isolate, target_origin_value);
}
if (!info[1].As<v8::Object>()->Get(
isolate->GetCurrentContext(),
js_string(isolate, "transfer")).ToLocal(&transfer)) {
return;
}
} else {
if (info.Length() > 1 && !info[1]->IsUndefined()) {
target_origin = to_utf8(isolate, info[1]);
}
if (info.Length() > 2) transfer = info[2];
}

clone_packet packet;
if (!serialize_clone(
info,
info[0],
transfer,
packet,
maximum_pending_window_message_bytes
- self->pending_window_message_bytes)) {
return;
}
const auto packet_bytes = clone_packet_size(packet);

const auto read_origin = [&](v8::Local<v8::Context> local_context) {
v8::Context::Scope scope(local_context);
v8::Local<v8::Value> location_value;
Expand All @@ -241,11 +288,10 @@
self->pending_window_messages.push_back(pending_window_message{
v8::Global<v8::Context>(isolate, target_context),
v8::Global<v8::Context>(isolate, source_context),
v8::Global<v8::Value>(isolate, info[0]),
info.Length() > 1 && !info[1]->IsUndefined()
? to_utf8(isolate, info[1])
: std::string("*"),
std::move(packet),
std::move(target_origin),
read_origin(source_context)});
self->pending_window_message_bytes += packet_bytes;
}

static void get_window_frames(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@
install_clipboard_api(local_context);
install_websocket_globals(local_context);
install_editor_web_platform_globals(local_context);
install_message_channel(local_context);
install_tree_walker_platform(local_context);
install_custom_elements_platform(local_context);
install_fetch_globals(local_context);
Expand Down
Loading
Loading