refactor: use node scheme imports in spec (#38487)
Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
bf1ba4a857
commit
d78f37ec8f
105 changed files with 533 additions and 352 deletions
|
@ -47,6 +47,7 @@
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^4.2.1",
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
"eslint-plugin-standard": "^4.0.1",
|
"eslint-plugin-standard": "^4.0.1",
|
||||||
|
"eslint-plugin-unicorn": "^46.0.1",
|
||||||
"events": "^3.2.0",
|
"events": "^3.2.0",
|
||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"folder-hash": "^2.1.1",
|
"folder-hash": "^2.1.1",
|
||||||
|
|
|
@ -11,9 +11,11 @@
|
||||||
"WebView": true
|
"WebView": true
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"mocha"
|
"mocha",
|
||||||
|
"unicorn"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"mocha/no-exclusive-tests": "error"
|
"mocha/no-exclusive-tests": "error",
|
||||||
|
"unicorn/prefer-node-protocol": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { assert, expect } from 'chai';
|
import { assert, expect } from 'chai';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
import * as https from 'https';
|
import * as https from 'node:https';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as net from 'net';
|
import * as net from 'node:net';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'node:util';
|
||||||
import { app, BrowserWindow, Menu, session, net as electronNet } from 'electron/main';
|
import { app, BrowserWindow, Menu, session, net as electronNet } from 'electron/main';
|
||||||
import { closeWindow, closeAllWindows } from './lib/window-helpers';
|
import { closeWindow, closeAllWindows } from './lib/window-helpers';
|
||||||
import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers';
|
import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import split = require('split')
|
import split = require('split')
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { autoUpdater } from 'electron/main';
|
import { autoUpdater } from 'electron/main';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { ifit, ifdescribe } from './lib/spec-helpers';
|
import { ifit, ifdescribe } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
ifdescribe(!process.mas)('autoUpdater module', function () {
|
ifdescribe(!process.mas)('autoUpdater module', function () {
|
||||||
describe('checkForUpdates', function () {
|
describe('checkForUpdates', function () {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import * as os from 'os';
|
import * as os from 'node:os';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as psList from 'ps-list';
|
import * as psList from 'ps-list';
|
||||||
import { AddressInfo } from 'net';
|
import { AddressInfo } from 'node:net';
|
||||||
import { ifdescribe, ifit } from './lib/spec-helpers';
|
import { ifdescribe, ifit } from './lib/spec-helpers';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import { systemPreferences } from 'electron';
|
import { systemPreferences } from 'electron';
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { BrowserView, BrowserWindow, screen, webContents } from 'electron/main';
|
import { BrowserView, BrowserWindow, screen, webContents } from 'electron/main';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { defer, ifit, startRemoteControlApp } from './lib/spec-helpers';
|
import { defer, ifit, startRemoteControlApp } from './lib/spec-helpers';
|
||||||
import { areColorsSimilar, captureScreen, getPixelColor } from './lib/screen-helpers';
|
import { areColorsSimilar, captureScreen, getPixelColor } from './lib/screen-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('BrowserView module', () => {
|
describe('BrowserView module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'node:child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as qs from 'querystring';
|
import * as qs from 'node:querystring';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as os from 'os';
|
import * as os from 'node:os';
|
||||||
import { AddressInfo } from 'net';
|
import { AddressInfo } from 'node:net';
|
||||||
import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main';
|
import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main';
|
||||||
|
|
||||||
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
|
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
|
||||||
import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers';
|
import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers';
|
||||||
import { closeWindow, closeAllWindows } from './lib/window-helpers';
|
import { closeWindow, closeAllWindows } from './lib/window-helpers';
|
||||||
import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers';
|
import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
const mainFixtures = path.resolve(__dirname, 'fixtures');
|
const mainFixtures = path.resolve(__dirname, 'fixtures');
|
||||||
|
@ -3463,7 +3463,7 @@ describe('BrowserWindow module', () => {
|
||||||
});
|
});
|
||||||
w.loadURL('about:blank');
|
w.loadURL('about:blank');
|
||||||
const [, rendererEventEmitterProperties] = await once(ipcMain, 'answer');
|
const [, rendererEventEmitterProperties] = await once(ipcMain, 'answer');
|
||||||
const { EventEmitter } = require('events');
|
const { EventEmitter } = require('node:events');
|
||||||
const emitter = new EventEmitter();
|
const emitter = new EventEmitter();
|
||||||
const browserEventEmitterProperties = [];
|
const browserEventEmitterProperties = [];
|
||||||
let currentObj = emitter;
|
let currentObj = emitter;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'node:buffer';
|
||||||
import { ifdescribe, ifit } from './lib/spec-helpers';
|
import { ifdescribe, ifit } from './lib/spec-helpers';
|
||||||
import { clipboard, nativeImage } from 'electron/common';
|
import { clipboard, nativeImage } from 'electron/common';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { app, contentTracing, TraceConfig, TraceCategoriesAndOptions } from 'electron/main';
|
import { app, contentTracing, TraceConfig, TraceCategoriesAndOptions } from 'electron/main';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
import { ifdescribe } from './lib/spec-helpers';
|
import { ifdescribe } from './lib/spec-helpers';
|
||||||
|
|
||||||
// FIXME: The tests are skipped on arm/arm64 and ia32.
|
// FIXME: The tests are skipped on arm/arm64 and ia32.
|
||||||
|
|
|
@ -2,14 +2,14 @@ import { BrowserWindow, ipcMain } from 'electron/main';
|
||||||
import { contextBridge } from 'electron/renderer';
|
import { contextBridge } from 'electron/renderer';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as os from 'os';
|
import * as os from 'node:os';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
|
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { listen } from './lib/spec-helpers';
|
import { listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'context-bridge');
|
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'context-bridge');
|
||||||
|
|
||||||
|
@ -67,16 +67,16 @@ describe('contextBridge', () => {
|
||||||
describe(`with sandbox=${useSandbox}`, () => {
|
describe(`with sandbox=${useSandbox}`, () => {
|
||||||
const makeBindingWindow = async (bindingCreator: Function, worldId: number = 0) => {
|
const makeBindingWindow = async (bindingCreator: Function, worldId: number = 0) => {
|
||||||
const preloadContentForMainWorld = `const renderer_1 = require('electron');
|
const preloadContentForMainWorld = `const renderer_1 = require('electron');
|
||||||
${useSandbox ? '' : `require('v8').setFlagsFromString('--expose_gc');
|
${useSandbox ? '' : `require('node:v8').setFlagsFromString('--expose_gc');
|
||||||
const gc=require('vm').runInNewContext('gc');
|
const gc=require('node:vm').runInNewContext('gc');
|
||||||
renderer_1.contextBridge.exposeInMainWorld('GCRunner', {
|
renderer_1.contextBridge.exposeInMainWorld('GCRunner', {
|
||||||
run: () => gc()
|
run: () => gc()
|
||||||
});`}
|
});`}
|
||||||
(${bindingCreator.toString()})();`;
|
(${bindingCreator.toString()})();`;
|
||||||
|
|
||||||
const preloadContentForIsolatedWorld = `const renderer_1 = require('electron');
|
const preloadContentForIsolatedWorld = `const renderer_1 = require('electron');
|
||||||
${useSandbox ? '' : `require('v8').setFlagsFromString('--expose_gc');
|
${useSandbox ? '' : `require('node:v8').setFlagsFromString('--expose_gc');
|
||||||
const gc=require('vm').runInNewContext('gc');
|
const gc=require('node:vm').runInNewContext('gc');
|
||||||
renderer_1.webFrame.setIsolatedWorldInfo(${worldId}, {
|
renderer_1.webFrame.setIsolatedWorldInfo(${worldId}, {
|
||||||
name: "Isolated World"
|
name: "Isolated World"
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'node:child_process';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as Busboy from 'busboy';
|
import * as Busboy from 'busboy';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { ifdescribe, ifit, defer, startRemoteControlApp, repeatedly, listen } from './lib/spec-helpers';
|
import { ifdescribe, ifit, defer, startRemoteControlApp, repeatedly, listen } from './lib/spec-helpers';
|
||||||
import { app } from 'electron/main';
|
import { app } from 'electron/main';
|
||||||
import { crashReporter } from 'electron/common';
|
import { crashReporter } from 'electron/common';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'node:events';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
|
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
|
||||||
const isLinuxOnArm = process.platform === 'linux' && process.arch.includes('arm');
|
const isLinuxOnArm = process.platform === 'linux' && process.arch.includes('arm');
|
||||||
|
@ -523,7 +523,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
|
||||||
const crashScriptPath = path.join(__dirname, 'fixtures', 'apps', 'crash', 'node-crash.js');
|
const crashScriptPath = path.join(__dirname, 'fixtures', 'apps', 'crash', 'node-crash.js');
|
||||||
return remotely((crashScriptPath: string) => {
|
return remotely((crashScriptPath: string) => {
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('node:child_process');
|
||||||
const version = app.getVersion();
|
const version = app.getVersion();
|
||||||
const url = 'http://127.0.0.1';
|
const url = 'http://127.0.0.1';
|
||||||
childProcess.fork(crashScriptPath, [url, version], { silent: true });
|
childProcess.fork(crashScriptPath, [url, version], { silent: true });
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { BrowserWindow } from 'electron/main';
|
import { BrowserWindow } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { emittedUntil } from './lib/events-helpers';
|
import { emittedUntil } from './lib/events-helpers';
|
||||||
import { listen } from './lib/spec-helpers';
|
import { listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('debugger module', () => {
|
describe('debugger module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { screen, desktopCapturer, BrowserWindow } from 'electron/main';
|
import { screen, desktopCapturer, BrowserWindow } from 'electron/main';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
import { ifdescribe, ifit } from './lib/spec-helpers';
|
import { ifdescribe, ifit } from './lib/spec-helpers';
|
||||||
|
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { expect } from 'chai';
|
||||||
import { dialog, BrowserWindow } from 'electron/main';
|
import { dialog, BrowserWindow } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { ifit } from './lib/spec-helpers';
|
import { ifit } from './lib/spec-helpers';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
describe('dialog module', () => {
|
describe('dialog module', () => {
|
||||||
describe('showOpenDialog', () => {
|
describe('showOpenDialog', () => {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { defer } from './lib/spec-helpers';
|
import { defer } from './lib/spec-helpers';
|
||||||
import { ipcMain, BrowserWindow } from 'electron/main';
|
import { ipcMain, BrowserWindow } from 'electron/main';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('ipc main module', () => {
|
describe('ipc main module', () => {
|
||||||
const fixtures = path.join(__dirname, 'fixtures');
|
const fixtures = path.join(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { ipcMain, BrowserWindow, WebContents, WebPreferences, webContents } from 'electron/main';
|
import { ipcMain, BrowserWindow, WebContents, WebPreferences, webContents } from 'electron/main';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('ipcRenderer module', () => {
|
describe('ipcRenderer module', () => {
|
||||||
const fixtures = path.join(__dirname, 'fixtures');
|
const fixtures = path.join(__dirname, 'fixtures');
|
||||||
|
@ -62,7 +62,7 @@ describe('ipcRenderer module', () => {
|
||||||
it('does not crash when sending external objects', async () => {
|
it('does not crash when sending external objects', async () => {
|
||||||
await expect(w.webContents.executeJavaScript(`{
|
await expect(w.webContents.executeJavaScript(`{
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
const http = require('http')
|
const http = require('node:http')
|
||||||
|
|
||||||
const request = http.request({ port: 5000, hostname: '127.0.0.1', method: 'GET', path: '/' })
|
const request = http.request({ port: 5000, hostname: '127.0.0.1', method: 'GET', path: '/' })
|
||||||
const stream = request.agent.sockets['127.0.0.1:5000:'][0]._handle._externalStream
|
const stream = request.agent.sockets['127.0.0.1:5000:'][0]._handle._externalStream
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { EventEmitter, once } from 'events';
|
import { EventEmitter, once } from 'node:events';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { BrowserWindow, ipcMain, IpcMainInvokeEvent, MessageChannelMain, WebContents } from 'electron/main';
|
import { BrowserWindow, ipcMain, IpcMainInvokeEvent, MessageChannelMain, WebContents } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { defer, listen } from './lib/spec-helpers';
|
import { defer, listen } from './lib/spec-helpers';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
|
|
||||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { BrowserWindow, session, desktopCapturer } from 'electron/main';
|
import { BrowserWindow, session, desktopCapturer } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import { ifit, listen } from './lib/spec-helpers';
|
import { ifit, listen } from './lib/spec-helpers';
|
||||||
|
|
||||||
describe('setDisplayMediaRequestHandler', () => {
|
describe('setDisplayMediaRequestHandler', () => {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { assert, expect } from 'chai';
|
import { assert, expect } from 'chai';
|
||||||
import { BrowserWindow, Menu, MenuItem } from 'electron/main';
|
import { BrowserWindow, Menu, MenuItem } from 'electron/main';
|
||||||
import { sortMenuItems } from '../lib/browser/api/menu-utils';
|
import { sortMenuItems } from '../lib/browser/api/menu-utils';
|
||||||
import { ifit } from './lib/spec-helpers';
|
import { ifit } from './lib/spec-helpers';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { nativeImage } from 'electron/common';
|
import { nativeImage } from 'electron/common';
|
||||||
import { ifdescribe, ifit } from './lib/spec-helpers';
|
import { ifdescribe, ifit } from './lib/spec-helpers';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
|
|
||||||
describe('nativeImage module', () => {
|
describe('nativeImage module', () => {
|
||||||
const fixturesPath = path.join(__dirname, 'fixtures');
|
const fixturesPath = path.join(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { nativeTheme, systemPreferences, BrowserWindow, ipcMain } from 'electron/main';
|
import { nativeTheme, systemPreferences, BrowserWindow, ipcMain } from 'electron/main';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import * as os from 'os';
|
import * as os from 'node:os';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
import { ifdescribe } from './lib/spec-helpers';
|
import { ifdescribe } from './lib/spec-helpers';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as os from 'os';
|
import * as os from 'node:os';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as ChildProcess from 'child_process';
|
import * as ChildProcess from 'node:child_process';
|
||||||
import { session, net } from 'electron/main';
|
import { session, net } from 'electron/main';
|
||||||
import { Socket } from 'net';
|
import { Socket } from 'node:net';
|
||||||
import { ifit, listen } from './lib/spec-helpers';
|
import { ifit, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'net-log');
|
const appPath = path.join(__dirname, 'fixtures', 'api', 'net-log');
|
||||||
const dumpFile = path.join(os.tmpdir(), 'net_log.json');
|
const dumpFile = path.join(os.tmpdir(), 'net_log.json');
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as dns from 'dns';
|
import * as dns from 'node:dns';
|
||||||
import { net, session, ClientRequest, BrowserWindow, ClientRequestConstructorOptions, protocol } from 'electron/main';
|
import { net, session, ClientRequest, BrowserWindow, ClientRequestConstructorOptions, protocol } from 'electron/main';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { Socket } from 'net';
|
import { Socket } from 'node:net';
|
||||||
import { defer, listen } from './lib/spec-helpers';
|
import { defer, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
// See https://github.com/nodejs/node/issues/40702.
|
// See https://github.com/nodejs/node/issues/40702.
|
||||||
dns.setDefaultResultOrder('ipv4first');
|
dns.setDefaultResultOrder('ipv4first');
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { expect } from 'chai';
|
||||||
import * as dbus from 'dbus-native';
|
import * as dbus from 'dbus-native';
|
||||||
import { app } from 'electron/main';
|
import { app } from 'electron/main';
|
||||||
import { ifdescribe } from './lib/spec-helpers';
|
import { ifdescribe } from './lib/spec-helpers';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'node:util';
|
||||||
|
|
||||||
const skip = process.platform !== 'linux' ||
|
const skip = process.platform !== 'linux' ||
|
||||||
process.arch === 'ia32' ||
|
process.arch === 'ia32' ||
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { Notification } from 'electron/main';
|
import { Notification } from 'electron/main';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { ifit } from './lib/spec-helpers';
|
import { ifit } from './lib/spec-helpers';
|
||||||
|
|
||||||
describe('Notification module', () => {
|
describe('Notification module', () => {
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as dbus from 'dbus-native';
|
import * as dbus from 'dbus-native';
|
||||||
import { ifdescribe, startRemoteControlApp } from './lib/spec-helpers';
|
import { ifdescribe, startRemoteControlApp } from './lib/spec-helpers';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'node:util';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
describe('powerMonitor', () => {
|
describe('powerMonitor', () => {
|
||||||
let logindMock: any, dbusMockPowerMonitor: any, getCalls: any, emitSignal: any, reset: any;
|
let logindMock: any, dbusMockPowerMonitor: any, getCalls: any, emitSignal: any, reset: any;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { BrowserWindow } from 'electron';
|
import { BrowserWindow } from 'electron';
|
||||||
import { defer, ifdescribe } from './lib/spec-helpers';
|
import { defer, ifdescribe } from './lib/spec-helpers';
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain, net } from 'electron/main';
|
import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain, net } from 'electron/main';
|
||||||
import * as ChildProcess from 'child_process';
|
import * as ChildProcess from 'node:child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as qs from 'querystring';
|
import * as qs from 'node:querystring';
|
||||||
import * as stream from 'stream';
|
import * as stream from 'node:stream';
|
||||||
import { EventEmitter, once } from 'events';
|
import { EventEmitter, once } from 'node:events';
|
||||||
import { closeAllWindows, closeWindow } from './lib/window-helpers';
|
import { closeAllWindows, closeWindow } from './lib/window-helpers';
|
||||||
import { WebmGenerator } from './lib/video-helpers';
|
import { WebmGenerator } from './lib/video-helpers';
|
||||||
import { listen, defer, ifit } from './lib/spec-helpers';
|
import { listen, defer, ifit } from './lib/spec-helpers';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { safeStorage } from 'electron/main';
|
import { safeStorage } from 'electron/main';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { ifdescribe } from './lib/spec-helpers';
|
import { ifdescribe } from './lib/spec-helpers';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
/* isEncryptionAvailable returns false in Linux when running CI due to a mocked dbus. This stops
|
/* isEncryptionAvailable returns false in Linux when running CI due to a mocked dbus. This stops
|
||||||
* Chrome from reaching the system's keyring or libsecret. When running the tests with config.store
|
* Chrome from reaching the system's keyring or libsecret. When running the tests with config.store
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { session, webContents, WebContents } from 'electron/main';
|
import { session, webContents, WebContents } from 'electron/main';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import { listen } from './lib/spec-helpers';
|
import { listen } from './lib/spec-helpers';
|
||||||
import { on, once } from 'events';
|
import { on, once } from 'node:events';
|
||||||
|
|
||||||
const partition = 'service-workers-spec';
|
const partition = 'service-workers-spec';
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as https from 'https';
|
import * as https from 'node:https';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as ChildProcess from 'child_process';
|
import * as ChildProcess from 'node:child_process';
|
||||||
import { app, session, BrowserWindow, net, ipcMain, Session, webFrameMain, WebFrameMain } from 'electron/main';
|
import { app, session, BrowserWindow, net, ipcMain, Session, webFrameMain, WebFrameMain } from 'electron/main';
|
||||||
import * as send from 'send';
|
import * as send from 'send';
|
||||||
import * as auth from 'basic-auth';
|
import * as auth from 'basic-auth';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { defer, listen } from './lib/spec-helpers';
|
import { defer, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
describe('session module', () => {
|
describe('session module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -2,12 +2,12 @@ import { BrowserWindow, app } from 'electron/main';
|
||||||
import { shell } from 'electron/common';
|
import { shell } from 'electron/common';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { ifdescribe, ifit, listen } from './lib/spec-helpers';
|
import { ifdescribe, ifit, listen } from './lib/spec-helpers';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
import * as os from 'os';
|
import * as os from 'node:os';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('shell module', () => {
|
describe('shell module', () => {
|
||||||
describe('shell.openExternal()', () => {
|
describe('shell.openExternal()', () => {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import { emittedNTimes } from './lib/events-helpers';
|
import { emittedNTimes } from './lib/events-helpers';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { app, BrowserWindow, ipcMain } from 'electron/main';
|
import { app, BrowserWindow, ipcMain } from 'electron/main';
|
||||||
import { ifdescribe, listen } from './lib/spec-helpers';
|
import { ifdescribe, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('renderer nodeIntegrationInSubFrames', () => {
|
describe('renderer nodeIntegrationInSubFrames', () => {
|
||||||
const generateTests = (description: string, webPreferences: any) => {
|
const generateTests = (description: string, webPreferences: any) => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { BrowserWindow, TouchBar } from 'electron/main';
|
import { BrowserWindow, TouchBar } from 'electron/main';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { expect } from 'chai';
|
||||||
import { Menu, Tray } from 'electron/main';
|
import { Menu, Tray } from 'electron/main';
|
||||||
import { nativeImage } from 'electron/common';
|
import { nativeImage } from 'electron/common';
|
||||||
import { ifdescribe, ifit } from './lib/spec-helpers';
|
import { ifdescribe, ifit } from './lib/spec-helpers';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
|
|
||||||
describe('tray module', () => {
|
describe('tray module', () => {
|
||||||
let tray: Tray;
|
let tray: Tray;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'node:child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { BrowserWindow, MessageChannelMain, utilityProcess } from 'electron/main';
|
import { BrowserWindow, MessageChannelMain, utilityProcess } from 'electron/main';
|
||||||
import { ifit } from './lib/spec-helpers';
|
import { ifit } from './lib/spec-helpers';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process');
|
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process');
|
||||||
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
|
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { AddressInfo } from 'net';
|
import { AddressInfo } from 'node:net';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import { BrowserWindow, ipcMain, webContents, session, app, BrowserView } from 'electron/main';
|
import { BrowserWindow, ipcMain, webContents, session, app, BrowserView } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers';
|
import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const pdfjs = require('pdfjs-dist');
|
const pdfjs = require('pdfjs-dist');
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain, app, WebContents } from 'electron/main';
|
import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain, app, WebContents } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { emittedNTimes } from './lib/events-helpers';
|
import { emittedNTimes } from './lib/events-helpers';
|
||||||
import { defer, ifit, listen, waitUntil } from './lib/spec-helpers';
|
import { defer, ifit, listen, waitUntil } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
describe('webFrameMain module', () => {
|
describe('webFrameMain module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { BrowserWindow, ipcMain, WebContents } from 'electron/main';
|
import { BrowserWindow, ipcMain, WebContents } from 'electron/main';
|
||||||
import { defer } from './lib/spec-helpers';
|
import { defer } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('webFrame module', () => {
|
describe('webFrame module', () => {
|
||||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as http2 from 'http2';
|
import * as http2 from 'node:http2';
|
||||||
import * as qs from 'querystring';
|
import * as qs from 'node:querystring';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import * as WebSocket from 'ws';
|
import * as WebSocket from 'ws';
|
||||||
import { ipcMain, protocol, session, WebContents, webContents } from 'electron/main';
|
import { ipcMain, protocol, session, WebContents, webContents } from 'electron/main';
|
||||||
import { AddressInfo, Socket } from 'net';
|
import { AddressInfo, Socket } from 'node:net';
|
||||||
import { listen, defer } from './lib/spec-helpers';
|
import { listen, defer } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { ReadableStream } from 'stream/web';
|
import { ReadableStream } from 'node:stream/web';
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ describe('webRequest module', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
server.on('upgrade', function upgrade (request, socket, head) {
|
server.on('upgrade', function upgrade (request, socket, head) {
|
||||||
const pathname = require('url').parse(request.url).pathname;
|
const pathname = require('node:url').parse(request.url).pathname;
|
||||||
if (pathname === '/websocket') {
|
if (pathname === '/websocket') {
|
||||||
reqHeaders[request.url!] = request.headers;
|
reqHeaders[request.url!] = request.headers;
|
||||||
wss.handleUpgrade(request, socket as Socket, head, function done (ws) {
|
wss.handleUpgrade(request, socket as Socket, head, function done (ws) {
|
||||||
|
@ -625,7 +625,7 @@ describe('webRequest module', () => {
|
||||||
callback({ requestHeaders: details.requestHeaders });
|
callback({ requestHeaders: details.requestHeaders });
|
||||||
});
|
});
|
||||||
ses.webRequest.onHeadersReceived((details, callback) => {
|
ses.webRequest.onHeadersReceived((details, callback) => {
|
||||||
const pathname = require('url').parse(details.url).pathname;
|
const pathname = require('node:url').parse(details.url).pathname;
|
||||||
receivedHeaders[pathname] = details.responseHeaders;
|
receivedHeaders[pathname] = details.responseHeaders;
|
||||||
callback({ cancel: false });
|
callback({ cancel: false });
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import { Worker } from 'worker_threads';
|
import { Worker } from 'node:worker_threads';
|
||||||
import { BrowserWindow, ipcMain } from 'electron/main';
|
import { BrowserWindow, ipcMain } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
|
import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
|
||||||
import * as importedFs from 'fs';
|
import * as importedFs from 'node:fs';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
describe('asar package', () => {
|
describe('asar package', () => {
|
||||||
const fixtures = path.join(__dirname, 'fixtures');
|
const fixtures = path.join(__dirname, 'fixtures');
|
||||||
|
@ -142,7 +142,7 @@ function promisify (_f: Function): any {
|
||||||
describe('asar package', function () {
|
describe('asar package', function () {
|
||||||
const fixtures = path.join(__dirname, 'fixtures');
|
const fixtures = path.join(__dirname, 'fixtures');
|
||||||
const asarDir = path.join(fixtures, 'test.asar');
|
const asarDir = path.join(fixtures, 'test.asar');
|
||||||
const fs = require('fs') as typeof importedFs; // dummy, to fool typescript
|
const fs = require('node:fs') as typeof importedFs; // dummy, to fool typescript
|
||||||
|
|
||||||
useRemoteContext({
|
useRemoteContext({
|
||||||
url: url.pathToFileURL(path.join(fixtures, 'pages', 'blank.html')),
|
url: url.pathToFileURL(path.join(fixtures, 'pages', 'blank.html')),
|
||||||
|
@ -159,8 +159,8 @@ describe('asar package', function () {
|
||||||
chai.expect(error).to.have.property('code').which.equals(code);
|
chai.expect(error).to.have.property('code').which.equals(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = require('fs')
|
fs = require('node:fs')
|
||||||
path = require('path')
|
path = require('node:path')
|
||||||
asarDir = ${JSON.stringify(asarDir)}
|
asarDir = ${JSON.stringify(asarDir)}
|
||||||
|
|
||||||
// This is used instead of util.promisify for some tests to dodge the
|
// This is used instead of util.promisify for some tests to dodge the
|
||||||
|
@ -1121,13 +1121,13 @@ describe('asar package', function () {
|
||||||
|
|
||||||
itremote('promisified version handles an existing file', async () => {
|
itremote('promisified version handles an existing file', async () => {
|
||||||
const p = path.join(asarDir, 'a.asar', 'file1');
|
const p = path.join(asarDir, 'a.asar', 'file1');
|
||||||
const exists = await require('util').promisify(fs.exists)(p);
|
const exists = await require('node:util').promisify(fs.exists)(p);
|
||||||
expect(exists).to.be.true();
|
expect(exists).to.be.true();
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('promisified version handles a non-existent file', async function () {
|
itremote('promisified version handles a non-existent file', async function () {
|
||||||
const p = path.join(asarDir, 'a.asar', 'not-exist');
|
const p = path.join(asarDir, 'a.asar', 'not-exist');
|
||||||
const exists = await require('util').promisify(fs.exists)(p);
|
const exists = await require('node:util').promisify(fs.exists)(p);
|
||||||
expect(exists).to.be.false();
|
expect(exists).to.be.false();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1311,7 +1311,7 @@ describe('asar package', function () {
|
||||||
describe('util.promisify', function () {
|
describe('util.promisify', function () {
|
||||||
itremote('can promisify all fs functions', function () {
|
itremote('can promisify all fs functions', function () {
|
||||||
const originalFs = require('original-fs');
|
const originalFs = require('original-fs');
|
||||||
const util = require('util');
|
const util = require('node:util');
|
||||||
const { hasOwnProperty } = Object.prototype;
|
const { hasOwnProperty } = Object.prototype;
|
||||||
|
|
||||||
for (const [propertyName, originalValue] of Object.entries(originalFs)) {
|
for (const [propertyName, originalValue] of Object.entries(originalFs)) {
|
||||||
|
@ -1405,7 +1405,7 @@ describe('asar package', function () {
|
||||||
itremote('is reset to its original value when execSync throws an error', function () {
|
itremote('is reset to its original value when execSync throws an error', function () {
|
||||||
process.noAsar = false;
|
process.noAsar = false;
|
||||||
expect(() => {
|
expect(() => {
|
||||||
require('child_process').execSync(path.join(__dirname, 'does-not-exist.txt'));
|
require('node:child_process').execSync(path.join(__dirname, 'does-not-exist.txt'));
|
||||||
}).to.throw();
|
}).to.throw();
|
||||||
expect(process.noAsar).to.be.false();
|
expect(process.noAsar).to.be.false();
|
||||||
});
|
});
|
||||||
|
@ -1531,8 +1531,8 @@ describe('asar package', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('has the same APIs as fs', function () {
|
itremote('has the same APIs as fs', function () {
|
||||||
expect(Object.keys(require('fs'))).to.deep.equal(Object.keys(require('original-fs')));
|
expect(Object.keys(require('node:fs'))).to.deep.equal(Object.keys(require('original-fs')));
|
||||||
expect(Object.keys(require('fs').promises)).to.deep.equal(Object.keys(require('original-fs').promises));
|
expect(Object.keys(require('node:fs').promises)).to.deep.equal(Object.keys(require('original-fs').promises));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { BrowserWindow } from 'electron';
|
import { BrowserWindow } from 'electron';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
const fixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { BrowserWindow, WebContents, webFrameMain, session, ipcMain, app, protocol, webContents } from 'electron/main';
|
import { BrowserWindow, WebContents, webFrameMain, session, ipcMain, app, protocol, webContents } from 'electron/main';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import * as https from 'https';
|
import * as https from 'node:https';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import * as ChildProcess from 'child_process';
|
import * as ChildProcess from 'node:child_process';
|
||||||
import { EventEmitter, once } from 'events';
|
import { EventEmitter, once } from 'node:events';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'node:util';
|
||||||
import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers';
|
import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers';
|
||||||
import { PipeTransport } from './pipe-transport';
|
import { PipeTransport } from './pipe-transport';
|
||||||
import * as ws from 'ws';
|
import * as ws from 'ws';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const features = process._linkedBinding('electron_common_features');
|
const features = process._linkedBinding('electron_common_features');
|
||||||
|
|
||||||
|
@ -1028,7 +1028,7 @@ describe('chromium features', () => {
|
||||||
ifit(process.platform !== 'win32' || process.arch !== 'arm64')('disables JavaScript when it is disabled on the parent window', async () => {
|
ifit(process.platform !== 'win32' || process.arch !== 'arm64')('disables JavaScript when it is disabled on the parent window', async () => {
|
||||||
const w = new BrowserWindow({ show: true, webPreferences: { nodeIntegration: true } });
|
const w = new BrowserWindow({ show: true, webPreferences: { nodeIntegration: true } });
|
||||||
w.webContents.loadFile(path.resolve(__dirname, 'fixtures', 'blank.html'));
|
w.webContents.loadFile(path.resolve(__dirname, 'fixtures', 'blank.html'));
|
||||||
const windowUrl = require('url').format({
|
const windowUrl = require('node:url').format({
|
||||||
pathname: `${fixturesPath}/pages/window-no-javascript.html`,
|
pathname: `${fixturesPath}/pages/window-no-javascript.html`,
|
||||||
protocol: 'file',
|
protocol: 'file',
|
||||||
slashes: true
|
slashes: true
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as cp from 'child_process';
|
import * as cp from 'node:child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import { ifit } from './lib/spec-helpers';
|
import { ifit } from './lib/spec-helpers';
|
||||||
|
|
||||||
const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases');
|
const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases');
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { app, session, BrowserWindow, ipcMain, WebContents, Extension, Session } from 'electron/main';
|
import { app, session, BrowserWindow, ipcMain, WebContents, Extension, Session } from 'electron/main';
|
||||||
import { closeAllWindows, closeWindow } from './lib/window-helpers';
|
import { closeAllWindows, closeWindow } from './lib/window-helpers';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as WebSocket from 'ws';
|
import * as WebSocket from 'ws';
|
||||||
import { emittedNTimes, emittedUntil } from './lib/events-helpers';
|
import { emittedNTimes, emittedUntil } from './lib/events-helpers';
|
||||||
import { ifit, listen } from './lib/spec-helpers';
|
import { ifit, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
const uuid = require('uuid');
|
const uuid = require('uuid');
|
||||||
|
|
||||||
|
|
2
spec/fixtures/api/close.html
vendored
2
spec/fixtures/api/close.html
vendored
|
@ -2,7 +2,7 @@
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
window.addEventListener('unload', function (e) {
|
window.addEventListener('unload', function (e) {
|
||||||
require('fs').writeFileSync(__dirname + '/close', 'close');
|
require('node:fs').writeFileSync(__dirname + '/close', 'close');
|
||||||
}, false);
|
}, false);
|
||||||
window.onload = () => window.close();
|
window.onload = () => window.close();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, BrowserWindow } = require('electron');
|
const { app, BrowserWindow } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
let win;
|
let win;
|
||||||
app.whenReady().then(function () {
|
app.whenReady().then(function () {
|
||||||
|
|
4
spec/fixtures/api/mixed-sandbox-app/main.js
vendored
4
spec/fixtures/api/mixed-sandbox-app/main.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
const net = require('net');
|
const net = require('node:net');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
process.on('uncaughtException', () => {
|
process.on('uncaughtException', () => {
|
||||||
app.exit(1);
|
app.exit(1);
|
||||||
|
|
2
spec/fixtures/api/relaunch/main.js
vendored
2
spec/fixtures/api/relaunch/main.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
const net = require('net');
|
const net = require('node:net');
|
||||||
|
|
||||||
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
|
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { app, safeStorage, ipcMain } = require('electron');
|
const { app, safeStorage, ipcMain } = require('electron');
|
||||||
const { promises: fs } = require('fs');
|
const { promises: fs } = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt');
|
const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt');
|
||||||
const readFile = fs.readFile;
|
const readFile = fs.readFile;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { app, safeStorage, ipcMain } = require('electron');
|
const { app, safeStorage, ipcMain } = require('electron');
|
||||||
const { promises: fs } = require('fs');
|
const { promises: fs } = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt');
|
const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt');
|
||||||
const writeFile = fs.writeFile;
|
const writeFile = fs.writeFile;
|
||||||
|
|
4
spec/fixtures/api/singleton-userdata/main.js
vendored
4
spec/fixtures/api/singleton-userdata/main.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
// non-existent user data folder should not break requestSingleInstanceLock()
|
// non-existent user data folder should not break requestSingleInstanceLock()
|
||||||
// ref: https://github.com/electron/electron/issues/33547
|
// ref: https://github.com/electron/electron/issues/33547
|
||||||
|
|
2
spec/fixtures/api/unload.html
vendored
2
spec/fixtures/api/unload.html
vendored
|
@ -2,7 +2,7 @@
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
window.addEventListener('unload', function (e) {
|
window.addEventListener('unload', function (e) {
|
||||||
require('fs').writeFileSync(__dirname + '/unload', 'unload');
|
require('node:fs').writeFileSync(__dirname + '/unload', 'unload');
|
||||||
}, false);
|
}, false);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, utilityProcess } = require('electron');
|
const { app, utilityProcess } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
let child = null;
|
let child = null;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, utilityProcess } = require('electron');
|
const { app, utilityProcess } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
const payload = app.commandLine.getSwitchValue('payload');
|
const payload = app.commandLine.getSwitchValue('payload');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, utilityProcess } = require('electron');
|
const { app, utilityProcess } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
const payload = app.commandLine.getSwitchValue('payload');
|
const payload = app.commandLine.getSwitchValue('payload');
|
||||||
|
|
2
spec/fixtures/api/utility-process/suid.js
vendored
2
spec/fixtures/api/utility-process/suid.js
vendored
|
@ -1,2 +1,2 @@
|
||||||
const result = require('child_process').execSync('sudo --help');
|
const result = require('node:child_process').execSync('sudo --help');
|
||||||
process.parentPort.postMessage(result);
|
process.parentPort.postMessage(result);
|
||||||
|
|
4
spec/fixtures/apps/crash/fork.js
vendored
4
spec/fixtures/apps/crash/fork.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('node:child_process');
|
||||||
|
|
||||||
const crashPath = path.join(__dirname, 'node-crash.js');
|
const crashPath = path.join(__dirname, 'node-crash.js');
|
||||||
const child = childProcess.fork(crashPath, { silent: true });
|
const child = childProcess.fork(crashPath, { silent: true });
|
||||||
|
|
4
spec/fixtures/apps/crash/main.js
vendored
4
spec/fixtures/apps/crash/main.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
const { app, BrowserWindow, crashReporter } = require('electron');
|
const { app, BrowserWindow, crashReporter } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('node:child_process');
|
||||||
|
|
||||||
app.setVersion('0.1.0');
|
app.setVersion('0.1.0');
|
||||||
|
|
||||||
|
|
4
spec/fixtures/apps/crash/node-extra-args.js
vendored
4
spec/fixtures/apps/crash/node-extra-args.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('node:child_process');
|
||||||
|
|
||||||
process.on('message', function () {
|
process.on('message', function () {
|
||||||
process.send(process.argv);
|
process.send(process.argv);
|
||||||
|
|
2
spec/fixtures/apps/libuv-hang/main.js
vendored
2
spec/fixtures/apps/libuv-hang/main.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
async function createWindow () {
|
async function createWindow () {
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
|
|
2
spec/fixtures/apps/libuv-hang/preload.js
vendored
2
spec/fixtures/apps/libuv-hang/preload.js
vendored
|
@ -3,7 +3,7 @@ const { contextBridge, ipcRenderer } = require('electron');
|
||||||
contextBridge.exposeInMainWorld('api', {
|
contextBridge.exposeInMainWorld('api', {
|
||||||
ipcRenderer,
|
ipcRenderer,
|
||||||
run: async () => {
|
run: async () => {
|
||||||
const { promises: fs } = require('fs');
|
const { promises: fs } = require('node:fs');
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
const list = await fs.readdir('.', { withFileTypes: true });
|
const list = await fs.readdir('.', { withFileTypes: true });
|
||||||
for (const file of list) {
|
for (const file of list) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, BrowserWindow } = require('electron');
|
const { app, BrowserWindow } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
async function createWindow () {
|
async function createWindow () {
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
|
|
6
spec/fixtures/apps/remote-control/main.js
vendored
6
spec/fixtures/apps/remote-control/main.js
vendored
|
@ -1,8 +1,8 @@
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
const http = require('http');
|
const http = require('node:http');
|
||||||
const v8 = require('v8');
|
const v8 = require('node:v8');
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
const promises_1 = require('timers/promises');
|
const promises_1 = require('node:timers/promises');
|
||||||
|
|
||||||
if (app.commandLine.hasSwitch('boot-eval')) {
|
if (app.commandLine.hasSwitch('boot-eval')) {
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
|
|
2
spec/fixtures/apps/self-module-paths/main.js
vendored
2
spec/fixtures/apps/self-module-paths/main.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
|
|
2
spec/fixtures/apps/set-path/main.js
vendored
2
spec/fixtures/apps/set-path/main.js
vendored
|
@ -1,4 +1,4 @@
|
||||||
const http = require('http');
|
const http = require('node:http');
|
||||||
const { app, ipcMain, BrowserWindow } = require('electron');
|
const { app, ipcMain, BrowserWindow } = require('electron');
|
||||||
|
|
||||||
if (process.argv.length > 3) {
|
if (process.argv.length > 3) {
|
||||||
|
|
2
spec/fixtures/apps/xwindow-icon/main.js
vendored
2
spec/fixtures/apps/xwindow-icon/main.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const { app, BrowserWindow } = require('electron');
|
const { app, BrowserWindow } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
const w = new BrowserWindow({
|
const w = new BrowserWindow({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
4
spec/fixtures/auto-update/update/index.js
vendored
4
spec/fixtures/auto-update/update/index.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
|
|
||||||
async function readFile(path) {
|
async function readFile(path) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
let reloadCount = 0;
|
let reloadCount = 0;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<body>
|
<body>
|
||||||
<iframe id="mainframe"></iframe>
|
<iframe id="mainframe"></iframe>
|
||||||
<script>
|
<script>
|
||||||
const net = require('net');
|
const net = require('node:net');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
document.getElementById("mainframe").src="./page2.html";
|
document.getElementById("mainframe").src="./page2.html";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { app, BrowserWindow } = require('electron');
|
const { app, BrowserWindow } = require('electron');
|
||||||
const net = require('net');
|
const net = require('node:net');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { app, ipcMain, BrowserWindow } = require('electron');
|
const { app, ipcMain, BrowserWindow } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const http = require('http');
|
const http = require('node:http');
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
const mainWindow = new BrowserWindow({
|
const mainWindow = new BrowserWindow({
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, BrowserWindow } = require('electron');
|
const { app, BrowserWindow } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
|
|
2
spec/fixtures/module/asar.js
vendored
2
spec/fixtures/module/asar.js
vendored
|
@ -1,4 +1,4 @@
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
process.on('message', function (file) {
|
process.on('message', function (file) {
|
||||||
process.send(fs.readFileSync(file).toString());
|
process.send(fs.readFileSync(file).toString());
|
||||||
});
|
});
|
||||||
|
|
2
spec/fixtures/module/create_socket.js
vendored
2
spec/fixtures/module/create_socket.js
vendored
|
@ -1,4 +1,4 @@
|
||||||
const net = require('net');
|
const net = require('node:net');
|
||||||
const server = net.createServer(function () {});
|
const server = net.createServer(function () {});
|
||||||
server.listen(process.argv[2]);
|
server.listen(process.argv[2]);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|
4
spec/fixtures/module/fork_ping.js
vendored
4
spec/fixtures/module/fork_ping.js
vendored
|
@ -1,10 +1,10 @@
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
process.on('uncaughtException', function (error) {
|
process.on('uncaughtException', function (error) {
|
||||||
process.send(error.stack);
|
process.send(error.stack);
|
||||||
});
|
});
|
||||||
|
|
||||||
const child = require('child_process').fork(path.join(__dirname, '/ping.js'));
|
const child = require('node:child_process').fork(path.join(__dirname, '/ping.js'));
|
||||||
process.on('message', function (msg) {
|
process.on('message', function (msg) {
|
||||||
child.send(msg);
|
child.send(msg);
|
||||||
});
|
});
|
||||||
|
|
6
spec/fixtures/module/inspector-binding.js
vendored
6
spec/fixtures/module/inspector-binding.js
vendored
|
@ -1,6 +1,6 @@
|
||||||
const inspector = require('inspector');
|
const inspector = require('node:inspector');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const { pathToFileURL } = require('url');
|
const { pathToFileURL } = require('node:url');
|
||||||
|
|
||||||
// This test case will set a breakpoint 4 lines below
|
// This test case will set a breakpoint 4 lines below
|
||||||
function debuggedFunction () {
|
function debuggedFunction () {
|
||||||
|
|
4
spec/fixtures/module/no-asar.js
vendored
4
spec/fixtures/module/no-asar.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const stats = fs.statSync(path.join(__dirname, '..', 'test.asar', 'a.asar'));
|
const stats = fs.statSync(path.join(__dirname, '..', 'test.asar', 'a.asar'));
|
||||||
|
|
||||||
|
|
2
spec/fixtures/module/preload-eventemitter.js
vendored
2
spec/fixtures/module/preload-eventemitter.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
(function () {
|
(function () {
|
||||||
const { EventEmitter } = require('events');
|
const { EventEmitter } = require('node:events');
|
||||||
const emitter = new EventEmitter();
|
const emitter = new EventEmitter();
|
||||||
const rendererEventEmitterProperties = [];
|
const rendererEventEmitterProperties = [];
|
||||||
let currentObj = emitter;
|
let currentObj = emitter;
|
||||||
|
|
5
spec/fixtures/module/preload-sandbox.js
vendored
5
spec/fixtures/module/preload-sandbox.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
(function () {
|
(function () {
|
||||||
const { setImmediate } = require('timers');
|
const { setImmediate } = require('node:timers');
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
window.ipcRenderer = ipcRenderer;
|
window.ipcRenderer = ipcRenderer;
|
||||||
window.setImmediate = setImmediate;
|
window.setImmediate = setImmediate;
|
||||||
|
@ -34,8 +34,11 @@
|
||||||
cpuUsage: invoke(() => process.getCPUUsage()),
|
cpuUsage: invoke(() => process.getCPUUsage()),
|
||||||
ioCounters: invoke(() => process.getIOCounters()),
|
ioCounters: invoke(() => process.getIOCounters()),
|
||||||
uptime: invoke(() => process.uptime()),
|
uptime: invoke(() => process.uptime()),
|
||||||
|
// eslint-disable-next-line unicorn/prefer-node-protocol
|
||||||
nodeEvents: invoke(() => require('events') === require('node:events')),
|
nodeEvents: invoke(() => require('events') === require('node:events')),
|
||||||
|
// eslint-disable-next-line unicorn/prefer-node-protocol
|
||||||
nodeTimers: invoke(() => require('timers') === require('node:timers')),
|
nodeTimers: invoke(() => require('timers') === require('node:timers')),
|
||||||
|
// eslint-disable-next-line unicorn/prefer-node-protocol
|
||||||
nodeUrl: invoke(() => require('url') === require('node:url')),
|
nodeUrl: invoke(() => require('url') === require('node:url')),
|
||||||
env: process.env,
|
env: process.env,
|
||||||
execPath: process.execPath,
|
execPath: process.execPath,
|
||||||
|
|
2
spec/fixtures/no-proprietary-codecs.js
vendored
2
spec/fixtures/no-proprietary-codecs.js
vendored
|
@ -5,7 +5,7 @@
|
||||||
// that does include proprietary codecs.
|
// that does include proprietary codecs.
|
||||||
|
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
|
const MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
|
||||||
const FIVE_MINUTES = 5 * 60 * 1000;
|
const FIVE_MINUTES = 5 * 60 * 1000;
|
||||||
|
|
2
spec/fixtures/pages/native-module.html
vendored
2
spec/fixtures/pages/native-module.html
vendored
|
@ -1,7 +1,7 @@
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
var path = require('path');
|
var path = require('node:path');
|
||||||
console.log(typeof require(path.join(__dirname, '..', '..', 'node_modules', '@electron-ci', 'echo')));
|
console.log(typeof require(path.join(__dirname, '..', '..', 'node_modules', '@electron-ci', 'echo')));
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
2
spec/fixtures/pages/send-after-node.html
vendored
2
spec/fixtures/pages/send-after-node.html
vendored
|
@ -1,7 +1,7 @@
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
require('fs').readdir(process.cwd(), () => {
|
require('node:fs').readdir(process.cwd(), () => {
|
||||||
require('electron').ipcRenderer.send('async-node-api-done');
|
require('electron').ipcRenderer.send('async-node-api-done');
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
const url = require('url')
|
const url = require('node:url')
|
||||||
function tryPostMessage(...args) {
|
function tryPostMessage(...args) {
|
||||||
try {
|
try {
|
||||||
window.opener.postMessage(...args)
|
window.opener.postMessage(...args)
|
||||||
|
|
6
spec/fixtures/test.asar/repack.js
vendored
6
spec/fixtures/test.asar/repack.js
vendored
|
@ -2,9 +2,9 @@
|
||||||
// using a new version of the asar package
|
// using a new version of the asar package
|
||||||
|
|
||||||
const asar = require('@electron/asar');
|
const asar = require('@electron/asar');
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const os = require('os');
|
const os = require('node:os');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
|
|
||||||
const archives = [];
|
const archives = [];
|
||||||
for (const child of fs.readdirSync(__dirname)) {
|
for (const child of fs.readdirSync(__dirname)) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import * as walkdir from 'walkdir';
|
import * as walkdir from 'walkdir';
|
||||||
|
|
||||||
export async function getFiles (directoryPath: string, { filter = null }: {filter?: ((file: string) => boolean) | null} = {}) {
|
export async function getFiles (directoryPath: string, { filter = null }: {filter?: ((file: string) => boolean) | null} = {}) {
|
||||||
|
|
|
@ -3,8 +3,8 @@ import { expect, assert } from 'chai';
|
||||||
import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers';
|
import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers';
|
||||||
import { ifit } from './lib/spec-helpers';
|
import { ifit } from './lib/spec-helpers';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout as setTimeoutAsync } from 'timers/promises';
|
import { setTimeout as setTimeoutAsync } from 'node:timers/promises';
|
||||||
|
|
||||||
describe('webContents.setWindowOpenHandler', () => {
|
describe('webContents.setWindowOpenHandler', () => {
|
||||||
let browserWindow: BrowserWindow;
|
let browserWindow: BrowserWindow;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const fs = require('fs');
|
const fs = require('node:fs');
|
||||||
const path = require('path');
|
const path = require('node:path');
|
||||||
const v8 = require('v8');
|
const v8 = require('node:v8');
|
||||||
|
|
||||||
// We want to terminate on errors, not throw up a dialog
|
// We want to terminate on errors, not throw up a dialog
|
||||||
process.on('uncaughtException', (err) => {
|
process.on('uncaughtException', (err) => {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* with events in async/await manner.
|
* with events in async/await manner.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { on } from 'events';
|
import { on } from 'node:events';
|
||||||
|
|
||||||
export const emittedNTimes = async (emitter: NodeJS.EventEmitter, eventName: string, times: number, trigger?: () => void) => {
|
export const emittedNTimes = async (emitter: NodeJS.EventEmitter, eventName: string, times: number, trigger?: () => void) => {
|
||||||
const events: any[][] = [];
|
const events: any[][] = [];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import { screen, desktopCapturer, NativeImage } from 'electron';
|
import { screen, desktopCapturer, NativeImage } from 'electron';
|
||||||
|
|
||||||
const fixtures = path.resolve(__dirname, '..', 'fixtures');
|
const fixtures = path.resolve(__dirname, '..', 'fixtures');
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'node:child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as https from 'https';
|
import * as https from 'node:https';
|
||||||
import * as net from 'net';
|
import * as net from 'node:net';
|
||||||
import * as v8 from 'v8';
|
import * as v8 from 'node:v8';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
import { SuiteFunction, TestFunction } from 'mocha';
|
import { SuiteFunction, TestFunction } from 'mocha';
|
||||||
import { BrowserWindow } from 'electron/main';
|
import { BrowserWindow } from 'electron/main';
|
||||||
import { AssertionError } from 'chai';
|
import { AssertionError } from 'chai';
|
||||||
|
@ -181,7 +181,7 @@ export async function itremote (name: string, fn: Function, args?: any[]) {
|
||||||
const { ok, message } = await w.webContents.executeJavaScript(`(async () => {
|
const { ok, message } = await w.webContents.executeJavaScript(`(async () => {
|
||||||
try {
|
try {
|
||||||
const chai_1 = require('chai')
|
const chai_1 = require('chai')
|
||||||
const promises_1 = require('timers/promises')
|
const promises_1 = require('node:timers/promises')
|
||||||
chai_1.use(require('chai-as-promised'))
|
chai_1.use(require('chai-as-promised'))
|
||||||
chai_1.use(require('dirty-chai'))
|
chai_1.use(require('dirty-chai'))
|
||||||
await (${fn})(...${JSON.stringify(args ?? [])})
|
await (${fn})(...${JSON.stringify(args ?? [])})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { BrowserWindow } from 'electron/main';
|
import { BrowserWindow } from 'electron/main';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
async function ensureWindowIsClosed (window: BrowserWindow | null) {
|
async function ensureWindowIsClosed (window: BrowserWindow | null) {
|
||||||
if (window && !window.isDestroyed()) {
|
if (window && !window.isDestroyed()) {
|
||||||
|
|
|
@ -2,10 +2,10 @@ import { app } from 'electron';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { startRemoteControlApp, ifdescribe } from './lib/spec-helpers';
|
import { startRemoteControlApp, ifdescribe } from './lib/spec-helpers';
|
||||||
|
|
||||||
import * as fs from 'fs/promises';
|
import * as fs from 'node:fs/promises';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
function isTestingBindingAvailable () {
|
function isTestingBindingAvailable () {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import { BrowserWindow } from 'electron/main';
|
import { BrowserWindow } from 'electron/main';
|
||||||
import { ifdescribe, ifit } from './lib/spec-helpers';
|
import { ifdescribe, ifit } from './lib/spec-helpers';
|
||||||
import { closeAllWindows } from './lib/window-helpers';
|
import { closeAllWindows } from './lib/window-helpers';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'node:child_process';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
const Module = require('module');
|
const Module = require('node:module');
|
||||||
|
|
||||||
const nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS;
|
const nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as childProcess from 'child_process';
|
import * as childProcess from 'node:child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as util from 'util';
|
import * as util from 'node:util';
|
||||||
import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
|
import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
|
||||||
import { webContents } from 'electron/main';
|
import { webContents } from 'electron/main';
|
||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'node:stream';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
|
|
||||||
const mainFixturesPath = path.resolve(__dirname, 'fixtures');
|
const mainFixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
describe('child_process.fork', () => {
|
describe('child_process.fork', () => {
|
||||||
itremote('works in current process', async (fixtures: string) => {
|
itremote('works in current process', async (fixtures: string) => {
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'ping.js'));
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'ping.js'));
|
||||||
const message = new Promise<any>(resolve => child.once('message', resolve));
|
const message = new Promise<any>(resolve => child.once('message', resolve));
|
||||||
child.send('message');
|
child.send('message');
|
||||||
const msg = await message;
|
const msg = await message;
|
||||||
|
@ -39,7 +39,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
itremote('preserves args', async (fixtures: string) => {
|
itremote('preserves args', async (fixtures: string) => {
|
||||||
const args = ['--expose_gc', '-test', '1'];
|
const args = ['--expose_gc', '-test', '1'];
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'process_args.js'), args);
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'process_args.js'), args);
|
||||||
const message = new Promise<any>(resolve => child.once('message', resolve));
|
const message = new Promise<any>(resolve => child.once('message', resolve));
|
||||||
child.send('message');
|
child.send('message');
|
||||||
const msg = await message;
|
const msg = await message;
|
||||||
|
@ -47,7 +47,7 @@ describe('node feature', () => {
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
|
|
||||||
itremote('works in forked process', async (fixtures: string) => {
|
itremote('works in forked process', async (fixtures: string) => {
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'fork_ping.js'));
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'fork_ping.js'));
|
||||||
const message = new Promise<any>(resolve => child.once('message', resolve));
|
const message = new Promise<any>(resolve => child.once('message', resolve));
|
||||||
child.send('message');
|
child.send('message');
|
||||||
const msg = await message;
|
const msg = await message;
|
||||||
|
@ -55,7 +55,7 @@ describe('node feature', () => {
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
|
|
||||||
itremote('works in forked process when options.env is specified', async (fixtures: string) => {
|
itremote('works in forked process when options.env is specified', async (fixtures: string) => {
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'fork_ping.js'), [], {
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'fork_ping.js'), [], {
|
||||||
path: process.env.PATH
|
path: process.env.PATH
|
||||||
});
|
});
|
||||||
const message = new Promise<any>(resolve => child.once('message', resolve));
|
const message = new Promise<any>(resolve => child.once('message', resolve));
|
||||||
|
@ -65,7 +65,7 @@ describe('node feature', () => {
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
|
|
||||||
itremote('has String::localeCompare working in script', async (fixtures: string) => {
|
itremote('has String::localeCompare working in script', async (fixtures: string) => {
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'locale-compare.js'));
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'locale-compare.js'));
|
||||||
const message = new Promise<any>(resolve => child.once('message', resolve));
|
const message = new Promise<any>(resolve => child.once('message', resolve));
|
||||||
child.send('message');
|
child.send('message');
|
||||||
const msg = await message;
|
const msg = await message;
|
||||||
|
@ -73,7 +73,7 @@ describe('node feature', () => {
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
|
|
||||||
itremote('has setImmediate working in script', async (fixtures: string) => {
|
itremote('has setImmediate working in script', async (fixtures: string) => {
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'set-immediate.js'));
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'set-immediate.js'));
|
||||||
const message = new Promise<any>(resolve => child.once('message', resolve));
|
const message = new Promise<any>(resolve => child.once('message', resolve));
|
||||||
child.send('message');
|
child.send('message');
|
||||||
const msg = await message;
|
const msg = await message;
|
||||||
|
@ -81,7 +81,7 @@ describe('node feature', () => {
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
|
|
||||||
itremote('pipes stdio', async (fixtures: string) => {
|
itremote('pipes stdio', async (fixtures: string) => {
|
||||||
const child = require('child_process').fork(require('path').join(fixtures, 'module', 'process-stdout.js'), { silent: true });
|
const child = require('node:child_process').fork(require('node:path').join(fixtures, 'module', 'process-stdout.js'), { silent: true });
|
||||||
let data = '';
|
let data = '';
|
||||||
child.stdout.on('data', (chunk: any) => {
|
child.stdout.on('data', (chunk: any) => {
|
||||||
data += String(chunk);
|
data += String(chunk);
|
||||||
|
@ -93,7 +93,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
itremote('works when sending a message to a process forked with the --eval argument', async () => {
|
itremote('works when sending a message to a process forked with the --eval argument', async () => {
|
||||||
const source = "process.on('message', (message) => { process.send(message) })";
|
const source = "process.on('message', (message) => { process.send(message) })";
|
||||||
const forked = require('child_process').fork('--eval', [source]);
|
const forked = require('node:child_process').fork('--eval', [source]);
|
||||||
const message = new Promise(resolve => forked.once('message', resolve));
|
const message = new Promise(resolve => forked.once('message', resolve));
|
||||||
forked.send('hello');
|
forked.send('hello');
|
||||||
const msg = await message;
|
const msg = await message;
|
||||||
|
@ -102,7 +102,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
it('has the electron version in process.versions', async () => {
|
it('has the electron version in process.versions', async () => {
|
||||||
const source = 'process.send(process.versions)';
|
const source = 'process.send(process.versions)';
|
||||||
const forked = require('child_process').fork('--eval', [source]);
|
const forked = require('node:child_process').fork('--eval', [source]);
|
||||||
const [message] = await once(forked, 'message');
|
const [message] = await once(forked, 'message');
|
||||||
expect(message)
|
expect(message)
|
||||||
.to.have.own.property('electron')
|
.to.have.own.property('electron')
|
||||||
|
@ -113,7 +113,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
describe('child_process.spawn', () => {
|
describe('child_process.spawn', () => {
|
||||||
itremote('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', async (fixtures: string) => {
|
itremote('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', async (fixtures: string) => {
|
||||||
const child = require('child_process').spawn(process.execPath, [require('path').join(fixtures, 'module', 'run-as-node.js')], {
|
const child = require('node:child_process').spawn(process.execPath, [require('node:path').join(fixtures, 'module', 'run-as-node.js')], {
|
||||||
env: {
|
env: {
|
||||||
ELECTRON_RUN_AS_NODE: true
|
ELECTRON_RUN_AS_NODE: true
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ describe('node feature', () => {
|
||||||
|
|
||||||
describe('setTimeout in fs callback', () => {
|
describe('setTimeout in fs callback', () => {
|
||||||
itremote('does not crash', async (filename: string) => {
|
itremote('does not crash', async (filename: string) => {
|
||||||
await new Promise(resolve => require('fs').readFile(filename, () => {
|
await new Promise(resolve => require('node:fs').readFile(filename, () => {
|
||||||
setTimeout(resolve, 0);
|
setTimeout(resolve, 0);
|
||||||
}));
|
}));
|
||||||
}, [__filename]);
|
}, [__filename]);
|
||||||
|
@ -277,7 +277,7 @@ describe('node feature', () => {
|
||||||
describe('error thrown in renderer process node context', () => {
|
describe('error thrown in renderer process node context', () => {
|
||||||
itremote('gets emitted as a process uncaughtException event', async (filename: string) => {
|
itremote('gets emitted as a process uncaughtException event', async (filename: string) => {
|
||||||
const error = new Error('boo!');
|
const error = new Error('boo!');
|
||||||
require('fs').readFile(filename, () => {
|
require('node:fs').readFile(filename, () => {
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
await new Promise<void>((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
@ -295,9 +295,9 @@ describe('node feature', () => {
|
||||||
|
|
||||||
describe('URL handling in the renderer process', () => {
|
describe('URL handling in the renderer process', () => {
|
||||||
itremote('can successfully handle WHATWG URLs constructed by Blink', (fixtures: string) => {
|
itremote('can successfully handle WHATWG URLs constructed by Blink', (fixtures: string) => {
|
||||||
const url = new URL('file://' + require('path').resolve(fixtures, 'pages', 'base-page.html'));
|
const url = new URL('file://' + require('node:path').resolve(fixtures, 'pages', 'base-page.html'));
|
||||||
expect(() => {
|
expect(() => {
|
||||||
require('fs').createReadStream(url);
|
require('node:fs').createReadStream(url);
|
||||||
}).to.not.throw();
|
}).to.not.throw();
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
});
|
});
|
||||||
|
@ -308,7 +308,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('works from the timers module', async () => {
|
itremote('works from the timers module', async () => {
|
||||||
await new Promise(resolve => require('timers').setTimeout(resolve, 10));
|
await new Promise(resolve => require('node:timers').setTimeout(resolve, 10));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('can be scheduled in time from timers module', async () => {
|
itremote('can be scheduled in time from timers module', async () => {
|
||||||
const { setInterval, clearInterval } = require('timers');
|
const { setInterval, clearInterval } = require('node:timers');
|
||||||
await new Promise<void>(resolve => {
|
await new Promise<void>(resolve => {
|
||||||
const id = setInterval(() => {
|
const id = setInterval(() => {
|
||||||
clearInterval(id);
|
clearInterval(id);
|
||||||
|
@ -361,12 +361,12 @@ describe('node feature', () => {
|
||||||
|
|
||||||
ifdescribe(process.platform === 'darwin')('net.connect', () => {
|
ifdescribe(process.platform === 'darwin')('net.connect', () => {
|
||||||
itremote('emit error when connect to a socket path without listeners', async (fixtures: string) => {
|
itremote('emit error when connect to a socket path without listeners', async (fixtures: string) => {
|
||||||
const socketPath = require('path').join(require('os').tmpdir(), 'electron-test.sock');
|
const socketPath = require('node:path').join(require('node:os').tmpdir(), 'electron-test.sock');
|
||||||
const script = require('path').join(fixtures, 'module', 'create_socket.js');
|
const script = require('node:path').join(fixtures, 'module', 'create_socket.js');
|
||||||
const child = require('child_process').fork(script, [socketPath]);
|
const child = require('node:child_process').fork(script, [socketPath]);
|
||||||
const code = await new Promise(resolve => child.once('exit', resolve));
|
const code = await new Promise(resolve => child.once('exit', resolve));
|
||||||
expect(code).to.equal(0);
|
expect(code).to.equal(0);
|
||||||
const client = require('net').connect(socketPath);
|
const client = require('node:net').connect(socketPath);
|
||||||
const error = await new Promise<any>(resolve => client.once('error', resolve));
|
const error = await new Promise<any>(resolve => client.once('error', resolve));
|
||||||
expect(error.code).to.equal('ECONNREFUSED');
|
expect(error.code).to.equal('ECONNREFUSED');
|
||||||
}, [fixtures]);
|
}, [fixtures]);
|
||||||
|
@ -399,7 +399,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('does not crash for crypto operations', () => {
|
itremote('does not crash for crypto operations', () => {
|
||||||
const crypto = require('crypto');
|
const crypto = require('node:crypto');
|
||||||
const data = 'lG9E+/g4JmRmedDAnihtBD4Dfaha/GFOjd+xUOQI05UtfVX3DjUXvrS98p7kZQwY3LNhdiFo7MY5rGft8yBuDhKuNNag9vRx/44IuClDhdQ=';
|
const data = 'lG9E+/g4JmRmedDAnihtBD4Dfaha/GFOjd+xUOQI05UtfVX3DjUXvrS98p7kZQwY3LNhdiFo7MY5rGft8yBuDhKuNNag9vRx/44IuClDhdQ=';
|
||||||
const key = 'q90K9yBqhWZnAMCMTOJfPQ==';
|
const key = 'q90K9yBqhWZnAMCMTOJfPQ==';
|
||||||
const cipherText = '{"error_code":114,"error_message":"Tham số không hợp lệ","data":null}';
|
const cipherText = '{"error_code":114,"error_message":"Tham số không hợp lệ","data":null}';
|
||||||
|
@ -413,7 +413,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('does not crash when using crypto.diffieHellman() constructors', () => {
|
itremote('does not crash when using crypto.diffieHellman() constructors', () => {
|
||||||
const crypto = require('crypto');
|
const crypto = require('node:crypto');
|
||||||
|
|
||||||
crypto.createDiffieHellman('abc');
|
crypto.createDiffieHellman('abc');
|
||||||
crypto.createDiffieHellman('abc', 2);
|
crypto.createDiffieHellman('abc', 2);
|
||||||
|
@ -425,7 +425,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('does not crash when calling crypto.createPrivateKey() with an unsupported algorithm', () => {
|
itremote('does not crash when calling crypto.createPrivateKey() with an unsupported algorithm', () => {
|
||||||
const crypto = require('crypto');
|
const crypto = require('node:crypto');
|
||||||
|
|
||||||
const ed448 = {
|
const ed448 = {
|
||||||
crv: 'Ed448',
|
crv: 'Ed448',
|
||||||
|
@ -481,58 +481,58 @@ describe('node feature', () => {
|
||||||
|
|
||||||
describe('vm.runInNewContext', () => {
|
describe('vm.runInNewContext', () => {
|
||||||
itremote('should not crash', () => {
|
itremote('should not crash', () => {
|
||||||
require('vm').runInNewContext('');
|
require('node:vm').runInNewContext('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('crypto', () => {
|
describe('crypto', () => {
|
||||||
useRemoteContext();
|
useRemoteContext();
|
||||||
itremote('should list the ripemd160 hash in getHashes', () => {
|
itremote('should list the ripemd160 hash in getHashes', () => {
|
||||||
expect(require('crypto').getHashes()).to.include('ripemd160');
|
expect(require('node:crypto').getHashes()).to.include('ripemd160');
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should be able to create a ripemd160 hash and use it', () => {
|
itremote('should be able to create a ripemd160 hash and use it', () => {
|
||||||
const hash = require('crypto').createHash('ripemd160');
|
const hash = require('node:crypto').createHash('ripemd160');
|
||||||
hash.update('electron-ripemd160');
|
hash.update('electron-ripemd160');
|
||||||
expect(hash.digest('hex')).to.equal('fa7fec13c624009ab126ebb99eda6525583395fe');
|
expect(hash.digest('hex')).to.equal('fa7fec13c624009ab126ebb99eda6525583395fe');
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should list aes-{128,256}-cfb in getCiphers', () => {
|
itremote('should list aes-{128,256}-cfb in getCiphers', () => {
|
||||||
expect(require('crypto').getCiphers()).to.include.members(['aes-128-cfb', 'aes-256-cfb']);
|
expect(require('node:crypto').getCiphers()).to.include.members(['aes-128-cfb', 'aes-256-cfb']);
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should be able to create an aes-128-cfb cipher', () => {
|
itremote('should be able to create an aes-128-cfb cipher', () => {
|
||||||
require('crypto').createCipheriv('aes-128-cfb', '0123456789abcdef', '0123456789abcdef');
|
require('node:crypto').createCipheriv('aes-128-cfb', '0123456789abcdef', '0123456789abcdef');
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should be able to create an aes-256-cfb cipher', () => {
|
itremote('should be able to create an aes-256-cfb cipher', () => {
|
||||||
require('crypto').createCipheriv('aes-256-cfb', '0123456789abcdef0123456789abcdef', '0123456789abcdef');
|
require('node:crypto').createCipheriv('aes-256-cfb', '0123456789abcdef0123456789abcdef', '0123456789abcdef');
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should be able to create a bf-{cbc,cfb,ecb} ciphers', () => {
|
itremote('should be able to create a bf-{cbc,cfb,ecb} ciphers', () => {
|
||||||
require('crypto').createCipheriv('bf-cbc', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
|
require('node:crypto').createCipheriv('bf-cbc', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
|
||||||
require('crypto').createCipheriv('bf-cfb', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
|
require('node:crypto').createCipheriv('bf-cfb', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
|
||||||
require('crypto').createCipheriv('bf-ecb', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
|
require('node:crypto').createCipheriv('bf-ecb', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should list des-ede-cbc in getCiphers', () => {
|
itremote('should list des-ede-cbc in getCiphers', () => {
|
||||||
expect(require('crypto').getCiphers()).to.include('des-ede-cbc');
|
expect(require('node:crypto').getCiphers()).to.include('des-ede-cbc');
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should be able to create an des-ede-cbc cipher', () => {
|
itremote('should be able to create an des-ede-cbc cipher', () => {
|
||||||
const key = Buffer.from('0123456789abcdeff1e0d3c2b5a49786', 'hex');
|
const key = Buffer.from('0123456789abcdeff1e0d3c2b5a49786', 'hex');
|
||||||
const iv = Buffer.from('fedcba9876543210', 'hex');
|
const iv = Buffer.from('fedcba9876543210', 'hex');
|
||||||
require('crypto').createCipheriv('des-ede-cbc', key, iv);
|
require('node:crypto').createCipheriv('des-ede-cbc', key, iv);
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should not crash when getting an ECDH key', () => {
|
itremote('should not crash when getting an ECDH key', () => {
|
||||||
const ecdh = require('crypto').createECDH('prime256v1');
|
const ecdh = require('node:crypto').createECDH('prime256v1');
|
||||||
expect(ecdh.generateKeys()).to.be.an.instanceof(Buffer);
|
expect(ecdh.generateKeys()).to.be.an.instanceof(Buffer);
|
||||||
expect(ecdh.getPrivateKey()).to.be.an.instanceof(Buffer);
|
expect(ecdh.getPrivateKey()).to.be.an.instanceof(Buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should not crash when generating DH keys or fetching DH fields', () => {
|
itremote('should not crash when generating DH keys or fetching DH fields', () => {
|
||||||
const dh = require('crypto').createDiffieHellman('modp15');
|
const dh = require('node:crypto').createDiffieHellman('modp15');
|
||||||
expect(dh.generateKeys()).to.be.an.instanceof(Buffer);
|
expect(dh.generateKeys()).to.be.an.instanceof(Buffer);
|
||||||
expect(dh.getPublicKey()).to.be.an.instanceof(Buffer);
|
expect(dh.getPublicKey()).to.be.an.instanceof(Buffer);
|
||||||
expect(dh.getPrivateKey()).to.be.an.instanceof(Buffer);
|
expect(dh.getPrivateKey()).to.be.an.instanceof(Buffer);
|
||||||
|
@ -541,7 +541,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
itremote('should not crash when creating an ECDH cipher', () => {
|
itremote('should not crash when creating an ECDH cipher', () => {
|
||||||
const crypto = require('crypto');
|
const crypto = require('node:crypto');
|
||||||
const dh = crypto.createECDH('prime256v1');
|
const dh = crypto.createECDH('prime256v1');
|
||||||
dh.generateKeys();
|
dh.generateKeys();
|
||||||
dh.setPrivateKey(dh.getPrivateKey());
|
dh.setPrivateKey(dh.getPrivateKey());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite';
|
import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as notes from '../script/release/notes/notes.js';
|
import * as notes from '../script/release/notes/notes.js';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as sinon from 'sinon';
|
import * as sinon from 'sinon';
|
||||||
|
|
||||||
/* Fake a Dugite GitProcess that only returns the specific
|
/* Fake a Dugite GitProcess that only returns the specific
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as url from 'url';
|
import * as url from 'node:url';
|
||||||
|
|
||||||
import { BrowserWindow, WebPreferences } from 'electron/main';
|
import { BrowserWindow, WebPreferences } from 'electron/main';
|
||||||
|
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { emittedUntil } from './lib/events-helpers';
|
import { emittedUntil } from './lib/events-helpers';
|
||||||
import { listen } from './lib/spec-helpers';
|
import { listen } from './lib/spec-helpers';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const messageContainsSecurityWarning = (event: Event, level: number, message: string) => {
|
const messageContainsSecurityWarning = (event: Event, level: number, message: string) => {
|
||||||
return message.indexOf('Electron Security Warning') > -1;
|
return message.indexOf('Electron Security Warning') > -1;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { BrowserWindow, Session, session } from 'electron/main';
|
import { BrowserWindow, Session, session } from 'electron/main';
|
||||||
|
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import * as path from 'path';
|
import * as path from 'node:path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'node:fs';
|
||||||
import * as http from 'http';
|
import * as http from 'node:http';
|
||||||
import { closeWindow } from './lib/window-helpers';
|
import { closeWindow } from './lib/window-helpers';
|
||||||
import { ifit, ifdescribe, listen } from './lib/spec-helpers';
|
import { ifit, ifdescribe, listen } from './lib/spec-helpers';
|
||||||
import { once } from 'events';
|
import { once } from 'node:events';
|
||||||
import { setTimeout } from 'timers/promises';
|
import { setTimeout } from 'node:timers/promises';
|
||||||
|
|
||||||
const features = process._linkedBinding('electron_common_features');
|
const features = process._linkedBinding('electron_common_features');
|
||||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue