From 84f680b64698f6f874403e74188c43733894cfb2 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 4 Oct 2021 17:09:14 +0200 Subject: [PATCH] fix: make frame property non-enumerable in params for 'context-menu' event --- shell/common/gin_converters/content_converter.cc | 2 +- shell/common/gin_helper/dictionary.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/shell/common/gin_converters/content_converter.cc b/shell/common/gin_converters/content_converter.cc index 4d6b250cfa166..b1509558e73bf 100644 --- a/shell/common/gin_converters/content_converter.cc +++ b/shell/common/gin_converters/content_converter.cc @@ -80,7 +80,7 @@ v8::Local Converter::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); diff --git a/shell/common/gin_helper/dictionary.h b/shell/common/gin_helper/dictionary.h index 5e55c418f2582..7015aef02d6ab 100644 --- a/shell/common/gin_helper/dictionary.h +++ b/shell/common/gin_helper/dictionary.h @@ -111,7 +111,9 @@ class Dictionary : public gin::Dictionary { } template - bool SetGetter(const K& key, const V& val) { + bool SetGetter(const K& key, + const V& val, + v8::PropertyAttribute attribute = v8::None) { AccessorValue acc_value; acc_value.Value = val; @@ -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 + bool SetGetterNonEnumerable(const K& key, const V& val) { + return SetGetter(key, val, v8::DontEnum); + } + template bool SetReadOnly(base::StringPiece key, const T& val) { v8::Local v8_value;