Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dockMenu not being referenced in JavaScript #12062

Merged
merged 2 commits into from Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/browser/api/app.js
Expand Up @@ -10,6 +10,8 @@ const electron = require('electron')
const {deprecate, Menu} = electron
const {EventEmitter} = require('events')

let dockMenu = null

// App is an EventEmitter.
Object.setPrototypeOf(App.prototype, EventEmitter.prototype)
EventEmitter.call(app)
Expand Down Expand Up @@ -49,7 +51,13 @@ if (process.platform === 'darwin') {
hide: bindings.dockHide,
show: bindings.dockShow,
isVisible: bindings.dockIsVisible,
setMenu: bindings.dockSetMenu,
setMenu (menu) {
dockMenu = menu
bindings.dockSetMenu(menu)
},
getMenu () {
return dockMenu
},
setIcon: bindings.dockSetIcon
}
}
Expand Down
16 changes: 15 additions & 1 deletion spec/api-app-spec.js
Expand Up @@ -7,7 +7,7 @@ const path = require('path')
const {ipcRenderer, remote} = require('electron')
const {closeWindow} = require('./window-helpers')

const {app, BrowserWindow, ipcMain} = remote
const {app, BrowserWindow, Menu, ipcMain} = remote

const isCI = remote.getGlobal('isCi')

Expand Down Expand Up @@ -881,4 +881,18 @@ describe('app module', () => {
}, /before app is ready/)
})
})

describe('dock.setMenu', () => {
before(function () {
if (process.platform !== 'darwin') {
this.skip()
}
})

it('keeps references to the menu', () => {
app.dock.setMenu(new Menu())
const v8Util = process.atomBinding('v8_util')
v8Util.requestGarbageCollectionForTesting()
})
})
})