From 9505c2831a9ffcd6d43e6c7e5800ce2d465e3ed1 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 6 Oct 2021 05:41:34 +0200 Subject: [PATCH] test: add missing context-menu event spec for (#31280) --- spec/webview-spec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index e1d2ab3d27c0..ebc5ecab387d 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -996,6 +996,26 @@ describe(' tag', function () { }); }); + describe('context-menu event', () => { + it('emits when right-clicked in page', async () => { + await loadWebView(webview, { src: 'about:blank' }); + + const promise = waitForEvent(webview, 'context-menu'); + + // Simulate right-click to create context-menu event. + const opts = { x: 0, y: 0, button: 'right' }; + webview.sendInputEvent({ ...opts, type: 'mouseDown' }); + webview.sendInputEvent({ ...opts, type: 'mouseUp' }); + + const { params } = await promise; + + expect(params.pageURL).to.equal(webview.getURL()); + expect(params.frame).to.be.undefined(); + expect(params.x).to.be.a('number'); + expect(params.y).to.be.a('number'); + }); + }); + describe('media-started-playing media-paused events', () => { beforeEach(function () { if (!document.createElement('audio').canPlayType('audio/wav')) {