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 = | |
10010 v8::FunctionTemplate::New(context->GetIsolate()); | |
10011 t1->SetHiddenPrototype(true); | |
10012 | |
10013 Local<v8::ObjectTemplate> i1 = t1->InstanceTemplate(); | |
10014 i1->SetAccessor(v8_str("foo"), | |
10015 SimpleAccessorGetter, SimpleAccessorSetter); | |
10016 i1->SetAccessor(v8_str("bar"), | |
10017 SimpleAccessorGetter, SimpleAccessorSetter); | |
10018 i1->SetAccessor(v8_str("baz"), | |
10019 SimpleAccessorGetter, SimpleAccessorSetter); | |
10020 i1->Set(v8_str("n1"), v8_num(1)); | |
10021 i1->Set(v8_str("n2"), v8_num(2)); | |
10022 | |
10023 Local<v8::Object> o1 = t1->GetFunction()->NewInstance(); | |
10024 Local<v8::FunctionTemplate> t2 = | |
10025 v8::FunctionTemplate::New(context->GetIsolate()); | |
10026 t2->SetHiddenPrototype(true); | |
10027 | |
10028 // Inherit from t1 and mark prototype as hidden. | |
10029 t2->Inherit(t1); | |
10030 t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4)); | |
10031 | |
10032 Local<v8::Object> o2 = t2->GetFunction()->NewInstance(); | |
10033 CHECK(o2->SetPrototype(o1)); | |
10034 | |
10035 // Call the runtime version of GetLocalPropertyNames() on | |
10036 // the natively created object through JavaScript. | |
10037 context->Global()->Set(v8_str("obj"), o2); | |
10038 CompileRun("var names = %GetLocalPropertyNames(obj, true);"); | |
10039 | |
10040 ExpectInt32("names.length", 4); | |
dcarney
2013/12/19 19:46:12
'names' should include 'n1' and 'n2' as they are i
sof
2013/12/22 08:39:55
Eh, right :) Thanks, updated the pass conditions a
| |
10041 ExpectTrue("names.indexOf(\"foo\") >= 0"); | |
10042 ExpectTrue("names.indexOf(\"bar\") >= 0"); | |
10043 ExpectTrue("names.indexOf(\"baz\") >= 0"); | |
10044 ExpectTrue("names.indexOf(\"mine\") >= 0"); | |
10045 } | |
10046 | |
10047 | |
10002 THREADED_TEST(FunctionReadOnlyPrototype) { | 10048 THREADED_TEST(FunctionReadOnlyPrototype) { |
10003 LocalContext context; | 10049 LocalContext context; |
10004 v8::HandleScope handle_scope(context->GetIsolate()); | 10050 v8::HandleScope handle_scope(context->GetIsolate()); |
10005 | 10051 |
10006 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); | 10052 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); |
10007 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); | 10053 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); |
10008 t1->ReadOnlyPrototype(); | 10054 t1->ReadOnlyPrototype(); |
10009 context->Global()->Set(v8_str("func1"), t1->GetFunction()); | 10055 context->Global()->Set(v8_str("func1"), t1->GetFunction()); |
10010 // Configured value of ReadOnly flag. | 10056 // Configured value of ReadOnly flag. |
10011 CHECK(CompileRun( | 10057 CHECK(CompileRun( |
(...skipping 10938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20950 } | 20996 } |
20951 for (int i = 0; i < runs; i++) { | 20997 for (int i = 0; i < runs; i++) { |
20952 Local<String> expected; | 20998 Local<String> expected; |
20953 if (i != 0) { | 20999 if (i != 0) { |
20954 CHECK_EQ(v8_str("escape value"), values[i]); | 21000 CHECK_EQ(v8_str("escape value"), values[i]); |
20955 } else { | 21001 } else { |
20956 CHECK(values[i].IsEmpty()); | 21002 CHECK(values[i].IsEmpty()); |
20957 } | 21003 } |
20958 } | 21004 } |
20959 } | 21005 } |
OLD | NEW |