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
feat: add activate option to webContents.openDevTools #13852
Conversation
48c3609
to
b69298c
Compare
b69298c
to
1c89271
Compare
@zcbenz can you please review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a style query
@@ -412,8 +414,9 @@ void InspectableWebContentsImpl::CloseWindow() { | |||
|
|||
void InspectableWebContentsImpl::LoadCompleted() { | |||
frontend_loaded_ = true; | |||
if (managed_devtools_web_contents_) | |||
view_->ShowDevTools(); | |||
if (managed_devtools_web_contents_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure we have a style guide / made a style decision that we wanted single liners to have no braces 🤔
cc @ckerr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it, but IMHO single liners without braces are really bad idea. It reminds me of the goto fail bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure we have a style guide / made a style decision that we wanted single liners to have no braces
What was a reasoning behind that decision? This style screws up git blame of a line with a condition when a second line (and braces) has to be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally follow the Chrome / Google C++ guidelines, where braces are generally optional (not forbidden) for single-liners:
In general, curly braces are not required for single-line statements, but they are allowed if you like them; conditional or loop statements with complex conditions or statements may be more readable with curly braces. Some projects require that an if must always have an accompanying brace.
So there's wiggle room there if we want to require braces or if we want them to be optional for single-liners. I don't really care what we use as long as we're consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really care what we use as long as we're consistent.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in general we should accept anything produced by clang-format
.
Curly braces are probably optional here.
d1e0fc3
to
3916d59
Compare
spec/api-web-contents-spec.js
Outdated
w.show() | ||
assert.equal(w.isFocused(), true) | ||
w.webContents.openDevTools({ mode: 'detach', activate: false }) | ||
w.webContents.once('devtools-opened', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await emittedOnce(w.webContents, 'devtools-opened')
expect(w.isFocused()).to.be.true()
3916d59
to
65e918f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments in code.
docs/api/web-contents.md
Outdated
@@ -1182,6 +1182,8 @@ app.once('ready', () => { | |||
* `options` Object (optional) | |||
* `mode` String - Opens the devtools with specified dock state, can be | |||
`right`, `bottom`, `undocked`, `detach`. Defaults to last used dock state. | |||
* `activate` Boolean (optional) - Whether to bring the opened devtools window to the | |||
foreground. The default is `true`. | |||
In `undocked` mode it's possible to dock back. In `detach` mode it's not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be right next to the mode
option description.
Please add a description of the activate
option below it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^
65e918f
to
6f7385d
Compare
6f7385d
to
e3a20a4
Compare
e3a20a4
to
1ae8b28
Compare
I have rebased the branch and resolved the review comments, this should be ready to go. |
Release Notes Persisted
|
Make it possible to show the devtools window without focusing. Fixes #13095
Checklist
npm test
passesNotes: Add
activate
option towebContents.openDevTools