From 399470e281e4bdb1832e3ac32d6fe9eb87f4d4d2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 23 Aug 2016 10:06:05 -0700 Subject: [PATCH] Add spec for detached window crash --- spec/api-web-contents-spec.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index 64a2f4aac39..7e77c39bdb5 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -49,11 +49,9 @@ describe('webContents module', function () { }) describe('getFocusedWebContents() API', function () { - if (isCi) { - return - } - it('returns the focused web contents', function (done) { + if (isCi) return done() + const specWebContents = remote.getCurrentWebContents() assert.equal(specWebContents.getId(), webContents.getFocusedWebContents().getId()) @@ -69,6 +67,27 @@ describe('webContents module', function () { specWebContents.openDevTools() }) + + it('does not crash when called on a detached dev tools window', function (done) { + const specWebContents = w.webContents + + specWebContents.once('devtools-opened', function () { + assert.doesNotThrow(function () { + webContents.getFocusedWebContents() + }) + specWebContents.closeDevTools() + }) + + specWebContents.once('devtools-closed', function () { + assert.doesNotThrow(function () { + webContents.getFocusedWebContents() + }) + done() + }) + + specWebContents.openDevTools({mode: 'detach'}) + w.inspectElement(100, 100) + }) }) describe('isFocused() API', function () {