fix: reject the executeJavaScript promise when it fails to execute the script (#18635)

* fix: reject the executeJavaScript promise when it fails to execute the script

Closes #9102

* Update atom/renderer/api/atom_api_web_frame.cc

Co-Authored-By: Jeremy Apthorp <nornagon@nornagon.net>

* Update atom/renderer/api/atom_api_web_frame.cc

Co-Authored-By: Jeremy Apthorp <nornagon@nornagon.net>

* fix: missing semicolon
This commit is contained in:
Samuel Attard 2019-06-05 15:43:02 -07:00 committed by GitHub
parent 7d326f6bc5
commit 0fc172fcaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,9 +101,21 @@ class ScriptExecutionCallback : public blink::WebScriptExecutionCallback {
void Completed(
const blink::WebVector<v8::Local<v8::Value>>& result) override {
if (!result.empty() && !result[0].IsEmpty())
// Right now only single results per frame is supported.
promise_.Resolve(result[0]);
if (!result.empty()) {
if (!result[0].IsEmpty()) {
// Right now only single results per frame is supported.
promise_.Resolve(result[0]);
} else {
promise_.RejectWithErrorMessage(
"Script failed to execute, this normally means an error "
"was thrown. Check the renderer console for the error."
"was thrown, check the renderer console for the error");
}
} else {
promise_.RejectWithErrorMessage(
"WebFrame was removed before script could run. This normally means "
"the underlying frame was destroyed");
}
delete this;
}