test: move some fixtures from spec/ to spec-main/ (#21403)

This commit is contained in:
Jeremy Apthorp 2020-01-09 11:50:56 -08:00 committed by GitHub
parent 8a92b65fd3
commit 768a6ace1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 27 additions and 32 deletions

View file

@ -9,7 +9,7 @@ import { AddressInfo } from 'net'
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
const describeFn = (process.platform === 'darwin' && !process.mas && !features.isComponentBuild() ? describe : describe.skip)

View file

@ -224,7 +224,7 @@ describe('BrowserView module', () => {
describe('new BrowserView()', () => {
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 appProcess = ChildProcess.spawn(electronPath, [appPath])
const [code] = await emittedOnce(appProcess, 'close')

View file

@ -3603,7 +3603,7 @@ describe('BrowserWindow module', () => {
})
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(() => {
BrowserWindow.addDevToolsExtension(badManifestExtensionPath)
}).to.throw(/Unexpected token }/)
@ -3614,7 +3614,7 @@ describe('BrowserWindow module', () => {
const extensionName = 'foo'
before(() => {
const extensionPath = path.join(fixtures, 'devtools-extensions', 'foo')
const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
BrowserWindow.addDevToolsExtension(extensionPath)
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)
try {
showLastDevToolsPanel(w)
@ -3728,7 +3728,7 @@ describe('BrowserWindow module', () => {
it('serializes the registered extensions on quit', () => {
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')
BrowserWindow.addDevToolsExtension(extensionPath)
@ -3749,7 +3749,7 @@ describe('BrowserWindow module', () => {
it('throws errors for invalid manifest.json files', () => {
expect(() => {
BrowserWindow.addExtension(path.join(fixtures, 'devtools-extensions', 'bad-manifest'))
BrowserWindow.addExtension(path.join(__dirname, 'fixtures', 'devtools-extensions', 'bad-manifest'))
}).to.throw('Unexpected token }')
})
})

View file

@ -32,7 +32,7 @@ describe('debugger module', () => {
expect(w.webContents.debugger.isAttached()).to.be.true()
done()
})
w.webContents.loadFile(path.join(fixtures, 'pages', 'a.html'))
w.webContents.loadURL('about:blank')
})
it('fails when protocol version is not supported', done => {
@ -134,7 +134,7 @@ describe('debugger module', () => {
const url = process.platform !== 'win32'
? `file://${path.join(fixtures, 'pages', 'a.html')}`
: `file:///${path.join(fixtures, 'pages', 'a.html').replace(/\\/g, '/')}`
w.webContents.loadFile(path.join(fixtures, 'pages', 'a.html'))
w.webContents.loadURL(url)
try {
w.webContents.debugger.attach()
@ -144,12 +144,16 @@ describe('debugger module', () => {
w.webContents.debugger.on('message', (e, method, params) => {
if (method === 'Console.messageAdded') {
try {
expect(params.message.level).to.equal('log')
expect(params.message.url).to.equal(url)
expect(params.message.text).to.equal('a')
w.webContents.debugger.detach()
done()
} catch (e) {
done(e)
} finally {
w.webContents.debugger.detach()
}
}
})
w.webContents.debugger.sendCommand('Console.enable')

View file

@ -6,7 +6,7 @@ import { emittedOnce } from './events-helpers'
import { ipcMain, BrowserWindow } from 'electron'
describe('ipc main module', () => {
const fixtures = path.join(__dirname, '..', 'spec', 'fixtures')
const fixtures = path.join(__dirname, 'fixtures')
afterEach(closeAllWindows)

View file

@ -82,7 +82,7 @@ describe('protocol module', () => {
// Note that we need to do navigation every time after a protocol is
// registered or unregistered, otherwise the new protocol won't be
// 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)})`)
}

View file

@ -5,7 +5,7 @@ import * as path from 'path'
import { session, WebContents, webContents } from 'electron'
import { AddressInfo } from 'net'
const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures')
const fixturesPath = path.resolve(__dirname, 'fixtures')
describe('webRequest module', () => {
const ses = session.defaultSession

View file

@ -309,7 +309,7 @@ describe('chromium features', () => {
const w = new BrowserWindow({ show: false })
w.webContents.once('did-finish-load', () => { done() })
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'))
})
})

View file

@ -7,7 +7,7 @@ import { emittedNTimes } from './events-helpers'
import { BrowserWindow, ipcMain, WebContents } from 'electron'
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 addExtension = (name: string) => BrowserWindow.addExtension(path.resolve(extensionPath, name))

View file

@ -91,7 +91,7 @@ ifdescribe(process.electronBinding('features').isExtensionsEnabled())('chrome ex
})
ifdescribe(!process.electronBinding('features').isExtensionsEnabled())('chrome extensions', () => {
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures')
const fixtures = path.resolve(__dirname, 'fixtures')
let w: BrowserWindow
before(() => {

View file

@ -1,6 +1,6 @@
<html>
<head>
<script src="../../static/jquery-2.0.3.min.js"></script>
<script src="../../../spec/static/jquery-2.0.3.min.js"></script>
</head>
<body>
<script>

View file

@ -161,7 +161,7 @@ describe('<webview> tag', function () {
})
BrowserWindow.removeDevToolsExtension('foo')
const extensionPath = path.join(fixtures, 'devtools-extensions', 'foo')
const extensionPath = path.join(__dirname, 'fixtures', 'devtools-extensions', 'foo')
BrowserWindow.addDevToolsExtension(extensionPath)
w.loadFile(path.join(__dirname, 'fixtures', 'pages', 'webview-devtools.html'))

View file

@ -1,5 +0,0 @@
const { app } = require('electron')
app.on('ready', () => {
process.crash()
})

View file

@ -1,4 +0,0 @@
{
"name": "electron-crash-app",
"main": "main.js"
}