refactor: use node scheme imports in spec (#38487)
Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
bf1ba4a857
commit
d78f37ec8f
105 changed files with 533 additions and 352 deletions
2
spec/fixtures/api/close.html
vendored
2
spec/fixtures/api/close.html
vendored
|
@ -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,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
let win;
|
||||
app.whenReady().then(function () {
|
||||
|
|
4
spec/fixtures/api/mixed-sandbox-app/main.js
vendored
4
spec/fixtures/api/mixed-sandbox-app/main.js
vendored
|
@ -1,6 +1,6 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const net = require('net');
|
||||
const path = require('path');
|
||||
const net = require('node:net');
|
||||
const path = require('node:path');
|
||||
|
||||
process.on('uncaughtException', () => {
|
||||
app.exit(1);
|
||||
|
|
2
spec/fixtures/api/relaunch/main.js
vendored
2
spec/fixtures/api/relaunch/main.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const { app } = require('electron');
|
||||
const net = require('net');
|
||||
const net = require('node:net');
|
||||
|
||||
const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch';
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
4
spec/fixtures/api/singleton-userdata/main.js
vendored
4
spec/fixtures/api/singleton-userdata/main.js
vendored
|
@ -1,6 +1,6 @@
|
|||
const { app } = require('electron');
|
||||
const 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
|
||||
|
|
2
spec/fixtures/api/unload.html
vendored
2
spec/fixtures/api/unload.html
vendored
|
@ -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,5 +1,5 @@
|
|||
const { app, utilityProcess } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
let child = null;
|
||||
|
|
|
@ -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,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');
|
||||
|
|
2
spec/fixtures/api/utility-process/suid.js
vendored
2
spec/fixtures/api/utility-process/suid.js
vendored
|
@ -1,2 +1,2 @@
|
|||
const result = require('child_process').execSync('sudo --help');
|
||||
const result = require('node:child_process').execSync('sudo --help');
|
||||
process.parentPort.postMessage(result);
|
||||
|
|
4
spec/fixtures/apps/crash/fork.js
vendored
4
spec/fixtures/apps/crash/fork.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const path = require('path');
|
||||
const 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 });
|
||||
|
|
4
spec/fixtures/apps/crash/main.js
vendored
4
spec/fixtures/apps/crash/main.js
vendored
|
@ -1,6 +1,6 @@
|
|||
const { app, BrowserWindow, crashReporter } = require('electron');
|
||||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const path = require('node:path');
|
||||
const childProcess = require('node:child_process');
|
||||
|
||||
app.setVersion('0.1.0');
|
||||
|
||||
|
|
4
spec/fixtures/apps/crash/node-extra-args.js
vendored
4
spec/fixtures/apps/crash/node-extra-args.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const path = require('path');
|
||||
const childProcess = require('child_process');
|
||||
const path = require('node:path');
|
||||
const childProcess = require('node:child_process');
|
||||
|
||||
process.on('message', function () {
|
||||
process.send(process.argv);
|
||||
|
|
2
spec/fixtures/apps/libuv-hang/main.js
vendored
2
spec/fixtures/apps/libuv-hang/main.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
async function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
2
spec/fixtures/apps/libuv-hang/preload.js
vendored
2
spec/fixtures/apps/libuv-hang/preload.js
vendored
|
@ -3,7 +3,7 @@ const { contextBridge, ipcRenderer } = require('electron');
|
|||
contextBridge.exposeInMainWorld('api', {
|
||||
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,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
async function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
6
spec/fixtures/apps/remote-control/main.js
vendored
6
spec/fixtures/apps/remote-control/main.js
vendored
|
@ -1,8 +1,8 @@
|
|||
const { app } = require('electron');
|
||||
const 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
|
||||
|
|
2
spec/fixtures/apps/self-module-paths/main.js
vendored
2
spec/fixtures/apps/self-module-paths/main.js
vendored
|
@ -1,6 +1,6 @@
|
|||
// Modules to control application life and create native browser window
|
||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
|
2
spec/fixtures/apps/set-path/main.js
vendored
2
spec/fixtures/apps/set-path/main.js
vendored
|
@ -1,4 +1,4 @@
|
|||
const http = require('http');
|
||||
const http = require('node:http');
|
||||
const { app, ipcMain, BrowserWindow } = require('electron');
|
||||
|
||||
if (process.argv.length > 3) {
|
||||
|
|
2
spec/fixtures/apps/xwindow-icon/main.js
vendored
2
spec/fixtures/apps/xwindow-icon/main.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const w = new BrowserWindow({
|
||||
|
|
|
@ -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);
|
||||
|
|
4
spec/fixtures/auto-update/update/index.js
vendored
4
spec/fixtures/auto-update/update/index.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error(err);
|
||||
|
|
|
@ -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,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,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";
|
||||
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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,5 +1,5 @@
|
|||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow({
|
||||
|
|
2
spec/fixtures/module/asar.js
vendored
2
spec/fixtures/module/asar.js
vendored
|
@ -1,4 +1,4 @@
|
|||
const fs = require('fs');
|
||||
const fs = require('node:fs');
|
||||
process.on('message', function (file) {
|
||||
process.send(fs.readFileSync(file).toString());
|
||||
});
|
||||
|
|
2
spec/fixtures/module/create_socket.js
vendored
2
spec/fixtures/module/create_socket.js
vendored
|
@ -1,4 +1,4 @@
|
|||
const net = require('net');
|
||||
const net = require('node:net');
|
||||
const server = net.createServer(function () {});
|
||||
server.listen(process.argv[2]);
|
||||
process.exit(0);
|
||||
|
|
4
spec/fixtures/module/fork_ping.js
vendored
4
spec/fixtures/module/fork_ping.js
vendored
|
@ -1,10 +1,10 @@
|
|||
const path = require('path');
|
||||
const path = require('node:path');
|
||||
|
||||
process.on('uncaughtException', function (error) {
|
||||
process.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);
|
||||
});
|
||||
|
|
6
spec/fixtures/module/inspector-binding.js
vendored
6
spec/fixtures/module/inspector-binding.js
vendored
|
@ -1,6 +1,6 @@
|
|||
const inspector = require('inspector');
|
||||
const 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 () {
|
||||
|
|
4
spec/fixtures/module/no-asar.js
vendored
4
spec/fixtures/module/no-asar.js
vendored
|
@ -1,5 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const stats = fs.statSync(path.join(__dirname, '..', 'test.asar', 'a.asar'));
|
||||
|
||||
|
|
2
spec/fixtures/module/preload-eventemitter.js
vendored
2
spec/fixtures/module/preload-eventemitter.js
vendored
|
@ -1,5 +1,5 @@
|
|||
(function () {
|
||||
const { EventEmitter } = require('events');
|
||||
const { EventEmitter } = require('node:events');
|
||||
const emitter = new EventEmitter();
|
||||
const rendererEventEmitterProperties = [];
|
||||
let currentObj = emitter;
|
||||
|
|
5
spec/fixtures/module/preload-sandbox.js
vendored
5
spec/fixtures/module/preload-sandbox.js
vendored
|
@ -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,
|
||||
|
|
2
spec/fixtures/no-proprietary-codecs.js
vendored
2
spec/fixtures/no-proprietary-codecs.js
vendored
|
@ -5,7 +5,7 @@
|
|||
// that does include proprietary codecs.
|
||||
|
||||
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;
|
||||
|
|
2
spec/fixtures/pages/native-module.html
vendored
2
spec/fixtures/pages/native-module.html
vendored
|
@ -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>
|
||||
|
|
2
spec/fixtures/pages/send-after-node.html
vendored
2
spec/fixtures/pages/send-after-node.html
vendored
|
@ -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,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)
|
||||
|
|
6
spec/fixtures/test.asar/repack.js
vendored
6
spec/fixtures/test.asar/repack.js
vendored
|
@ -2,9 +2,9 @@
|
|||
// using a new version of the asar package
|
||||
|
||||
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)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue