diff options
author | Adam Klein <adamk@chromium.org> | 2018-01-22 17:53:56 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-22 17:53:56 +0000 |
commit | 434e28dd41e37dc829440aab1eb4cb4ec561962b (patch) | |
tree | 3fe7c26d9e4e9d34b0883c11214ab3fb2f93efd8 /fxjs/cfxjse_value.cpp | |
parent | 1fa1b1f771dd077b0fb4056c7b84f701ba733a8c (diff) | |
download | pdfium-434e28dd41e37dc829440aab1eb4cb4ec561962b.tar.xz |
Use MaybeLocal versions of v8::Script APIs
The non-Maybe versions will soon be deprecated.
Where the code was already handling failures, I did the same; where the
code was not handling failures, I inserted ToLocalChecked() calls. Thus
the behavior before and after this patch should be the same.
For consistency, also updated the use of v8::Function::Call
in CFXJSE_Context::ExecuteScript() to the Maybe version, so
that all code in that function now branches on the non-emptyness
of MaybeLocals, rather than TryCatch::HasCaught(). ASSERTs were
inserted to sanity-check the API usage.
Bug: v8:7269, v8:7273, v8:7274
Change-Id: I59696e63a64a233a9f9c2b72c621a05b5e349a31
Reviewed-on: https://pdfium-review.googlesource.com/23270
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Diffstat (limited to 'fxjs/cfxjse_value.cpp')
-rw-r--r-- | fxjs/cfxjse_value.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fxjs/cfxjse_value.cpp b/fxjs/cfxjse_value.cpp index d07b3565d3..c1dd7b0027 100644 --- a/fxjs/cfxjse_value.cpp +++ b/fxjs/cfxjse_value.cpp @@ -250,10 +250,15 @@ bool CFXJSE_Value::SetFunctionBind(CFXJSE_Value* lpOldFunction, v8::String::NewFromUtf8(m_pIsolate, "(function (oldfunction, newthis) { return " "oldfunction.bind(newthis); })"); + v8::Local<v8::Context> hContext = m_pIsolate->GetCurrentContext(); v8::Local<v8::Function> hBinderFunc = - v8::Script::Compile(hBinderFuncSource)->Run().As<v8::Function>(); + v8::Script::Compile(hContext, hBinderFuncSource) + .ToLocalChecked() + ->Run(hContext) + .ToLocalChecked() + .As<v8::Function>(); v8::Local<v8::Value> hBoundFunction = - hBinderFunc->Call(m_pIsolate->GetCurrentContext()->Global(), 2, rgArgs); + hBinderFunc->Call(hContext->Global(), 2, rgArgs); if (hBoundFunction.IsEmpty() || !hBoundFunction->IsFunction()) return false; |