|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
const ChildProcess = require('child_process')
|
|
|
const fs = require('fs')
|
|
|
-const os = require('os')
|
|
|
const http = require('http')
|
|
|
const path = require('path')
|
|
|
const { closeWindow } = require('./window-helpers')
|
|
@@ -1072,16 +1071,6 @@ describe('webContents module', () => {
|
|
|
describe('preload-error event', () => {
|
|
|
const generateSpecs = (description, sandbox) => {
|
|
|
describe(description, () => {
|
|
|
- const tmpPreload = path.join(os.tmpdir(), 'preload.js')
|
|
|
-
|
|
|
- before((done) => {
|
|
|
- fs.writeFile(tmpPreload, '', done)
|
|
|
- })
|
|
|
-
|
|
|
- after((done) => {
|
|
|
- fs.unlink(tmpPreload, () => done())
|
|
|
- })
|
|
|
-
|
|
|
it('is triggered when unhandled exception is thrown', async () => {
|
|
|
const preload = path.join(fixtures, 'module', 'preload-error-exception.js')
|
|
|
|
|
@@ -1141,26 +1130,6 @@ describe('webContents module', () => {
|
|
|
expect(preloadPath).to.equal(preload)
|
|
|
expect(error.message).to.contain('preload-invalid.js')
|
|
|
})
|
|
|
-
|
|
|
- it('is triggered when preload script is outside of app path', async () => {
|
|
|
- const preload = tmpPreload
|
|
|
-
|
|
|
- w.destroy()
|
|
|
- w = new BrowserWindow({
|
|
|
- show: false,
|
|
|
- webPreferences: {
|
|
|
- sandbox,
|
|
|
- preload
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- const promise = emittedOnce(w.webContents, 'preload-error')
|
|
|
- w.loadURL('about:blank')
|
|
|
-
|
|
|
- const [, preloadPath, error] = await promise
|
|
|
- expect(preloadPath).to.equal(preload)
|
|
|
- expect(error.message).to.contain('Preload scripts outside of app path are not allowed')
|
|
|
- })
|
|
|
})
|
|
|
}
|
|
|
|