8000 fix: reject the executeJavaScript promise when it fails to execute the script by MarshallOfSound · Pull Request #18635 · 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 #18635

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
merged 4 commits into from
Jun 5, 2019
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
18 changes: 15 additions & 3 deletions atom/renderer/api/atom_api_web_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How strange 😕 I definitely wouldn't type the same thing twice, the auto-formatter might have done this 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's because you directly committed my suggestion in the github UI, which can't handle suggesting changing multiple lines

}
} else {
promise_.RejectWithErrorMessage(
"WebFrame was removed before script could run. This normally means "
"the underlying frame was destroyed");
}
delete this;
}

Expand Down
0