From 2c5f4aadfb609689965b9ae4921f47cedcb4cfdf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 18 Jun 2016 09:51:37 +0900 Subject: [PATCH] spec: Test cases for win.setModal(modal) --- spec/api-browser-window-spec.js | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 6579da2b4687..5b7794ab6ea3 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -876,6 +876,57 @@ describe('browser-window module', function () { c.close() }) }) + + describe('win.setModal(modal)', function () { + it('disables parent window', function () { + assert.equal(w.isEnabled(), true) + c.setParentWindow(w) + c.setModal(true) + assert.equal(w.isEnabled(), false) + }) + + it('enables parent window when closed', function (done) { + c.once('closed', () => { + assert.equal(w.isEnabled(), true) + done() + }) + c.setParentWindow(w) + c.setModal(true) + c.close() + }) + + it('enables parent window when setting not modal', function () { + assert.equal(w.isEnabled(), true) + c.setParentWindow(w) + c.setModal(true) + assert.equal(w.isEnabled(), false) + c.setModal(false) + assert.equal(w.isEnabled(), true) + }) + + it('enables parent window when removing parent', function () { + assert.equal(w.isEnabled(), true) + c.setParentWindow(w) + c.setModal(true) + assert.equal(w.isEnabled(), false) + c.setParentWindow(null) + assert.equal(w.isEnabled(), true) + }) + + it('disables parent window recursively', function () { + let c2 = new BrowserWindow({show: false}) + c.setParentWindow(w) + c.setModal(true) + c2.setParentWindow(w) + c2.setModal(true) + assert.equal(w.isEnabled(), false) + c.setModal(false) + assert.equal(w.isEnabled(), false) + c2.setModal(false) + assert.equal(w.isEnabled(), true) + c2.destroy() + }) + }) }) describe('window.webContents.send(channel, args...)', function () {