Browse Source

refactor: use node scheme imports in spec (#38487)

Co-authored-by: Milan Burda <[email protected]>
Milan Burda 1 year ago
parent
commit
d78f37ec8f
100 changed files with 333 additions and 327 deletions
  1. 1 0
      package.json
  2. 4 2
      spec/.eslintrc
  3. 7 7
      spec/api-app-spec.ts
  4. 1 1
      spec/api-auto-updater-spec.ts
  5. 5 5
      spec/api-autoupdater-darwin-spec.ts
  6. 2 2
      spec/api-browser-view-spec.ts
  7. 10 10
      spec/api-browser-window-spec.ts
  8. 2 2
      spec/api-clipboard-spec.ts
  9. 3 3
      spec/api-content-tracing-spec.ts
  10. 9 9
      spec/api-context-bridge-spec.ts
  11. 7 7
      spec/api-crash-reporter-spec.ts
  12. 3 3
      spec/api-debugger-spec.ts
  13. 2 2
      spec/api-desktop-capturer-spec.ts
  14. 1 1
      spec/api-dialog-spec.ts
  15. 3 3
      spec/api-ipc-main-spec.ts
  16. 3 3
      spec/api-ipc-renderer-spec.ts
  17. 3 3
      spec/api-ipc-spec.ts
  18. 1 1
      spec/api-media-handler-spec.ts
  19. 4 4
      spec/api-menu-spec.ts
  20. 1 1
      spec/api-native-image-spec.ts
  21. 4 4
      spec/api-native-theme-spec.ts
  22. 7 7
      spec/api-net-log-spec.ts
  23. 7 7
      spec/api-net-spec.ts
  24. 1 1
      spec/api-notification-dbus-spec.ts
  25. 1 1
      spec/api-notification-spec.ts
  26. 2 2
      spec/api-power-monitor-spec.ts
  27. 2 2
      spec/api-process-spec.ts
  28. 9 9
      spec/api-protocol-spec.ts
  29. 3 3
      spec/api-safe-storage-spec.ts
  30. 4 4
      spec/api-service-workers-spec.ts
  31. 7 7
      spec/api-session-spec.ts
  32. 4 4
      spec/api-shell-spec.ts
  33. 3 3
      spec/api-subframe-spec.ts
  34. 1 1
      spec/api-touch-bar-spec.ts
  35. 1 1
      spec/api-tray-spec.ts
  36. 3 3
      spec/api-utility-process-spec.ts
  37. 6 6
      spec/api-web-contents-spec.ts
  38. 5 5
      spec/api-web-frame-main-spec.ts
  39. 2 2
      spec/api-web-frame-spec.ts
  40. 11 11
      spec/api-web-request-spec.ts
  41. 14 14
      spec/asar-spec.ts
  42. 2 2
      spec/autofill-spec.ts
  43. 10 10
      spec/chromium-spec.ts
  44. 3 3
      spec/crash-spec.ts
  45. 4 4
      spec/extensions-spec.ts
  46. 1 1
      spec/fixtures/api/close.html
  47. 1 1
      spec/fixtures/api/context-bridge/context-bridge-mutability/main.js
  48. 2 2
      spec/fixtures/api/mixed-sandbox-app/main.js
  49. 1 1
      spec/fixtures/api/relaunch/main.js
  50. 2 2
      spec/fixtures/api/safe-storage/decrypt-app/main.js
  51. 2 2
      spec/fixtures/api/safe-storage/encrypt-app/main.js
  52. 2 2
      spec/fixtures/api/singleton-userdata/main.js
  53. 1 1
      spec/fixtures/api/unload.html
  54. 1 1
      spec/fixtures/api/utility-process/env-app/main.js
  55. 1 1
      spec/fixtures/api/utility-process/inherit-stderr/main.js
  56. 1 1
      spec/fixtures/api/utility-process/inherit-stdout/main.js
  57. 1 1
      spec/fixtures/api/utility-process/suid.js
  58. 2 2
      spec/fixtures/apps/crash/fork.js
  59. 2 2
      spec/fixtures/apps/crash/main.js
  60. 2 2
      spec/fixtures/apps/crash/node-extra-args.js
  61. 1 1
      spec/fixtures/apps/libuv-hang/main.js
  62. 1 1
      spec/fixtures/apps/libuv-hang/preload.js
  63. 1 1
      spec/fixtures/apps/open-new-window-from-link/main.js
  64. 3 3
      spec/fixtures/apps/remote-control/main.js
  65. 1 1
      spec/fixtures/apps/self-module-paths/main.js
  66. 1 1
      spec/fixtures/apps/set-path/main.js
  67. 1 1
      spec/fixtures/apps/xwindow-icon/main.js
  68. 2 2
      spec/fixtures/auto-update/update-json/index.js
  69. 2 2
      spec/fixtures/auto-update/update/index.js
  70. 1 1
      spec/fixtures/crash-cases/fs-promises-renderer-crash/index.html
  71. 1 1
      spec/fixtures/crash-cases/fs-promises-renderer-crash/index.js
  72. 2 2
      spec/fixtures/crash-cases/js-execute-iframe/index.html
  73. 2 2
      spec/fixtures/crash-cases/js-execute-iframe/index.js
  74. 2 2
      spec/fixtures/crash-cases/native-window-open-exit/index.js
  75. 1 1
      spec/fixtures/crash-cases/setimmediate-renderer-crash/index.js
  76. 1 1
      spec/fixtures/module/asar.js
  77. 1 1
      spec/fixtures/module/create_socket.js
  78. 2 2
      spec/fixtures/module/fork_ping.js
  79. 3 3
      spec/fixtures/module/inspector-binding.js
  80. 2 2
      spec/fixtures/module/no-asar.js
  81. 1 1
      spec/fixtures/module/preload-eventemitter.js
  82. 4 1
      spec/fixtures/module/preload-sandbox.js
  83. 1 1
      spec/fixtures/no-proprietary-codecs.js
  84. 1 1
      spec/fixtures/pages/native-module.html
  85. 1 1
      spec/fixtures/pages/send-after-node.html
  86. 1 1
      spec/fixtures/pages/window-opener-targetOrigin.html
  87. 3 3
      spec/fixtures/test.asar/repack.js
  88. 1 1
      spec/get-files.ts
  89. 2 2
      spec/guest-window-manager-spec.ts
  90. 3 3
      spec/index.js
  91. 1 1
      spec/lib/events-helpers.ts
  92. 2 2
      spec/lib/screen-helpers.ts
  93. 8 8
      spec/lib/spec-helpers.ts
  94. 1 1
      spec/lib/window-helpers.ts
  95. 3 3
      spec/logging-spec.ts
  96. 5 5
      spec/modules-spec.ts
  97. 43 43
      spec/node-spec.ts
  98. 1 1
      spec/release-notes-spec.ts
  99. 5 5
      spec/security-warnings-spec.ts
  100. 5 5
      spec/spellchecker-spec.ts

+ 1 - 0
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",

+ 4 - 2
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"
   }
 }

