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

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

Issue 7324027: Fix: FunctionTemplate::SetPrototypeAttributes broke prototype object (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
« src/objects.cc ('K') | « src/objects.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 6867 matching lines...) Expand 10 before | Expand all | Expand 10 after
6878 Local<Value> proto1 = o1->GetPrototype(); 6878 Local<Value> proto1 = o1->GetPrototype();
6879 CHECK(proto1->IsObject()); 6879 CHECK(proto1->IsObject());
6880 CHECK_EQ(proto1.As<v8::Object>(), o2); 6880 CHECK_EQ(proto1.As<v8::Object>(), o2);
6881 6881
6882 Local<Value> proto2 = o2->GetPrototype(); 6882 Local<Value> proto2 = o2->GetPrototype();
6883 CHECK(proto2->IsObject()); 6883 CHECK(proto2->IsObject());
6884 CHECK_EQ(proto2.As<v8::Object>(), o3); 6884 CHECK_EQ(proto2.As<v8::Object>(), o3);
6885 } 6885 }
6886 6886
6887 6887
6888 THREADED_TEST(SetPrototypeProperties) { 6888 THREADED_TEST(SetPrototypeAttributes) {
6889 v8::HandleScope handle_scope; 6889 v8::HandleScope handle_scope;
6890 LocalContext context; 6890 LocalContext context;
6891 6891
6892 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New(); 6892 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
6893 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
6893 t1->SetPrototypeAttributes(v8::DontDelete); 6894 t1->SetPrototypeAttributes(v8::DontDelete);
6894 context->Global()->Set(v8_str("func1"), t1->GetFunction()); 6895 context->Global()->Set(v8_str("func1"), t1->GetFunction());
6895 CHECK(CompileRun( 6896 CHECK(CompileRun(
6896 "(function() {" 6897 "(function() {"
6897 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');" 6898 " descriptor = Object.getOwnPropertyDescriptor(func1, 'prototype');"
6898 " return (descriptor['writable'] == true) &&" 6899 " return (descriptor['writable'] == true) &&"
6899 " (descriptor['enumerable'] == true) &&" 6900 " (descriptor['enumerable'] == true) &&"
6900 " (descriptor['configurable'] == false);" 6901 " (descriptor['configurable'] == false);"
6901 "})()")->BooleanValue()); 6902 "})()")->BooleanValue());
6903 CHECK_EQ(42, CompileRun("func1.prototype.x")->Int32Value());
6902 6904
6903 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New(); 6905 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
6906 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
6904 t2->SetPrototypeAttributes(v8::DontEnum); 6907 t2->SetPrototypeAttributes(v8::DontEnum);
6905 context->Global()->Set(v8_str("func2"), t2->GetFunction()); 6908 context->Global()->Set(v8_str("func2"), t2->GetFunction());
6906 CHECK(CompileRun( 6909 CHECK(CompileRun(
6907 "(function() {" 6910 "(function() {"
6908 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');" 6911 " descriptor = Object.getOwnPropertyDescriptor(func2, 'prototype');"
6909 " return (descriptor['writable'] == true) &&" 6912 " return (descriptor['writable'] == true) &&"
6910 " (descriptor['enumerable'] == false) &&" 6913 " (descriptor['enumerable'] == false) &&"
6911 " (descriptor['configurable'] == true);" 6914 " (descriptor['configurable'] == true);"
6912 "})()")->BooleanValue()); 6915 "})()")->BooleanValue());
6916 CHECK_EQ(42, CompileRun("func2.prototype.x")->Int32Value());
6913 6917
6914 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New(); 6918 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
6919 t3->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
6915 t3->SetPrototypeAttributes(v8::ReadOnly); 6920 t3->SetPrototypeAttributes(v8::ReadOnly);
6916 context->Global()->Set(v8_str("func3"), t3->GetFunction()); 6921 context->Global()->Set(v8_str("func3"), t3->GetFunction());
6917 CHECK(CompileRun( 6922 CHECK(CompileRun(
6918 "(function() {" 6923 "(function() {"
6919 " descriptor = Object.getOwnPropertyDescriptor(func3, 'prototype');" 6924 " descriptor = Object.getOwnPropertyDescriptor(func3, 'prototype');"
6920 " return (descriptor['writable'] == false) &&" 6925 " return (descriptor['writable'] == false) &&"
6921 " (descriptor['enumerable'] == true) &&" 6926 " (descriptor['enumerable'] == true) &&"
6922 " (descriptor['configurable'] == true);" 6927 " (descriptor['configurable'] == true);"
6923 "})()")->BooleanValue()); 6928 "})()")->BooleanValue());
6929 CHECK_EQ(42, CompileRun("func3.prototype.x")->Int32Value());
6924 6930
6925 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New(); 6931 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New();
6932 t4->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
6926 t4->SetPrototypeAttributes(v8::ReadOnly | v8::DontEnum | v8::DontDelete); 6933 t4->SetPrototypeAttributes(v8::ReadOnly | v8::DontEnum | v8::DontDelete);
6927 context->Global()->Set(v8_str("func4"), t4->GetFunction()); 6934 context->Global()->Set(v8_str("func4"), t4->GetFunction());
6928 CHECK(CompileRun( 6935 CHECK(CompileRun(
6929 "(function() {" 6936 "(function() {"
6930 " descriptor = Object.getOwnPropertyDescriptor(func4, 'prototype');" 6937 " descriptor = Object.getOwnPropertyDescriptor(func4, 'prototype');"
6931 " return (descriptor['writable'] == false) &&" 6938 " return (descriptor['writable'] == false) &&"
6932 " (descriptor['enumerable'] == false) &&" 6939 " (descriptor['enumerable'] == false) &&"
6933 " (descriptor['configurable'] == false);" 6940 " (descriptor['configurable'] == false);"
6934 "})()")->BooleanValue()); 6941 "})()")->BooleanValue());
6942 CHECK_EQ(42, CompileRun("func4.prototype.x")->Int32Value());
6935 } 6943 }
6936 6944
6937 6945
6938 THREADED_TEST(SetPrototypeThrows) { 6946 THREADED_TEST(SetPrototypeThrows) {
6939 v8::HandleScope handle_scope; 6947 v8::HandleScope handle_scope;
6940 LocalContext context; 6948 LocalContext context;
6941 6949
6942 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(); 6950 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
6943 6951
6944 Local<v8::Object> o0 = t->GetFunction()->NewInstance(); 6952 Local<v8::Object> o0 = t->GetFunction()->NewInstance();
(...skipping 7732 matching lines...) Expand 10 before | Expand all | Expand 10 after
14677 } 14685 }
14678 14686
14679 i::Isolate::Current()->heap()->CollectAllGarbage(true); 14687 i::Isolate::Current()->heap()->CollectAllGarbage(true);
14680 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); 14688 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache();
14681 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { 14689 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) {
14682 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); 14690 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache);
14683 CHECK_GT(elements, map_cache->NumberOfElements()); 14691 CHECK_GT(elements, map_cache->NumberOfElements());
14684 } 14692 }
14685 } 14693 }
14686 } 14694 }
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698