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:
parent
7d326f6bc5
commit
0fc172fcaf
1 changed files with 15 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue