From 214dd9716517031365ece671c95a450e174e5a6e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 17 Jun 2016 16:57:18 +0900 Subject: [PATCH] spec: Test cases for parent window --- spec/api-browser-window-spec.js | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 598a3470f75c..6579da2b4687 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -836,6 +836,48 @@ describe('browser-window module', function () { }) }) + describe('parent window', function () { + let c = null + + beforeEach(function () { + if (c != null) c.destroy() + c = new BrowserWindow({show: false}) + }) + + afterEach(function () { + if (c != null) c.destroy() + c = null + }) + + describe('win.setParentWindow(parent)', function () { + it('sets parent window', function () { + assert.equal(w.getParentWindow(), null) + assert.equal(c.getParentWindow(), null) + c.setParentWindow(w) + assert.equal(c.getParentWindow(), w) + c.setParentWindow(null) + assert.equal(c.getParentWindow(), null) + }) + + it('adds window to child windows of parent', function () { + assert.deepEqual(w.getChildWindows(), []) + c.setParentWindow(w) + assert.deepEqual(w.getChildWindows(), [c]) + c.setParentWindow(null) + assert.deepEqual(w.getChildWindows(), []) + }) + + it('removes from child windows of parent when window is closed', function (done) { + c.once('closed', () => { + assert.deepEqual(w.getChildWindows(), []) + done() + }) + c.setParentWindow(w) + c.close() + }) + }) + }) + describe('window.webContents.send(channel, args...)', function () { it('throws an error when the channel is missing', function () { assert.throws(function () {