Browse Source

Add spec for detached window crash

Kevin Sawicki 8 years ago
parent
commit
399470e281
1 changed files with 23 additions and 4 deletions
  1. 23 4
      spec/api-web-contents-spec.js

+ 23 - 4
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 () {