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

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

Issue 1242093002: Fix getPrototypeOf for access checked objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Return null rather than undefined Created 5 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
« no previous file with comments | « src/runtime/runtime-object.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 18086 matching lines...) Expand 10 before | Expand all | Expand 10 after
18097 global_template->Set(v8_str("proxy"), proxy_object); 18097 global_template->Set(v8_str("proxy"), proxy_object);
18098 global_template->Set(v8_str("hidden"), object_with_hidden); 18098 global_template->Set(v8_str("hidden"), object_with_hidden);
18099 global_template->Set(v8_str("phidden"), object_with_protected_hidden); 18099 global_template->Set(v8_str("phidden"), object_with_protected_hidden);
18100 18100
18101 LocalContext context2(NULL, global_template); 18101 LocalContext context2(NULL, global_template);
18102 18102
18103 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)"); 18103 Local<Value> result1 = CompileRun("Object.getPrototypeOf(simple)");
18104 CHECK(result1->Equals(simple_object->GetPrototype())); 18104 CHECK(result1->Equals(simple_object->GetPrototype()));
18105 18105
18106 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)"); 18106 Local<Value> result2 = CompileRun("Object.getPrototypeOf(protected)");
18107 CHECK(result2.IsEmpty()); 18107 CHECK(result2->IsNull());
18108 18108
18109 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)"); 18109 Local<Value> result3 = CompileRun("Object.getPrototypeOf(global)");
18110 CHECK(result3->Equals(global_object->GetPrototype())); 18110 CHECK(result3->Equals(global_object->GetPrototype()));
18111 18111
18112 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)"); 18112 Local<Value> result4 = CompileRun("Object.getPrototypeOf(proxy)");
18113 CHECK(result4.IsEmpty()); 18113 CHECK(result4->IsNull());
18114 18114
18115 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)"); 18115 Local<Value> result5 = CompileRun("Object.getPrototypeOf(hidden)");
18116 CHECK(result5->Equals( 18116 CHECK(result5->Equals(
18117 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype())); 18117 object_with_hidden->GetPrototype()->ToObject(isolate)->GetPrototype()));
18118 18118
18119 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)"); 18119 Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
18120 CHECK(result6.IsEmpty()); 18120 CHECK(result6->IsNull());
18121 } 18121 }
18122 18122
18123 18123
18124 static void TestReceiver(Local<Value> expected_result, 18124 static void TestReceiver(Local<Value> expected_result,
18125 Local<Value> expected_receiver, 18125 Local<Value> expected_receiver,
18126 const char* code) { 18126 const char* code) {
18127 Local<Value> result = CompileRun(code); 18127 Local<Value> result = CompileRun(code);
18128 CHECK(result->IsObject()); 18128 CHECK(result->IsObject());
18129 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1))); 18129 CHECK(expected_receiver->Equals(result.As<v8::Object>()->Get(1)));
18130 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0))); 18130 CHECK(expected_result->Equals(result.As<v8::Object>()->Get(0)));
(...skipping 3147 matching lines...) Expand 10 before | Expand all | Expand 10 after
21278 v8::Isolate* isolate = CcTest::isolate(); 21278 v8::Isolate* isolate = CcTest::isolate();
21279 v8::HandleScope handle_scope(isolate); 21279 v8::HandleScope handle_scope(isolate);
21280 LocalContext env; 21280 LocalContext env;
21281 21281
21282 v8::Handle<v8::ObjectTemplate> obj_template = 21282 v8::Handle<v8::ObjectTemplate> obj_template =
21283 v8::ObjectTemplate::New(isolate); 21283 v8::ObjectTemplate::New(isolate);
21284 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL); 21284 obj_template->SetAccessCheckCallbacks(AccessAlwaysBlocked, NULL);
21285 21285
21286 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); 21286 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
21287 21287
21288 { 21288 CHECK(CompileRun(
21289 v8::TryCatch try_catch(isolate); 21289 "function f() { return %_GetPrototype(prohibited); }"
21290 CompileRun( 21290 "%OptimizeFunctionOnNextCall(f);"
21291 "function f() { %_GetPrototype(prohibited); }" 21291 "f();")->IsNull());
21292 "%OptimizeFunctionOnNextCall(f);"
21293 "f();");
21294 CHECK(try_catch.HasCaught());
21295 }
21296 } 21292 }
21297 21293
21298 21294
21299 TEST(GetPrototypeHidden) { 21295 TEST(GetPrototypeHidden) {
21300 i::FLAG_allow_natives_syntax = true; 21296 i::FLAG_allow_natives_syntax = true;
21301 v8::Isolate* isolate = CcTest::isolate(); 21297 v8::Isolate* isolate = CcTest::isolate();
21302 v8::HandleScope handle_scope(isolate); 21298 v8::HandleScope handle_scope(isolate);
21303 LocalContext env; 21299 LocalContext env;
21304 21300
21305 Handle<FunctionTemplate> t = FunctionTemplate::New(isolate); 21301 Handle<FunctionTemplate> t = FunctionTemplate::New(isolate);
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
21841 " fake.age;\n" 21837 " fake.age;\n"
21842 " result = 1;\n" 21838 " result = 1;\n"
21843 " } catch (e) {\n" 21839 " } catch (e) {\n"
21844 " }\n" 21840 " }\n"
21845 " test(d+1);\n" 21841 " test(d+1);\n"
21846 "}\n" 21842 "}\n"
21847 "test(0);\n" 21843 "test(0);\n"
21848 "result;\n", 21844 "result;\n",
21849 0); 21845 0);
21850 } 21846 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698