electron/spec/fixtures/api/default-menu/main.js

33 lines
646 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const { app, Menu } = require('electron');
function output (value) {
2020-03-20 20:28:31 +00:00
process.stdout.write(JSON.stringify(value));
process.stdout.end();
2020-03-20 20:28:31 +00:00
app.quit();
}
try {
2020-03-20 20:28:31 +00:00
let expectedMenu;
if (app.commandLine.hasSwitch('custom-menu')) {
2020-03-20 20:28:31 +00:00
expectedMenu = new Menu();
Menu.setApplicationMenu(expectedMenu);
} else if (app.commandLine.hasSwitch('null-menu')) {
2020-03-20 20:28:31 +00:00
expectedMenu = null;
Menu.setApplicationMenu(null);
}
app.whenReady().then(() => {
setImmediate(() => {
try {
2020-03-20 20:28:31 +00:00
output(Menu.getApplicationMenu() === expectedMenu);
} catch {
2020-03-20 20:28:31 +00:00
output(null);
}
2020-03-20 20:28:31 +00:00
});
});
} catch {
2020-03-20 20:28:31 +00:00
output(null);
}