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

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

Issue 2244123005: [api] Add PropertyDescriptor and DefineProperty(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move destructor. Created 4 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
« src/api.cc ('K') | « src/counters.h ('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 15986 matching lines...) Expand 10 before | Expand all | Expand 10 after
15997 templ->NewInstance(env.local()).ToLocalChecked(); 15997 templ->NewInstance(env.local()).ToLocalChecked();
15998 { 15998 {
15999 v8::TryCatch try_catch(isolate); 15999 v8::TryCatch try_catch(isolate);
16000 CHECK(access_checked->DefineOwnProperty(env.local(), v8_str("foo"), 16000 CHECK(access_checked->DefineOwnProperty(env.local(), v8_str("foo"),
16001 v8::Integer::New(isolate, 42)) 16001 v8::Integer::New(isolate, 42))
16002 .IsNothing()); 16002 .IsNothing());
16003 CHECK(try_catch.HasCaught()); 16003 CHECK(try_catch.HasCaught());
16004 } 16004 }
16005 } 16005 }
16006 16006
16007 TEST(DefineProperty) {
16008 LocalContext env;
16009 v8::Isolate* isolate = env->GetIsolate();
16010 v8::HandleScope handle_scope(isolate);
16011
16012 v8::Local<v8::Name> p;
16013
16014 CompileRun(
16015 "var a = {};"
16016 "var b = [];"
16017 "Object.defineProperty(a, 'v1', {value: 23});"
16018 "Object.defineProperty(a, 'v2', {value: 23, configurable: true});");
16019
16020 v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(
16021 env->Global()->Get(env.local(), v8_str("a")).ToLocalChecked());
16022 v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(
16023 env->Global()->Get(env.local(), v8_str("b")).ToLocalChecked());
16024
16025 const v8::PropertyDescriptor desc(v8_num(42),
16026 v8::PropertyDescriptor::State::kNotSet);
16027 {
16028 // Use a data descriptor.
16029
16030 // Can't change a non-configurable property.
16031 p = v8_str("v1");
16032 v8::TryCatch try_catch(isolate);
16033 CHECK(!obj->DefineProperty(env.local(), p, desc).FromJust());
16034 CHECK(!try_catch.HasCaught());
16035 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16036 CHECK(val->IsNumber());
16037 CHECK_EQ(23.0, val->NumberValue(env.local()).FromJust());
16038
16039 // Change configurable property
16040 p = v8_str("v2");
16041 CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
16042 CHECK(!try_catch.HasCaught());
16043 val = obj->Get(env.local(), p).ToLocalChecked();
16044 CHECK(val->IsNumber());
16045 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust());
16046 }
16047
16048 {
16049 // Set a regular property.
16050 p = v8_str("v3");
16051 v8::TryCatch try_catch(isolate);
16052 CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
16053 CHECK(!try_catch.HasCaught());
16054 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16055 CHECK(val->IsNumber());
16056 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust());
16057 }
16058
16059 {
16060 // Set an indexed property.
16061 v8::TryCatch try_catch(isolate);
16062 CHECK(obj->DefineProperty(env.local(), v8_str("1"), desc).FromJust());
16063 CHECK(!try_catch.HasCaught());
16064 v8::Local<v8::Value> val = obj->Get(env.local(), 1).ToLocalChecked();
16065 CHECK(val->IsNumber());
16066 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust());
16067 }
16068
16069 {
16070 // No special case when changing array length.
16071 v8::TryCatch try_catch(isolate);
16072 CHECK(arr->DefineProperty(env.local(), v8_str("length"), desc).FromJust());
16073 CHECK(!try_catch.HasCaught());
16074 }
16075
16076 {
16077 // Special cases for arrays: index exceeds the array's length.
16078 v8::TryCatch try_catch(isolate);
16079 CHECK(arr->DefineProperty(env.local(), v8_str("100"), desc).FromJust());
16080 CHECK(!try_catch.HasCaught());
16081 CHECK_EQ(101U, arr->Length());
16082 v8::Local<v8::Value> val = arr->Get(env.local(), 100).ToLocalChecked();
16083 CHECK(val->IsNumber());
16084 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust());
16085
16086 // Set an existing entry.
16087 CHECK(arr->DefineProperty(env.local(), v8_str("0"), desc).FromJust());
16088 CHECK(!try_catch.HasCaught());
16089 val = arr->Get(env.local(), 0).ToLocalChecked();
16090 CHECK(val->IsNumber());
16091 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust());
16092 }
16093
16094 {
16095 // Use a generic descriptor.
16096 const v8::PropertyDescriptor desc_generic;
16097
16098 p = v8_str("v4");
16099 v8::TryCatch try_catch(isolate);
16100 CHECK(obj->DefineProperty(env.local(), p, desc_generic).FromJust());
16101 CHECK(!try_catch.HasCaught());
16102 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16103 CHECK(val->IsUndefined());
16104
16105 obj->Set(env.local(), p, v8_num(1)).FromJust();
16106 CHECK(!try_catch.HasCaught());
16107
16108 val = obj->Get(env.local(), p).ToLocalChecked();
16109 CHECK(val->IsUndefined());
16110 CHECK(!try_catch.HasCaught());
16111 }
16112
16113 {
16114 // Use a data descriptor with undefined value.
16115 const v8::PropertyDescriptor desc_empty(
16116 v8::Undefined(isolate), v8::PropertyDescriptor::State::kNotSet);
16117
16118 v8::TryCatch try_catch(isolate);
16119 CHECK(obj->DefineProperty(env.local(), p, desc_empty).FromJust());
16120 CHECK(!try_catch.HasCaught());
16121 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16122 CHECK(val->IsUndefined());
16123 CHECK(!try_catch.HasCaught());
16124 }
16125
16126 {
16127 // Use a descriptor with attribute == v8::ReadOnly.
16128 v8::PropertyDescriptor desc_read_only(
16129 v8_num(42), v8::PropertyDescriptor::State::kFalse);
16130 desc_read_only.set_enumerable(true);
16131 desc_read_only.set_configurable(true);
16132
16133 p = v8_str("v5");
16134 v8::TryCatch try_catch(isolate);
16135 CHECK(obj->DefineProperty(env.local(), p, desc_read_only).FromJust());
16136 CHECK(!try_catch.HasCaught());
16137 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16138 CHECK(val->IsNumber());
16139 CHECK_EQ(42.0, val->NumberValue(env.local()).FromJust());
16140 CHECK_EQ(v8::ReadOnly,
16141 obj->GetPropertyAttributes(env.local(), p).FromJust());
16142 CHECK(!try_catch.HasCaught());
16143 }
16144
16145 {
16146 // Use an accessor descriptor with empty handles.
16147 const v8::PropertyDescriptor desc_empty(v8::Undefined(isolate),
16148 v8::Undefined(isolate));
16149
16150 p = v8_str("v6");
16151 v8::TryCatch try_catch(isolate);
16152 CHECK(obj->DefineProperty(env.local(), p, desc_empty).FromJust());
16153 CHECK(!try_catch.HasCaught());
16154 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16155 CHECK(val->IsUndefined());
16156 CHECK(!try_catch.HasCaught());
16157 }
16158
16159 {
16160 // Use an accessor descriptor.
16161 CompileRun(
16162 "var set = function(x) {this.val = 2*x;};"
16163 "var get = function() {return this.val || 0;};");
16164
16165 v8::Local<v8::Function> get = v8::Local<v8::Function>::Cast(
16166 env->Global()->Get(env.local(), v8_str("get")).ToLocalChecked());
16167 v8::Local<v8::Function> set = v8::Local<v8::Function>::Cast(
16168 env->Global()->Get(env.local(), v8_str("set")).ToLocalChecked());
16169 const v8::PropertyDescriptor desc(get, set);
16170
16171 p = v8_str("v7");
16172 v8::TryCatch try_catch(isolate);
16173 CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
16174 CHECK(!try_catch.HasCaught());
16175
16176 v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
16177 CHECK(val->IsNumber());
16178 CHECK_EQ(0.0, val->NumberValue(env.local()).FromJust());
16179 CHECK(!try_catch.HasCaught());
16180
16181 obj->Set(env.local(), p, v8_num(7)).FromJust();
16182 CHECK(!try_catch.HasCaught());
16183
16184 val = obj->Get(env.local(), p).ToLocalChecked();
16185 CHECK(val->IsNumber());
16186 CHECK_EQ(14.0, val->NumberValue(env.local()).FromJust());
16187 CHECK(!try_catch.HasCaught());
16188 }
16189
16190 {
16191 // Re-define a property
16192 // desc = {value: 42, enumerable: true}
16193 v8::PropertyDescriptor desc(v8_num(42),
16194 v8::PropertyDescriptor::State::kNotSet);
16195 desc.set_enumerable(true);
16196
16197 p = v8_str("v8");
16198 v8::TryCatch try_catch(isolate);
16199 CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
16200 CHECK(!try_catch.HasCaught());
16201
16202 // desc = {enumerable: true}
16203 // successful because has_enumerable with same value as existing descriptor
16204 v8::PropertyDescriptor desc_true(v8::Local<v8::Value>(),
16205 v8::PropertyDescriptor::State::kNotSet);
16206 desc_true.set_enumerable(true);
16207 CHECK(obj->DefineProperty(env.local(), p, desc_true).FromJust());
16208 CHECK(!try_catch.HasCaught());
16209
16210 // desc = {}
16211 // successful because !has_enumerable
16212 const v8::PropertyDescriptor desc_empty;
16213 CHECK(obj->DefineProperty(env.local(), p, desc_empty).FromJust());
16214 CHECK(!try_catch.HasCaught());
16215
16216 // desc = {enumerable: false}
16217 v8::PropertyDescriptor desc_false(v8::Local<v8::Value>(),
16218 v8::PropertyDescriptor::State::kNotSet);
16219 desc_false.set_enumerable(false);
16220 // not successful, because we cannot overwrite enumerable
16221 CHECK(!obj->DefineProperty(env.local(), p, desc_false).FromJust());
16222 CHECK(!try_catch.HasCaught());
16223 }
16224
16225 {
16226 // Re-define a property that has a getter
16227 CompileRun("var get = function() {};");
16228 v8::Local<v8::Function> get = v8::Local<v8::Function>::Cast(
16229 env->Global()->Get(env.local(), v8_str("get")).ToLocalChecked());
16230
16231 // desc = {get: function() {}}
16232 const v8::PropertyDescriptor desc(get, v8::Local<v8::Function>());
16233 v8::TryCatch try_catch(isolate);
16234
16235 p = v8_str("v9");
16236 CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
16237 CHECK(!try_catch.HasCaught());
16238
16239 // desc = {}
16240 // successful because get not redefined
16241 const v8::PropertyDescriptor desc_empty;
16242 CHECK(obj->DefineProperty(env.local(), p, desc_empty).FromJust());
16243 CHECK(!try_catch.HasCaught());
16244
16245 // desc = {get: function() {}}
16246 // successful because re-define with same value
16247 CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
16248 CHECK(!try_catch.HasCaught());
16249
16250 // desc = {get: undefined}
16251 const v8::PropertyDescriptor desc_undefined(v8::Undefined(isolate),
16252 v8::Local<v8::Function>());
16253 // not successful, because we cannot overwrite with undefined
16254 CHECK(!obj->DefineProperty(env.local(), p, desc_undefined).FromJust());
16255 CHECK(!try_catch.HasCaught());
16256 }
16257
16258 CompileRun("Object.freeze(a);");
16259 {
16260 // Can't change non-extensible objects.
16261 v8::TryCatch try_catch(isolate);
16262 CHECK(!obj->DefineProperty(env.local(), v8_str("v10"), desc).FromJust());
16263 CHECK(!try_catch.HasCaught());
16264 }
16265
16266 v8::Local<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
16267 templ->SetAccessCheckCallback(AccessAlwaysBlocked);
16268 v8::Local<v8::Object> access_checked =
16269 templ->NewInstance(env.local()).ToLocalChecked();
16270 {
16271 v8::TryCatch try_catch(isolate);
16272 CHECK(access_checked->DefineProperty(env.local(), v8_str("v11"), desc)
16273 .IsNothing());
16274 CHECK(try_catch.HasCaught());
16275 }
16276 }
16007 16277
16008 THREADED_TEST(GetCurrentContextWhenNotInContext) { 16278 THREADED_TEST(GetCurrentContextWhenNotInContext) {
16009 i::Isolate* isolate = CcTest::i_isolate(); 16279 i::Isolate* isolate = CcTest::i_isolate();
16010 CHECK(isolate != NULL); 16280 CHECK(isolate != NULL);
16011 CHECK(isolate->context() == NULL); 16281 CHECK(isolate->context() == NULL);
16012 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 16282 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
16013 v8::HandleScope scope(v8_isolate); 16283 v8::HandleScope scope(v8_isolate);
16014 // The following should not crash, but return an empty handle. 16284 // The following should not crash, but return an empty handle.
16015 v8::Local<v8::Context> current = v8_isolate->GetCurrentContext(); 16285 v8::Local<v8::Context> current = v8_isolate->GetCurrentContext();
16016 CHECK(current.IsEmpty()); 16286 CHECK(current.IsEmpty());
(...skipping 7315 matching lines...) Expand 10 before | Expand all | Expand 10 after
23332 "V8.Test", 0, 10000, v8::internal::HistogramTimer::MILLISECOND, 50, 23602 "V8.Test", 0, 10000, v8::internal::HistogramTimer::MILLISECOND, 50,
23333 reinterpret_cast<v8::internal::Isolate*>(isolate)); 23603 reinterpret_cast<v8::internal::Isolate*>(isolate));
23334 histogramTimer.Start(); 23604 histogramTimer.Start();
23335 CHECK_EQ(0, strcmp("V8.Test", last_event_message)); 23605 CHECK_EQ(0, strcmp("V8.Test", last_event_message));
23336 CHECK_EQ(0, last_event_status); 23606 CHECK_EQ(0, last_event_status);
23337 histogramTimer.Stop(); 23607 histogramTimer.Stop();
23338 CHECK_EQ(0, strcmp("V8.Test", last_event_message)); 23608 CHECK_EQ(0, strcmp("V8.Test", last_event_message));
23339 CHECK_EQ(1, last_event_status); 23609 CHECK_EQ(1, last_event_status);
23340 } 23610 }
23341 23611
23612 TEST(PropertyDescriptor) {
23613 LocalContext context;
23614 v8::Isolate* isolate = context->GetIsolate();
23615 v8::HandleScope scope(isolate);
23616
23617 { // empty descriptor
23618 v8::PropertyDescriptor desc;
23619 CHECK(!desc.has_value());
23620 CHECK(desc.value() == v8::Local<v8::Value>());
23621 CHECK(!desc.has_set());
23622 CHECK(!desc.has_get());
23623 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23624 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kNotSet);
23625 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23626 }
23627 {
23628 // data descriptor
23629 v8::PropertyDescriptor desc(v8_num(42),
23630 v8::PropertyDescriptor::State::kNotSet);
23631 desc.set_enumerable(false);
23632 CHECK(desc.value() == v8_num(42));
23633 CHECK(desc.has_value());
23634 CHECK(!desc.has_set());
23635 CHECK(!desc.has_get());
23636 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kFalse);
23637 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kNotSet);
23638 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23639 }
23640 {
23641 // data descriptor
23642 v8::PropertyDescriptor desc(v8_num(42),
23643 v8::PropertyDescriptor::State::kNotSet);
23644 desc.set_configurable(true);
23645 CHECK(desc.value() == v8_num(42));
23646 CHECK(desc.has_value());
23647 CHECK(!desc.has_set());
23648 CHECK(!desc.has_get());
23649 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23650 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kTrue);
23651 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23652 }
23653 {
23654 // data descriptor
23655 v8::PropertyDescriptor desc(v8_num(42),
23656 v8::PropertyDescriptor::State::kNotSet);
23657 desc.set_configurable(false);
23658 CHECK(desc.value() == v8_num(42));
23659 CHECK(desc.has_value());
23660 CHECK(!desc.has_set());
23661 CHECK(!desc.has_get());
23662 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23663 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kFalse);
23664 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23665 }
23666 {
23667 // data descriptor
23668 v8::PropertyDescriptor desc(v8_num(42),
23669 v8::PropertyDescriptor::State::kFalse);
23670 CHECK(desc.value() == v8_num(42));
23671 CHECK(desc.has_value());
23672 CHECK(!desc.has_set());
23673 CHECK(!desc.has_get());
23674 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23675 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kNotSet);
23676 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kFalse);
23677 }
23678 {
23679 // data descriptor
23680 v8::PropertyDescriptor desc(v8::Local<v8::Value>(),
23681 v8::PropertyDescriptor::State::kFalse);
23682 CHECK(desc.value() == v8::Local<v8::Value>());
23683 CHECK(!desc.has_value());
23684 CHECK(!desc.has_set());
23685 CHECK(!desc.has_get());
23686 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23687 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kNotSet);
23688 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kFalse);
23689 }
23690 {
23691 // accessor descriptor
23692 CompileRun(
23693 "var set = function() {return 43;};"
23694 "var get = function() {return 42;};");
23695
23696 v8::Local<v8::Function> set =
23697 v8::Local<v8::Function>::Cast(context->Global()
23698 ->Get(context.local(), v8_str("set"))
23699 .ToLocalChecked());
23700 v8::PropertyDescriptor desc(v8::Undefined(isolate), set);
23701 desc.set_configurable(false);
23702 CHECK(!desc.has_value());
23703 CHECK(desc.has_get());
23704 CHECK(desc.set() == set);
23705 CHECK(desc.has_set());
23706 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23707 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kFalse);
23708 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23709 }
23710 {
23711 // accessor descriptor with Proxy
23712 CompileRun(
23713 "var set = new Proxy(function() {}, {});"
23714 "var get = undefined;");
23715
23716 v8::Local<v8::Value> get =
23717 v8::Local<v8::Value>::Cast(context->Global()
23718 ->Get(context.local(), v8_str("get"))
23719 .ToLocalChecked());
23720 v8::Local<v8::Function> set =
23721 v8::Local<v8::Function>::Cast(context->Global()
23722 ->Get(context.local(), v8_str("set"))
23723 .ToLocalChecked());
23724 v8::PropertyDescriptor desc(get, set);
23725 desc.set_configurable(false);
23726 CHECK(!desc.has_value());
23727 CHECK(desc.get() == get);
23728 CHECK(desc.has_get());
23729 CHECK(desc.set() == set);
23730 CHECK(desc.has_set());
23731 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23732 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kFalse);
23733 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23734 }
23735 {
23736 // accessor descriptor with empty function handle
23737 v8::Local<v8::Function> get = v8::Local<v8::Function>();
23738 v8::PropertyDescriptor desc(get, get);
23739 CHECK(!desc.has_value());
23740 CHECK(desc.get() == get);
23741 CHECK(!desc.has_get());
23742 CHECK(desc.set() == v8::Local<v8::Function>());
23743 CHECK(!desc.has_set());
23744 CHECK_EQ(desc.enumerable(), v8::PropertyDescriptor::State::kNotSet);
23745 CHECK_EQ(desc.configurable(), v8::PropertyDescriptor::State::kNotSet);
23746 CHECK_EQ(desc.writable(), v8::PropertyDescriptor::State::kNotSet);
23747 }
23748 }
23342 23749
23343 TEST(Promises) { 23750 TEST(Promises) {
23344 LocalContext context; 23751 LocalContext context;
23345 v8::Isolate* isolate = context->GetIsolate(); 23752 v8::Isolate* isolate = context->GetIsolate();
23346 v8::HandleScope scope(isolate); 23753 v8::HandleScope scope(isolate);
23347 23754
23348 // Creation. 23755 // Creation.
23349 Local<v8::Promise::Resolver> pr = 23756 Local<v8::Promise::Resolver> pr =
23350 v8::Promise::Resolver::New(context.local()).ToLocalChecked(); 23757 v8::Promise::Resolver::New(context.local()).ToLocalChecked();
23351 Local<v8::Promise::Resolver> rr = 23758 Local<v8::Promise::Resolver> rr =
(...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after
25524 25931
25525 // Put the function into context1 and call it. Since the access check 25932 // Put the function into context1 and call it. Since the access check
25526 // callback always returns true, the call succeeds even though the tokens 25933 // callback always returns true, the call succeeds even though the tokens
25527 // are different. 25934 // are different.
25528 context1->Enter(); 25935 context1->Enter();
25529 context1->Global()->Set(context1, v8_str("fun"), fun).FromJust(); 25936 context1->Global()->Set(context1, v8_str("fun"), fun).FromJust();
25530 v8::Local<v8::Value> x_value = CompileRun("fun('x')"); 25937 v8::Local<v8::Value> x_value = CompileRun("fun('x')");
25531 CHECK_EQ(42, x_value->Int32Value(context1).FromJust()); 25938 CHECK_EQ(42, x_value->Int32Value(context1).FromJust());
25532 context1->Exit(); 25939 context1->Exit();
25533 } 25940 }
OLDNEW
« src/api.cc ('K') | « src/counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698