Browse Source

spec: Calling methods of destroyed webContents should not crash

Cheng Zhao 9 years ago
parent
commit
d674db6606
1 changed files with 6 additions and 0 deletions
  1. 6 0
      spec/api-browser-window-spec.coffee

+ 6 - 0
spec/api-browser-window-spec.coffee

@@ -55,6 +55,12 @@ describe 'browser-window module', ->
         done()
       w.loadURL 'file://' + path.join(fixtures, 'api', 'close-beforeunload-false.html')
 
+  describe 'BrowserWindow.destroy()', ->
+    it 'prevents users to access methods of webContents', ->
+      webContents = w.webContents
+      w.destroy()
+      assert.throws (-> webContents.getId()), /Object has been destroyed/
+
   describe 'BrowserWindow.loadURL(url)', ->
     it 'should emit did-start-loading event', (done) ->
       w.webContents.on 'did-start-loading', ->