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

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

Issue 527963002: Implement loads and calls from 'super' (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased before landing Created 6 years, 3 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
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/super.js » ('j') | 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 9525 matching lines...) Expand 10 before | Expand all | Expand 10 after
9536 CompileRun("other.accessible_prop = 42"); 9536 CompileRun("other.accessible_prop = 42");
9537 CHECK_EQ(42, g_echo_value); 9537 CHECK_EQ(42, g_echo_value);
9538 9538
9539 v8::Handle<Value> value; 9539 v8::Handle<Value> value;
9540 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: -1})"); 9540 CompileRun("Object.defineProperty(other, 'accessible_prop', {value: -1})");
9541 value = CompileRun("other.accessible_prop == 42"); 9541 value = CompileRun("other.accessible_prop == 42");
9542 CHECK(value->IsTrue()); 9542 CHECK(value->IsTrue());
9543 } 9543 }
9544 9544
9545 9545
9546 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, 9546 static bool BlockEverythingNamed(Local<v8::Object> object, Local<Value> name,
9547 Local<Value> name, 9547 v8::AccessType type, Local<Value> data) {
9548 v8::AccessType type,
9549 Local<Value> data) {
9550 return false; 9548 return false;
9551 } 9549 }
9552 9550
9553 9551
9554 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global, 9552 static bool BlockEverythingIndexed(Local<v8::Object> object, uint32_t key,
9555 uint32_t key, 9553 v8::AccessType type, Local<Value> data) {
9556 v8::AccessType type,
9557 Local<Value> data) {
9558 return false; 9554 return false;
9559 } 9555 }
9560 9556
9561 9557
9562 THREADED_TEST(AccessControlGetOwnPropertyNames) { 9558 THREADED_TEST(AccessControlGetOwnPropertyNames) {
9563 v8::Isolate* isolate = CcTest::isolate(); 9559 v8::Isolate* isolate = CcTest::isolate();
9564 v8::HandleScope handle_scope(isolate); 9560 v8::HandleScope handle_scope(isolate);
9565 v8::Handle<v8::ObjectTemplate> obj_template = 9561 v8::Handle<v8::ObjectTemplate> obj_template =
9566 v8::ObjectTemplate::New(isolate); 9562 v8::ObjectTemplate::New(isolate);
9567 9563
9568 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); 9564 obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42));
9569 obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, 9565 obj_template->SetAccessCheckCallbacks(BlockEverythingNamed,
9570 GetOwnPropertyNamesIndexedBlocker); 9566 BlockEverythingIndexed);
9571 9567
9572 // Create an environment 9568 // Create an environment
9573 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); 9569 v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
9574 context0->Enter(); 9570 context0->Enter();
9575 9571
9576 v8::Handle<v8::Object> global0 = context0->Global(); 9572 v8::Handle<v8::Object> global0 = context0->Global();
9577 9573
9578 v8::HandleScope scope1(CcTest::isolate()); 9574 v8::HandleScope scope1(CcTest::isolate());
9579 9575
9580 v8::Local<Context> context1 = Context::New(isolate); 9576 v8::Local<Context> context1 = Context::New(isolate);
(...skipping 14 matching lines...) Expand all
9595 CHECK(value.IsEmpty()); 9591 CHECK(value.IsEmpty());
9596 9592
9597 value = CompileRun("Object.getOwnPropertyNames(object).length == 0"); 9593 value = CompileRun("Object.getOwnPropertyNames(object).length == 0");
9598 CHECK(value.IsEmpty()); 9594 CHECK(value.IsEmpty());
9599 9595
9600 context1->Exit(); 9596 context1->Exit();
9601 context0->Exit(); 9597 context0->Exit();
9602 } 9598 }
9603 9599
9604 9600
9601 TEST(SuperAccessControl) {
9602 i::FLAG_harmony_classes = true;
9603 v8::Isolate* isolate = CcTest::isolate();
9604 v8::HandleScope handle_scope(isolate);
9605 v8::Handle<v8::ObjectTemplate> obj_template =
9606 v8::ObjectTemplate::New(isolate);
9607 obj_template->SetAccessCheckCallbacks(BlockEverythingNamed,
9608 BlockEverythingIndexed);
9609 LocalContext env;
9610 env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance());
9611
9612 v8::TryCatch try_catch;
9613 CompileRun(
9614 "function f() { return super.hasOwnProperty; };"
9615 "var m = f.toMethod(prohibited);"
9616 "m();");
9617 CHECK(try_catch.HasCaught());
9618 }
9619
9620
9605 static void IndexedPropertyEnumerator( 9621 static void IndexedPropertyEnumerator(
9606 const v8::PropertyCallbackInfo<v8::Array>& info) { 9622 const v8::PropertyCallbackInfo<v8::Array>& info) {
9607 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); 9623 v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2);
9608 result->Set(0, v8::Integer::New(info.GetIsolate(), 7)); 9624 result->Set(0, v8::Integer::New(info.GetIsolate(), 7));
9609 result->Set(1, v8::Object::New(info.GetIsolate())); 9625 result->Set(1, v8::Object::New(info.GetIsolate()));
9610 info.GetReturnValue().Set(result); 9626 info.GetReturnValue().Set(result);
9611 } 9627 }
9612 9628
9613 9629
9614 static void NamedPropertyEnumerator( 9630 static void NamedPropertyEnumerator(
(...skipping 13696 matching lines...) Expand 10 before | Expand all | Expand 10 after
23311 // TestSourceStream::GetMoreData won't block, so it's OK to just run the 23327 // TestSourceStream::GetMoreData won't block, so it's OK to just run the
23312 // task here in the main thread. 23328 // task here in the main thread.
23313 task->Run(); 23329 task->Run();
23314 delete task; 23330 delete task;
23315 23331
23316 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); 23332 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData();
23317 CHECK(cached_data != NULL); 23333 CHECK(cached_data != NULL);
23318 CHECK(cached_data->data != NULL); 23334 CHECK(cached_data->data != NULL);
23319 CHECK_GT(cached_data->length, 0); 23335 CHECK_GT(cached_data->length, 0);
23320 } 23336 }
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/mjsunit/harmony/super.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698