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

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

Issue 1677483002: Always load data for access check callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/isolate.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 8924 matching lines...) Expand 10 before | Expand all | Expand 10 after
8935 CHECK_EQ(0, strcmp(*finally_exception_value, "2")); 8935 CHECK_EQ(0, strcmp(*finally_exception_value, "2"));
8936 } 8936 }
8937 8937
8938 8938
8939 // For use within the TestSecurityHandler() test. 8939 // For use within the TestSecurityHandler() test.
8940 static bool g_security_callback_result = false; 8940 static bool g_security_callback_result = false;
8941 static bool SecurityTestCallback(Local<v8::Context> accessing_context, 8941 static bool SecurityTestCallback(Local<v8::Context> accessing_context,
8942 Local<v8::Object> accessed_object, 8942 Local<v8::Object> accessed_object,
8943 Local<v8::Value> data) { 8943 Local<v8::Value> data) {
8944 printf("a\n"); 8944 printf("a\n");
8945 CHECK(!data.IsEmpty() && data->IsInt32());
8946 CHECK_EQ(42, data->Int32Value(accessing_context).FromJust());
8945 return g_security_callback_result; 8947 return g_security_callback_result;
8946 } 8948 }
8947 8949
8948 8950
8949 // SecurityHandler can't be run twice 8951 // SecurityHandler can't be run twice
8950 TEST(SecurityHandler) { 8952 TEST(SecurityHandler) {
8951 v8::Isolate* isolate = CcTest::isolate(); 8953 v8::Isolate* isolate = CcTest::isolate();
8952 v8::HandleScope scope0(isolate); 8954 v8::HandleScope scope0(isolate);
8953 v8::Local<v8::ObjectTemplate> global_template = 8955 v8::Local<v8::ObjectTemplate> global_template =
8954 v8::ObjectTemplate::New(isolate); 8956 v8::ObjectTemplate::New(isolate);
8955 global_template->SetAccessCheckCallback(SecurityTestCallback); 8957 global_template->SetAccessCheckCallback(SecurityTestCallback, v8_num(42));
8956 // Create an environment 8958 // Create an environment
8957 v8::Local<Context> context0 = Context::New(isolate, NULL, global_template); 8959 v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
8958 context0->Enter(); 8960 context0->Enter();
8959 8961
8960 v8::Local<v8::Object> global0 = context0->Global(); 8962 v8::Local<v8::Object> global0 = context0->Global();
8961 v8::Local<Script> script0 = v8_compile("foo = 111"); 8963 v8::Local<Script> script0 = v8_compile("foo = 111");
8962 script0->Run(context0).ToLocalChecked(); 8964 script0->Run(context0).ToLocalChecked();
8963 CHECK(global0->Set(context0, v8_str("0"), v8_num(999)).FromJust()); 8965 CHECK(global0->Set(context0, v8_str("0"), v8_num(999)).FromJust());
8964 v8::Local<Value> foo0 = 8966 v8::Local<Value> foo0 =
8965 global0->Get(context0, v8_str("foo")).ToLocalChecked(); 8967 global0->Get(context0, v8_str("foo")).ToLocalChecked();
(...skipping 15682 matching lines...) Expand 10 before | Expand all | Expand 10 after
24648 CHECK(proxy->GetTarget()->SameValue(target)); 24650 CHECK(proxy->GetTarget()->SameValue(target));
24649 CHECK(proxy->GetHandler()->SameValue(handler)); 24651 CHECK(proxy->GetHandler()->SameValue(handler));
24650 24652
24651 proxy->Revoke(); 24653 proxy->Revoke();
24652 CHECK(proxy->IsProxy()); 24654 CHECK(proxy->IsProxy());
24653 CHECK(!target->IsProxy()); 24655 CHECK(!target->IsProxy());
24654 CHECK(proxy->IsRevoked()); 24656 CHECK(proxy->IsRevoked());
24655 CHECK(proxy->GetTarget()->SameValue(target)); 24657 CHECK(proxy->GetTarget()->SameValue(target));
24656 CHECK(proxy->GetHandler()->IsNull()); 24658 CHECK(proxy->GetHandler()->IsNull());
24657 } 24659 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698