Merge pull request #11055 from electron/fix-menu-bug
fix: Don't crash on `setApplicationMenu(null)`
This commit is contained in:
commit
ba754cf5c3
2 changed files with 17 additions and 10 deletions
|
@ -133,7 +133,7 @@ Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder
|
|||
|
||||
// set application menu with a preexisting menu
|
||||
Menu.setApplicationMenu = function (menu) {
|
||||
if (!(menu || menu.constructor === Menu)) {
|
||||
if (menu && menu.constructor !== Menu) {
|
||||
throw new TypeError('Invalid menu')
|
||||
}
|
||||
|
||||
|
|
|
@ -291,15 +291,22 @@ describe('Menu module', () => {
|
|||
})
|
||||
|
||||
describe('Menu.setApplicationMenu', () => {
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: '1'
|
||||
}, {
|
||||
label: '2'
|
||||
}
|
||||
])
|
||||
Menu.setApplicationMenu(menu)
|
||||
assert.notEqual(Menu.getApplicationMenu(), null)
|
||||
it('sets a menu', () => {
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: '1'
|
||||
}, {
|
||||
label: '2'
|
||||
}
|
||||
])
|
||||
Menu.setApplicationMenu(menu)
|
||||
assert.notEqual(Menu.getApplicationMenu(), null)
|
||||
})
|
||||
|
||||
it('unsets a menu with null', () => {
|
||||
Menu.setApplicationMenu(null)
|
||||
assert.equal(Menu.getApplicationMenu(), null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('MenuItem.click', () => {
|
||||
|
|
Loading…
Reference in a new issue