feat: use default-app behavior in packaged apps (#16310)
Unify the behavior between default app and packaged apps: - create default application menu unless the app has one - default window-all-closed handling unless the app handles the event
This commit is contained in:
parent
8e2ab8b20b
commit
23d44e322d
11 changed files with 133 additions and 37 deletions
32
spec/fixtures/api/default-menu/main.js
vendored
Normal file
32
spec/fixtures/api/default-menu/main.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
const { app, Menu } = require('electron')
|
||||
|
||||
function output (value) {
|
||||
process.stdout.write(JSON.stringify(value))
|
||||
process.stdout.end()
|
||||
|
||||
app.quit()
|
||||
}
|
||||
|
||||
try {
|
||||
let expectedMenu
|
||||
|
||||
if (app.commandLine.hasSwitch('custom-menu')) {
|
||||
expectedMenu = new Menu()
|
||||
Menu.setApplicationMenu(expectedMenu)
|
||||
} else if (app.commandLine.hasSwitch('null-menu')) {
|
||||
expectedMenu = null
|
||||
Menu.setApplicationMenu(null)
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
setImmediate(() => {
|
||||
try {
|
||||
output(Menu.getApplicationMenu() === expectedMenu)
|
||||
} catch (error) {
|
||||
output(null)
|
||||
}
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
output(null)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue