diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 119b869c9f25..ff91fee761af 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -687,17 +687,26 @@ v8::MaybeLocal CreateProxyForAPI( continue; } } - v8::Local value; - if (!api.Get(key, &value)) - continue; - auto passed_value = PassValueToOtherContextInner( - source_context, source_execution_context, destination_context, value, - api.GetHandle(), object_cache, support_dynamic_properties, - recursion_depth + 1, error_target); - if (passed_value.IsEmpty()) - return {}; - proxy.Set(key, passed_value.ToLocalChecked()); + { + v8::Context::Scope source_context_scope(source_context); + v8::Local value; + if (!api.Get(key, &value)) + continue; + + auto passed_value = PassValueToOtherContextInner( + source_context, source_execution_context, destination_context, + value, api.GetHandle(), object_cache, support_dynamic_properties, + recursion_depth + 1, error_target); + if (passed_value.IsEmpty()) + return {}; + + { + v8::Context::Scope inner_destination_context_scope( + destination_context); + proxy.Set(key, passed_value.ToLocalChecked()); + } + } } return proxy.GetHandle();