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}
This commit is contained in:
parent
2dd659f8e7
commit
bb21979adf
@ -141,7 +141,7 @@ static Maybe<PropertyAttributes> UnscopableLookup(LookupIterator* it) {
|
||||
DCHECK(isolate->has_pending_exception());
|
||||
return Nothing<PropertyAttributes>();
|
||||
}
|
||||
return blacklist->IsUndefined() ? attrs : Just(ABSENT);
|
||||
return blacklist->BooleanValue() ? Just(ABSENT) : attrs;
|
||||
}
|
||||
|
||||
static void GetAttributesAndBindingFlags(VariableMode mode,
|
||||
|
@ -130,25 +130,35 @@ function TestBasics(object) {
|
||||
assertEquals(3, z);
|
||||
}
|
||||
|
||||
object[Symbol.unscopables] = {x: true};
|
||||
with (object) {
|
||||
assertEquals(1, x);
|
||||
assertEquals(5, y);
|
||||
assertEquals(3, z);
|
||||
var truthyValues = [true, 1, 'x', {}, Symbol()];
|
||||
for (var truthyValue of truthyValues) {
|
||||
object[Symbol.unscopables] = {x: truthyValue};
|
||||
with (object) {
|
||||
assertEquals(1, x);
|
||||
assertEquals(5, y);
|
||||
assertEquals(3, z);
|
||||
}
|
||||
}
|
||||
|
||||
object[Symbol.unscopables] = {x: 0, y: true};
|
||||
with (object) {
|
||||
assertEquals(1, x);
|
||||
assertEquals(2, y);
|
||||
assertEquals(3, z);
|
||||
var falsyValues = [false, 0, -0, NaN, '', null, undefined];
|
||||
for (var falsyValue of falsyValues) {
|
||||
object[Symbol.unscopables] = {x: falsyValue, y: true};
|
||||
with (object) {
|
||||
assertEquals(4, x);
|
||||
assertEquals(2, y);
|
||||
assertEquals(3, z);
|
||||
}
|
||||
}
|
||||
|
||||
object[Symbol.unscopables] = {x: 0, y: undefined};
|
||||
with (object) {
|
||||
assertEquals(1, x);
|
||||
assertEquals(5, y);
|
||||
assertEquals(3, z);
|
||||
for (var xFalsy of falsyValues) {
|
||||
for (var yFalsy of falsyValues) {
|
||||
object[Symbol.unscopables] = {x: xFalsy, y: yFalsy};
|
||||
with (object) {
|
||||
assertEquals(4, x);
|
||||
assertEquals(5, y);
|
||||
assertEquals(3, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
runTest(TestBasics);
|
||||
|
Loading…
Reference in New Issue
Block a user