Skip to content

Commit

Permalink
fix: make frame property non-enumerable in params for 'context-menu' …
Browse files Browse the repository at this point in the history
…event
  • Loading branch information
miniak committed Oct 4, 2021
1 parent d95d4b2 commit 84f680b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shell/common/gin_converters/content_converter.cc
Expand Up @@ -80,7 +80,7 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithRenderFrameHost>::ToV8(
const auto& params = val.first;
content::RenderFrameHost* render_frame_host = val.second;
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
dict.SetGetter("frame", render_frame_host);
dict.SetGetterNonEnumerable("frame", render_frame_host);
dict.Set("x", params.x);
dict.Set("y", params.y);
dict.Set("linkURL", params.link_url);
Expand Down
11 changes: 9 additions & 2 deletions shell/common/gin_helper/dictionary.h
Expand Up @@ -111,7 +111,9 @@ class Dictionary : public gin::Dictionary {
}

template <typename K, typename V>
bool SetGetter(const K& key, const V& val) {
bool SetGetter(const K& key,
const V& val,
v8::PropertyAttribute attribute = v8::None) {
AccessorValue<V> acc_value;
acc_value.Value = val;

Expand All @@ -136,10 +138,15 @@ class Dictionary : public gin::Dictionary {
if (gin::TryConvertToV8(info.GetIsolate(), val, &v8_value))
info.GetReturnValue().Set(v8_value);
},
NULL, v8_value_accessor)
nullptr, v8_value_accessor, v8::DEFAULT, attribute)
.ToChecked();
}

template <typename K, typename V>
bool SetGetterNonEnumerable(const K& key, const V& val) {
return SetGetter(key, val, v8::DontEnum);
}

template <typename T>
bool SetReadOnly(base::StringPiece key, const T& val) {
v8::Local<v8::Value> v8_value;
Expand Down

0 comments on commit 84f680b

Please sign in to comment.