+ 7 - 7
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');

+ 1 - 1
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 () {

+ 5 - 5
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';

+ 2 - 2
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');

+ 10 - 10
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;

+ 2 - 2
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';
 

+ 3 - 3
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.

+ 9 - 9
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"
         });

+ 7 - 7
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 });

+ 3 - 3
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');

+ 2 - 2
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';

+ 1 - 1
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', () => {

+ 3 - 3
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');

+ 3 - 3
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

+ 3 - 3
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');

+ 1 - 1
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', () => {

+ 4 - 4
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');
 

+ 1 - 1
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');

+ 4 - 4
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';

+ 7 - 7
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');

+ 7 - 7
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');

+ 1 - 1
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' ||

+ 1 - 1
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', () => {

+ 2 - 2
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;

+ 2 - 2
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';

+ 9 - 9
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');
 

+ 3 - 3
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

+ 4 - 4
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';
 

+ 7 - 7
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');

+ 4 - 4
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()', () => {

+ 3 - 3
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) => {

+ 1 - 1
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';

+ 1 - 1
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;

+ 3 - 3
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';

+ 6 - 6
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');

+ 5 - 5
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');

+ 2 - 2
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');

+ 11 - 11
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 });
       });

+ 14 - 14
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));
     });
   });
 

+ 2 - 2
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');
 

