diff --git a/spec/api-subframe-spec.js b/spec-main/api-subframe-spec.ts similarity index 80% rename from spec/api-subframe-spec.js rename to spec-main/api-subframe-spec.ts index bf1b11418c7a..8809f7f444cd 100644 --- a/spec/api-subframe-spec.js +++ b/spec-main/api-subframe-spec.ts @@ -1,18 +1,17 @@ -const { expect } = require('chai') -const { remote } = require('electron') -const path = require('path') -const http = require('http') - -const { emittedNTimes, emittedOnce } = require('./events-helpers') -const { closeWindow } = require('./window-helpers') - -const { app, BrowserWindow, ipcMain } = remote +import { expect } from 'chai' +import * as path from 'path' +import * as http from 'http' +import { emittedNTimes, emittedOnce } from './events-helpers' +import { closeWindow } from './window-helpers' +import { app, BrowserWindow, ipcMain } from 'electron' +import { AddressInfo } from 'net' +import { ifdescribe } from './spec-helpers'; describe('renderer nodeIntegrationInSubFrames', () => { - const generateTests = (description, webPreferences) => { + const generateTests = (description: string, webPreferences: any) => { describe(description, () => { const fixtureSuffix = webPreferences.webviewTag ? '-webview' : '' - let w + let w: BrowserWindow beforeEach(async () => { await closeWindow(w) @@ -24,10 +23,9 @@ describe('renderer nodeIntegrationInSubFrames', () => { }) }) - afterEach(() => { - return closeWindow(w).then(() => { - w = null - }) + afterEach(async () => { + await closeWindow(w) + w = null as unknown as BrowserWindow }) it('should load preload scripts in top level iframes', async () => { @@ -103,8 +101,8 @@ describe('renderer nodeIntegrationInSubFrames', () => { }) } - const generateConfigs = (webPreferences, ...permutations) => { - const configs = [{ webPreferences, names: [] }] + const generateConfigs = (webPreferences: any, ...permutations: {name: string, webPreferences: any}[]) => { + const configs = [{ webPreferences, names: [] as string[] }] for (let i = 0; i < permutations.length; i++) { const length = configs.length for (let j = 0; j < length; j++) { @@ -117,7 +115,7 @@ describe('renderer nodeIntegrationInSubFrames', () => { } } - return configs.map(config => { + return configs.map((config: any) => { if (config.names.length > 0) { config.title = `with ${config.names.join(', ')} on` } else { @@ -125,7 +123,7 @@ describe('renderer nodeIntegrationInSubFrames', () => { } delete config.names - return config + return config as {title: string, webPreferences: any} }) } @@ -151,7 +149,7 @@ describe('renderer nodeIntegrationInSubFrames', () => { }) describe('internal