| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -210,7 +210,8 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context( | |||
| 210 | 210 | return MaybeLocal<Context>(); | |
| 211 | 211 | } | |
| 212 | 212 | ||
| 213 | - ctx->SetSecurityToken(env->context()->GetSecurityToken()); | ||
| 213 | + Local<Context> context = env->context(); | ||
| 214 | + ctx->SetSecurityToken(context->GetSecurityToken()); | ||
| 214 | 215 | ||
| 215 | 216 | // We need to tie the lifetime of the sandbox object with the lifetime of | |
| 216 | 217 | // newly created context. We do this by making them hold references to each | |
@@ -219,7 +220,7 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context( | |||
| 219 | 220 | // directly in an Object, we instead hold onto the new context's global | |
| 220 | 221 | // object instead (which then has a reference to the context). | |
| 221 | 222 | ctx->SetEmbedderData(ContextEmbedderIndex::kSandboxObject, sandbox_obj); | |
| 222 | - sandbox_obj->SetPrivate(env->context(), | ||
| 223 | + sandbox_obj->SetPrivate(context, | ||
| 223 | 224 | env->contextify_global_private_symbol(), | |
| 224 | 225 | ctx->Global()); | |
| 225 | 226 | ||
@@ -394,16 +395,17 @@ void ContextifyContext::PropertySetterCallback( | |||
| 394 | 395 | if (ctx->context_.IsEmpty()) | |
| 395 | 396 | return; | |
| 396 | 397 | ||
| 398 | + Local<Context> context = ctx->context(); | ||
| 397 | 399 | auto attributes = PropertyAttribute::None; | |
| 398 | 400 | bool is_declared_on_global_proxy = ctx->global_proxy() | |
| 399 | - ->GetRealNamedPropertyAttributes(ctx->context(), property) | ||
| 401 | + ->GetRealNamedPropertyAttributes(context, property) | ||
| 400 | 402 | .To(&attributes); | |
| 401 | 403 | bool read_only = | |
| 402 | 404 | static_cast<int>(attributes) & | |
| 403 | 405 | static_cast<int>(PropertyAttribute::ReadOnly); | |
| 404 | 406 | ||
| 405 | 407 | bool is_declared_on_sandbox = ctx->sandbox() | |
| 406 | - ->GetRealNamedPropertyAttributes(ctx->context(), property) | ||
| 408 | + ->GetRealNamedPropertyAttributes(context, property) | ||
| 407 | 409 | .To(&attributes); | |
| 408 | 410 | read_only = read_only || | |
| 409 | 411 | (static_cast<int>(attributes) & | |
@@ -441,7 +443,7 @@ void ContextifyContext::PropertySetterCallback( | |||
| 441 | 443 | args.GetReturnValue().Set(false); | |
| 442 | 444 | } | |
| 443 | 445 | ||
| 444 | - USE(ctx->sandbox()->Set(ctx->context(), property, value)); | ||
| 446 | + USE(ctx->sandbox()->Set(context, property, value)); | ||
| 445 | 447 | } | |
| 446 | 448 | ||
| 447 | 449 | // static | |
@@ -482,7 +484,7 @@ void ContextifyContext::PropertyDefinerCallback( | |||
| 482 | 484 | ||
| 483 | 485 | auto attributes = PropertyAttribute::None; | |
| 484 | 486 | bool is_declared = | |
| 485 | - ctx->global_proxy()->GetRealNamedPropertyAttributes(ctx->context(), | ||
| 487 | + ctx->global_proxy()->GetRealNamedPropertyAttributes(context, | ||
| 486 | 488 | property) | |
| 487 | 489 | .To(&attributes); | |
| 488 | 490 | bool read_only = | |
@@ -656,8 +658,10 @@ void ContextifyScript::Init(Environment* env, Local<Object> target) { | |||
| 656 | 658 | env->SetProtoMethod(script_tmpl, "runInContext", RunInContext); | |
| 657 | 659 | env->SetProtoMethod(script_tmpl, "runInThisContext", RunInThisContext); | |
| 658 | 660 | ||
| 659 | - target->Set(env->context(), class_name, | ||
| 660 | - script_tmpl->GetFunction(env->context()).ToLocalChecked()).Check(); | ||
| 661 | + Local<Context> context = env->context(); | ||
| 662 | + | ||
| 663 | + target->Set(context, class_name, | ||
| 664 | + script_tmpl->GetFunction(context).ToLocalChecked()).Check(); | ||
| 661 | 665 | env->set_script_context_constructor_template(script_tmpl); | |
| 662 | 666 | } | |
| 663 | 667 | ||
@@ -775,9 +779,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) { | |||
| 775 | 779 | } | |
| 776 | 780 | contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked()); | |
| 777 | 781 | ||
| 782 | + Local<Context> env_context = env->context(); | ||
| 778 | 783 | if (compile_options == ScriptCompiler::kConsumeCodeCache) { | |
| 779 | 784 | args.This()->Set( | |
| 780 | - env->context(), | ||
| 785 | + env_context, | ||
| 781 | 786 | env->cached_data_rejected_string(), | |
| 782 | 787 | Boolean::New(isolate, source.GetCachedData()->rejected)).Check(); | |
| 783 | 788 | } else if (produce_cached_data) { | |
@@ -789,12 +794,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) { | |||
| 789 | 794 | env, | |
| 790 | 795 | reinterpret_cast<const char*>(cached_data->data), | |
| 791 | 796 | cached_data->length); | |
| 792 | - args.This()->Set(env->context(), | ||
| 797 | + args.This()->Set(env_context, | ||
| 793 | 798 | env->cached_data_string(), | |
| 794 | 799 | buf.ToLocalChecked()).Check(); | |
| 795 | 800 | } | |
| 796 | 801 | args.This()->Set( | |
| 797 | - env->context(), | ||
| 802 | + env_context, | ||
| 798 | 803 | env->cached_data_produced_string(), | |
| 799 | 804 | Boolean::New(isolate, cached_data_produced)).Check(); | |
| 800 | 805 | } | |
@@ -884,7 +889,8 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) { | |||
| 884 | 889 | ContextifyContext::ContextFromContextifiedSandbox(env, sandbox); | |
| 885 | 890 | CHECK_NOT_NULL(contextify_context); | |
| 886 | 891 | ||
| 887 | - if (contextify_context->context().IsEmpty()) | ||
| 892 | + Local<Context> context = contextify_context->context(); | ||
| 893 | + if (context.IsEmpty()) | ||
| 888 | 894 | return; | |
| 889 | 895 | ||
| 890 | 896 | TRACE_EVENT_NESTABLE_ASYNC_BEGIN0( | |
@@ -903,7 +909,7 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) { | |||
| 903 | 909 | bool break_on_first_line = args[4]->IsTrue(); | |
| 904 | 910 | ||
| 905 | 911 | // Do the eval within the context | |
| 906 | - Context::Scope context_scope(contextify_context->context()); | ||
| 912 | + Context::Scope context_scope(context); | ||
| 907 | 913 | EvalMachine(contextify_context->env(), | |
| 908 | 914 | timeout, | |
| 909 | 915 | display_errors, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments