Commit e2dd98a3 authored by jkummerow's avatar jkummerow Committed by Commit bot

[proxies] Fix "with" statements for proxies

BUG=v8:1543
LOG=n

Review URL: https://codereview.chromium.org/1510913005

Cr-Commit-Position: refs/heads/master@{#32756}
parent 989f44f1
......@@ -146,30 +146,24 @@ void Context::set_global_proxy(JSObject* object) {
* Lookups a property in an object environment, taking the unscopables into
* account. This is used For HasBinding spec algorithms for ObjectEnvironment.
*/
static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
static Maybe<bool> UnscopableLookup(LookupIterator* it) {
Isolate* isolate = it->isolate();
Maybe<PropertyAttributes> attrs = JSReceiver::GetPropertyAttributes(it);
DCHECK(attrs.IsJust() || isolate->has_pending_exception());
if (!attrs.IsJust() || attrs.FromJust() == ABSENT) return attrs;
Maybe<bool> found = JSReceiver::HasProperty(it);
if (!found.IsJust() || !found.FromJust()) return found;
Handle<Symbol> unscopables_symbol = isolate->factory()->unscopables_symbol();
Handle<Object> receiver = it->GetReceiver();
Handle<Object> unscopables;
MaybeHandle<Object> maybe_unscopables =
Object::GetProperty(receiver, unscopables_symbol);
if (!maybe_unscopables.ToHandle(&unscopables)) {
return Nothing<PropertyAttributes>();
}
if (!unscopables->IsJSReceiver()) return attrs;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, unscopables,
Object::GetProperty(it->GetReceiver(),
isolate->factory()->unscopables_symbol()),
Nothing<bool>());
if (!unscopables->IsJSReceiver()) return Just(true);
Handle<Object> blacklist;
MaybeHandle<Object> maybe_blacklist =
Object::GetProperty(unscopables, it->name());
if (!maybe_blacklist.ToHandle(&blacklist)) {
DCHECK(isolate->has_pending_exception());
return Nothing<PropertyAttributes>();
}
return blacklist->BooleanValue() ? Just(ABSENT) : attrs;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, blacklist,
Object::GetProperty(unscopables, it->name()),
Nothing<bool>());
return Just(!blacklist->BooleanValue());
}
static void GetAttributesAndBindingFlags(VariableMode mode,
......@@ -289,7 +283,15 @@ Handle<Object> Context::Lookup(Handle<String> name,
maybe = Just(ABSENT);
} else {
LookupIterator it(object, name);
maybe = UnscopableLookup(&it);
Maybe<bool> found = UnscopableLookup(&it);
if (found.IsNothing()) {
maybe = Nothing<PropertyAttributes>();
} else {
// Luckily, consumers of |maybe| only care whether the property
// was absent or not, so we can return a dummy |NONE| value
// for its attributes when it was present.
maybe = Just(found.FromJust() ? NONE : ABSENT);
}
}
} else {
maybe = JSReceiver::GetPropertyAttributes(object, name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment