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

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

Powered by Google App Engine
This is Rietveld 408576698