Listen for browser-window-created event for asserts
authorKevin Sawicki <kevinsawicki@gmail.com>
Wed, 30 Mar 2016 18:17:24 +0000 (11:17 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Fri, 1 Apr 2016 23:50:20 +0000 (16:50 -0700)
spec/webview-spec.js

index 3d45d51e6ac2fe2b9f57bf3ce4386ce59ec5fb34..122c22ad28953f3b239a092a7d4b400456746593 100644 (file)
@@ -4,7 +4,7 @@ const http = require('http')
 const url = require('url')
 
 const {remote} = require('electron')
-const {BrowserWindow} = remote
+const {app} = remote
 
 describe('<webview> tag', function () {
   this.timeout(10000)
@@ -79,14 +79,8 @@ describe('<webview> tag', function () {
 
 
     it('disables node integration on child windows when it is disabled on the webview', function (done) {
-      webview.addEventListener('console-message', function (e) {
-        assert.equal(e.message, 'window opened')
-        const sourceId = remote.getCurrentWindow().id
-        const windows = BrowserWindow.getAllWindows().filter(function (window) {
-          return window.id !== sourceId
-        })
-        assert.equal(windows.length, 1)
-        assert.equal(windows[0].webContents.getWebPreferences().nodeIntegration, false)
+      app.once('browser-window-created', function (event, window) {
+        assert.equal(window.webContents.getWebPreferences().nodeIntegration, false)
         done()
       })