+ 10 - 10
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

+ 3 - 3
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');

+ 4 - 4
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');
 

+ 1 - 1
spec/fixtures/api/close.html

@@ -2,7 +2,7 @@
 <body>
 <script type="text/javascript" charset="utf-8">
   window.addEventListener('unload', function (e) {
-    require('fs').writeFileSync(__dirname + '/close', 'close');
+    require('node:fs').writeFileSync(__dirname + '/close', 'close');
   }, false);
   window.onload = () => window.close();
 </script>

+ 1 - 1
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 () {

+ 2 - 2
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);

+ 1 - 1
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';
 

+ 2 - 2
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;

+ 2 - 2
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;

+ 2 - 2
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

+ 1 - 1
spec/fixtures/api/unload.html

@@ -2,7 +2,7 @@
 <body>
 <script type="text/javascript" charset="utf-8">
   window.addEventListener('unload', function (e) {
-    require('fs').writeFileSync(__dirname + '/unload', 'unload');
+    require('node:fs').writeFileSync(__dirname + '/unload', 'unload');
   }, false);
 </script>
 </body>

+ 1 - 1
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;

+ 1 - 1
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');

+ 1 - 1
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');

+ 1 - 1
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);

+ 2 - 2
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 });

+ 2 - 2
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');
 

+ 2 - 2
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);

