fix: context-menu emitted twice (#44978)

* fix: context-menu emitted twice

* refactor: simplify disabling draggable regions

* cleanup
This commit is contained in:
Sam Maddock 2024-12-11 11:42:48 -05:00 committed by GitHub
parent cf5a4640f5
commit 2c698d3f75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 51 additions and 65 deletions

View file

@ -2731,6 +2731,26 @@ describe('webContents module', () => {
expect(params.y).to.be.a('number');
});
// Skipping due to lack of native click support.
it.skip('emits the correct number of times when right-clicked in page', async () => {
const w = new BrowserWindow({ show: true });
await w.loadFile(path.join(fixturesPath, 'pages', 'base-page.html'));
let contextMenuEmitCount = 0;
w.webContents.on('context-menu', () => {
contextMenuEmitCount++;
});
// TODO(samuelmaddock): Perform native right-click. We've tried then
// dropped robotjs and nutjs so for now this is a manual test.
await once(w.webContents, 'context-menu');
await setTimeout(100);
expect(contextMenuEmitCount).to.equal(1);
});
it('emits when right-clicked in page in a draggable region', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixturesPath, 'pages', 'draggable-page.html'));