fix: ensure context-menu emitted for draggable regions (#44761)

* fix: ensure context-menu emitted for draggable regions

* chore: address suggestions from review
This commit is contained in:
Shelley Vohr 2024-11-22 12:33:38 +01:00 committed by GitHub
parent 4fd1b5b186
commit 86e4529d26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 84 additions and 21 deletions

View file

@ -2730,6 +2730,25 @@ describe('webContents module', () => {
expect(params.x).to.be.a('number');
expect(params.y).to.be.a('number');
});
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'));
const promise = once(w.webContents, 'context-menu') as Promise<[any, Electron.ContextMenuParams]>;
// Simulate right-click to create context-menu event.
const opts = { x: 0, y: 0, button: 'right' as const };
w.webContents.sendInputEvent({ ...opts, type: 'mouseDown' });
w.webContents.sendInputEvent({ ...opts, type: 'mouseUp' });
const [, params] = await promise;
expect(params.pageURL).to.equal(w.webContents.getURL());
expect(params.frame).to.be.an('object');
expect(params.x).to.be.a('number');
expect(params.y).to.be.a('number');
});
});
describe('close() method', () => {