mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Merge pull request from GHSA-h9jc-284h-533g
This commit is contained in:
@@ -388,19 +388,19 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||
context_bridge::RenderFramePersistenceStore* store,
|
||||
int recursion_depth) {
|
||||
mate::Dictionary api(source_context->GetIsolate(), api_object);
|
||||
mate::Dictionary proxy =
|
||||
mate::Dictionary::CreateEmpty(destination_context->GetIsolate());
|
||||
store->CacheProxiedObject(api.GetHandle(), proxy.GetHandle());
|
||||
auto maybe_keys = api.GetHandle()->GetOwnPropertyNames(
|
||||
source_context,
|
||||
static_cast<v8::PropertyFilter>(v8::ONLY_ENUMERABLE | v8::SKIP_SYMBOLS),
|
||||
v8::KeyConversionMode::kConvertToString);
|
||||
if (maybe_keys.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Object>(proxy.GetHandle());
|
||||
auto keys = maybe_keys.ToLocalChecked();
|
||||
|
||||
v8::Context::Scope destination_context_scope(destination_context);
|
||||
{
|
||||
mate::Dictionary proxy =
|
||||
mate::Dictionary::CreateEmpty(destination_context->GetIsolate());
|
||||
store->CacheProxiedObject(api.GetHandle(), proxy.GetHandle());
|
||||
auto maybe_keys = api.GetHandle()->GetOwnPropertyNames(
|
||||
source_context,
|
||||
static_cast<v8::PropertyFilter>(v8::ONLY_ENUMERABLE | v8::SKIP_SYMBOLS),
|
||||
v8::KeyConversionMode::kConvertToString);
|
||||
if (maybe_keys.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Object>(proxy.GetHandle());
|
||||
auto keys = maybe_keys.ToLocalChecked();
|
||||
|
||||
uint32_t length = keys->Length();
|
||||
std::string key_str;
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
|
||||
@@ -583,6 +583,7 @@ describe('contextBridge', () => {
|
||||
string: 'string',
|
||||
boolean: true,
|
||||
arr: [123, 'string', true, ['foo']],
|
||||
getObject: () => ({ thing: 123 }),
|
||||
getNumber: () => 123,
|
||||
getString: () => 'string',
|
||||
getBoolean: () => true,
|
||||
@@ -616,6 +617,7 @@ describe('contextBridge', () => {
|
||||
[example.arr[3][0], String],
|
||||
[example.getNumber, Function],
|
||||
[example.getNumber(), Number],
|
||||
[example.getObject(), Object],
|
||||
[example.getString(), String],
|
||||
[example.getBoolean(), Boolean],
|
||||
[example.getArr(), Array],
|
||||
|
||||
Reference in New Issue
Block a user