| Index: test/cctest/test-api.cc
|
| ===================================================================
|
| --- test/cctest/test-api.cc (revision 1718)
|
| +++ test/cctest/test-api.cc (working copy)
|
| @@ -2925,10 +2925,22 @@
|
|
|
| static v8::Handle<Value> GetK(Local<String> name, const AccessorInfo&) {
|
| ApiTestFuzzer::Fuzz();
|
| - return v8::Undefined();
|
| + if (name->Equals(v8_str("foo")) ||
|
| + name->Equals(v8_str("bar")) ||
|
| + name->Equals(v8_str("baz"))) {
|
| + return v8::Undefined();
|
| + }
|
| + return v8::Handle<Value>();
|
| }
|
|
|
|
|
| +static v8::Handle<Value> IndexedGetK(uint32_t index, const AccessorInfo&) {
|
| + ApiTestFuzzer::Fuzz();
|
| + if (index == 0 || index == 1) return v8::Undefined();
|
| + return v8::Handle<Value>();
|
| +}
|
| +
|
| +
|
| static v8::Handle<v8::Array> NamedEnum(const AccessorInfo&) {
|
| ApiTestFuzzer::Fuzz();
|
| v8::Handle<v8::Array> result = v8::Array::New(3);
|
| @@ -2942,8 +2954,8 @@
|
| static v8::Handle<v8::Array> IndexedEnum(const AccessorInfo&) {
|
| ApiTestFuzzer::Fuzz();
|
| v8::Handle<v8::Array> result = v8::Array::New(2);
|
| - result->Set(v8::Integer::New(0), v8_str("hat"));
|
| - result->Set(v8::Integer::New(1), v8_str("gyt"));
|
| + result->Set(v8::Integer::New(0), v8_str("0"));
|
| + result->Set(v8::Integer::New(1), v8_str("1"));
|
| return result;
|
| }
|
|
|
| @@ -2952,21 +2964,56 @@
|
| v8::HandleScope scope;
|
| v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
|
| obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum);
|
| - obj->SetIndexedPropertyHandler(NULL, NULL, NULL, NULL, IndexedEnum);
|
| + obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum);
|
| LocalContext context;
|
| context->Global()->Set(v8_str("k"), obj->NewInstance());
|
| v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
|
| + "k[10] = 0;"
|
| + "k.a = 0;"
|
| + "k[5] = 0;"
|
| + "k.b = 0;"
|
| + "k[4294967295] = 0;"
|
| + "k.c = 0;"
|
| + "k[4294967296] = 0;"
|
| + "k.d = 0;"
|
| + "k[140000] = 0;"
|
| + "k.e = 0;"
|
| + "k[30000000000] = 0;"
|
| + "k.f = 0;"
|
| "var result = [];"
|
| "for (var prop in k) {"
|
| " result.push(prop);"
|
| "}"
|
| "result"));
|
| - CHECK_EQ(5, result->Length());
|
| - CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(0)));
|
| - CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(1)));
|
| - CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(2)));
|
| - CHECK_EQ(v8_str("hat"), result->Get(v8::Integer::New(3)));
|
| - CHECK_EQ(v8_str("gyt"), result->Get(v8::Integer::New(4)));
|
| + // Check that we get all the property names returned including the
|
| + // ones from the enumerators in the right order: indexed properties
|
| + // in numerical order, indexed interceptor properties, named
|
| + // properties in insertion order, named interceptor properties.
|
| + // This order is not mandated by the spec, so this test is just
|
| + // documenting our behavior.
|
| + CHECK_EQ(17, result->Length());
|
| + // Indexed properties in numerical order.
|
| + CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(0)));
|
| + CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(1)));
|
| + CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(2)));
|
| + CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(3)));
|
| + // Indexed interceptor properties in the order they are returned
|
| + // from the enumerator interceptor.
|
| + CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(4)));
|
| + CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(5)));
|
| + // Named properties in insertion order.
|
| + CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(6)));
|
| + CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(7)));
|
| + CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(8)));
|
| + CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(9)));
|
| + CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(10)));
|
| + CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(11)));
|
| + CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(12)));
|
| + CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(13)));
|
| + // Named interceptor properties.
|
| + CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(14)));
|
| + CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(15)));
|
| + CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(16)));
|
| }
|
|
|
|
|
|
|