Commit bb21979a authored by arv's avatar arv Committed by Commit bot

ES6: Unscopable should use ToBoolean

The spec settled on ToBoolean instead of only using not undefined.

BUG=v8:3827
LOG=N
R=adamk

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

Cr-Commit-Position: refs/heads/master@{#27548}
parent 2dd659f8
...@@ -141,7 +141,7 @@ static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) { ...@@ -141,7 +141,7 @@ static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
return Nothing<PropertyAttributes>(); return Nothing<PropertyAttributes>();
} }
return blacklist->IsUndefined() ? attrs : Just(ABSENT); return blacklist->BooleanValue() ? Just(ABSENT) : attrs;
} }
static void GetAttributesAndBindingFlags(VariableMode mode, static void GetAttributesAndBindingFlags(VariableMode mode,
......
...@@ -130,25 +130,35 @@ function TestBasics(object) { ...@@ -130,25 +130,35 @@ function TestBasics(object) {
assertEquals(3, z); assertEquals(3, z);
} }
object[Symbol.unscopables] = {x: true}; var truthyValues = [true, 1, 'x', {}, Symbol()];
with (object) { for (var truthyValue of truthyValues) {
assertEquals(1, x); object[Symbol.unscopables] = {x: truthyValue};
assertEquals(5, y); with (object) {
assertEquals(3, z); assertEquals(1, x);
assertEquals(5, y);
assertEquals(3, z);
}
} }
object[Symbol.unscopables] = {x: 0, y: true}; var falsyValues = [false, 0, -0, NaN, '', null, undefined];
with (object) { for (var falsyValue of falsyValues) {
assertEquals(1, x); object[Symbol.unscopables] = {x: falsyValue, y: true};
assertEquals(2, y); with (object) {
assertEquals(3, z); assertEquals(4, x);
assertEquals(2, y);
assertEquals(3, z);
}
} }
object[Symbol.unscopables] = {x: 0, y: undefined}; for (var xFalsy of falsyValues) {
with (object) { for (var yFalsy of falsyValues) {
assertEquals(1, x); object[Symbol.unscopables] = {x: xFalsy, y: yFalsy};
assertEquals(5, y); with (object) {
assertEquals(3, z); assertEquals(4, x);
assertEquals(5, y);
assertEquals(3, z);
}
}
} }
} }
runTest(TestBasics); runTest(TestBasics);
......
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