Commit b0cb54dd authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

Update WebLocalFrame::CallFunctionEvenIfScriptDisabled to v8::MaybeLocal

Have WebLocalFrame::CallFunctionEvenIfScriptDisabled() return a
v8::MaybeLocal instead of a v8::Local. This is more inline with the
patterns v8 uses.

Bug: None

Change-Id: Id466ff9ba46d40123df77a835a7ec84a7c1442be
Reviewed-on: https://chromium-review.googlesource.com/807405Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521754}
parent 26a09b96
......@@ -270,9 +270,14 @@ PP_Var CallDeprecatedInternal(PP_Var var,
return PP_MakeUndefined();
}
v8::Local<v8::Value> result = frame->CallFunctionEvenIfScriptDisabled(
function.As<v8::Function>(), recv, argc, converted_args.get());
ScopedPPVar result_var = try_catch.FromV8(result);
ScopedPPVar result_var;
v8::Local<v8::Value> result;
if (frame
->CallFunctionEvenIfScriptDisabled(function.As<v8::Function>(), recv,
argc, converted_args.get())
.ToLocal(&result)) {
result_var = try_catch.FromV8(result);
}
if (try_catch.HasException())
return PP_MakeUndefined();
......
......@@ -539,9 +539,15 @@ v8::Local<v8::Value> ScriptContext::CallFunction(
v8::Local<v8::Object> global = v8_context()->Global();
if (!web_frame_)
return handle_scope.Escape(function->Call(global, argc, argv));
return handle_scope.Escape(
v8::Local<v8::Value>(web_frame_->CallFunctionEvenIfScriptDisabled(
function, global, argc, argv)));
v8::MaybeLocal<v8::Value> result =
web_frame_->CallFunctionEvenIfScriptDisabled(function, global, argc,
argv);
// TODO(devlin): Stop coercing this to a v8::Local.
v8::Local<v8::Value> coerced_result;
ignore_result(result.ToLocal(&coerced_result));
return handle_scope.Escape(coerced_result);
}
} // namespace extensions
......@@ -817,20 +817,15 @@ void WebLocalFrameImpl::RequestExecuteScriptInIsolatedWorld(
}
}
// TODO(bashi): Consider returning MaybeLocal.
v8::Local<v8::Value> WebLocalFrameImpl::CallFunctionEvenIfScriptDisabled(
v8::MaybeLocal<v8::Value> WebLocalFrameImpl::CallFunctionEvenIfScriptDisabled(
v8::Local<v8::Function> function,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> argv[]) {
DCHECK(GetFrame());
v8::Local<v8::Value> result;
if (!V8ScriptRunner::CallFunction(
function, GetFrame()->GetDocument(), receiver, argc,
static_cast<v8::Local<v8::Value>*>(argv), ToIsolate(GetFrame()))
.ToLocal(&result))
return v8::Local<v8::Value>();
return result;
return V8ScriptRunner::CallFunction(
function, GetFrame()->GetDocument(), receiver, argc,
static_cast<v8::Local<v8::Value>*>(argv), ToIsolate(GetFrame()));
}
v8::Local<v8::Context> WebLocalFrameImpl::MainWorldScriptContext() const {
......
......@@ -133,7 +133,7 @@ class CORE_EXPORT WebLocalFrameImpl final
bool user_gesture,
ScriptExecutionType,
WebScriptExecutionCallback*) override;
v8::Local<v8::Value> CallFunctionEvenIfScriptDisabled(
v8::MaybeLocal<v8::Value> CallFunctionEvenIfScriptDisabled(
v8::Local<v8::Function>,
v8::Local<v8::Value>,
int argc,
......
......@@ -398,7 +398,7 @@ class WebLocalFrame : public WebFrame {
// Call the function with the given receiver and arguments, bypassing
// canExecute().
virtual v8::Local<v8::Value> CallFunctionEvenIfScriptDisabled(
virtual v8::MaybeLocal<v8::Value> CallFunctionEvenIfScriptDisabled(
v8::Local<v8::Function>,
v8::Local<v8::Value>,
int argc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment