Support setting read-only property value

This commit is contained in:
Kevin Sawicki 2017-01-11 17:49:41 -08:00
parent 912307386c
commit c78a6fa7d4

View file

@ -93,6 +93,19 @@ class Dictionary {
return !result.IsNothing() && result.FromJust();
}
template<typename T>
bool SetReadOnly(const base::StringPiece& key, T val) {
v8::Local<v8::Value> v8_value;
if (!TryConvertToV8(isolate_, val, &v8_value))
return false;
v8::Maybe<bool> result =
GetHandle()->DefineOwnProperty(isolate_->GetCurrentContext(),
StringToV8(isolate_, key),
v8_value,
v8::ReadOnly);
return !result.IsNothing() && result.FromJust();
}
template<typename T>
bool SetMethod(const base::StringPiece& key, const T& callback) {
return GetHandle()->Set(