]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: Calling methods of destroyed webContents should not crash
authorCheng Zhao <zcbenz@gmail.com>
Tue, 12 Jan 2016 13:15:12 +0000 (21:15 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 12 Jan 2016 13:15:12 +0000 (21:15 +0800)
spec/api-browser-window-spec.coffee

index 38c8217041e7da35d02bad20377ad52fe28e65fb..724f149cd9e503c520d8719051aa5f1944a2e172 100644 (file)
@@ -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', ->