Add "parent" option for BrowserWindow

This commit is contained in:
Cheng Zhao 2016-06-19 12:06:08 +09:00
parent 473413e874
commit 85ba382027
8 changed files with 68 additions and 11 deletions

View file

@ -849,7 +849,32 @@ describe('browser-window module', function () {
c = null
})
describe('parent option', function () {
beforeEach(function () {
if (c != null) c.destroy()
c = new BrowserWindow({show: false, parent: w})
})
it('sets parent window', function () {
assert.equal(c.getParentWindow(), w)
})
it('adds window to child windows of parent', function () {
assert.deepEqual(w.getChildWindows(), [c])
})
it('removes from child windows of parent when window is closed', function (done) {
c.once('closed', () => {
assert.deepEqual(w.getChildWindows(), [])
done()
})
c.close()
})
})
describe('win.setParentWindow(parent)', function () {
if (process.platform !== 'darwin') return
it('sets parent window', function () {
assert.equal(w.getParentWindow(), null)
assert.equal(c.getParentWindow(), null)