Making test code run directly in main browser context to avoid rpc persistent handles.

This commit is contained in:
ali.ibrahim 2016-10-17 11:51:20 +02:00
parent c6ae27c7c9
commit 9b4e9c642a
2 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,6 @@
const assert = require('assert') const assert = require('assert')
const {remote} = require('electron') const {remote} = require('electron')
const {ipcRenderer} = require('electron')
const http = require('http') const http = require('http')
const url = require('url') const url = require('url')
const {net} = remote const {net} = remote
@ -1169,13 +1170,21 @@ describe('net module', function () {
server = null server = null
}) })
it.only('should free unreferenced, never-started request objects', function() { it.only('should free unreferenced, never-started request objects', function(done) {
const requestUrl = '/requestUrl' const requestUrl = '/requestUrl'
const urlRequest = net.request( `${server.url}${requestUrl}`) ipcRenderer.on('api-net-spec-done', function() {
done()
})
const testCode = `
// Load the net module in the main browser process.
const {net} = require('electron')
const urlRequest = net.request('${server.url}${requestUrl}')
process.nextTick(function() { process.nextTick(function() {
net._RequestGarbageCollectionForTesting() net._RequestGarbageCollectionForTesting()
process.nextTick(done) event.sender.send('api-net-spec-done')
}) })
`
ipcRenderer.send('eval', testCode)
}) })
it.skip('should not collect on-going requests', function(done) { it.skip('should not collect on-going requests', function(done) {
assert(false) assert(false)
@ -1183,5 +1192,5 @@ describe('net module', function () {
it.skip('should collect unreferenced, ended requests', function(done) { it.skip('should collect unreferenced, ended requests', function(done) {
assert(false) assert(false)
}) })
} })
}) })

View file

@ -8,6 +8,7 @@ const ipcMain = electron.ipcMain
const dialog = electron.dialog const dialog = electron.dialog
const BrowserWindow = electron.BrowserWindow const BrowserWindow = electron.BrowserWindow
const protocol = electron.protocol const protocol = electron.protocol
const v8 = require('v8');
const Coverage = require('electabul').Coverage const Coverage = require('electabul').Coverage
const fs = require('fs') const fs = require('fs')
@ -24,6 +25,7 @@ var argv = require('yargs')
var window = null var window = null
process.port = 0 // will be used by crash-reporter spec. process.port = 0 // will be used by crash-reporter spec.
v8.setFlagsFromString('--expose_gc')
app.commandLine.appendSwitch('js-flags', '--expose_gc') app.commandLine.appendSwitch('js-flags', '--expose_gc')
app.commandLine.appendSwitch('ignore-certificate-errors') app.commandLine.appendSwitch('ignore-certificate-errors')
app.commandLine.appendSwitch('disable-renderer-backgrounding') app.commandLine.appendSwitch('disable-renderer-backgrounding')