+ 1 - 1
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({

+ 1 - 1
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) {

+ 1 - 1
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({

+ 3 - 3
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

+ 1 - 1
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({

+ 1 - 1
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) {

+ 1 - 1
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({

+ 2 - 2
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);

+ 2 - 2
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);

+ 1 - 1
spec/fixtures/crash-cases/fs-promises-renderer-crash/index.html

@@ -1,7 +1,7 @@
 <html>
 <body>
 <script>
-const fs = require('fs');
+const fs = require('node:fs');
 const { ipcRenderer } = require('electron');
 
 async function readFile(path) {

+ 1 - 1
spec/fixtures/crash-cases/fs-promises-renderer-crash/index.js

@@ -1,5 +1,5 @@
 const { app, BrowserWindow, ipcMain } = require('electron');
-const path = require('path');
+const path = require('node:path');
 
 app.whenReady().then(() => {
   let reloadCount = 0;

+ 2 - 2
spec/fixtures/crash-cases/js-execute-iframe/index.html

@@ -2,8 +2,8 @@
   <body>
     <iframe id="mainframe"></iframe>
     <script>
-      const net = require('net');
-      const path = require('path');
+      const net = require('node:net');
+      const path = require('node:path');
 
       document.getElementById("mainframe").src="./page2.html";
 

+ 2 - 2
spec/fixtures/crash-cases/js-execute-iframe/index.js

@@ -1,6 +1,6 @@
 const { app, BrowserWindow } = require('electron');
-const net = require('net');
-const path = require('path');
+const net = require('node:net');
+const path = require('node:path');
 
 function createWindow () {
   const mainWindow = new BrowserWindow({

+ 2 - 2
spec/fixtures/crash-cases/native-window-open-exit/index.js

@@ -1,6 +1,6 @@
 const { app, ipcMain, BrowserWindow } = require('electron');
-const path = require('path');
-const http = require('http');
+const path = require('node:path');
+const http = require('node:http');
 
 function createWindow () {
   const mainWindow = new BrowserWindow({

+ 1 - 1
spec/fixtures/crash-cases/setimmediate-renderer-crash/index.js

@@ -1,5 +1,5 @@
 const { app, BrowserWindow } = require('electron');
-const path = require('path');
+const path = require('node:path');
 
 app.whenReady().then(() => {
   const win = new BrowserWindow({

+ 1 - 1
spec/fixtures/module/asar.js

@@ -1,4 +1,4 @@
-const fs = require('fs');
+const fs = require('node:fs');
 process.on('message', function (file) {
   process.send(fs.readFileSync(file).toString());
 });

+ 1 - 1
spec/fixtures/module/create_socket.js

@@ -1,4 +1,4 @@
-const net = require('net');
+const net = require('node:net');
 const server = net.createServer(function () {});
 server.listen(process.argv[2]);
 process.exit(0);

+ 2 - 2
spec/fixtures/module/fork_ping.js

@@ -1,10 +1,10 @@
-const path = require('path');
+const path = require('node:path');
 
 process.on('uncaughtException', function (error) {
   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) {
   child.send(msg);
 });

+ 3 - 3
spec/fixtures/module/inspector-binding.js

@@ -1,6 +1,6 @@
-const inspector = require('inspector');
-const path = require('path');
-const { pathToFileURL } = require('url');
+const inspector = require('node:inspector');
+const path = require('node:path');
+const { pathToFileURL } = require('node:url');
 
 // This test case will set a breakpoint 4 lines below
 function debuggedFunction () {

+ 2 - 2
spec/fixtures/module/no-asar.js

@@ -1,5 +1,5 @@
-const fs = require('fs');
-const path = require('path');
+const fs = require('node:fs');
+const path = require('node:path');
 
 const stats = fs.statSync(path.join(__dirname, '..', 'test.asar', 'a.asar'));
 

+ 1 - 1
spec/fixtures/module/preload-eventemitter.js

@@ -1,5 +1,5 @@
 (function () {
-  const { EventEmitter } = require('events');
+  const { EventEmitter } = require('node:events');
   const emitter = new EventEmitter();
   const rendererEventEmitterProperties = [];
   let currentObj = emitter;

+ 4 - 1
spec/fixtures/module/preload-sandbox.js

@@ -1,5 +1,5 @@
 (function () {
-  const { setImmediate } = require('timers');
+  const { setImmediate } = require('node:timers');
   const { ipcRenderer } = require('electron');
   window.ipcRenderer = ipcRenderer;
   window.setImmediate = setImmediate;
@@ -34,8 +34,11 @@
         cpuUsage: invoke(() => process.getCPUUsage()),
         ioCounters: invoke(() => process.getIOCounters()),
         uptime: invoke(() => process.uptime()),
+        // eslint-disable-next-line unicorn/prefer-node-protocol
         nodeEvents: invoke(() => require('events') === require('node:events')),
+        // eslint-disable-next-line unicorn/prefer-node-protocol
         nodeTimers: invoke(() => require('timers') === require('node:timers')),
+        // eslint-disable-next-line unicorn/prefer-node-protocol
         nodeUrl: invoke(() => require('url') === require('node:url')),
         env: process.env,
         execPath: process.execPath,

+ 1 - 1
spec/fixtures/no-proprietary-codecs.js

@@ -5,7 +5,7 @@
 // that does include proprietary codecs.
 
 const { app, BrowserWindow, ipcMain } = require('electron');
-const path = require('path');
+const path = require('node:path');
 
 const MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
 const FIVE_MINUTES = 5 * 60 * 1000;

+ 1 - 1
spec/fixtures/pages/native-module.html

@@ -1,7 +1,7 @@
 <html>
 <body>
 <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')));
 </script>
 </body>

+ 1 - 1
spec/fixtures/pages/send-after-node.html

@@ -1,7 +1,7 @@
 <html>
 <body>
 <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');
   })
 </script>

+ 1 - 1
spec/fixtures/pages/window-opener-targetOrigin.html

@@ -1,7 +1,7 @@
 <html>
 <body>
 <script type="text/javascript" charset="utf-8">
-  const url = require('url')
+  const url = require('node:url')
   function tryPostMessage(...args) {
     try {
       window.opener.postMessage(...args)

+ 3 - 3
spec/fixtures/test.asar/repack.js

@@ -2,9 +2,9 @@
 // using a new version of the asar package
 
 const asar = require('@electron/asar');
-const fs = require('fs');
-const os = require('os');
-const path = require('path');
+const fs = require('node:fs');
+const os = require('node:os');
+const path = require('node:path');
 
 const archives = [];
 for (const child of fs.readdirSync(__dirname)) {

+ 1 - 1
spec/get-files.ts

@@ -1,4 +1,4 @@
-import { once } from 'events';
+import { once } from 'node:events';
 import * as walkdir from 'walkdir';
 
 export async function getFiles (directoryPath: string, { filter = null }: {filter?: ((file: string) => boolean) | null} = {}) {

+ 2 - 2
spec/guest-window-manager-spec.ts

@@ -3,8 +3,8 @@ import { expect, assert } from 'chai';
 import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers';
 import { ifit } from './lib/spec-helpers';
 import { closeAllWindows } from './lib/window-helpers';
-import { once } from 'events';
-import { setTimeout as setTimeoutAsync } from 'timers/promises';
+import { once } from 'node:events';
+import { setTimeout as setTimeoutAsync } from 'node:timers/promises';
 
 describe('webContents.setWindowOpenHandler', () => {
   let browserWindow: BrowserWindow;

+ 3 - 3
spec/index.js

@@ -1,6 +1,6 @@
-const fs = require('fs');
-const path = require('path');
-const v8 = require('v8');
+const fs = require('node:fs');
+const path = require('node:path');
+const v8 = require('node:v8');
 
 // We want to terminate on errors, not throw up a dialog
 process.on('uncaughtException', (err) => {

+ 1 - 1
spec/lib/events-helpers.ts

@@ -3,7 +3,7 @@
  * 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) => {
   const events: any[][] = [];

+ 2 - 2
spec/lib/screen-helpers.ts

@@ -1,5 +1,5 @@
-import * as path from 'path';
-import * as fs from 'fs';
+import * as path from 'node:path';
+import * as fs from 'node:fs';
 import { screen, desktopCapturer, NativeImage } from 'electron';
 
 const fixtures = path.resolve(__dirname, '..', 'fixtures');

+ 8 - 8
spec/lib/spec-helpers.ts

@@ -1,10 +1,10 @@
-import * as childProcess from 'child_process';
-import * as path from 'path';
-import * as http from 'http';
-import * as https from 'https';
-import * as net from 'net';
-import * as v8 from 'v8';
-import * as url from 'url';
+import * as childProcess from 'node:child_process';
+import * as path from 'node:path';
+import * as http from 'node:http';
+import * as https from 'node:https';
+import * as net from 'node:net';
+import * as v8 from 'node:v8';
+import * as url from 'node:url';
 import { SuiteFunction, TestFunction } from 'mocha';
 import { BrowserWindow } from 'electron/main';
 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 () => {
       try {
         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('dirty-chai'))
         await (${fn})(...${JSON.stringify(args ?? [])})

+ 1 - 1
spec/lib/window-helpers.ts

@@ -1,6 +1,6 @@
 import { expect } from 'chai';
 import { BrowserWindow } from 'electron/main';
-import { once } from 'events';
+import { once } from 'node:events';
 
 async function ensureWindowIsClosed (window: BrowserWindow | null) {
   if (window && !window.isDestroyed()) {

+ 3 - 3
spec/logging-spec.ts

@@ -2,10 +2,10 @@ import { app } from 'electron';
 import { expect } from 'chai';
 import { startRemoteControlApp, ifdescribe } from './lib/spec-helpers';
 
-import * as fs from 'fs/promises';
-import * as path from 'path';
+import * as fs from 'node:fs/promises';
+import * as path from 'node:path';
 import * as uuid from 'uuid';
-import { once } from 'events';
+import { once } from 'node:events';
 
 function isTestingBindingAvailable () {
   try {

+ 5 - 5
spec/modules-spec.ts

@@ -1,13 +1,13 @@
 import { expect } from 'chai';
-import * as path from 'path';
-import * as fs from 'fs';
+import * as path from 'node:path';
+import * as fs from 'node:fs';
 import { BrowserWindow } from 'electron/main';
 import { ifdescribe, ifit } from './lib/spec-helpers';
 import { closeAllWindows } from './lib/window-helpers';
-import * as childProcess from 'child_process';
-import { once } from 'events';
+import * as childProcess from 'node:child_process';
+import { once } from 'node:events';
 
-const Module = require('module');
+const Module = require('node:module');
 
 const nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS;
 

+ 43 - 43
spec/node-spec.ts

@@ -1,12 +1,12 @@
 import { expect } from 'chai';
-import * as childProcess from 'child_process';
-import * as fs from 'fs';
-import * as path from 'path';
-import * as util from 'util';
+import * as childProcess from 'node:child_process';
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+import * as util from 'node:util';
 import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
 import { webContents } from 'electron/main';
-import { EventEmitter } from 'stream';
-import { once } from 'events';
+import { EventEmitter } from 'node:stream';
+import { once } from 'node:events';
 
 const mainFixturesPath = path.resolve(__dirname, 'fixtures');
 
@@ -30,7 +30,7 @@ describe('node feature', () => {
 
     describe('child_process.fork', () => {
       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));
         child.send('message');
         const msg = await message;
@@ -39,7 +39,7 @@ describe('node feature', () => {
 
       itremote('preserves args', async (fixtures: string) => {
         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));
         child.send('message');
         const msg = await message;
@@ -47,7 +47,7 @@ describe('node feature', () => {
       }, [fixtures]);
 
       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));
         child.send('message');
         const msg = await message;
@@ -55,7 +55,7 @@ describe('node feature', () => {
       }, [fixtures]);
 
       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
         });
         const message = new Promise<any>(resolve => child.once('message', resolve));
@@ -65,7 +65,7 @@ describe('node feature', () => {
       }, [fixtures]);
 
       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));
         child.send('message');
         const msg = await message;
@@ -73,7 +73,7 @@ describe('node feature', () => {
       }, [fixtures]);
 
       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));
         child.send('message');
         const msg = await message;
@@ -81,7 +81,7 @@ describe('node feature', () => {
       }, [fixtures]);
 
       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 = '';
         child.stdout.on('data', (chunk: any) => {
           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 () => {
         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));
         forked.send('hello');
         const msg = await message;
@@ -102,7 +102,7 @@ describe('node feature', () => {
 
       it('has the electron version in process.versions', async () => {
         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');
         expect(message)
           .to.have.own.property('electron')
@@ -113,7 +113,7 @@ describe('node feature', () => {
 
     describe('child_process.spawn', () => {
       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: {
             ELECTRON_RUN_AS_NODE: true
           }
@@ -268,7 +268,7 @@ describe('node feature', () => {
 
     describe('setTimeout in fs callback', () => {
       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);
         }));
       }, [__filename]);
@@ -277,7 +277,7 @@ describe('node feature', () => {
     describe('error thrown in renderer process node context', () => {
       itremote('gets emitted as a process uncaughtException event', async (filename: string) => {
         const error = new Error('boo!');
-        require('fs').readFile(filename, () => {
+        require('node:fs').readFile(filename, () => {
           throw error;
         });
         await new Promise<void>((resolve, reject) => {
@@ -295,9 +295,9 @@ describe('node feature', () => {
 
     describe('URL handling in the renderer process', () => {
       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(() => {
-          require('fs').createReadStream(url);
+          require('node:fs').createReadStream(url);
         }).to.not.throw();
       }, [fixtures]);
     });
@@ -308,7 +308,7 @@ describe('node feature', () => {
       });
 
       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 () => {
-        const { setInterval, clearInterval } = require('timers');
+        const { setInterval, clearInterval } = require('node:timers');
         await new Promise<void>(resolve => {
           const id = setInterval(() => {
             clearInterval(id);
@@ -361,12 +361,12 @@ describe('node feature', () => {
 
   ifdescribe(process.platform === 'darwin')('net.connect', () => {
     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 script = require('path').join(fixtures, 'module', 'create_socket.js');
-      const child = require('child_process').fork(script, [socketPath]);
+      const socketPath = require('node:path').join(require('node:os').tmpdir(), 'electron-test.sock');
+      const script = require('node:path').join(fixtures, 'module', 'create_socket.js');
+      const child = require('node:child_process').fork(script, [socketPath]);
       const code = await new Promise(resolve => child.once('exit', resolve));
       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));
       expect(error.code).to.equal('ECONNREFUSED');
     }, [fixtures]);
@@ -399,7 +399,7 @@ describe('node feature', () => {
     });
 
     itremote('does not crash for crypto operations', () => {
-      const crypto = require('crypto');
+      const crypto = require('node:crypto');
       const data = 'lG9E+/g4JmRmedDAnihtBD4Dfaha/GFOjd+xUOQI05UtfVX3DjUXvrS98p7kZQwY3LNhdiFo7MY5rGft8yBuDhKuNNag9vRx/44IuClDhdQ=';
       const key = 'q90K9yBqhWZnAMCMTOJfPQ==';
       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', () => {
-      const crypto = require('crypto');
+      const crypto = require('node:crypto');
 
       crypto.createDiffieHellman('abc');
       crypto.createDiffieHellman('abc', 2);
@@ -425,7 +425,7 @@ describe('node feature', () => {
     });
 
     itremote('does not crash when calling crypto.createPrivateKey() with an unsupported algorithm', () => {
-      const crypto = require('crypto');
+      const crypto = require('node:crypto');
 
       const ed448 = {
         crv: 'Ed448',
@@ -481,58 +481,58 @@ describe('node feature', () => {
 
   describe('vm.runInNewContext', () => {
     itremote('should not crash', () => {
-      require('vm').runInNewContext('');
+      require('node:vm').runInNewContext('');
     });
   });
 
   describe('crypto', () => {
     useRemoteContext();
     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', () => {
-      const hash = require('crypto').createHash('ripemd160');
+      const hash = require('node:crypto').createHash('ripemd160');
       hash.update('electron-ripemd160');
       expect(hash.digest('hex')).to.equal('fa7fec13c624009ab126ebb99eda6525583395fe');
     });
 
     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', () => {
-      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', () => {
-      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', () => {
-      require('crypto').createCipheriv('bf-cbc', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
-      require('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-cbc', Buffer.from('0123456789abcdef'), Buffer.from('01234567'));
+      require('node:crypto').createCipheriv('bf-cfb', 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', () => {
-      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', () => {
       const key = Buffer.from('0123456789abcdeff1e0d3c2b5a49786', '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', () => {
-      const ecdh = require('crypto').createECDH('prime256v1');
+      const ecdh = require('node:crypto').createECDH('prime256v1');
       expect(ecdh.generateKeys()).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', () => {
-      const dh = require('crypto').createDiffieHellman('modp15');
+      const dh = require('node:crypto').createDiffieHellman('modp15');
       expect(dh.generateKeys()).to.be.an.instanceof(Buffer);
       expect(dh.getPublicKey()).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', () => {
-      const crypto = require('crypto');
+      const crypto = require('node:crypto');
       const dh = crypto.createECDH('prime256v1');
       dh.generateKeys();
       dh.setPrivateKey(dh.getPrivateKey());

+ 1 - 1
spec/release-notes-spec.ts

@@ -1,7 +1,7 @@
 import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite';
 import { expect } from 'chai';
 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';
 
 /* Fake a Dugite GitProcess that only returns the specific

+ 5 - 5
spec/security-warnings-spec.ts

@@ -1,15 +1,15 @@
 import { expect } from 'chai';
-import * as http from 'http';
-import * as fs from 'fs';
-import * as path from 'path';
-import * as url from 'url';
+import * as http from 'node:http';
+import * as fs from 'node:fs';
+import * as path from 'node:path';
+import * as url from 'node:url';
 
 import { BrowserWindow, WebPreferences } from 'electron/main';
 
 import { closeWindow } from './lib/window-helpers';
 import { emittedUntil } from './lib/events-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) => {
   return message.indexOf('Electron Security Warning') > -1;

+ 5 - 5
spec/spellchecker-spec.ts

@@ -1,13 +1,13 @@
 import { BrowserWindow, Session, session } from 'electron/main';
 
 import { expect } from 'chai';
-import * as path from 'path';
-import * as fs from 'fs';
-import * as http from 'http';
+import * as path from 'node:path';
+import * as fs from 'node:fs';
+import * as http from 'node:http';
 import { closeWindow } from './lib/window-helpers';
 import { ifit, ifdescribe, 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';
 
 const features = process._linkedBinding('electron_common_features');
 const v8Util = process._linkedBinding('electron_common_v8_util');

Some files were not shown because too many files changed in this diff