Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: test/cctest/test-api.cc

Issue 116533003: Avoid duplication of a hidden & inherited prototype's properties. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Remove DEBUG protection Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10045 matching lines...) Expand 10 before | Expand all | Expand 10 after
10056 ExpectInt32("names.length", 1006); 10056 ExpectInt32("names.length", 1006);
10057 ExpectTrue("names.indexOf(\"baz\") >= 0"); 10057 ExpectTrue("names.indexOf(\"baz\") >= 0");
10058 ExpectTrue("names.indexOf(\"boo\") >= 0"); 10058 ExpectTrue("names.indexOf(\"boo\") >= 0");
10059 ExpectTrue("names.indexOf(\"foo\") >= 0"); 10059 ExpectTrue("names.indexOf(\"foo\") >= 0");
10060 ExpectTrue("names.indexOf(\"fuz1\") >= 0"); 10060 ExpectTrue("names.indexOf(\"fuz1\") >= 0");
10061 ExpectTrue("names.indexOf(\"fuz2\") >= 0"); 10061 ExpectTrue("names.indexOf(\"fuz2\") >= 0");
10062 ExpectFalse("names[1005] == undefined"); 10062 ExpectFalse("names[1005] == undefined");
10063 } 10063 }
10064 10064
10065 10065
10066 // Getting property names of an object with a hidden and inherited
10067 // prototype should not duplicate the accessor properties inherited.
10068 THREADED_TEST(Regress269562) {
10069 i::FLAG_allow_natives_syntax = true;
10070 LocalContext context;
10071 v8::HandleScope handle_scope(context->GetIsolate());
10072
10073 Local<v8::FunctionTemplate> t1 =
10074 v8::FunctionTemplate::New(context->GetIsolate());
10075 t1->SetHiddenPrototype(true);
10076
10077 Local<v8::ObjectTemplate> i1 = t1->InstanceTemplate();
10078 i1->SetAccessor(v8_str("foo"),
10079 SimpleAccessorGetter, SimpleAccessorSetter);
10080 i1->SetAccessor(v8_str("bar"),
10081 SimpleAccessorGetter, SimpleAccessorSetter);
10082 i1->SetAccessor(v8_str("baz"),
10083 SimpleAccessorGetter, SimpleAccessorSetter);
10084 i1->Set(v8_str("n1"), v8_num(1));
10085 i1->Set(v8_str("n2"), v8_num(2));
10086
10087 Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
10088 Local<v8::FunctionTemplate> t2 =
10089 v8::FunctionTemplate::New(context->GetIsolate());
10090 t2->SetHiddenPrototype(true);
10091
10092 // Inherit from t1 and mark prototype as hidden.
10093 t2->Inherit(t1);
10094 t2->InstanceTemplate()->Set(v8_str("mine"), v8_num(4));
10095
10096 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
10097 CHECK(o2->SetPrototype(o1));
10098
10099 v8::Local<v8::Symbol> sym = v8::Symbol::New(context->GetIsolate(), "s1");
10100 o1->Set(sym, v8_num(3));
10101 o1->SetHiddenValue(v8_str("h1"), v8::Integer::New(2013));
10102
10103 // Call the runtime version of GetLocalPropertyNames() on
10104 // the natively created object through JavaScript.
10105 context->Global()->Set(v8_str("obj"), o2);
10106 context->Global()->Set(v8_str("sym"), sym);
10107 CompileRun("var names = %GetLocalPropertyNames(obj, true);");
10108
10109 ExpectInt32("names.length", 7);
10110 ExpectTrue("names.indexOf(\"foo\") >= 0");
10111 ExpectTrue("names.indexOf(\"bar\") >= 0");
10112 ExpectTrue("names.indexOf(\"baz\") >= 0");
10113 ExpectTrue("names.indexOf(\"n1\") >= 0");
10114 ExpectTrue("names.indexOf(\"n2\") >= 0");
10115 ExpectTrue("names.indexOf(sym) >= 0");
10116 ExpectTrue("names.indexOf(\"mine\") >= 0");
10117 }
10118
10119
10066 THREADED_TEST(FunctionReadOnlyPrototype) { 10120 THREADED_TEST(FunctionReadOnlyPrototype) {
10067 LocalContext context; 10121 LocalContext context;
10068 v8::Isolate* isolate = context->GetIsolate(); 10122 v8::Isolate* isolate = context->GetIsolate();
10069 v8::HandleScope handle_scope(isolate); 10123 v8::HandleScope handle_scope(isolate);
10070 10124
10071 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate); 10125 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(isolate);
10072 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42)); 10126 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
10073 t1->ReadOnlyPrototype(); 10127 t1->ReadOnlyPrototype();
10074 context->Global()->Set(v8_str("func1"), t1->GetFunction()); 10128 context->Global()->Set(v8_str("func1"), t1->GetFunction());
10075 // Configured value of ReadOnly flag. 10129 // Configured value of ReadOnly flag.
(...skipping 11279 matching lines...) Expand 10 before | Expand all | Expand 10 after
21355 } 21409 }
21356 for (int i = 0; i < runs; i++) { 21410 for (int i = 0; i < runs; i++) {
21357 Local<String> expected; 21411 Local<String> expected;
21358 if (i != 0) { 21412 if (i != 0) {
21359 CHECK_EQ(v8_str("escape value"), values[i]); 21413 CHECK_EQ(v8_str("escape value"), values[i]);
21360 } else { 21414 } else {
21361 CHECK(values[i].IsEmpty()); 21415 CHECK(values[i].IsEmpty());
21362 } 21416 }
21363 } 21417 }
21364 } 21418 }
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698