Skip to content
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

fix: handle shortcuts by default if no WebPreference object exists #14766

Merged
merged 1 commit into from
Sep 27, 2018

Conversation

MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Sep 22, 2018

DevTools webContents do not have webPreferences

reccomend viewing the diff with ?w=1

Fixes #14685

Notes: fix basic shortcuts (copy, paste, etc.) not working in devtools

@MarshallOfSound MarshallOfSound requested a review from a team September 22, 2018 12:29
Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

LGTM, can you try adding a spec ?

@deepak1556 deepak1556 requested a review from zcbenz September 22, 2018 18:42
@MarshallOfSound
Copy link
Member Author

@deepak1556 I did look into making a spec but we currently have no way to trigger keyboard inputs that map into the HandleKeyboardEvent method (we skip them and go straight to ForwardKeyboardEvent.

@deepak1556
Copy link
Member

deepak1556 commented Sep 22, 2018

webContents.sendInputEvent should work, maybe create an internal event that gets emitted from HandleKeyboardEvent and check if it receives right shortcuts for devtools with something like the following.

await emitOnce('devtools-focused', mainWindow.webContents)
mainWindow.devToolsWebContents.sendInputEvent({
    type: 'keyDown',
    modifiers: ['command'],
    keyCode: 'V'
})

@MarshallOfSound
Copy link
Member Author

@deepak1556 I thought sendInputEvent skipped this stuff, will give it a shot 👍

@MarshallOfSound MarshallOfSound force-pushed the fix-menu-shortcuts-devtools branch from 5066258 to 8813304 Compare September 23, 2018 06:42
@MarshallOfSound
Copy link
Member Author

@deepak1556 Test added 👍

@MarshallOfSound
Copy link
Member Author

@deepak1556 The test was failing on CI and it was super flaky locally, ended up using the robotjs npm module to fake a paste keypress at the OS level and see if the app responds correctly. IMO it's a better test anyway 👍

@deepak1556
Copy link
Member

deepak1556 commented Sep 26, 2018

Why is it required to test the specific shortcut execution ? Wouldn't it be enough to just see if the shortcut gets passed to the desired window in HandleKeyboardEvent ? The specs could be simpler in that case.

@MarshallOfSound
Copy link
Member Author

@deepak1556 I don't want to emit an event purely for the case of testing, people will start using it when they shouldn't and making this spec isn't too hard and is guaruntee'ed end-to-end working 👍

@deepak1556
Copy link
Member

I don't want to emit an event purely for the case of testing, people will start using it when they shouldn't

We already have a couple of internal events, methods purely for testing. Agreed this could be easier if we have native tests. Incase we want to go with the non event route then a shortcut thats deterministic like devtools reload, I am just worried about the polling for checking the clipboard response, it can get flaky on ci.

I am good with the original fix for the issue and the spec looks good too, was just hoping it could be better.

@MarshallOfSound
Copy link
Member Author

I am just worried about the polling for checking the clipboard response, it can get flaky on ci.

To be honest, I added that even though it was working synchronously consistently. I added it with the specific intent of avoiding future race condition flakes. I think this is in a relatively good state.

@MarshallOfSound MarshallOfSound changed the title fix: handle shortcuts by default if no WebPreferences object exists fix: handle shortcuts by default if no WebPreference object exists Sep 26, 2018
DevTools webcontents do not have webpreferences

Fixes #14685
@MarshallOfSound MarshallOfSound force-pushed the fix-menu-shortcuts-devtools branch from 8b22a96 to a39a13c Compare September 27, 2018 08:00
@MarshallOfSound
Copy link
Member Author

I've disabled these tests on CI on macOS, assuming the VM's don't work with robotjs or something. The tests pass locally on macOS on both my macOS machines and someone else's.

@MarshallOfSound
Copy link
Member Author

Failed windows ia32 CI was a flake

@MarshallOfSound MarshallOfSound merged commit 6be6904 into master Sep 27, 2018
@release-clerk
Copy link

release-clerk bot commented Sep 27, 2018

Release Notes Persisted

fix basic shortcuts (copy, paste, etc.) not working in devtools

@MarshallOfSound MarshallOfSound deleted the fix-menu-shortcuts-devtools branch September 27, 2018 15:41
codebytere pushed a commit that referenced this pull request Sep 27, 2018
@ckerr
Copy link
Member

ckerr commented Sep 27, 2018

/trop run backport-to 3-0-x

@trop
Copy link
Contributor

trop bot commented Sep 27, 2018

The backport process for this PR has been manually initiated,
sending your 1's and 0's to "3-0-x" here we go! :D

@mhuggins
Copy link

Does this have any relation to #14905 & #14883?

@MarshallOfSound
Copy link
Member Author

@mhuggins no

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paste shortcut doesn't work in DevTools in 3.0.0
4 participants