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
|
// set application menu with a preexisting menu
|
||||||
Menu.setApplicationMenu = function (menu) {
|
Menu.setApplicationMenu = function (menu) {
|
||||||
if (!(menu || menu.constructor === Menu)) {
|
if (menu && menu.constructor !== Menu) {
|
||||||
throw new TypeError('Invalid menu')
|
throw new TypeError('Invalid menu')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,7 @@ describe('Menu module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Menu.setApplicationMenu', () => {
|
describe('Menu.setApplicationMenu', () => {
|
||||||
|
it('sets a menu', () => {
|
||||||
const menu = Menu.buildFromTemplate([
|
const menu = Menu.buildFromTemplate([
|
||||||
{
|
{
|
||||||
label: '1'
|
label: '1'
|
||||||
|
@ -302,6 +303,12 @@ describe('Menu module', () => {
|
||||||
assert.notEqual(Menu.getApplicationMenu(), null)
|
assert.notEqual(Menu.getApplicationMenu(), null)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('unsets a menu with null', () => {
|
||||||
|
Menu.setApplicationMenu(null)
|
||||||
|
assert.equal(Menu.getApplicationMenu(), null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('MenuItem.click', () => {
|
describe('MenuItem.click', () => {
|
||||||
it('should be called with the item object passed', function (done) {
|
it('should be called with the item object passed', function (done) {
|
||||||
const menu = Menu.buildFromTemplate([
|
const menu = Menu.buildFromTemplate([
|
||||||
|
|
Loading…
Reference in a new issue