Compare commits

...

1 Commits

Author SHA1 Message Date
Samuel Maddock
d14b77c066 test: mac context-menu using native right-click 2024-12-11 16:24:44 -05:00
3 changed files with 38 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents, BaseWindow, WebContentsView } from 'electron/main';
import { nativeInput } from '@smaddock/electron-native-utils';
import { expect } from 'chai';
import * as cp from 'node:child_process';
@@ -2731,8 +2732,8 @@ 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 () => {
// Native click only supported on macOS
ifit(process.platform === 'darwin')('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'));
@@ -2742,8 +2743,14 @@ describe('webContents module', () => {
contextMenuEmitCount++;
});
// TODO(samuelmaddock): Perform native right-click. We've tried then
// dropped robotjs and nutjs so for now this is a manual test.
const position = w.getPosition();
const size = w.getSize();
nativeInput.setMousePosition({
x: position[0] + size[0] / 2,
y: position[1] + size[1] / 2
});
await setTimeout(1000 / 60);
nativeInput.click({ button: 'right' });
await once(w.webContents, 'context-menu');
await setTimeout(100);

View File

@@ -7,6 +7,15 @@
"node-gyp-install": "node-gyp install"
},
"devDependencies": {
"@electron-ci/echo": "file:./fixtures/native-addon/echo",
"@electron-ci/external-ab": "file:./fixtures/native-addon/external-ab/",
"@electron-ci/is-valid-window": "file:./is-valid-window",
"@electron-ci/osr-gpu": "file:./fixtures/native-addon/osr-gpu/",
"@electron-ci/uv-dlopen": "file:./fixtures/native-addon/uv-dlopen/",
"@electron/fuses": "^1.8.0",
"@electron/packager": "^18.3.2",
"@marshallofsound/mocha-appveyor-reporter": "^0.4.3",
"@smaddock/electron-native-utils": "^1.0.0",
"@types/basic-auth": "^1.1.8",
"@types/busboy": "^1.5.4",
"@types/chai": "^4.3.19",
@@ -15,19 +24,10 @@
"@types/express": "^4.17.13",
"@types/mocha": "^7.0.2",
"@types/send": "^0.14.5",
"@types/sinon": "^9.0.4",
"@types/split": "^1.0.5",
"@types/uuid": "^3.4.6",
"@types/w3c-web-serial": "^1.0.7",
"express": "^4.20.0",
"@electron-ci/echo": "file:./fixtures/native-addon/echo",
"@electron-ci/is-valid-window": "file:./is-valid-window",
"@electron-ci/uv-dlopen": "file:./fixtures/native-addon/uv-dlopen/",
"@electron-ci/osr-gpu": "file:./fixtures/native-addon/osr-gpu/",
"@electron-ci/external-ab": "file:./fixtures/native-addon/external-ab/",
"@electron/fuses": "^1.8.0",
"@electron/packager": "^18.3.2",
"@marshallofsound/mocha-appveyor-reporter": "^0.4.3",
"@types/sinon": "^9.0.4",
"@types/ws": "^7.2.0",
"basic-auth": "^2.0.1",
"busboy": "^1.6.0",
@@ -36,6 +36,7 @@
"coffeescript": "^2.4.1",
"dbus-native": "github:nornagon/dbus-native#master",
"dirty-chai": "^2.0.1",
"express": "^4.20.0",
"graceful-fs": "^4.1.15",
"mkdirp": "^0.5.1",
"mocha": "^10.0.0",

View File

@@ -129,7 +129,7 @@
dependencies:
cross-spawn "^7.0.1"
"@mapbox/node-pre-gyp@^1.0.0":
"@mapbox/node-pre-gyp@^1.0.0", "@mapbox/node-pre-gyp@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz#417db42b7f5323d79e93b34a6d7a2a12c0df43fa"
integrity sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==
@@ -189,6 +189,15 @@
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz#5981a8db18b56ba38ef0efb7d995b12aa7b51918"
integrity sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==
"@smaddock/electron-native-utils@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@smaddock/electron-native-utils/-/electron-native-utils-1.0.0.tgz#99053ca5fd679993b757028b0463775514abbb0d"
integrity sha512-4YMV1nPj6RH6s0dUMVnOP1+owVkJSqIBEkNG7PBmCgQkuKpy7N5j24ulXZv0Nx8XgYcP7PclPE7qkp36/46xDA==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.11"
bindings "^1.5.0"
node-addon-api "^6.1.0"
"@szmarczak/http-timer@^4.0.5":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807"
@@ -524,7 +533,7 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==
bindings@^1.2.1:
bindings@^1.2.1, bindings@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df"
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
@@ -1899,6 +1908,11 @@ node-addon-api@8.0.0:
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-8.0.0.tgz#5453b7ad59dd040d12e0f1a97a6fa1c765c5c9d2"
integrity sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==
node-addon-api@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-6.1.0.tgz#ac8470034e58e67d0c6f1204a18ae6995d9c0d76"
integrity sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==
node-fetch@^2.6.7:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"