diff --git a/package.json b/package.json index 58738bfebc..2cf4aef739 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", + "eslint-plugin-unicorn": "^46.0.1", "events": "^3.2.0", "express": "^4.16.4", "folder-hash": "^2.1.1", diff --git a/spec/.eslintrc b/spec/.eslintrc index 60be8a0dac..364b1639cb 100644 --- a/spec/.eslintrc +++ b/spec/.eslintrc @@ -11,9 +11,11 @@ "WebView": true }, "plugins": [ - "mocha" + "mocha", + "unicorn" ], "rules": { - "mocha/no-exclusive-tests": "error" + "mocha/no-exclusive-tests": "error", + "unicorn/prefer-node-protocol": "error" } } diff --git a/spec/api-app-spec.ts b/spec/api-app-spec.ts index 6fdf528e98..0cade3e490 100644 --- a/spec/api-app-spec.ts +++ b/spec/api-app-spec.ts @@ -1,15 +1,15 @@ import { assert, expect } from 'chai'; -import * as cp from 'child_process'; -import * as https from 'https'; -import * as http from 'http'; -import * as net from 'net'; +import * as cp from 'node:child_process'; +import * as https from 'node:https'; +import * as http from 'node:http'; +import * as net from 'node:net'; import * as fs from 'fs-extra'; -import * as path from 'path'; -import { promisify } from 'util'; +import * as path from 'node:path'; +import { promisify } from 'node:util'; import { app, BrowserWindow, Menu, session, net as electronNet } from 'electron/main'; import { closeWindow, closeAllWindows } from './lib/window-helpers'; import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; import split = require('split') const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-auto-updater-spec.ts b/spec/api-auto-updater-spec.ts index fe89b97be2..6c5ed269f1 100644 --- a/spec/api-auto-updater-spec.ts +++ b/spec/api-auto-updater-spec.ts @@ -1,7 +1,7 @@ import { autoUpdater } from 'electron/main'; import { expect } from 'chai'; import { ifit, ifdescribe } from './lib/spec-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; ifdescribe(!process.mas)('autoUpdater module', function () { describe('checkForUpdates', function () { diff --git a/spec/api-autoupdater-darwin-spec.ts b/spec/api-autoupdater-darwin-spec.ts index 28004cf1e1..bcf8d934e1 100644 --- a/spec/api-autoupdater-darwin-spec.ts +++ b/spec/api-autoupdater-darwin-spec.ts @@ -1,12 +1,12 @@ import { expect } from 'chai'; -import * as cp from 'child_process'; -import * as http from 'http'; +import * as cp from 'node:child_process'; +import * as http from 'node:http'; import * as express from 'express'; import * as fs from 'fs-extra'; -import * as os from 'os'; -import * as path from 'path'; +import * as os from 'node:os'; +import * as path from 'node:path'; import * as psList from 'ps-list'; -import { AddressInfo } from 'net'; +import { AddressInfo } from 'node:net'; import { ifdescribe, ifit } from './lib/spec-helpers'; import * as uuid from 'uuid'; import { systemPreferences } from 'electron'; diff --git a/spec/api-browser-view-spec.ts b/spec/api-browser-view-spec.ts index 0099d85c33..69084034d2 100644 --- a/spec/api-browser-view-spec.ts +++ b/spec/api-browser-view-spec.ts @@ -1,10 +1,10 @@ import { expect } from 'chai'; -import * as path from 'path'; +import * as path from 'node:path'; import { BrowserView, BrowserWindow, screen, webContents } from 'electron/main'; import { closeWindow } from './lib/window-helpers'; import { defer, ifit, startRemoteControlApp } from './lib/spec-helpers'; import { areColorsSimilar, captureScreen, getPixelColor } from './lib/screen-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; describe('BrowserView module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index f3f1901b9f..9e1e7e7ec0 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1,19 +1,19 @@ import { expect } from 'chai'; -import * as childProcess from 'child_process'; -import * as path from 'path'; -import * as fs from 'fs'; -import * as qs from 'querystring'; -import * as http from 'http'; -import * as os from 'os'; -import { AddressInfo } from 'net'; +import * as childProcess from 'node:child_process'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; +import * as qs from 'node:querystring'; +import * as http from 'node:http'; +import * as os from 'node:os'; +import { AddressInfo } from 'node:net'; 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 { ifit, ifdescribe, defer, listen } from './lib/spec-helpers'; import { closeWindow, closeAllWindows } from './lib/window-helpers'; import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; const fixtures = path.resolve(__dirname, 'fixtures'); const mainFixtures = path.resolve(__dirname, 'fixtures'); @@ -3463,7 +3463,7 @@ describe('BrowserWindow module', () => { }); w.loadURL('about:blank'); const [, rendererEventEmitterProperties] = await once(ipcMain, 'answer'); - const { EventEmitter } = require('events'); + const { EventEmitter } = require('node:events'); const emitter = new EventEmitter(); const browserEventEmitterProperties = []; let currentObj = emitter; diff --git a/spec/api-clipboard-spec.ts b/spec/api-clipboard-spec.ts index 69ba70e06a..89ed06e243 100644 --- a/spec/api-clipboard-spec.ts +++ b/spec/api-clipboard-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as path from 'path'; -import { Buffer } from 'buffer'; +import * as path from 'node:path'; +import { Buffer } from 'node:buffer'; import { ifdescribe, ifit } from './lib/spec-helpers'; import { clipboard, nativeImage } from 'electron/common'; diff --git a/spec/api-content-tracing-spec.ts b/spec/api-content-tracing-spec.ts index 2d43de3e90..bccf82ce92 100644 --- a/spec/api-content-tracing-spec.ts +++ b/spec/api-content-tracing-spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; import { app, contentTracing, TraceConfig, TraceCategoriesAndOptions } from 'electron/main'; -import * as fs from 'fs'; -import * as path from 'path'; -import { setTimeout } from 'timers/promises'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import { setTimeout } from 'node:timers/promises'; import { ifdescribe } from './lib/spec-helpers'; // FIXME: The tests are skipped on arm/arm64 and ia32. diff --git a/spec/api-context-bridge-spec.ts b/spec/api-context-bridge-spec.ts index b54fba8555..c3f8ab3183 100644 --- a/spec/api-context-bridge-spec.ts +++ b/spec/api-context-bridge-spec.ts @@ -2,14 +2,14 @@ import { BrowserWindow, ipcMain } from 'electron/main'; import { contextBridge } from 'electron/renderer'; import { expect } from 'chai'; import * as fs from 'fs-extra'; -import * as http from 'http'; -import * as os from 'os'; -import * as path from 'path'; -import * as cp from 'child_process'; +import * as http from 'node:http'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import * as cp from 'node:child_process'; import { closeWindow } from './lib/window-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'); @@ -67,16 +67,16 @@ describe('contextBridge', () => { describe(`with sandbox=${useSandbox}`, () => { const makeBindingWindow = async (bindingCreator: Function, worldId: number = 0) => { const preloadContentForMainWorld = `const renderer_1 = require('electron'); - ${useSandbox ? '' : `require('v8').setFlagsFromString('--expose_gc'); - const gc=require('vm').runInNewContext('gc'); + ${useSandbox ? '' : `require('node:v8').setFlagsFromString('--expose_gc'); + const gc=require('node:vm').runInNewContext('gc'); renderer_1.contextBridge.exposeInMainWorld('GCRunner', { run: () => gc() });`} (${bindingCreator.toString()})();`; const preloadContentForIsolatedWorld = `const renderer_1 = require('electron'); - ${useSandbox ? '' : `require('v8').setFlagsFromString('--expose_gc'); - const gc=require('vm').runInNewContext('gc'); + ${useSandbox ? '' : `require('node:v8').setFlagsFromString('--expose_gc'); + const gc=require('node:vm').runInNewContext('gc'); renderer_1.webFrame.setIsolatedWorldInfo(${worldId}, { name: "Isolated World" }); diff --git a/spec/api-crash-reporter-spec.ts b/spec/api-crash-reporter-spec.ts index 06f552acda..76cb935292 100644 --- a/spec/api-crash-reporter-spec.ts +++ b/spec/api-crash-reporter-spec.ts @@ -1,15 +1,15 @@ import { expect } from 'chai'; -import * as childProcess from 'child_process'; -import * as http from 'http'; +import * as childProcess from 'node:child_process'; +import * as http from 'node:http'; 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 { app } from 'electron/main'; import { crashReporter } from 'electron/common'; -import { EventEmitter } from 'events'; -import * as fs from 'fs'; +import { EventEmitter } from 'node:events'; +import * as fs from 'node:fs'; 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 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'); return remotely((crashScriptPath: string) => { const { app } = require('electron'); - const childProcess = require('child_process'); + const childProcess = require('node:child_process'); const version = app.getVersion(); const url = 'http://127.0.0.1'; childProcess.fork(crashScriptPath, [url, version], { silent: true }); diff --git a/spec/api-debugger-spec.ts b/spec/api-debugger-spec.ts index 62b5a7f0c7..311b7ec6c6 100644 --- a/spec/api-debugger-spec.ts +++ b/spec/api-debugger-spec.ts @@ -1,11 +1,11 @@ import { expect } from 'chai'; -import * as http from 'http'; -import * as path from 'path'; +import * as http from 'node:http'; +import * as path from 'node:path'; import { BrowserWindow } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { emittedUntil } from './lib/events-helpers'; import { listen } from './lib/spec-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; describe('debugger module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-desktop-capturer-spec.ts b/spec/api-desktop-capturer-spec.ts index a2bfff42af..55dcaf4205 100644 --- a/spec/api-desktop-capturer-spec.ts +++ b/spec/api-desktop-capturer-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { screen, desktopCapturer, BrowserWindow } from 'electron/main'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; import { ifdescribe, ifit } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; diff --git a/spec/api-dialog-spec.ts b/spec/api-dialog-spec.ts index 72cb18573f..ab115a02c3 100644 --- a/spec/api-dialog-spec.ts +++ b/spec/api-dialog-spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { dialog, BrowserWindow } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { ifit } from './lib/spec-helpers'; -import { setTimeout } from 'timers/promises'; +import { setTimeout } from 'node:timers/promises'; describe('dialog module', () => { describe('showOpenDialog', () => { diff --git a/spec/api-ipc-main-spec.ts b/spec/api-ipc-main-spec.ts index cc164e5e39..b9bcb155e3 100644 --- a/spec/api-ipc-main-spec.ts +++ b/spec/api-ipc-main-spec.ts @@ -1,10 +1,10 @@ import { expect } from 'chai'; -import * as path from 'path'; -import * as cp from 'child_process'; +import * as path from 'node:path'; +import * as cp from 'node:child_process'; import { closeAllWindows } from './lib/window-helpers'; import { defer } from './lib/spec-helpers'; import { ipcMain, BrowserWindow } from 'electron/main'; -import { once } from 'events'; +import { once } from 'node:events'; describe('ipc main module', () => { const fixtures = path.join(__dirname, 'fixtures'); diff --git a/spec/api-ipc-renderer-spec.ts b/spec/api-ipc-renderer-spec.ts index b725f8a030..446eecb389 100644 --- a/spec/api-ipc-renderer-spec.ts +++ b/spec/api-ipc-renderer-spec.ts @@ -1,8 +1,8 @@ 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 { closeWindow } from './lib/window-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; describe('ipcRenderer module', () => { const fixtures = path.join(__dirname, 'fixtures'); @@ -62,7 +62,7 @@ describe('ipcRenderer module', () => { it('does not crash when sending external objects', async () => { await expect(w.webContents.executeJavaScript(`{ 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 stream = request.agent.sockets['127.0.0.1:5000:'][0]._handle._externalStream diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts index c2befb323c..57491ed570 100644 --- a/spec/api-ipc-spec.ts +++ b/spec/api-ipc-spec.ts @@ -1,10 +1,10 @@ -import { EventEmitter, once } from 'events'; +import { EventEmitter, once } from 'node:events'; import { expect } from 'chai'; import { BrowserWindow, ipcMain, IpcMainInvokeEvent, MessageChannelMain, WebContents } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { defer, listen } from './lib/spec-helpers'; -import * as path from 'path'; -import * as http from 'http'; +import * as path from 'node:path'; +import * as http from 'node:http'; const v8Util = process._linkedBinding('electron_common_v8_util'); const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-media-handler-spec.ts b/spec/api-media-handler-spec.ts index de330b9a03..95e9c4dc83 100644 --- a/spec/api-media-handler-spec.ts +++ b/spec/api-media-handler-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { BrowserWindow, session, desktopCapturer } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; -import * as http from 'http'; +import * as http from 'node:http'; import { ifit, listen } from './lib/spec-helpers'; describe('setDisplayMediaRequestHandler', () => { diff --git a/spec/api-menu-spec.ts b/spec/api-menu-spec.ts index 824d5117a2..b27f0d3a4d 100644 --- a/spec/api-menu-spec.ts +++ b/spec/api-menu-spec.ts @@ -1,12 +1,12 @@ -import * as cp from 'child_process'; -import * as path from 'path'; +import * as cp from 'node:child_process'; +import * as path from 'node:path'; import { assert, expect } from 'chai'; import { BrowserWindow, Menu, MenuItem } from 'electron/main'; import { sortMenuItems } from '../lib/browser/api/menu-utils'; import { ifit } from './lib/spec-helpers'; import { closeWindow } from './lib/window-helpers'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-native-image-spec.ts b/spec/api-native-image-spec.ts index 51f26679bf..0e277043a0 100644 --- a/spec/api-native-image-spec.ts +++ b/spec/api-native-image-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { nativeImage } from 'electron/common'; import { ifdescribe, ifit } from './lib/spec-helpers'; -import * as path from 'path'; +import * as path from 'node:path'; describe('nativeImage module', () => { const fixturesPath = path.join(__dirname, 'fixtures'); diff --git a/spec/api-native-theme-spec.ts b/spec/api-native-theme-spec.ts index c111e9b4b7..8bba141ae2 100644 --- a/spec/api-native-theme-spec.ts +++ b/spec/api-native-theme-spec.ts @@ -1,10 +1,10 @@ import { expect } from 'chai'; import { nativeTheme, systemPreferences, BrowserWindow, ipcMain } from 'electron/main'; -import { once } from 'events'; -import * as os from 'os'; -import * as path from 'path'; +import { once } from 'node:events'; +import * as os from 'node:os'; +import * as path from 'node:path'; import * as semver from 'semver'; -import { setTimeout } from 'timers/promises'; +import { setTimeout } from 'node:timers/promises'; import { ifdescribe } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; diff --git a/spec/api-net-log-spec.ts b/spec/api-net-log-spec.ts index 7fb5d6ceee..eb5957e825 100644 --- a/spec/api-net-log-spec.ts +++ b/spec/api-net-log-spec.ts @@ -1,13 +1,13 @@ import { expect } from 'chai'; -import * as http from 'http'; -import * as fs from 'fs'; -import * as os from 'os'; -import * as path from 'path'; -import * as ChildProcess from 'child_process'; +import * as http from 'node:http'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import * as ChildProcess from 'node:child_process'; import { session, net } from 'electron/main'; -import { Socket } from 'net'; +import { Socket } from 'node:net'; 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 dumpFile = path.join(os.tmpdir(), 'net_log.json'); diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index 7560f989e8..a42a00c727 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -1,13 +1,13 @@ 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 * as http from 'http'; -import * as url from 'url'; -import * as path from 'path'; -import { Socket } from 'net'; +import * as http from 'node:http'; +import * as url from 'node:url'; +import * as path from 'node:path'; +import { Socket } from 'node:net'; import { defer, listen } from './lib/spec-helpers'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; // See https://github.com/nodejs/node/issues/40702. dns.setDefaultResultOrder('ipv4first'); diff --git a/spec/api-notification-dbus-spec.ts b/spec/api-notification-dbus-spec.ts index 81ba4f62cc..26e50e9bf3 100644 --- a/spec/api-notification-dbus-spec.ts +++ b/spec/api-notification-dbus-spec.ts @@ -10,7 +10,7 @@ import { expect } from 'chai'; import * as dbus from 'dbus-native'; import { app } from 'electron/main'; import { ifdescribe } from './lib/spec-helpers'; -import { promisify } from 'util'; +import { promisify } from 'node:util'; const skip = process.platform !== 'linux' || process.arch === 'ia32' || diff --git a/spec/api-notification-spec.ts b/spec/api-notification-spec.ts index b17d811cf3..b56d17c1fb 100644 --- a/spec/api-notification-spec.ts +++ b/spec/api-notification-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { Notification } from 'electron/main'; -import { once } from 'events'; +import { once } from 'node:events'; import { ifit } from './lib/spec-helpers'; describe('Notification module', () => { diff --git a/spec/api-power-monitor-spec.ts b/spec/api-power-monitor-spec.ts index 485b5f62e5..f381b70f13 100644 --- a/spec/api-power-monitor-spec.ts +++ b/spec/api-power-monitor-spec.ts @@ -9,8 +9,8 @@ import { expect } from 'chai'; import * as dbus from 'dbus-native'; import { ifdescribe, startRemoteControlApp } from './lib/spec-helpers'; -import { promisify } from 'util'; -import { setTimeout } from 'timers/promises'; +import { promisify } from 'node:util'; +import { setTimeout } from 'node:timers/promises'; describe('powerMonitor', () => { let logindMock: any, dbusMockPowerMonitor: any, getCalls: any, emitSignal: any, reset: any; diff --git a/spec/api-process-spec.ts b/spec/api-process-spec.ts index ea2ca726a4..a5d1326a66 100644 --- a/spec/api-process-spec.ts +++ b/spec/api-process-spec.ts @@ -1,5 +1,5 @@ -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { expect } from 'chai'; import { BrowserWindow } from 'electron'; import { defer, ifdescribe } from './lib/spec-helpers'; diff --git a/spec/api-protocol-spec.ts b/spec/api-protocol-spec.ts index 18fe0ea837..365e3ae137 100644 --- a/spec/api-protocol-spec.ts +++ b/spec/api-protocol-spec.ts @@ -1,18 +1,18 @@ import { expect } from 'chai'; import { v4 } from 'uuid'; import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain, net } from 'electron/main'; -import * as ChildProcess from 'child_process'; -import * as path from 'path'; -import * as url from 'url'; -import * as http from 'http'; -import * as fs from 'fs'; -import * as qs from 'querystring'; -import * as stream from 'stream'; -import { EventEmitter, once } from 'events'; +import * as ChildProcess from 'node:child_process'; +import * as path from 'node:path'; +import * as url from 'node:url'; +import * as http from 'node:http'; +import * as fs from 'node:fs'; +import * as qs from 'node:querystring'; +import * as stream from 'node:stream'; +import { EventEmitter, once } from 'node:events'; import { closeAllWindows, closeWindow } from './lib/window-helpers'; import { WebmGenerator } from './lib/video-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'); diff --git a/spec/api-safe-storage-spec.ts b/spec/api-safe-storage-spec.ts index 51278a13c7..1f48175017 100644 --- a/spec/api-safe-storage-spec.ts +++ b/spec/api-safe-storage-spec.ts @@ -1,10 +1,10 @@ -import * as cp from 'child_process'; -import * as path from 'path'; +import * as cp from 'node:child_process'; +import * as path from 'node:path'; import { safeStorage } from 'electron/main'; import { expect } from 'chai'; import { ifdescribe } from './lib/spec-helpers'; 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 * Chrome from reaching the system's keyring or libsecret. When running the tests with config.store diff --git a/spec/api-service-workers-spec.ts b/spec/api-service-workers-spec.ts index db68eed251..c5376130b5 100644 --- a/spec/api-service-workers-spec.ts +++ b/spec/api-service-workers-spec.ts @@ -1,11 +1,11 @@ -import * as fs from 'fs'; -import * as http from 'http'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; +import * as path from 'node:path'; import { session, webContents, WebContents } from 'electron/main'; import { expect } from 'chai'; import { v4 } from 'uuid'; import { listen } from './lib/spec-helpers'; -import { on, once } from 'events'; +import { on, once } from 'node:events'; const partition = 'service-workers-spec'; diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts index 7b4c5ed295..5105574571 100644 --- a/spec/api-session-spec.ts +++ b/spec/api-session-spec.ts @@ -1,16 +1,16 @@ import { expect } from 'chai'; -import * as http from 'http'; -import * as https from 'https'; -import * as path from 'path'; -import * as fs from 'fs'; -import * as ChildProcess from 'child_process'; +import * as http from 'node:http'; +import * as https from 'node:https'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; +import * as ChildProcess from 'node:child_process'; import { app, session, BrowserWindow, net, ipcMain, Session, webFrameMain, WebFrameMain } from 'electron/main'; import * as send from 'send'; import * as auth from 'basic-auth'; import { closeAllWindows } from './lib/window-helpers'; import { defer, listen } from './lib/spec-helpers'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; describe('session module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-shell-spec.ts b/spec/api-shell-spec.ts index eddf372939..749677311b 100644 --- a/spec/api-shell-spec.ts +++ b/spec/api-shell-spec.ts @@ -2,12 +2,12 @@ import { BrowserWindow, app } from 'electron/main'; import { shell } from 'electron/common'; import { closeAllWindows } from './lib/window-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 os from 'os'; -import * as path from 'path'; +import * as os from 'node:os'; +import * as path from 'node:path'; import { expect } from 'chai'; -import { once } from 'events'; +import { once } from 'node:events'; describe('shell module', () => { describe('shell.openExternal()', () => { diff --git a/spec/api-subframe-spec.ts b/spec/api-subframe-spec.ts index af9933609d..c14803c0a2 100644 --- a/spec/api-subframe-spec.ts +++ b/spec/api-subframe-spec.ts @@ -1,11 +1,11 @@ import { expect } from 'chai'; -import * as path from 'path'; -import * as http from 'http'; +import * as path from 'node:path'; +import * as http from 'node:http'; import { emittedNTimes } from './lib/events-helpers'; import { closeWindow } from './lib/window-helpers'; import { app, BrowserWindow, ipcMain } from 'electron/main'; import { ifdescribe, listen } from './lib/spec-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; describe('renderer nodeIntegrationInSubFrames', () => { const generateTests = (description: string, webPreferences: any) => { diff --git a/spec/api-touch-bar-spec.ts b/spec/api-touch-bar-spec.ts index 7c26b81344..0de1bbe3b9 100644 --- a/spec/api-touch-bar-spec.ts +++ b/spec/api-touch-bar-spec.ts @@ -1,4 +1,4 @@ -import * as path from 'path'; +import * as path from 'node:path'; import { BrowserWindow, TouchBar } from 'electron/main'; import { closeWindow } from './lib/window-helpers'; import { expect } from 'chai'; diff --git a/spec/api-tray-spec.ts b/spec/api-tray-spec.ts index e346533765..ac098c9bee 100644 --- a/spec/api-tray-spec.ts +++ b/spec/api-tray-spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { Menu, Tray } from 'electron/main'; import { nativeImage } from 'electron/common'; import { ifdescribe, ifit } from './lib/spec-helpers'; -import * as path from 'path'; +import * as path from 'node:path'; describe('tray module', () => { let tray: Tray; diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index 1c24a7a1c0..2afaeca61e 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -1,10 +1,10 @@ import { expect } from 'chai'; -import * as childProcess from 'child_process'; -import * as path from 'path'; +import * as childProcess from 'node:child_process'; +import * as path from 'node:path'; import { BrowserWindow, MessageChannelMain, utilityProcess } from 'electron/main'; import { ifit } from './lib/spec-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 isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64'; diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index 22831b7947..63af200d5d 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -1,13 +1,13 @@ import { expect } from 'chai'; -import { AddressInfo } from 'net'; -import * as path from 'path'; -import * as fs from 'fs'; -import * as http from 'http'; +import { AddressInfo } from 'node:net'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; import { BrowserWindow, ipcMain, webContents, session, app, BrowserView } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; const pdfjs = require('pdfjs-dist'); const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-frame-main-spec.ts b/spec/api-web-frame-main-spec.ts index 4f155850bb..2da465a130 100644 --- a/spec/api-web-frame-main-spec.ts +++ b/spec/api-web-frame-main-spec.ts @@ -1,13 +1,13 @@ import { expect } from 'chai'; -import * as http from 'http'; -import * as path from 'path'; -import * as url from 'url'; +import * as http from 'node:http'; +import * as path from 'node:path'; +import * as url from 'node:url'; import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain, app, WebContents } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { emittedNTimes } from './lib/events-helpers'; import { defer, ifit, listen, waitUntil } from './lib/spec-helpers'; -import { once } from 'events'; -import { setTimeout } from 'timers/promises'; +import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; describe('webFrameMain module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-frame-spec.ts b/spec/api-web-frame-spec.ts index d2b007aee0..39b1716482 100644 --- a/spec/api-web-frame-spec.ts +++ b/spec/api-web-frame-spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import * as path from 'path'; +import * as path from 'node:path'; import { BrowserWindow, ipcMain, WebContents } from 'electron/main'; import { defer } from './lib/spec-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; describe('webFrame module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-request-spec.ts b/spec/api-web-request-spec.ts index 136cd6c293..f3091b579a 100644 --- a/spec/api-web-request-spec.ts +++ b/spec/api-web-request-spec.ts @@ -1,16 +1,16 @@ import { expect } from 'chai'; -import * as http from 'http'; -import * as http2 from 'http2'; -import * as qs from 'querystring'; -import * as path from 'path'; -import * as fs from 'fs'; -import * as url from 'url'; +import * as http from 'node:http'; +import * as http2 from 'node:http2'; +import * as qs from 'node:querystring'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; +import * as url from 'node:url'; import * as WebSocket from 'ws'; 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 { once } from 'events'; -import { ReadableStream } from 'stream/web'; +import { once } from 'node:events'; +import { ReadableStream } from 'node:stream/web'; const fixturesPath = path.resolve(__dirname, 'fixtures'); @@ -603,7 +603,7 @@ describe('webRequest module', () => { }); }); 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') { reqHeaders[request.url!] = request.headers; wss.handleUpgrade(request, socket as Socket, head, function done (ws) { @@ -625,7 +625,7 @@ describe('webRequest module', () => { callback({ requestHeaders: details.requestHeaders }); }); 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; callback({ cancel: false }); }); diff --git a/spec/asar-spec.ts b/spec/asar-spec.ts index d1098ef2a3..9d67cab39f 100644 --- a/spec/asar-spec.ts +++ b/spec/asar-spec.ts @@ -1,12 +1,12 @@ import { expect } from 'chai'; -import * as path from 'path'; -import * as url from 'url'; -import { Worker } from 'worker_threads'; +import * as path from 'node:path'; +import * as url from 'node:url'; +import { Worker } from 'node:worker_threads'; import { BrowserWindow, ipcMain } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers'; -import * as importedFs from 'fs'; -import { once } from 'events'; +import * as importedFs from 'node:fs'; +import { once } from 'node:events'; describe('asar package', () => { const fixtures = path.join(__dirname, 'fixtures'); @@ -142,7 +142,7 @@ function promisify (_f: Function): any { describe('asar package', function () { const fixtures = path.join(__dirname, 'fixtures'); 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({ 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); } - fs = require('fs') - path = require('path') + fs = require('node:fs') + path = require('node:path') asarDir = ${JSON.stringify(asarDir)} // 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 () => { 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(); }); itremote('promisified version handles a non-existent file', async function () { 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(); }); }); @@ -1311,7 +1311,7 @@ describe('asar package', function () { describe('util.promisify', function () { itremote('can promisify all fs functions', function () { const originalFs = require('original-fs'); - const util = require('util'); + const util = require('node:util'); const { hasOwnProperty } = Object.prototype; 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 () { process.noAsar = false; 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(); expect(process.noAsar).to.be.false(); }); @@ -1531,8 +1531,8 @@ describe('asar package', 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('fs').promises)).to.deep.equal(Object.keys(require('original-fs').promises)); + expect(Object.keys(require('node:fs'))).to.deep.equal(Object.keys(require('original-fs'))); + expect(Object.keys(require('node:fs').promises)).to.deep.equal(Object.keys(require('original-fs').promises)); }); }); diff --git a/spec/autofill-spec.ts b/spec/autofill-spec.ts index fac4e67ee3..5e55112588 100644 --- a/spec/autofill-spec.ts +++ b/spec/autofill-spec.ts @@ -1,8 +1,8 @@ import { BrowserWindow } from 'electron'; -import * as path from 'path'; +import * as path from 'node:path'; import { expect } from 'chai'; import { closeAllWindows } from './lib/window-helpers'; -import { setTimeout } from 'timers/promises'; +import { setTimeout } from 'node:timers/promises'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index ceffda8549..99735ef204 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -1,18 +1,18 @@ import { expect } from 'chai'; import { BrowserWindow, WebContents, webFrameMain, session, ipcMain, app, protocol, webContents } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; -import * as https from 'https'; -import * as http from 'http'; -import * as path from 'path'; -import * as fs from 'fs'; -import * as url from 'url'; -import * as ChildProcess from 'child_process'; -import { EventEmitter, once } from 'events'; -import { promisify } from 'util'; +import * as https from 'node:https'; +import * as http from 'node:http'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; +import * as url from 'node:url'; +import * as ChildProcess from 'node:child_process'; +import { EventEmitter, once } from 'node:events'; +import { promisify } from 'node:util'; import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers'; import { PipeTransport } from './pipe-transport'; import * as ws from 'ws'; -import { setTimeout } from 'timers/promises'; +import { setTimeout } from 'node:timers/promises'; 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 () => { const w = new BrowserWindow({ show: true, webPreferences: { nodeIntegration: true } }); 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`, protocol: 'file', slashes: true diff --git a/spec/crash-spec.ts b/spec/crash-spec.ts index ab517120e5..7ec747080d 100644 --- a/spec/crash-spec.ts +++ b/spec/crash-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import * as cp from 'child_process'; -import * as fs from 'fs'; -import * as path from 'path'; +import * as cp from 'node:child_process'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { ifit } from './lib/spec-helpers'; const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases'); diff --git a/spec/extensions-spec.ts b/spec/extensions-spec.ts index 72e5827735..b0cc0f6e63 100644 --- a/spec/extensions-spec.ts +++ b/spec/extensions-spec.ts @@ -1,13 +1,13 @@ import { expect } from 'chai'; import { app, session, BrowserWindow, ipcMain, WebContents, Extension, Session } from 'electron/main'; import { closeAllWindows, closeWindow } from './lib/window-helpers'; -import * as http from 'http'; -import * as path from 'path'; -import * as fs from 'fs'; +import * as http from 'node:http'; +import * as path from 'node:path'; +import * as fs from 'node:fs'; import * as WebSocket from 'ws'; import { emittedNTimes, emittedUntil } from './lib/events-helpers'; import { ifit, listen } from './lib/spec-helpers'; -import { once } from 'events'; +import { once } from 'node:events'; const uuid = require('uuid'); diff --git a/spec/fixtures/api/close.html b/spec/fixtures/api/close.html index 0388b82a73..7e80005649 100644 --- a/spec/fixtures/api/close.html +++ b/spec/fixtures/api/close.html @@ -2,7 +2,7 @@
diff --git a/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js b/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js index 622ef6acbf..3422a3fd56 100644 --- a/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js +++ b/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow } = require('electron'); -const path = require('path'); +const path = require('node:path'); let win; app.whenReady().then(function () { diff --git a/spec/fixtures/api/mixed-sandbox-app/main.js b/spec/fixtures/api/mixed-sandbox-app/main.js index bb61f2b628..5182dd66dc 100644 --- a/spec/fixtures/api/mixed-sandbox-app/main.js +++ b/spec/fixtures/api/mixed-sandbox-app/main.js @@ -1,6 +1,6 @@ const { app, BrowserWindow, ipcMain } = require('electron'); -const net = require('net'); -const path = require('path'); +const net = require('node:net'); +const path = require('node:path'); process.on('uncaughtException', () => { app.exit(1); diff --git a/spec/fixtures/api/relaunch/main.js b/spec/fixtures/api/relaunch/main.js index 94898f6059..d66d30921b 100644 --- a/spec/fixtures/api/relaunch/main.js +++ b/spec/fixtures/api/relaunch/main.js @@ -1,5 +1,5 @@ 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'; diff --git a/spec/fixtures/api/safe-storage/decrypt-app/main.js b/spec/fixtures/api/safe-storage/decrypt-app/main.js index 95608a41e8..249165fdcd 100644 --- a/spec/fixtures/api/safe-storage/decrypt-app/main.js +++ b/spec/fixtures/api/safe-storage/decrypt-app/main.js @@ -1,6 +1,6 @@ const { app, safeStorage, ipcMain } = require('electron'); -const { promises: fs } = require('fs'); -const path = require('path'); +const { promises: fs } = require('node:fs'); +const path = require('node:path'); const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt'); const readFile = fs.readFile; diff --git a/spec/fixtures/api/safe-storage/encrypt-app/main.js b/spec/fixtures/api/safe-storage/encrypt-app/main.js index da1a19a3da..5f5bdc0917 100644 --- a/spec/fixtures/api/safe-storage/encrypt-app/main.js +++ b/spec/fixtures/api/safe-storage/encrypt-app/main.js @@ -1,6 +1,6 @@ const { app, safeStorage, ipcMain } = require('electron'); -const { promises: fs } = require('fs'); -const path = require('path'); +const { promises: fs } = require('node:fs'); +const path = require('node:path'); const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt'); const writeFile = fs.writeFile; diff --git a/spec/fixtures/api/singleton-userdata/main.js b/spec/fixtures/api/singleton-userdata/main.js index 98f6841b42..2d4a487866 100644 --- a/spec/fixtures/api/singleton-userdata/main.js +++ b/spec/fixtures/api/singleton-userdata/main.js @@ -1,6 +1,6 @@ const { app } = require('electron'); -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); // non-existent user data folder should not break requestSingleInstanceLock() // ref: https://github.com/electron/electron/issues/33547 diff --git a/spec/fixtures/api/unload.html b/spec/fixtures/api/unload.html index da749641f9..d4040ee3b4 100644 --- a/spec/fixtures/api/unload.html +++ b/spec/fixtures/api/unload.html @@ -2,7 +2,7 @@ diff --git a/spec/fixtures/api/utility-process/env-app/main.js b/spec/fixtures/api/utility-process/env-app/main.js index df4d078cd4..5edb3ea823 100644 --- a/spec/fixtures/api/utility-process/env-app/main.js +++ b/spec/fixtures/api/utility-process/env-app/main.js @@ -1,5 +1,5 @@ const { app, utilityProcess } = require('electron'); -const path = require('path'); +const path = require('node:path'); app.whenReady().then(() => { let child = null; diff --git a/spec/fixtures/api/utility-process/inherit-stderr/main.js b/spec/fixtures/api/utility-process/inherit-stderr/main.js index 65510c45b7..80fbaff5cc 100644 --- a/spec/fixtures/api/utility-process/inherit-stderr/main.js +++ b/spec/fixtures/api/utility-process/inherit-stderr/main.js @@ -1,5 +1,5 @@ const { app, utilityProcess } = require('electron'); -const path = require('path'); +const path = require('node:path'); app.whenReady().then(() => { const payload = app.commandLine.getSwitchValue('payload'); diff --git a/spec/fixtures/api/utility-process/inherit-stdout/main.js b/spec/fixtures/api/utility-process/inherit-stdout/main.js index 65510c45b7..80fbaff5cc 100644 --- a/spec/fixtures/api/utility-process/inherit-stdout/main.js +++ b/spec/fixtures/api/utility-process/inherit-stdout/main.js @@ -1,5 +1,5 @@ const { app, utilityProcess } = require('electron'); -const path = require('path'); +const path = require('node:path'); app.whenReady().then(() => { const payload = app.commandLine.getSwitchValue('payload'); diff --git a/spec/fixtures/api/utility-process/suid.js b/spec/fixtures/api/utility-process/suid.js index 178a52618e..714a288f44 100644 --- a/spec/fixtures/api/utility-process/suid.js +++ b/spec/fixtures/api/utility-process/suid.js @@ -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); diff --git a/spec/fixtures/apps/crash/fork.js b/spec/fixtures/apps/crash/fork.js index 888cfea5e7..2b0cb8be0c 100644 --- a/spec/fixtures/apps/crash/fork.js +++ b/spec/fixtures/apps/crash/fork.js @@ -1,5 +1,5 @@ -const path = require('path'); -const childProcess = require('child_process'); +const path = require('node:path'); +const childProcess = require('node:child_process'); const crashPath = path.join(__dirname, 'node-crash.js'); const child = childProcess.fork(crashPath, { silent: true }); diff --git a/spec/fixtures/apps/crash/main.js b/spec/fixtures/apps/crash/main.js index 54037c6784..cabedbb1aa 100644 --- a/spec/fixtures/apps/crash/main.js +++ b/spec/fixtures/apps/crash/main.js @@ -1,6 +1,6 @@ const { app, BrowserWindow, crashReporter } = require('electron'); -const path = require('path'); -const childProcess = require('child_process'); +const path = require('node:path'); +const childProcess = require('node:child_process'); app.setVersion('0.1.0'); diff --git a/spec/fixtures/apps/crash/node-extra-args.js b/spec/fixtures/apps/crash/node-extra-args.js index 3a16785850..cf8837ae09 100644 --- a/spec/fixtures/apps/crash/node-extra-args.js +++ b/spec/fixtures/apps/crash/node-extra-args.js @@ -1,5 +1,5 @@ -const path = require('path'); -const childProcess = require('child_process'); +const path = require('node:path'); +const childProcess = require('node:child_process'); process.on('message', function () { process.send(process.argv); diff --git a/spec/fixtures/apps/libuv-hang/main.js b/spec/fixtures/apps/libuv-hang/main.js index 3c9b9d0b6f..55a65ca93a 100644 --- a/spec/fixtures/apps/libuv-hang/main.js +++ b/spec/fixtures/apps/libuv-hang/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow, ipcMain } = require('electron'); -const path = require('path'); +const path = require('node:path'); async function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/spec/fixtures/apps/libuv-hang/preload.js b/spec/fixtures/apps/libuv-hang/preload.js index a5840f557f..2629549fbf 100644 --- a/spec/fixtures/apps/libuv-hang/preload.js +++ b/spec/fixtures/apps/libuv-hang/preload.js @@ -3,7 +3,7 @@ const { contextBridge, ipcRenderer } = require('electron'); contextBridge.exposeInMainWorld('api', { ipcRenderer, run: async () => { - const { promises: fs } = require('fs'); + const { promises: fs } = require('node:fs'); for (let i = 0; i < 10; i++) { const list = await fs.readdir('.', { withFileTypes: true }); for (const file of list) { diff --git a/spec/fixtures/apps/open-new-window-from-link/main.js b/spec/fixtures/apps/open-new-window-from-link/main.js index 7d41b3bb29..4f4d4999d0 100644 --- a/spec/fixtures/apps/open-new-window-from-link/main.js +++ b/spec/fixtures/apps/open-new-window-from-link/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow } = require('electron'); -const path = require('path'); +const path = require('node:path'); async function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/spec/fixtures/apps/remote-control/main.js b/spec/fixtures/apps/remote-control/main.js index a9cbf2e9e1..d1ac3163fa 100644 --- a/spec/fixtures/apps/remote-control/main.js +++ b/spec/fixtures/apps/remote-control/main.js @@ -1,8 +1,8 @@ const { app } = require('electron'); -const http = require('http'); -const v8 = require('v8'); +const http = require('node:http'); +const v8 = require('node:v8'); // eslint-disable-next-line camelcase -const promises_1 = require('timers/promises'); +const promises_1 = require('node:timers/promises'); if (app.commandLine.hasSwitch('boot-eval')) { // eslint-disable-next-line no-eval diff --git a/spec/fixtures/apps/self-module-paths/main.js b/spec/fixtures/apps/self-module-paths/main.js index 3baae49b7a..6138e7983c 100644 --- a/spec/fixtures/apps/self-module-paths/main.js +++ b/spec/fixtures/apps/self-module-paths/main.js @@ -1,6 +1,6 @@ // Modules to control application life and create native browser window const { app, BrowserWindow, ipcMain } = require('electron'); -const path = require('path'); +const path = require('node:path'); function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/spec/fixtures/apps/set-path/main.js b/spec/fixtures/apps/set-path/main.js index efc6a624ee..abde440957 100644 --- a/spec/fixtures/apps/set-path/main.js +++ b/spec/fixtures/apps/set-path/main.js @@ -1,4 +1,4 @@ -const http = require('http'); +const http = require('node:http'); const { app, ipcMain, BrowserWindow } = require('electron'); if (process.argv.length > 3) { diff --git a/spec/fixtures/apps/xwindow-icon/main.js b/spec/fixtures/apps/xwindow-icon/main.js index 0da98ad277..f5e23deda9 100644 --- a/spec/fixtures/apps/xwindow-icon/main.js +++ b/spec/fixtures/apps/xwindow-icon/main.js @@ -1,5 +1,5 @@ const { app, BrowserWindow } = require('electron'); -const path = require('path'); +const path = require('node:path'); app.whenReady().then(() => { const w = new BrowserWindow({ diff --git a/spec/fixtures/auto-update/update-json/index.js b/spec/fixtures/auto-update/update-json/index.js index 1595696131..320dbffe22 100644 --- a/spec/fixtures/auto-update/update-json/index.js +++ b/spec/fixtures/auto-update/update-json/index.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); process.on('uncaughtException', (err) => { console.error(err); diff --git a/spec/fixtures/auto-update/update/index.js b/spec/fixtures/auto-update/update/index.js index b15dc7dc72..f9d1b1670b 100644 --- a/spec/fixtures/auto-update/update/index.js +++ b/spec/fixtures/auto-update/update/index.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); process.on('uncaughtException', (err) => { console.error(err); diff --git a/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.html b/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.html index 9721dac6ed..6c45f3f330 100644 --- a/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.html +++ b/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.html @@ -1,7 +1,7 @@ diff --git a/spec/fixtures/pages/send-after-node.html b/spec/fixtures/pages/send-after-node.html index 68f5a40b67..7a1ffa727c 100644 --- a/spec/fixtures/pages/send-after-node.html +++ b/spec/fixtures/pages/send-after-node.html @@ -1,7 +1,7 @@ diff --git a/spec/fixtures/pages/window-opener-targetOrigin.html b/spec/fixtures/pages/window-opener-targetOrigin.html index daa51a48cf..9a52296ca2 100644 --- a/spec/fixtures/pages/window-opener-targetOrigin.html +++ b/spec/fixtures/pages/window-opener-targetOrigin.html @@ -1,7 +1,7 @@