test: move some fixtures from spec/ to spec-main/ (#21403)
This commit is contained in:
parent
8a92b65fd3
commit
768a6ace1b
44 changed files with 27 additions and 32 deletions
|
@ -9,7 +9,7 @@ import { AddressInfo } from 'net'
|
||||||
|
|
||||||
const features = process.electronBinding('features')
|
const features = process.electronBinding('features')
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, '../spec/fixtures')
|
const fixturesPath = path.resolve(__dirname, 'fixtures')
|
||||||
|
|
||||||
// We can only test the auto updater on darwin non-component builds
|
// We can only test the auto updater on darwin non-component builds
|
||||||
const describeFn = (process.platform === 'darwin' && !process.mas && !features.isComponentBuild() ? describe : describe.skip)
|
const describeFn = (process.platform === 'darwin' && !process.mas && !features.isComponentBuild() ? describe : describe.skip)
|
||||||
|
|
|
@ -224,7 +224,7 @@ describe('BrowserView module', () => {
|
||||||
|
|
||||||
describe('new BrowserView()', () => {
|
describe('new BrowserView()', () => {
|
||||||
it('does not crash on exit', async () => {
|
it('does not crash on exit', async () => {
|
||||||
const appPath = path.join(fixtures, 'api', 'leak-exit-browserview.js')
|
const appPath = path.join(__dirname, 'fixtures', 'api', 'leak-exit-browserview.js')
|
||||||
const electronPath = process.execPath
|
const electronPath = process.execPath
|
||||||
const appProcess = ChildProcess.spawn(electronPath, [appPath])
|
const appProcess = ChildProcess.spawn(electronPath, [appPath])
|
||||||
const [code] = await emittedOnce(appProcess, 'close')
|
const [code] = await emittedOnce(appProcess, 'close')
|
||||||
|
|
|
@ -3603,7 +3603,7 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws errors for invalid manifest.json files', () => {
|
it('throws errors for invalid manifest.json files', () => {
|
||||||
const badManifestExtensionPath = path.join(fixtures, 'devtools-extensions', 'bad-manifest')
|
const badManifestExtensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest')
|
||||||
expect(() => {
|
expect(() => {
|
||||||
BrowserWindow.addDevToolsExtension(badManifestExtensionPath)
|
BrowserWindow.addDevToolsExtension(badManifestExtensionPath)
|
||||||
}).to.throw(/Unexpected token }/)
|
}).to.throw(/Unexpected token }/)
|
||||||
|
@ -3614,7 +3614,7 @@ describe('BrowserWindow module', () => {
|
||||||
const extensionName = 'foo'
|
const extensionName = 'foo'
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
const extensionPath = path.join(fixtures, 'devtools-extensions', 'foo')
|
const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
expect(BrowserWindow.getDevToolsExtensions()).to.have.property(extensionName)
|
expect(BrowserWindow.getDevToolsExtensions()).to.have.property(extensionName)
|
||||||
})
|
})
|
||||||
|
@ -3707,7 +3707,7 @@ describe('BrowserWindow module', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const extensionPath = path.join(fixtures, 'devtools-extensions', 'foo')
|
const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
try {
|
try {
|
||||||
showLastDevToolsPanel(w)
|
showLastDevToolsPanel(w)
|
||||||
|
@ -3728,7 +3728,7 @@ describe('BrowserWindow module', () => {
|
||||||
|
|
||||||
it('serializes the registered extensions on quit', () => {
|
it('serializes the registered extensions on quit', () => {
|
||||||
const extensionName = 'foo'
|
const extensionName = 'foo'
|
||||||
const extensionPath = path.join(fixtures, 'devtools-extensions', extensionName)
|
const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', extensionName)
|
||||||
const serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions')
|
const serializedPath = path.join(app.getPath('userData'), 'DevTools Extensions')
|
||||||
|
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
|
@ -3749,7 +3749,7 @@ describe('BrowserWindow module', () => {
|
||||||
|
|
||||||
it('throws errors for invalid manifest.json files', () => {
|
it('throws errors for invalid manifest.json files', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
BrowserWindow.addExtension(path.join(fixtures, 'devtools-extensions', 'bad-manifest'))
|
BrowserWindow.addExtension(path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest'))
|
||||||
}).to.throw('Unexpected token }')
|
}).to.throw('Unexpected token }')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('debugger module', () => {
|
||||||
expect(w.webContents.debugger.isAttached()).to.be.true()
|
expect(w.webContents.debugger.isAttached()).to.be.true()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.webContents.loadFile(path.join(fixtures, 'pages', 'a.html'))
|
w.webContents.loadURL('about:blank')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('fails when protocol version is not supported', done => {
|
it('fails when protocol version is not supported', done => {
|
||||||
|
@ -134,7 +134,7 @@ describe('debugger module', () => {
|
||||||
const url = process.platform !== 'win32'
|
const url = process.platform !== 'win32'
|
||||||
? `file://${path.join(fixtures, 'pages', 'a.html')}`
|
? `file://${path.join(fixtures, 'pages', 'a.html')}`
|
||||||
: `file:///${path.join(fixtures, 'pages', 'a.html').replace(/\\/g, '/')}`
|
: `file:///${path.join(fixtures, 'pages', 'a.html').replace(/\\/g, '/')}`
|
||||||
w.webContents.loadFile(path.join(fixtures, 'pages', 'a.html'))
|
w.webContents.loadURL(url)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
w.webContents.debugger.attach()
|
w.webContents.debugger.attach()
|
||||||
|
@ -144,12 +144,16 @@ describe('debugger module', () => {
|
||||||
|
|
||||||
w.webContents.debugger.on('message', (e, method, params) => {
|
w.webContents.debugger.on('message', (e, method, params) => {
|
||||||
if (method === 'Console.messageAdded') {
|
if (method === 'Console.messageAdded') {
|
||||||
expect(params.message.level).to.equal('log')
|
try {
|
||||||
expect(params.message.url).to.equal(url)
|
expect(params.message.level).to.equal('log')
|
||||||
expect(params.message.text).to.equal('a')
|
expect(params.message.url).to.equal(url)
|
||||||
|
expect(params.message.text).to.equal('a')
|
||||||
w.webContents.debugger.detach()
|
done()
|
||||||
done()
|
} catch (e) {
|
||||||
|
done(e)
|
||||||
|
} finally {
|
||||||
|
w.webContents.debugger.detach()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
w.webContents.debugger.sendCommand('Console.enable')
|
w.webContents.debugger.sendCommand('Console.enable')
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { emittedOnce } from './events-helpers'
|
||||||
import { ipcMain, BrowserWindow } from 'electron'
|
import { ipcMain, BrowserWindow } from 'electron'
|
||||||
|
|
||||||
describe('ipc main module', () => {
|
describe('ipc main module', () => {
|
||||||
const fixtures = path.join(__dirname, '..', 'spec', 'fixtures')
|
const fixtures = path.join(__dirname, 'fixtures')
|
||||||
|
|
||||||
afterEach(closeAllWindows)
|
afterEach(closeAllWindows)
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ describe('protocol module', () => {
|
||||||
// Note that we need to do navigation every time after a protocol is
|
// Note that we need to do navigation every time after a protocol is
|
||||||
// registered or unregistered, otherwise the new protocol won't be
|
// registered or unregistered, otherwise the new protocol won't be
|
||||||
// recognized by current page when NetworkService is used.
|
// recognized by current page when NetworkService is used.
|
||||||
await contents.loadFile(path.join(fixturesPath, 'pages', 'jquery.html'))
|
await contents.loadFile(path.join(__dirname, 'fixtures', 'pages', 'jquery.html'))
|
||||||
return contents.executeJavaScript(`ajax("${url}", ${JSON.stringify(options)})`)
|
return contents.executeJavaScript(`ajax("${url}", ${JSON.stringify(options)})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as path from 'path'
|
||||||
import { session, WebContents, webContents } from 'electron'
|
import { session, WebContents, webContents } from 'electron'
|
||||||
import { AddressInfo } from 'net'
|
import { AddressInfo } from 'net'
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures')
|
const fixturesPath = path.resolve(__dirname, 'fixtures')
|
||||||
|
|
||||||
describe('webRequest module', () => {
|
describe('webRequest module', () => {
|
||||||
const ses = session.defaultSession
|
const ses = session.defaultSession
|
||||||
|
|
|
@ -309,7 +309,7 @@ describe('chromium features', () => {
|
||||||
const w = new BrowserWindow({ show: false })
|
const w = new BrowserWindow({ show: false })
|
||||||
w.webContents.once('did-finish-load', () => { done() })
|
w.webContents.once('did-finish-load', () => { done() })
|
||||||
w.webContents.once('crashed', () => done(new Error('WebContents crashed.')))
|
w.webContents.once('crashed', () => done(new Error('WebContents crashed.')))
|
||||||
w.loadFile(path.join(fixturesPath, 'pages', 'jquery.html'))
|
w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'jquery.html'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { emittedNTimes } from './events-helpers'
|
||||||
import { BrowserWindow, ipcMain, WebContents } from 'electron'
|
import { BrowserWindow, ipcMain, WebContents } from 'electron'
|
||||||
|
|
||||||
describe('chrome extension content scripts', () => {
|
describe('chrome extension content scripts', () => {
|
||||||
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
|
const fixtures = path.resolve(__dirname, 'fixtures')
|
||||||
const extensionPath = path.resolve(fixtures, 'extensions')
|
const extensionPath = path.resolve(fixtures, 'extensions')
|
||||||
|
|
||||||
const addExtension = (name: string) => BrowserWindow.addExtension(path.resolve(extensionPath, name))
|
const addExtension = (name: string) => BrowserWindow.addExtension(path.resolve(extensionPath, name))
|
||||||
|
|
|
@ -91,7 +91,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
|
||||||
})
|
})
|
||||||
|
|
||||||
ifdescribe(!process.electronBinding('features').isExtensionsEnabled())('chrome extensions', () => {
|
ifdescribe(!process.electronBinding('features').isExtensionsEnabled())('chrome extensions', () => {
|
||||||
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
|
const fixtures = path.resolve(__dirname, 'fixtures')
|
||||||
let w: BrowserWindow
|
let w: BrowserWindow
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="../../static/jquery-2.0.3.min.js"></script>
|
<script src="../../../spec/static/jquery-2.0.3.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
|
@ -161,7 +161,7 @@ describe('<webview> tag', function () {
|
||||||
})
|
})
|
||||||
BrowserWindow.removeDevToolsExtension('foo')
|
BrowserWindow.removeDevToolsExtension('foo')
|
||||||
|
|
||||||
const extensionPath = path.join(fixtures, 'devtools-extensions', 'foo')
|
const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
|
||||||
BrowserWindow.addDevToolsExtension(extensionPath)
|
BrowserWindow.addDevToolsExtension(extensionPath)
|
||||||
|
|
||||||
w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'webview-devtools.html'))
|
w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'webview-devtools.html'))
|
||||||
|
|
5
spec/fixtures/crash-app/main.js
vendored
5
spec/fixtures/crash-app/main.js
vendored
|
@ -1,5 +0,0 @@
|
||||||
const { app } = require('electron')
|
|
||||||
|
|
||||||
app.on('ready', () => {
|
|
||||||
process.crash()
|
|
||||||
})
|
|
4
spec/fixtures/crash-app/package.json
vendored
4
spec/fixtures/crash-app/package.json
vendored
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"name": "electron-crash-app",
|
|
||||||
"main": "main.js"
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue