From da35ac3bb946b6a6f4b8e6201bddfe76a0632161 Mon Sep 17 00:00:00 2001 From: Michael Achenbach Date: Wed, 24 May 2017 15:44:34 +0200 Subject: [PATCH] v8: backport bd59e7452be from upstream v8 Original commit message: [PATCH] Merged: Make Object::GetOwnPropertyDescriptor() take a Name, not a String. Revision: b5e610c19208ef854755eec67011ca7aff008bf4 NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true TBR=vogelheim@chromium.org Bug: Change-Id: I396b559b28aab6afa138db747711e50cd0da3da7 Reviewed-on: https://chromium-review.googlesource.com/513927 Reviewed-by: Michael Achenbach 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: https://github.com/nodejs/node/pull/13217 Reviewed-By: Franziska Hinkelmann Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- deps/v8/include/v8.h | 6 +++--- deps/v8/src/api.cc | 8 +++----- deps/v8/test/cctest/test-api.cc | 21 +++++++++++++++------ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index fe124d44c644c5..f51efbdf503671 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -3070,12 +3070,12 @@ class V8_EXPORT Object : public Value { Local context, Local 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 GetOwnPropertyDescriptor(Local key)); + Local GetOwnPropertyDescriptor(Local key)); V8_WARN_UNUSED_RESULT MaybeLocal GetOwnPropertyDescriptor( - Local context, Local key); + Local context, Local key); V8_DEPRECATE_SOON("Use maybe version", bool Has(Local key)); /** diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index cacf469d0dd555..1b8bafacc29919 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -4530,12 +4530,11 @@ PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local key) { .FromMaybe(static_cast(i::NONE)); } - MaybeLocal v8::Object::GetOwnPropertyDescriptor(Local context, - Local key) { + Local key) { PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyDescriptor, Value); i::Handle obj = Utils::OpenHandle(this); - i::Handle key_name = Utils::OpenHandle(*key); + i::Handle key_name = Utils::OpenHandle(*key); i::PropertyDescriptor desc; Maybe found = @@ -4548,8 +4547,7 @@ MaybeLocal v8::Object::GetOwnPropertyDescriptor(Local context, RETURN_ESCAPED(Utils::ToLocal(desc.ToObject(isolate))); } - -Local v8::Object::GetOwnPropertyDescriptor(Local key) { +Local v8::Object::GetOwnPropertyDescriptor(Local key) { auto context = ContextFromHeapObject(Utils::OpenHandle(this)); RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyDescriptor(context, key), Value); } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index f2cbc7dabfe90f..81d2ff1b1ef4a8 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -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 x = Local::Cast( env->Global()->Get(env.local(), v8_str("x")).ToLocalChecked()); Local desc = @@ -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::Cast(desc) + ->Get(env.local(), v8_str("value")) + .ToLocalChecked()) + .FromJust()); }