Skip to content

Commit

Permalink
v8: backport bd59e7452be from upstream v8
Browse files Browse the repository at this point in the history
Original commit message:
    [PATCH] Merged: Make Object::GetOwnPropertyDescriptor() take a Name, not a String.

    Revision: b5e610c19208ef854755eec67011ca7aff008bf4

    NOTRY=true
    NOPRESUBMIT=true
    NOTREECHECKS=true
    [email protected]

    Bug:
    Change-Id: I396b559b28aab6afa138db747711e50cd0da3da7
    Reviewed-on: https://chromium-review.googlesource.com/513927
    Reviewed-by: Michael Achenbach <[email protected]>
    Cr-Commit-Position: refs/branch-heads/6.0@{#5}
    Cr-Branched-From: 97dbf624a5eeffb3a8df36d24cdb2a883137385f-refs/heads/6.0.286@{#1}
    Cr-Branched-From: 12e6f1cb5cd9616da7b9d4a7655c088778a6d415-refs/heads/master@{#45439}

PR-URL: #13217
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mi-ac authored and addaleax committed Jul 11, 2017
1 parent f76dab2 commit 275fb1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
6 changes: 3 additions & 3 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -3070,12 +3070,12 @@ class V8_EXPORT Object : public Value {
Local<Context> context, Local<Value> key);

/**
* Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3.
* Returns Object.getOwnPropertyDescriptor as per ES2016 section 19.1.2.6.
*/
V8_DEPRECATED("Use maybe version",
Local<Value> GetOwnPropertyDescriptor(Local<String> key));
Local<Value> GetOwnPropertyDescriptor(Local<Name> key));
V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
Local<Context> context, Local<String> key);
Local<Context> context, Local<Name> key);

V8_DEPRECATE_SOON("Use maybe version", bool Has(Local<Value> key));
/**
Expand Down
8 changes: 3 additions & 5 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4530,12 +4530,11 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) {
.FromMaybe(static_cast<PropertyAttribute>(i::NONE));
}


MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
Local<String> key) {
Local<Name> key) {
PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyDescriptor, Value);
i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this);
i::Handle<i::String> key_name = Utils::OpenHandle(*key);
i::Handle<i::Name> key_name = Utils::OpenHandle(*key);

i::PropertyDescriptor desc;
Maybe<bool> found =
Expand All @@ -4548,8 +4547,7 @@ MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
RETURN_ESCAPED(Utils::ToLocal(desc.ToObject(isolate)));
}


Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) {
Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<Name> key) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyDescriptor(context, key), Value);
}
Expand Down
21 changes: 15 additions & 6 deletions deps/v8/test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24362,12 +24362,13 @@ TEST(GetOwnPropertyDescriptor) {
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
CompileRun(
"var x = { value : 13};"
"Object.defineProperty(x, 'p0', {value : 12});"
"Object.defineProperty(x, 'p1', {"
" set : function(value) { this.value = value; },"
" get : function() { return this.value; },"
"});");
"var x = { value : 13};"
"Object.defineProperty(x, 'p0', {value : 12});"
"Object.defineProperty(x, Symbol.toStringTag, {value: 'foo'});"
"Object.defineProperty(x, 'p1', {"
" set : function(value) { this.value = value; },"
" get : function() { return this.value; },"
"});");
Local<Object> x = Local<Object>::Cast(
env->Global()->Get(env.local(), v8_str("x")).ToLocalChecked());
Local<Value> desc =
Expand Down Expand Up @@ -24401,6 +24402,14 @@ TEST(GetOwnPropertyDescriptor) {
->Equals(env.local(),
get->Call(env.local(), x, 0, NULL).ToLocalChecked())
.FromJust());
desc =
x->GetOwnPropertyDescriptor(env.local(), Symbol::GetToStringTag(isolate))
.ToLocalChecked();
CHECK(v8_str("foo")
->Equals(env.local(), Local<Object>::Cast(desc)
->Get(env.local(), v8_str("value"))
.ToLocalChecked())
.FromJust());
}


Expand Down

0 comments on commit 275fb1f

Please sign in to comment.