Reland "[api] Add test for EnumeratorCallback and for...in."
This is a reland of 56772de7f9
Original change's description:
> [api] Add test for EnumeratorCallback and for...in.
>
> If a QueryCallback is present, it is used to
> filter the result from the EnumeratorCallback for
> enumerable properties. This tests assures that
> for...in loops work correctly with these interceptors.
>
> Bug: v8:6627
> Change-Id: I1e568beac1e138a330034492b87bd49c22e0c804
> Reviewed-on: https://chromium-review.googlesource.com/609982
> Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#47445}
TBR=adamk@chromium.org
Bug: v8:6627
Change-Id: I509016a879d175b01f7cc7918758354fe0df8ebf
Reviewed-on: https://chromium-review.googlesource.com/650906
Reviewed-by: Franziska Hinkelmann <franzih@chromium.org>
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47838}
This commit is contained in:
parent
a636fcc9d2
commit
b6bf9ad92d
@ -5161,6 +5161,33 @@ THREADED_TEST(EnumeratorsAndUnenumerableIndexedProperties) {
|
||||
ExpectInt32("Object.values(obj)[0]", 24);
|
||||
}
|
||||
|
||||
THREADED_TEST(EnumeratorsAndForIn) {
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> obj = ObjectTemplate::New(isolate);
|
||||
obj->SetHandler(v8::NamedPropertyHandlerConfiguration(
|
||||
ConcatNamedPropertyGetter, NULL, RestrictiveNamedQuery, NULL, NamedEnum));
|
||||
LocalContext context;
|
||||
context->Global()
|
||||
->Set(context.local(), v8_str("obj"),
|
||||
obj->NewInstance(context.local()).ToLocalChecked())
|
||||
.FromJust();
|
||||
|
||||
ExpectInt32("Object.getOwnPropertyNames(obj).length", 3);
|
||||
ExpectString("Object.getOwnPropertyNames(obj)[0]", "foo");
|
||||
|
||||
ExpectTrue("Object.getOwnPropertyDescriptor(obj, 'foo').enumerable");
|
||||
|
||||
CompileRun(
|
||||
"let concat = '';"
|
||||
"for(var prop in obj) {"
|
||||
" concat += `key:${prop}:value:${obj[prop]}`;"
|
||||
"}");
|
||||
|
||||
// Check that for...in only iterates over enumerable properties.
|
||||
ExpectString("concat", "key:foo:value:foofoo");
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void DatabaseGetter(Local<Name> name,
|
||||
|
Loading…
Reference in New Issue
Block a user