feat: add frame to context-menu event params (#30831)
* feat: add frame to context-menu event params * doc: rephrase frame description
This commit is contained in:
parent
52bacd38a9
commit
70c534fd14
5 changed files with 36 additions and 8 deletions
|
@ -2056,6 +2056,28 @@ describe('webContents module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('context-menu event', () => {
|
||||
afterEach(closeAllWindows);
|
||||
it('emits when right-clicked in page', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
await w.loadFile(path.join(fixturesPath, 'pages', 'base-page.html'));
|
||||
|
||||
const promise = emittedOnce(w.webContents, 'context-menu');
|
||||
|
||||
// Simulate right-click to create context-menu event.
|
||||
const opts = { x: 0, y: 0, button: 'right' as any };
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
||||
it('emits a cancelable event before creating a child webcontents', async () => {
|
||||
const w = new BrowserWindow({
|
||||
show: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue