test: clean up some stale code in renderer spec runner (#21384)
* test: clean up some stale code in renderer spec runner * remove jquery from spec * remove extraneous close tag * Revert "remove jquery from spec" This reverts commit 7b885c8ca807e15bad3b7bf94691eee3c53d0a8d. * re-clean-up html * don't highlight tags * update session docs; clear cache on boot * clear user-data-dir before running tests
This commit is contained in:
parent
b57d218466
commit
53957d47d6
5 changed files with 17 additions and 73 deletions
|
@ -2,7 +2,13 @@
|
|||
process.throwDeprecation = false
|
||||
|
||||
const electron = require('electron')
|
||||
const { app, BrowserWindow, crashReporter, dialog, ipcMain, protocol, webContents } = electron
|
||||
const { app, BrowserWindow, crashReporter, dialog, ipcMain, protocol, webContents, session } = electron
|
||||
|
||||
try {
|
||||
require('fs').rmdirSync(app.getPath('userData'), { recursive: true })
|
||||
} catch (e) {
|
||||
console.warn(`Warning: couldn't clear user data directory:`, e)
|
||||
}
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
@ -18,9 +24,6 @@ const argv = require('yargs')
|
|||
|
||||
let window = null
|
||||
|
||||
// will be used by crash-reporter spec.
|
||||
process.port = 0
|
||||
|
||||
v8.setFlagsFromString('--expose_gc')
|
||||
app.commandLine.appendSwitch('js-flags', '--expose_gc')
|
||||
app.commandLine.appendSwitch('ignore-certificate-errors')
|
||||
|
@ -47,11 +50,6 @@ ipcMain.handle('get-modules', () => Object.keys(electron))
|
|||
ipcMain.handle('get-temp-dir', () => app.getPath('temp'))
|
||||
ipcMain.handle('ping', () => null)
|
||||
|
||||
// Set productName so getUploadedReports() uses the right directory in specs
|
||||
if (process.platform !== 'darwin') {
|
||||
crashReporter.productName = 'Zombies'
|
||||
}
|
||||
|
||||
// Write output to file if OUTPUT_TO_FILE is defined.
|
||||
const outputToFile = process.env.OUTPUT_TO_FILE
|
||||
const print = function (_, method, args) {
|
||||
|
@ -76,8 +74,6 @@ ipcMain.on('echo', function (event, msg) {
|
|||
event.returnValue = msg
|
||||
})
|
||||
|
||||
global.setTimeoutPromisified = util.promisify(setTimeout)
|
||||
|
||||
process.removeAllListeners('uncaughtException')
|
||||
process.on('uncaughtException', function (error) {
|
||||
console.error(error, error.stack)
|
||||
|
@ -86,18 +82,6 @@ process.on('uncaughtException', function (error) {
|
|||
|
||||
global.nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS
|
||||
|
||||
// Register app as standard scheme.
|
||||
global.standardScheme = 'app'
|
||||
global.zoomScheme = 'zoom'
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{ scheme: global.standardScheme, privileges: { standard: true, secure: true } },
|
||||
{ scheme: global.zoomScheme, privileges: { standard: true, secure: true } },
|
||||
{ scheme: 'cors', privileges: { corsEnabled: true, supportFetchAPI: true } },
|
||||
{ scheme: 'cors-blob', privileges: { corsEnabled: true, supportFetchAPI: true } },
|
||||
{ scheme: 'no-cors', privileges: { supportFetchAPI: true } },
|
||||
{ scheme: 'no-fetch', privileges: { corsEnabled: true } }
|
||||
])
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
app.quit()
|
||||
})
|
||||
|
@ -110,15 +94,12 @@ app.on('renderer-process-crashed', (event, contents, killed) => {
|
|||
console.log(`webContents ${contents.id} crashed: ${contents.getURL()} (killed=${killed})`)
|
||||
})
|
||||
|
||||
app.on('ready', function () {
|
||||
app.on('ready', async function () {
|
||||
await session.defaultSession.clearCache()
|
||||
await session.defaultSession.clearStorageData()
|
||||
// Test if using protocol module would crash.
|
||||
electron.protocol.registerStringProtocol('test-if-crashes', function () {})
|
||||
|
||||
// Send auto updater errors to window to be verified in specs
|
||||
electron.autoUpdater.on('error', function (error) {
|
||||
window.send('auto-updater-error', error.message)
|
||||
})
|
||||
|
||||
window = new BrowserWindow({
|
||||
title: 'Electron Tests',
|
||||
show: false,
|
||||
|
@ -153,35 +134,6 @@ app.on('ready', function () {
|
|||
})
|
||||
})
|
||||
|
||||
for (const eventName of [
|
||||
'remote-get-guest-web-contents'
|
||||
]) {
|
||||
ipcMain.on(`handle-next-${eventName}`, function (event, returnValue) {
|
||||
event.sender.once(eventName, (event) => {
|
||||
if (returnValue) {
|
||||
event.returnValue = returnValue
|
||||
} else {
|
||||
event.preventDefault()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
ipcMain.on('set-client-certificate-option', function (event, skip) {
|
||||
app.once('select-client-certificate', function (event, webContents, url, list, callback) {
|
||||
event.preventDefault()
|
||||
if (skip) {
|
||||
callback()
|
||||
} else {
|
||||
ipcMain.on('client-certificate-response', function (event, certificate) {
|
||||
callback(certificate)
|
||||
})
|
||||
window.webContents.send('select-client-certificate', webContents.id, list)
|
||||
}
|
||||
})
|
||||
event.returnValue = 'done'
|
||||
})
|
||||
|
||||
ipcMain.on('prevent-next-will-attach-webview', (event) => {
|
||||
event.sender.once('will-attach-webview', event => event.preventDefault())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue