8000 fix: reject the executeJavaScript promise when it fails to execute the script by trop[bot] · Pull Request #18714 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions atom/renderer/api/atom_api_web_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,20 @@ 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.");
}
} else {
promise_.RejectWithErrorMessage(
"WebFrame was removed before script could run. This normally means "
"the underlying frame was destroyed");
}
delete this;
}

Expand Down
0