Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 9981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9992 ExpectInt32("names.length", 1006); | 9992 ExpectInt32("names.length", 1006); |
| 9993 ExpectTrue("names.indexOf(\"baz\") >= 0"); | 9993 ExpectTrue("names.indexOf(\"baz\") >= 0"); |
| 9994 ExpectTrue("names.indexOf(\"boo\") >= 0"); | 9994 ExpectTrue("names.indexOf(\"boo\") >= 0"); |
| 9995 ExpectTrue("names.indexOf(\"foo\") >= 0"); | 9995 ExpectTrue("names.indexOf(\"foo\") >= 0"); |
| 9996 ExpectTrue("names.indexOf(\"fuz1\") >= 0"); | 9996 ExpectTrue("names.indexOf(\"fuz1\") >= 0"); |
| 9997 ExpectTrue("names.indexOf(\"fuz2\") >= 0"); | 9997 ExpectTrue("names.indexOf(\"fuz2\") >= 0"); |
| 9998 ExpectFalse("names[1005] == undefined"); | 9998 ExpectFalse("names[1005] == undefined"); |
| 9999 } | 9999 } |
| 10000 | 10000 |
| 10001 | 10001 |
| 10002 // Getting property names of an object with a hidden and inherited | |
| 10003 // prototype should not duplicate the accessor properties inherited. | |
| 10004 THREADED_TEST(Regress269562) { | |
| 10005 i::FLAG_allow_natives_syntax = true; | |
| 10006 LocalContext context; | |
| 10007 v8::HandleScope handle_scope(context->GetIsolate()); | |
| 10008 | |
| 10009 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | |
|
jochen (gone - plz use gerrit)
2013/12/17 15:00:53
please pass an isolate to ::New (here and below)
| |
| 10010 t1->SetHiddenPrototype(true); | |
| 10011 | |
| 10012 Local<v8::ObjectTemplate> i1 = t1->InstanceTemplate(); | |
| 10013 i1->SetAccessor(v8_str("foo"), | |
| 10014 SimpleAccessorGetter, SimpleAccessorSetter); | |
| 10015 i1->SetAccessor(v8_str("bar"), | |
| 10016 SimpleAccessorGetter, SimpleAccessorSetter); | |
| 10017 i1->SetAccessor(v8_str("baz"), | |
| 10018 SimpleAccessorGetter, SimpleAccessorSetter); | |
| 10019 i1->Set(v8_str("n1"), v8_num(1)); | |
| 10020 i1->Set(v8_str("n2"), v8_num(2)); | |
| 10021 | |
| 10022 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); | |
| 10023 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); | |
| 10024 t2->SetHiddenPrototype(true); | |
| 10025 | |
| 10026 // Inherit from t1 and mark prototype as hidden. | |
| 10027 t2->Inherit(t1); | |
| 10028 t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4)); | |
| 10029 | |
| 10030 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); | |
| 10031 CHECK(o2->SetPrototype(o1)); | |
| 10032 | |
| 10033 // Call the runtime version of GetLocalPropertyNames() on | |
| 10034 // the natively created object through JavaScript. | |
| 10035 context->Global()->Set(v8_str("obj"), o2); | |
| 10036 CompileRun("var names = %GetLocalPropertyNames(obj, true);"); | |
| 10037 | |
| 10038 ExpectInt32("names.length", 4); | |
| 10039 ExpectTrue("names.indexOf(\"foo\") >= 0"); | |
| 10040 ExpectTrue("names.indexOf(\"bar\") >= 0"); | |
| 10041 ExpectTrue("names.indexOf(\"baz\") >= 0"); | |
| 10042 ExpectTrue("names.indexOf(\"mine\") >= 0"); | |
| 10043 } | |
| 10044 | |
| 10045 | |
| 10002 THREADED_TEST(FunctionReadOnlyPrototype) { | 10046 THREADED_TEST(FunctionReadOnlyPrototype) { |
| 10003 LocalContext context; | 10047 LocalContext context; |
| 10004 v8::HandleScope handle_scope(context->GetIsolate()); | 10048 v8::HandleScope handle_scope(context->GetIsolate()); |
| 10005 | 10049 |
| 10006 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 10050 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); |
| 10007 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10051 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); |
| 10008 t1->ReadOnlyPrototype(); | 10052 t1->ReadOnlyPrototype(); |
| 10009 context->Global()->Set(v8_str("func1"), t1->GetFunction()); | 10053 context->Global()->Set(v8_str("func1"), t1->GetFunction()); |
| 10010 // Configured value of ReadOnly flag. | 10054 // Configured value of ReadOnly flag. |
| 10011 CHECK(CompileRun( | 10055 CHECK(CompileRun( |
| (...skipping 10938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 20950 } | 20994 } |
| 20951 for (int i = 0; i < runs; i++) { | 20995 for (int i = 0; i < runs; i++) { |
| 20952 Local<String> expected; | 20996 Local<String> expected; |
| 20953 if (i != 0) { | 20997 if (i != 0) { |
| 20954 CHECK_EQ(v8_str("escape value"), values[i]); | 20998 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20955 } else { | 20999 } else { |
| 20956 CHECK(values[i].IsEmpty()); | 21000 CHECK(values[i].IsEmpty()); |
| 20957 } | 21001 } |
| 20958 } | 21002 } |
| 20959 } | 21003 } |
| OLD | NEW |