| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 076fb4f576c011f4d4909ebabb63a9a952b7a905..1416d7d74bcc471ba0eece12bf11397b9ee725b1 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -7453,6 +7453,60 @@ THREADED_TEST(SetPrototype) {
|
| }
|
|
|
|
|
| +// Getting property names of an object with a prototype chain that
|
| +// triggers dictionary elements in GetLocalPropertyNames() shouldn't
|
| +// crash the runtime.
|
| +THREADED_TEST(Regress91517) {
|
| + i::FLAG_allow_natives_syntax = true;
|
| + v8::HandleScope handle_scope;
|
| + LocalContext context;
|
| +
|
| + Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
|
| + t1->SetHiddenPrototype(true);
|
| + t1->InstanceTemplate()->Set(v8_str("foo"), v8_num(1));
|
| + Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
|
| + t2->SetHiddenPrototype(true);
|
| + t2->InstanceTemplate()->Set(v8_str("fuz1"), v8_num(2));
|
| + t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New());
|
| + t2->InstanceTemplate()->Set(v8_str("fuz2"), v8_num(2));
|
| + Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
|
| + t3->SetHiddenPrototype(true);
|
| + t3->InstanceTemplate()->Set(v8_str("boo"), v8_num(3));
|
| + Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New();
|
| + t4->InstanceTemplate()->Set(v8_str("baz"), v8_num(4));
|
| +
|
| + // Force dictionary-based properties.
|
| + i::ScopedVector<char> name_buf(1024);
|
| + for (int i = 1; i <= 1000; i++) {
|
| + i::OS::SNPrintF(name_buf, "sdf%d", i);
|
| + t2->InstanceTemplate()->Set(v8_str(name_buf.start()), v8_num(2));
|
| + }
|
| +
|
| + Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
|
| + Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
|
| + Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
|
| + Local<v8::Object> o4 = t4->GetFunction()->NewInstance();
|
| +
|
| + // Create prototype chain of hidden prototypes.
|
| + CHECK(o4->SetPrototype(o3));
|
| + CHECK(o3->SetPrototype(o2));
|
| + CHECK(o2->SetPrototype(o1));
|
| +
|
| + // Call the runtime version of GetLocalPropertyNames() on the natively
|
| + // created object through JavaScript.
|
| + context->Global()->Set(v8_str("obj"), o4);
|
| + CompileRun("var names = %GetLocalPropertyNames(obj);");
|
| +
|
| + ExpectInt32("names.length", 1006);
|
| + ExpectTrue("names.indexOf(\"baz\") >= 0");
|
| + ExpectTrue("names.indexOf(\"boo\") >= 0");
|
| + ExpectTrue("names.indexOf(\"foo\") >= 0");
|
| + ExpectTrue("names.indexOf(\"fuz1\") >= 0");
|
| + ExpectTrue("names.indexOf(\"fuz2\") >= 0");
|
| + ExpectFalse("names[1005] == undefined");
|
| +}
|
| +
|
| +
|
| THREADED_TEST(FunctionReadOnlyPrototype) {
|
| v8::HandleScope handle_scope;
|
| LocalContext context;
|
|
|