diff --git a/.eslintrc.json b/.eslintrc.json index 0e448b6bd30a..2bec582ff6fa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,7 +19,40 @@ "prefer-const": ["error", { "destructuring": "all" }], - "n/no-callback-literal": "off" + "n/no-callback-literal": "off", + "import/newline-after-import": "error", + "import/order": ["error", { + "alphabetize": { + "order": "asc" + }, + "newlines-between": "always", + "pathGroups": [ + { + "pattern": "@electron/internal/**", + "group": "external", + "position": "before" + }, + { + "pattern": "@electron/**", + "group": "external", + "position": "before" + }, + { + "pattern": "{electron,electron/**}", + "group": "external", + "position": "before" + } + ], + "pathGroupsExcludedImportTypes": [], + "distinctGroup": true, + "groups": [ + "external", + "builtin", + ["sibling", "parent"], + "index", + "type" + ] + }] }, "parserOptions": { "ecmaVersion": 6, diff --git a/build/webpack/webpack.config.base.js b/build/webpack/webpack.config.base.js index 9a8a164dd619..b806e43535ce 100644 --- a/build/webpack/webpack.config.base.js +++ b/build/webpack/webpack.config.base.js @@ -1,8 +1,9 @@ +const TerserPlugin = require('terser-webpack-plugin'); +const webpack = require('webpack'); +const WrapperPlugin = require('wrapper-webpack-plugin'); + const fs = require('node:fs'); const path = require('node:path'); -const webpack = require('webpack'); -const TerserPlugin = require('terser-webpack-plugin'); -const WrapperPlugin = require('wrapper-webpack-plugin'); const electronRoot = path.resolve(__dirname, '../..'); diff --git a/default_app/default_app.ts b/default_app/default_app.ts index 6a521b9d62be..6cd280bb555c 100644 --- a/default_app/default_app.ts +++ b/default_app/default_app.ts @@ -1,5 +1,6 @@ import { shell } from 'electron/common'; import { app, dialog, BrowserWindow, ipcMain } from 'electron/main'; + import * as path from 'node:path'; import * as url from 'node:url'; diff --git a/default_app/main.ts b/default_app/main.ts index 9062cfca8e55..4c3f35719c11 100644 --- a/default_app/main.ts +++ b/default_app/main.ts @@ -4,6 +4,7 @@ import * as fs from 'node:fs'; import { Module } from 'node:module'; import * as path from 'node:path'; import * as url from 'node:url'; + const { app, dialog } = electron; type DefaultAppOptions = { diff --git a/lib/browser/api/app.ts b/lib/browser/api/app.ts index f952dcd0194b..20dbec908fa1 100644 --- a/lib/browser/api/app.ts +++ b/lib/browser/api/app.ts @@ -1,7 +1,7 @@ -import * as fs from 'fs'; - import { Menu } from 'electron/main'; +import * as fs from 'fs'; + const bindings = process._linkedBinding('electron_browser_app'); const commandLine = process._linkedBinding('electron_common_command_line'); const { app } = bindings; diff --git a/lib/browser/api/auto-updater/auto-updater-win.ts b/lib/browser/api/auto-updater/auto-updater-win.ts index 4b2bac16c0c0..255049cec3f8 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.ts +++ b/lib/browser/api/auto-updater/auto-updater-win.ts @@ -1,7 +1,9 @@ -import { app } from 'electron/main'; -import { EventEmitter } from 'events'; import * as squirrelUpdate from '@electron/internal/browser/api/auto-updater/squirrel-update-win'; +import { app } from 'electron/main'; + +import { EventEmitter } from 'events'; + class AutoUpdater extends EventEmitter implements Electron.AutoUpdater { updateAvailable: boolean = false; updateURL: string | null = null; diff --git a/lib/browser/api/auto-updater/squirrel-update-win.ts b/lib/browser/api/auto-updater/squirrel-update-win.ts index 07dead8ad74d..12f26fe25ad2 100644 --- a/lib/browser/api/auto-updater/squirrel-update-win.ts +++ b/lib/browser/api/auto-updater/squirrel-update-win.ts @@ -1,6 +1,6 @@ +import { spawn, ChildProcessWithoutNullStreams } from 'child_process'; import * as fs from 'fs'; import * as path from 'path'; -import { spawn, ChildProcessWithoutNullStreams } from 'child_process'; // i.e. my-app/app-0.1.13/ const appFolder = path.dirname(process.execPath); diff --git a/lib/browser/api/base-window.ts b/lib/browser/api/base-window.ts index 8d9c5899da98..d12c0f5ad591 100644 --- a/lib/browser/api/base-window.ts +++ b/lib/browser/api/base-window.ts @@ -1,6 +1,7 @@ -import { EventEmitter } from 'events'; -import type { BaseWindow as TLWT } from 'electron/main'; import { TouchBar } from 'electron/main'; +import type { BaseWindow as TLWT } from 'electron/main'; + +import { EventEmitter } from 'events'; const { BaseWindow } = process._linkedBinding('electron_browser_base_window') as { BaseWindow: typeof TLWT }; diff --git a/lib/browser/api/browser-window.ts b/lib/browser/api/browser-window.ts index ec6b99e14179..19a98c17565e 100644 --- a/lib/browser/api/browser-window.ts +++ b/lib/browser/api/browser-window.ts @@ -1,5 +1,6 @@ import { BaseWindow, WebContents, BrowserView } from 'electron/main'; import type { BrowserWindow as BWT } from 'electron/main'; + const { BrowserWindow } = process._linkedBinding('electron_browser_window') as { BrowserWindow: typeof BWT }; Object.setPrototypeOf(BrowserWindow.prototype, BaseWindow.prototype); diff --git a/lib/browser/api/crash-reporter.ts b/lib/browser/api/crash-reporter.ts index 036ab47906c4..ae7744d5c60a 100644 --- a/lib/browser/api/crash-reporter.ts +++ b/lib/browser/api/crash-reporter.ts @@ -1,6 +1,7 @@ -import { app } from 'electron/main'; import * as deprecate from '@electron/internal/common/deprecate'; +import { app } from 'electron/main'; + const binding = process._linkedBinding('electron_browser_crash_reporter'); class CrashReporter implements Electron.CrashReporter { diff --git a/lib/browser/api/desktop-capturer.ts b/lib/browser/api/desktop-capturer.ts index 6b9720510f52..4d950169ab95 100644 --- a/lib/browser/api/desktop-capturer.ts +++ b/lib/browser/api/desktop-capturer.ts @@ -1,4 +1,5 @@ import { BrowserWindow } from 'electron/main'; + const { createDesktopCapturer } = process._linkedBinding('electron_browser_desktop_capturer'); const deepEqual = (a: ElectronInternal.GetSourcesOptions, b: ElectronInternal.GetSourcesOptions) => JSON.stringify(a) === JSON.stringify(b); diff --git a/lib/browser/api/dialog.ts b/lib/browser/api/dialog.ts index d7d79ca9aee1..04d95238c869 100644 --- a/lib/browser/api/dialog.ts +++ b/lib/browser/api/dialog.ts @@ -1,5 +1,6 @@ import { app, BaseWindow } from 'electron/main'; import type { OpenDialogOptions, OpenDialogReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, MessageBoxReturnValue, CertificateTrustDialogOptions } from 'electron/main'; + const dialogBinding = process._linkedBinding('electron_browser_dialog'); enum SaveFileDialogProperties { diff --git a/lib/browser/api/exports/electron.ts b/lib/browser/api/exports/electron.ts index 904de54f6983..d4bc2b5cd948 100644 --- a/lib/browser/api/exports/electron.ts +++ b/lib/browser/api/exports/electron.ts @@ -1,6 +1,6 @@ -import { defineProperties } from '@electron/internal/common/define-properties'; -import { commonModuleList } from '@electron/internal/common/api/module-list'; import { browserModuleList } from '@electron/internal/browser/api/module-list'; +import { commonModuleList } from '@electron/internal/common/api/module-list'; +import { defineProperties } from '@electron/internal/common/define-properties'; module.exports = {}; diff --git a/lib/browser/api/menu-item.ts b/lib/browser/api/menu-item.ts index ae74948064ae..1ff4836caf30 100644 --- a/lib/browser/api/menu-item.ts +++ b/lib/browser/api/menu-item.ts @@ -1,4 +1,5 @@ import * as roles from '@electron/internal/browser/api/menu-item-roles'; + import { Menu, BaseWindow, WebContents, KeyboardEvent } from 'electron/main'; let nextCommandId = 0; diff --git a/lib/browser/api/menu.ts b/lib/browser/api/menu.ts index 48a7f475b1c1..c0244cc3c1bf 100644 --- a/lib/browser/api/menu.ts +++ b/lib/browser/api/menu.ts @@ -1,7 +1,8 @@ -import { BaseWindow, MenuItem, webContents, Menu as MenuType, MenuItemConstructorOptions } from 'electron/main'; import { sortMenuItems } from '@electron/internal/browser/api/menu-utils'; import { setApplicationMenuWasSet } from '@electron/internal/browser/default-menu'; +import { BaseWindow, MenuItem, webContents, Menu as MenuType, MenuItemConstructorOptions } from 'electron/main'; + const bindings = process._linkedBinding('electron_browser_menu'); const { Menu } = bindings as { Menu: typeof MenuType }; diff --git a/lib/browser/api/message-channel.ts b/lib/browser/api/message-channel.ts index 93fe3e83fcd0..1a6b967e35ed 100644 --- a/lib/browser/api/message-channel.ts +++ b/lib/browser/api/message-channel.ts @@ -1,5 +1,7 @@ import { MessagePortMain } from '@electron/internal/browser/message-port-main'; + import { EventEmitter } from 'events'; + const { createPair } = process._linkedBinding('electron_browser_message_port'); export default class MessageChannelMain extends EventEmitter implements Electron.MessageChannelMain { diff --git a/lib/browser/api/net-fetch.ts b/lib/browser/api/net-fetch.ts index 4f44f2cc4223..54fdc788d6c6 100644 --- a/lib/browser/api/net-fetch.ts +++ b/lib/browser/api/net-fetch.ts @@ -1,7 +1,9 @@ -import { ClientRequestConstructorOptions, ClientRequest, IncomingMessage, Session as SessionT } from 'electron/main'; -import { Readable, Writable, isReadable } from 'stream'; import { allowAnyProtocol } from '@electron/internal/common/api/net-client-request'; +import { ClientRequestConstructorOptions, ClientRequest, IncomingMessage, Session as SessionT } from 'electron/main'; + +import { Readable, Writable, isReadable } from 'stream'; + function createDeferredPromise (): { promise: Promise; resolve: (x: T) => void; reject: (e: E) => void; } { let res: (x: T) => void; let rej: (e: E) => void; diff --git a/lib/browser/api/net.ts b/lib/browser/api/net.ts index dd824c990f8f..b806aef95e30 100644 --- a/lib/browser/api/net.ts +++ b/lib/browser/api/net.ts @@ -1,6 +1,7 @@ +import { ClientRequest } from '@electron/internal/common/api/net-client-request'; + import { app, IncomingMessage, session } from 'electron/main'; import type { ClientRequestConstructorOptions } from 'electron/main'; -import { ClientRequest } from '@electron/internal/common/api/net-client-request'; const { isOnline } = process._linkedBinding('electron_common_net'); diff --git a/lib/browser/api/protocol.ts b/lib/browser/api/protocol.ts index 1b7f00b433c0..cb6a1492eb22 100644 --- a/lib/browser/api/protocol.ts +++ b/lib/browser/api/protocol.ts @@ -1,4 +1,5 @@ import { ProtocolRequest, session } from 'electron/main'; + import { createReadStream } from 'fs'; import { Readable } from 'stream'; import { ReadableStream } from 'stream/web'; diff --git a/lib/browser/api/session.ts b/lib/browser/api/session.ts index 5f9343c1bd30..ccdd17910edb 100644 --- a/lib/browser/api/session.ts +++ b/lib/browser/api/session.ts @@ -1,5 +1,7 @@ import { fetchWithSession } from '@electron/internal/browser/api/net-fetch'; + import { net } from 'electron/main'; + const { fromPartition, fromPath, Session } = process._linkedBinding('electron_browser_session'); Session.prototype.fetch = function (input: RequestInfo, init?: RequestInit) { diff --git a/lib/browser/api/share-menu.ts b/lib/browser/api/share-menu.ts index 1a339a16614c..a296500390c9 100644 --- a/lib/browser/api/share-menu.ts +++ b/lib/browser/api/share-menu.ts @@ -1,4 +1,5 @@ import { BrowserWindow, Menu, SharingItem, PopupOptions } from 'electron/main'; + import { EventEmitter } from 'events'; class ShareMenu extends EventEmitter implements Electron.ShareMenu { diff --git a/lib/browser/api/utility-process.ts b/lib/browser/api/utility-process.ts index bee8f1032aaa..626ba1643cd5 100644 --- a/lib/browser/api/utility-process.ts +++ b/lib/browser/api/utility-process.ts @@ -1,7 +1,9 @@ -import { EventEmitter } from 'events'; -import { Duplex, PassThrough } from 'stream'; -import { Socket } from 'net'; import { MessagePortMain } from '@electron/internal/browser/message-port-main'; + +import { EventEmitter } from 'events'; +import { Socket } from 'net'; +import { Duplex, PassThrough } from 'stream'; + const { _fork } = process._linkedBinding('electron_browser_utility_process'); class ForkUtilityProcess extends EventEmitter implements Electron.UtilityProcess { diff --git a/lib/browser/api/view.ts b/lib/browser/api/view.ts index 2cdf5b590466..581b937d7e63 100644 --- a/lib/browser/api/view.ts +++ b/lib/browser/api/view.ts @@ -1,4 +1,5 @@ import { EventEmitter } from 'events'; + const { View } = process._linkedBinding('electron_browser_view'); Object.setPrototypeOf((View as any).prototype, EventEmitter.prototype); diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index f37f03e0a47c..e107bbef7614 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -1,16 +1,17 @@ -import { app, ipcMain, session, webFrameMain, dialog } from 'electron/main'; -import type { BrowserWindowConstructorOptions, MessageBoxOptions } from 'electron/main'; - -import * as url from 'url'; -import * as path from 'path'; import { openGuestWindow, makeWebPreferences, parseContentTypeFormat } from '@electron/internal/browser/guest-window-manager'; -import { parseFeatures } from '@electron/internal/browser/parse-features-string'; +import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl'; import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; import { MessagePortMain } from '@electron/internal/browser/message-port-main'; -import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; -import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl'; +import { parseFeatures } from '@electron/internal/browser/parse-features-string'; import * as deprecate from '@electron/internal/common/deprecate'; +import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; + +import { app, ipcMain, session, webFrameMain, dialog } from 'electron/main'; +import type { BrowserWindowConstructorOptions, MessageBoxOptions } from 'electron/main'; + +import * as path from 'path'; +import * as url from 'url'; // session is not used here, the purpose is to make sure session is initialized // before the webContents module. diff --git a/lib/browser/api/web-frame-main.ts b/lib/browser/api/web-frame-main.ts index 9212c797cb08..ce6023f843fd 100644 --- a/lib/browser/api/web-frame-main.ts +++ b/lib/browser/api/web-frame-main.ts @@ -1,5 +1,5 @@ -import { MessagePortMain } from '@electron/internal/browser/message-port-main'; import { IpcMainImpl } from '@electron/internal/browser/ipc-main-impl'; +import { MessagePortMain } from '@electron/internal/browser/message-port-main'; const { WebFrameMain, fromId } = process._linkedBinding('electron_browser_web_frame_main'); diff --git a/lib/browser/default-menu.ts b/lib/browser/default-menu.ts index 16eef15fbee2..0cef9aa5c8ca 100644 --- a/lib/browser/default-menu.ts +++ b/lib/browser/default-menu.ts @@ -1,5 +1,5 @@ -import { app, Menu } from 'electron/main'; import { shell } from 'electron/common'; +import { app, Menu } from 'electron/main'; const isMac = process.platform === 'darwin'; diff --git a/lib/browser/devtools.ts b/lib/browser/devtools.ts index 47e9272a7bfc..f9cd52077af5 100644 --- a/lib/browser/devtools.ts +++ b/lib/browser/devtools.ts @@ -1,9 +1,10 @@ -import { dialog, Menu } from 'electron/main'; -import * as fs from 'fs'; - +import { IPC_MESSAGES } from '@electron/internal//common/ipc-messages'; import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; -import { IPC_MESSAGES } from '@electron/internal//common/ipc-messages'; + +import { dialog, Menu } from 'electron/main'; + +import * as fs from 'fs'; const convertToMenuTemplate = function (items: ContextMenuItem[], handler: (id: number) => void) { return items.map(function (item) { diff --git a/lib/browser/guest-view-manager.ts b/lib/browser/guest-view-manager.ts index 20cd98c7104f..51cd74162adb 100644 --- a/lib/browser/guest-view-manager.ts +++ b/lib/browser/guest-view-manager.ts @@ -1,10 +1,11 @@ -import { webContents } from 'electron/main'; import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; import { parseWebViewWebPreferences } from '@electron/internal/browser/parse-features-string'; -import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods'; import { webViewEvents } from '@electron/internal/browser/web-view-events'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods'; + +import { webContents } from 'electron/main'; interface GuestInstance { elementInstanceId: number; diff --git a/lib/browser/guest-window-manager.ts b/lib/browser/guest-window-manager.ts index 65526e1c5a92..3f7ddc303666 100644 --- a/lib/browser/guest-window-manager.ts +++ b/lib/browser/guest-window-manager.ts @@ -5,9 +5,10 @@ * out-of-process (cross-origin) are created here. "Embedder" roughly means * "parent." */ +import { parseFeatures } from '@electron/internal/browser/parse-features-string'; + import { BrowserWindow } from 'electron/main'; import type { BrowserWindowConstructorOptions, Referrer, WebContents, LoadURLOptions } from 'electron/main'; -import { parseFeatures } from '@electron/internal/browser/parse-features-string'; type PostData = LoadURLOptions['postData'] export type WindowOpenArgs = { diff --git a/lib/browser/init.ts b/lib/browser/init.ts index 49922ae57267..cba94237b769 100644 --- a/lib/browser/init.ts +++ b/lib/browser/init.ts @@ -1,8 +1,9 @@ +import type * as defaultMenuModule from '@electron/internal/browser/default-menu'; + import { EventEmitter } from 'events'; import * as fs from 'fs'; import * as path from 'path'; -import type * as defaultMenuModule from '@electron/internal/browser/default-menu'; import type * as url from 'url'; import type * as v8 from 'v8'; diff --git a/lib/browser/ipc-main-impl.ts b/lib/browser/ipc-main-impl.ts index f3088d93a5a7..e80739104b9d 100644 --- a/lib/browser/ipc-main-impl.ts +++ b/lib/browser/ipc-main-impl.ts @@ -1,6 +1,7 @@ -import { EventEmitter } from 'events'; import { IpcMainInvokeEvent } from 'electron/main'; +import { EventEmitter } from 'events'; + export class IpcMainImpl extends EventEmitter implements Electron.IpcMain { private _invokeHandlers: Map void> = new Map(); diff --git a/lib/browser/rpc-server.ts b/lib/browser/rpc-server.ts index 48e6ca16b595..4eef7baa1f5d 100644 --- a/lib/browser/rpc-server.ts +++ b/lib/browser/rpc-server.ts @@ -1,9 +1,11 @@ -import { clipboard } from 'electron/common'; -import * as fs from 'fs'; import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +import { clipboard } from 'electron/common'; + +import * as fs from 'fs'; + // Implements window.close() ipcMainInternal.on(IPC_MESSAGES.BROWSER_WINDOW_CLOSE, function (event) { const window = event.sender.getOwnerBrowserWindow(); diff --git a/lib/common/api/net-client-request.ts b/lib/common/api/net-client-request.ts index 05622af6a8f1..1a087ae47647 100644 --- a/lib/common/api/net-client-request.ts +++ b/lib/common/api/net-client-request.ts @@ -1,10 +1,11 @@ -import * as url from 'url'; -import { Readable, Writable } from 'stream'; import type { ClientRequestConstructorOptions, UploadProgress } from 'electron/common'; +import { Readable, Writable } from 'stream'; +import * as url from 'url'; + const { isValidHeaderName, isValidHeaderValue, diff --git a/lib/common/init.ts b/lib/common/init.ts index 9032ed9994be..d6ad120eb931 100644 --- a/lib/common/init.ts +++ b/lib/common/init.ts @@ -1,7 +1,7 @@ -import * as util from 'util'; -import type * as stream from 'stream'; - import timers = require('timers'); +import * as util from 'util'; + +import type * as stream from 'stream'; type AnyFn = (...args: any[]) => any diff --git a/lib/node/init.ts b/lib/node/init.ts index 12c908a60739..8857eabb6bb0 100644 --- a/lib/node/init.ts +++ b/lib/node/init.ts @@ -1,3 +1,5 @@ +/* eslint-disable import/newline-after-import */ +/* eslint-disable import/order */ // Initialize ASAR support in fs module. import { wrapFsWithAsar } from './asar-fs-wrapper'; wrapFsWithAsar(require('fs')); diff --git a/lib/renderer/api/exports/electron.ts b/lib/renderer/api/exports/electron.ts index 13ea2fc57a20..d50bc9edbd9b 100644 --- a/lib/renderer/api/exports/electron.ts +++ b/lib/renderer/api/exports/electron.ts @@ -1,5 +1,5 @@ -import { defineProperties } from '@electron/internal/common/define-properties'; import { commonModuleList } from '@electron/internal/common/api/module-list'; +import { defineProperties } from '@electron/internal/common/define-properties'; import { rendererModuleList } from '@electron/internal/renderer/api/module-list'; module.exports = {}; diff --git a/lib/renderer/common-init.ts b/lib/renderer/common-init.ts index 4910ca667166..c944125f9feb 100644 --- a/lib/renderer/common-init.ts +++ b/lib/renderer/common-init.ts @@ -1,10 +1,10 @@ -import { ipcRenderer } from 'electron/renderer'; import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; - +import type * as securityWarningsModule from '@electron/internal/renderer/security-warnings'; +import type * as webFrameInitModule from '@electron/internal/renderer/web-frame-init'; import type * as webViewInitModule from '@electron/internal/renderer/web-view/web-view-init'; import type * as windowSetupModule from '@electron/internal/renderer/window-setup'; -import type * as webFrameInitModule from '@electron/internal/renderer/web-frame-init'; -import type * as securityWarningsModule from '@electron/internal/renderer/security-warnings'; + +import { ipcRenderer } from 'electron/renderer'; const { mainFrame } = process._linkedBinding('electron_renderer_web_frame'); const v8Util = process._linkedBinding('electron_common_v8_util'); @@ -49,6 +49,7 @@ if (process.isMainFrame) { } const { webFrameInit } = require('@electron/internal/renderer/web-frame-init') as typeof webFrameInitModule; + webFrameInit(); // Warn about security issues diff --git a/lib/renderer/init.ts b/lib/renderer/init.ts index 8be38b26e5fa..7d53e0b79201 100644 --- a/lib/renderer/init.ts +++ b/lib/renderer/init.ts @@ -1,10 +1,10 @@ -import * as path from 'path'; -import { pathToFileURL } from 'url'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; - import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal'; import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils'; +import * as path from 'path'; +import { pathToFileURL } from 'url'; + const Module = require('module') as NodeJS.ModuleInternal; // We do not want to allow use of the VM module in the renderer process as diff --git a/lib/renderer/inspector.ts b/lib/renderer/inspector.ts index 8dd941d30619..023c4ee36b48 100644 --- a/lib/renderer/inspector.ts +++ b/lib/renderer/inspector.ts @@ -1,8 +1,9 @@ +import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; import { internalContextBridge } from '@electron/internal/renderer/api/context-bridge'; import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'; + import { webFrame } from 'electron/renderer'; -import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; const { contextIsolationEnabled } = internalContextBridge; diff --git a/lib/renderer/security-warnings.ts b/lib/renderer/security-warnings.ts index 619641d20edc..1065048a4596 100644 --- a/lib/renderer/security-warnings.ts +++ b/lib/renderer/security-warnings.ts @@ -1,5 +1,5 @@ -import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; const { mainFrame: webFrame } = process._linkedBinding('electron_renderer_web_frame'); diff --git a/lib/renderer/web-frame-init.ts b/lib/renderer/web-frame-init.ts index ac4db7f9a74d..47bf2ea28125 100644 --- a/lib/renderer/web-frame-init.ts +++ b/lib/renderer/web-frame-init.ts @@ -1,6 +1,7 @@ -import { webFrame, WebFrame } from 'electron/renderer'; -import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'; + +import { webFrame, WebFrame } from 'electron/renderer'; // All keys of WebFrame that extend Function type WebFrameMethod = { diff --git a/lib/renderer/web-view/guest-view-internal.ts b/lib/renderer/web-view/guest-view-internal.ts index e6d25d51790c..ba38adfefa5d 100644 --- a/lib/renderer/web-view/guest-view-internal.ts +++ b/lib/renderer/web-view/guest-view-internal.ts @@ -1,6 +1,6 @@ +import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'; -import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; const { mainFrame: webFrame } = process._linkedBinding('electron_renderer_web_frame'); diff --git a/lib/renderer/web-view/web-view-attributes.ts b/lib/renderer/web-view/web-view-attributes.ts index 66d17209a222..18cc238d3f40 100644 --- a/lib/renderer/web-view/web-view-attributes.ts +++ b/lib/renderer/web-view/web-view-attributes.ts @@ -1,5 +1,5 @@ -import type { WebViewImpl } from '@electron/internal/renderer/web-view/web-view-impl'; import { WEB_VIEW_ATTRIBUTES, WEB_VIEW_ERROR_MESSAGES } from '@electron/internal/renderer/web-view/web-view-constants'; +import type { WebViewImpl } from '@electron/internal/renderer/web-view/web-view-impl'; const resolveURL = function (url?: string | null) { return url ? new URL(url, location.href).href : ''; diff --git a/lib/renderer/web-view/web-view-element.ts b/lib/renderer/web-view/web-view-element.ts index 7d2dd14a3f32..6f6419769862 100644 --- a/lib/renderer/web-view/web-view-element.ts +++ b/lib/renderer/web-view/web-view-element.ts @@ -8,9 +8,9 @@ // which runs in browserify environment instead of Node environment, all native // modules must be passed from outside, all included files must be plain JS. +import type { SrcAttribute } from '@electron/internal/renderer/web-view/web-view-attributes'; import { WEB_VIEW_ATTRIBUTES, WEB_VIEW_ERROR_MESSAGES } from '@electron/internal/renderer/web-view/web-view-constants'; import { WebViewImpl, WebViewImplHooks, setupMethods } from '@electron/internal/renderer/web-view/web-view-impl'; -import type { SrcAttribute } from '@electron/internal/renderer/web-view/web-view-attributes'; const internals = new WeakMap(); diff --git a/lib/renderer/web-view/web-view-impl.ts b/lib/renderer/web-view/web-view-impl.ts index f5ca329d638f..a82e86af4399 100644 --- a/lib/renderer/web-view/web-view-impl.ts +++ b/lib/renderer/web-view/web-view-impl.ts @@ -1,8 +1,8 @@ -import type * as guestViewInternalModule from '@electron/internal/renderer/web-view/guest-view-internal'; -import { WEB_VIEW_ATTRIBUTES } from '@electron/internal/renderer/web-view/web-view-constants'; import { syncMethods, asyncMethods, properties } from '@electron/internal/common/web-view-methods'; +import type * as guestViewInternalModule from '@electron/internal/renderer/web-view/guest-view-internal'; import type { WebViewAttribute, PartitionAttribute } from '@electron/internal/renderer/web-view/web-view-attributes'; import { setupWebViewAttributes } from '@electron/internal/renderer/web-view/web-view-attributes'; +import { WEB_VIEW_ATTRIBUTES } from '@electron/internal/renderer/web-view/web-view-constants'; // ID generator. let nextId = 0; diff --git a/lib/renderer/web-view/web-view-init.ts b/lib/renderer/web-view/web-view-init.ts index 29ca6cc959f2..c918800273a5 100644 --- a/lib/renderer/web-view/web-view-init.ts +++ b/lib/renderer/web-view/web-view-init.ts @@ -1,8 +1,7 @@ -import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; - -import type * as webViewElementModule from '@electron/internal/renderer/web-view/web-view-element'; +import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; import type * as guestViewInternalModule from '@electron/internal/renderer/web-view/guest-view-internal'; +import type * as webViewElementModule from '@electron/internal/renderer/web-view/web-view-element'; const v8Util = process._linkedBinding('electron_common_v8_util'); const { mainFrame: webFrame } = process._linkedBinding('electron_renderer_web_frame'); diff --git a/lib/renderer/window-setup.ts b/lib/renderer/window-setup.ts index 9dc539edb6a5..9f48ea3941e5 100644 --- a/lib/renderer/window-setup.ts +++ b/lib/renderer/window-setup.ts @@ -1,6 +1,6 @@ -import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; -import { internalContextBridge } from '@electron/internal/renderer/api/context-bridge'; import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +import { internalContextBridge } from '@electron/internal/renderer/api/context-bridge'; +import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'; const { contextIsolationEnabled } = internalContextBridge; diff --git a/lib/sandboxed_renderer/init.ts b/lib/sandboxed_renderer/init.ts index 83ddf4a1bd6d..6762945a628e 100644 --- a/lib/sandboxed_renderer/init.ts +++ b/lib/sandboxed_renderer/init.ts @@ -1,9 +1,9 @@ +import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; +import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal'; +import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils'; + import * as events from 'events'; import { setImmediate, clearImmediate } from 'timers'; -import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; - -import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils'; -import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal'; declare const binding: { get: (name: string) => any; diff --git a/lib/utility/api/net.ts b/lib/utility/api/net.ts index b5237e8233fb..70228ee0e5f4 100644 --- a/lib/utility/api/net.ts +++ b/lib/utility/api/net.ts @@ -1,7 +1,8 @@ +import { fetchWithSession } from '@electron/internal/browser/api/net-fetch'; +import { ClientRequest } from '@electron/internal/common/api/net-client-request'; + import { IncomingMessage } from 'electron/utility'; import type { ClientRequestConstructorOptions } from 'electron/utility'; -import { ClientRequest } from '@electron/internal/common/api/net-client-request'; -import { fetchWithSession } from '@electron/internal/browser/api/net-fetch'; const { isOnline, resolveHost } = process._linkedBinding('electron_common_net'); diff --git a/lib/utility/init.ts b/lib/utility/init.ts index ddd935f483ac..1c7e5e8a4b4c 100644 --- a/lib/utility/init.ts +++ b/lib/utility/init.ts @@ -1,8 +1,8 @@ +import { ParentPort } from '@electron/internal/utility/parent-port'; + import { EventEmitter } from 'events'; import { pathToFileURL } from 'url'; -import { ParentPort } from '@electron/internal/utility/parent-port'; - const v8Util = process._linkedBinding('electron_common_v8_util'); const entryScript: string = v8Util.getHiddenValue(process, '_serviceStartupScript'); diff --git a/lib/utility/parent-port.ts b/lib/utility/parent-port.ts index 1ce54aac5d60..3cb484e3ad9d 100644 --- a/lib/utility/parent-port.ts +++ b/lib/utility/parent-port.ts @@ -1,5 +1,7 @@ -import { EventEmitter } from 'events'; import { MessagePortMain } from '@electron/internal/browser/message-port-main'; + +import { EventEmitter } from 'events'; + const { createParentPort } = process._linkedBinding('electron_utility_parent_port'); export class ParentPort extends EventEmitter implements Electron.ParentPort { diff --git a/npm/cli.js b/npm/cli.js index 09f4677bc93d..7dbb3d5a3c0c 100755 --- a/npm/cli.js +++ b/npm/cli.js @@ -1,9 +1,9 @@ #!/usr/bin/env node -const electron = require('./'); - const proc = require('child_process'); +const electron = require('./'); + const child = proc.spawn(electron, process.argv.slice(2), { stdio: 'inherit', windowsHide: false }); child.on('close', function (code, signal) { if (code === null) { diff --git a/npm/install.js b/npm/install.js index fcd765313364..a0c177dea416 100755 --- a/npm/install.js +++ b/npm/install.js @@ -1,13 +1,15 @@ #!/usr/bin/env node -const { version } = require('./package'); +const { downloadArtifact } = require('@electron/get'); + +const extract = require('extract-zip'); const childProcess = require('child_process'); const fs = require('fs'); const os = require('os'); const path = require('path'); -const extract = require('extract-zip'); -const { downloadArtifact } = require('@electron/get'); + +const { version } = require('./package'); if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) { process.exit(0); diff --git a/script/create-api-json.js b/script/create-api-json.js index 4f3b5ecfc22a..26198efc26d7 100644 --- a/script/create-api-json.js +++ b/script/create-api-json.js @@ -1,4 +1,5 @@ const { parseDocs } = require('@electron/docs-parser'); + const fs = require('node:fs'); const path = require('node:path'); diff --git a/script/doc-only-change.js b/script/doc-only-change.js index ace463d484d6..20333382e6ef 100644 --- a/script/doc-only-change.js +++ b/script/doc-only-change.js @@ -1,5 +1,8 @@ -const args = require('minimist')(process.argv.slice(2)); const { Octokit } = require('@octokit/rest'); +const minimist = require('minimist'); + +const args = minimist(process.argv.slice(2)); + const octokit = new Octokit(); async function checkIfDocOnlyChange () { diff --git a/script/generate-version-json.js b/script/generate-version-json.js index dcd69e2d11d2..df01d640bc47 100644 --- a/script/generate-version-json.js +++ b/script/generate-version-json.js @@ -1,6 +1,7 @@ -const fs = require('node:fs'); const semver = require('semver'); +const fs = require('node:fs'); + const outputPath = process.argv[2]; const currentVersion = process.argv[3]; diff --git a/script/gn-asar-hash.js b/script/gn-asar-hash.js index ad341cb2cd9e..86337d669ec1 100644 --- a/script/gn-asar-hash.js +++ b/script/gn-asar-hash.js @@ -1,4 +1,5 @@ const asar = require('@electron/asar'); + const crypto = require('node:crypto'); const fs = require('node:fs'); diff --git a/script/gn-asar.js b/script/gn-asar.js index 29a1b99108e0..717f7aaa2c1a 100644 --- a/script/gn-asar.js +++ b/script/gn-asar.js @@ -1,4 +1,5 @@ const asar = require('@electron/asar'); + const assert = require('node:assert'); const fs = require('node:fs'); const os = require('node:os'); diff --git a/script/gn-check.js b/script/gn-check.js index 54ba2b5b7d23..884dde58439f 100644 --- a/script/gn-check.js +++ b/script/gn-check.js @@ -4,9 +4,12 @@ Usage: $ node ./script/gn-check.js [--outDir=dirName] */ +const minimist = require('minimist'); + const cp = require('node:child_process'); const path = require('node:path'); -const args = require('minimist')(process.argv.slice(2), { string: ['outDir'] }); + +const args = minimist(process.argv.slice(2), { string: ['outDir'] }); const { getOutDir } = require('./lib/utils'); diff --git a/script/lib/azput.js b/script/lib/azput.js index e5e389b0ee42..6165817ef949 100644 --- a/script/lib/azput.js +++ b/script/lib/azput.js @@ -1,10 +1,13 @@ /* eslint-disable camelcase */ + const { BlobServiceClient } = require('@azure/storage-blob'); +const minimist = require('minimist'); + const path = require('node:path'); const blobServiceClient = BlobServiceClient.fromConnectionString(process.env.ELECTRON_ARTIFACTS_BLOB_STORAGE); -const args = require('minimist')(process.argv.slice(2)); +const args = minimist(process.argv.slice(2)); let { prefix = '/', key_prefix = '', _: files } = args; if (prefix && !prefix.endsWith(path.sep)) prefix = path.resolve(prefix) + path.sep; diff --git a/script/lib/utils.js b/script/lib/utils.js index 3684812ecd35..25521af9b4d5 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -1,5 +1,6 @@ const chalk = require('chalk'); const { GitProcess } = require('dugite'); + const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); diff --git a/script/lint.js b/script/lint.js index ad9a978011dc..695e116732df 100755 --- a/script/lint.js +++ b/script/lint.js @@ -1,14 +1,16 @@ #!/usr/bin/env node -const crypto = require('node:crypto'); -const { GitProcess } = require('dugite'); -const childProcess = require('node:child_process'); -const { ESLint } = require('eslint'); -const fs = require('node:fs'); -const minimist = require('minimist'); -const path = require('node:path'); const { getCodeBlocks } = require('@electron/lint-roller/dist/lib/markdown'); +const { GitProcess } = require('dugite'); +const { ESLint } = require('eslint'); +const minimist = require('minimist'); + +const childProcess = require('node:child_process'); +const crypto = require('node:crypto'); +const fs = require('node:fs'); +const path = require('node:path'); + const { chunkFilenames, findMatchingFiles } = require('./lib/utils'); const ELECTRON_ROOT = path.normalize(path.dirname(__dirname)); diff --git a/script/nan-spec-runner.js b/script/nan-spec-runner.js index 643954fe7cda..fd6b98ba7c93 100644 --- a/script/nan-spec-runner.js +++ b/script/nan-spec-runner.js @@ -1,3 +1,5 @@ +const minimist = require('minimist'); + const cp = require('node:child_process'); const fs = require('node:fs'); const path = require('node:path'); @@ -13,7 +15,7 @@ if (!require.main) { throw new Error('Must call the nan spec runner directly'); } -const args = require('minimist')(process.argv.slice(2), { +const args = minimist(process.argv.slice(2), { string: ['only'] }); diff --git a/script/node-spec-runner.js b/script/node-spec-runner.js index 3d904e9a669d..60564137910e 100644 --- a/script/node-spec-runner.js +++ b/script/node-spec-runner.js @@ -1,20 +1,23 @@ +const minimist = require('minimist'); + const cp = require('node:child_process'); const fs = require('node:fs'); const path = require('node:path'); -const args = require('minimist')(process.argv.slice(2), { +const utils = require('./lib/utils'); +const DISABLED_TESTS = require('./node-disabled-tests.json'); + +const args = minimist(process.argv.slice(2), { boolean: ['default', 'validateDisabled'], string: ['jUnitDir'] }); const BASE = path.resolve(__dirname, '../..'); -const DISABLED_TESTS = require('./node-disabled-tests.json'); + const NODE_DIR = path.resolve(BASE, 'third_party', 'electron_node'); const JUNIT_DIR = args.jUnitDir ? path.resolve(args.jUnitDir) : null; const TAP_FILE_NAME = 'test.tap'; -const utils = require('./lib/utils'); - if (!require.main) { throw new Error('Must call the node spec runner directly'); } diff --git a/script/prepare-appveyor.js b/script/prepare-appveyor.js index 9c9591ae8608..d1f610400463 100644 --- a/script/prepare-appveyor.js +++ b/script/prepare-appveyor.js @@ -1,9 +1,12 @@ +const { Octokit } = require('@octokit/rest'); +const got = require('got'); + const assert = require('node:assert'); const fs = require('node:fs'); -const got = require('got'); const path = require('node:path'); + const { handleGitCall, ELECTRON_DIR } = require('./lib/utils.js'); -const { Octokit } = require('@octokit/rest'); + const octokit = new Octokit(); const APPVEYOR_IMAGES_URL = 'https://ci.appveyor.com/api/build-clouds'; diff --git a/script/push-patch.js b/script/push-patch.js index 8a0296c4b9ba..b32f46c3ebaf 100644 --- a/script/push-patch.js +++ b/script/push-patch.js @@ -1,4 +1,5 @@ const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth'); + const cp = require('node:child_process'); async function main () { diff --git a/script/release/bin/cleanup-release.ts b/script/release/bin/cleanup-release.ts index 8f1420d2e3dc..a659031c39cb 100644 --- a/script/release/bin/cleanup-release.ts +++ b/script/release/bin/cleanup-release.ts @@ -1,4 +1,5 @@ import { parseArgs } from 'node:util'; + import { cleanReleaseArtifacts } from '../release-artifact-cleanup'; const { values: { tag: _tag, releaseID } } = parseArgs({ diff --git a/script/release/bin/publish-to-npm.ts b/script/release/bin/publish-to-npm.ts index 53c4634d1226..ddb067e395d9 100644 --- a/script/release/bin/publish-to-npm.ts +++ b/script/release/bin/publish-to-npm.ts @@ -1,13 +1,13 @@ import { Octokit } from '@octokit/rest'; -import * as childProcess from 'node:child_process'; -import * as fs from 'node:fs'; -import * as path from 'node:path'; import * as semver from 'semver'; import * as temp from 'temp'; -import { getCurrentBranch, ELECTRON_DIR } from '../../lib/utils'; -import { getElectronVersion } from '../../lib/get-version'; +import * as childProcess from 'node:child_process'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import { getElectronVersion } from '../../lib/get-version'; +import { getCurrentBranch, ELECTRON_DIR } from '../../lib/utils'; import { getAssetContents } from '../get-asset'; import { createGitHubTokenStrategy } from '../github-token'; import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from '../types'; diff --git a/script/release/find-github-release.ts b/script/release/find-github-release.ts index 4b625a05b116..830501e7e060 100644 --- a/script/release/find-github-release.ts +++ b/script/release/find-github-release.ts @@ -1,4 +1,5 @@ import { Octokit } from '@octokit/rest'; + import { createGitHubTokenStrategy } from './github-token'; import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from './types'; diff --git a/script/release/get-asset.ts b/script/release/get-asset.ts index 0a129f84c359..bc0ca69343da 100644 --- a/script/release/get-asset.ts +++ b/script/release/get-asset.ts @@ -1,5 +1,6 @@ import { Octokit } from '@octokit/rest'; import got from 'got'; + import { createGitHubTokenStrategy } from './github-token'; import { ELECTRON_ORG, ElectronReleaseRepo } from './types'; diff --git a/script/release/get-url-hash.ts b/script/release/get-url-hash.ts index 19e3fb3a6ceb..b4fc10b053b0 100644 --- a/script/release/get-url-hash.ts +++ b/script/release/get-url-hash.ts @@ -1,4 +1,5 @@ import got from 'got'; + import * as url from 'node:url'; const HASHER_FUNCTION_HOST = 'electron-artifact-hasher.azurewebsites.net'; diff --git a/script/release/notes/index.ts b/script/release/notes/index.ts index d993d1ba1d47..a6e7ebf01c3f 100755 --- a/script/release/notes/index.ts +++ b/script/release/notes/index.ts @@ -1,15 +1,15 @@ #!/usr/bin/env node +import { Octokit } from '@octokit/rest'; import { GitProcess } from 'dugite'; -import { basename } from 'node:path'; import { valid, compare, gte, lte } from 'semver'; -import { ELECTRON_DIR } from '../../lib/utils'; -import { get, render } from './notes'; - -import { Octokit } from '@octokit/rest'; -import { createGitHubTokenStrategy } from '../github-token'; +import { basename } from 'node:path'; import { parseArgs } from 'node:util'; + +import { get, render } from './notes'; +import { ELECTRON_DIR } from '../../lib/utils'; +import { createGitHubTokenStrategy } from '../github-token'; import { ELECTRON_ORG, ELECTRON_REPO } from '../types'; const octokit = new Octokit({ diff --git a/script/release/notes/notes.ts b/script/release/notes/notes.ts index 819c304fec32..009dbaccb941 100644 --- a/script/release/notes/notes.ts +++ b/script/release/notes/notes.ts @@ -1,11 +1,11 @@ #!/usr/bin/env node -import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'; -import { resolve as _resolve } from 'node:path'; - import { Octokit } from '@octokit/rest'; import { GitProcess } from 'dugite'; +import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'; +import { resolve as _resolve } from 'node:path'; + import { ELECTRON_DIR } from '../../lib/utils'; import { createGitHubTokenStrategy } from '../github-token'; import { ELECTRON_ORG, ELECTRON_REPO } from '../types'; diff --git a/script/release/prepare-release.ts b/script/release/prepare-release.ts index 269e3ea7ed88..b58e476369f9 100755 --- a/script/release/prepare-release.ts +++ b/script/release/prepare-release.ts @@ -1,14 +1,15 @@ import { Octokit } from '@octokit/rest'; import * as chalk from 'chalk'; import { GitProcess } from 'dugite'; + import { execSync } from 'node:child_process'; import { join } from 'node:path'; -import { runReleaseCIJobs } from './run-release-ci-jobs'; -import releaseNotesGenerator from './notes'; -import { getCurrentBranch, ELECTRON_DIR } from '../lib/utils.js'; import { createGitHubTokenStrategy } from './github-token'; +import releaseNotesGenerator from './notes'; +import { runReleaseCIJobs } from './run-release-ci-jobs'; import { ELECTRON_ORG, ElectronReleaseRepo, VersionBumpType } from './types'; +import { getCurrentBranch, ELECTRON_DIR } from '../lib/utils.js'; const pass = chalk.green('✓'); const fail = chalk.red('✗'); diff --git a/script/release/release.ts b/script/release/release.ts index 4fc9d1396c63..1438577fae8d 100755 --- a/script/release/release.ts +++ b/script/release/release.ts @@ -4,17 +4,18 @@ import { BlobServiceClient } from '@azure/storage-blob'; import { Octokit } from '@octokit/rest'; import * as chalk from 'chalk'; import got from 'got'; -import { execSync, ExecSyncOptions } from 'node:child_process'; -import { statSync, createReadStream, writeFileSync, close } from 'node:fs'; -import { join } from 'node:path'; import { gte } from 'semver'; import { track as trackTemp } from 'temp'; -import { ELECTRON_DIR } from '../lib/utils'; -import { getElectronVersion } from '../lib/get-version'; +import { execSync, ExecSyncOptions } from 'node:child_process'; +import { statSync, createReadStream, writeFileSync, close } from 'node:fs'; +import { join } from 'node:path'; + import { getUrlHash } from './get-url-hash'; import { createGitHubTokenStrategy } from './github-token'; import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from './types'; +import { getElectronVersion } from '../lib/get-version'; +import { ELECTRON_DIR } from '../lib/utils'; const temp = trackTemp(); diff --git a/script/release/run-release-ci-jobs.ts b/script/release/run-release-ci-jobs.ts index 6799314f24a5..c4f6acc5ef57 100644 --- a/script/release/run-release-ci-jobs.ts +++ b/script/release/run-release-ci-jobs.ts @@ -1,5 +1,6 @@ import { Octokit } from '@octokit/rest'; import got, { OptionsOfTextResponseBody } from 'got'; + import * as assert from 'node:assert'; import { createGitHubTokenStrategy } from './github-token'; diff --git a/script/release/uploaders/upload-to-github.ts b/script/release/uploaders/upload-to-github.ts index 43a1dcbf240c..b801ded782a7 100644 --- a/script/release/uploaders/upload-to-github.ts +++ b/script/release/uploaders/upload-to-github.ts @@ -1,5 +1,7 @@ import { Octokit } from '@octokit/rest'; + import * as fs from 'node:fs'; + import { createGitHubTokenStrategy } from '../github-token'; import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from '../types'; diff --git a/script/release/version-bumper.ts b/script/release/version-bumper.ts index ef86e2229894..c7ae8bb0525d 100644 --- a/script/release/version-bumper.ts +++ b/script/release/version-bumper.ts @@ -2,7 +2,9 @@ import { valid, coerce, inc } from 'semver'; -import { getElectronVersion } from '../lib/get-version'; +import { parseArgs } from 'node:util'; + +import { VersionBumpType } from './types'; import { isNightly, isAlpha, @@ -12,8 +14,7 @@ import { nextBeta, isStable } from './version-utils'; -import { VersionBumpType } from './types'; -import { parseArgs } from 'node:util'; +import { getElectronVersion } from '../lib/get-version'; // run the script async function main () { diff --git a/script/release/version-utils.ts b/script/release/version-utils.ts index 8ebb22e38b25..67ffac650d8d 100644 --- a/script/release/version-utils.ts +++ b/script/release/version-utils.ts @@ -1,5 +1,5 @@ -import * as semver from 'semver'; import { GitProcess } from 'dugite'; +import * as semver from 'semver'; import { ELECTRON_DIR } from '../lib/utils'; diff --git a/script/run-clang-tidy.ts b/script/run-clang-tidy.ts index 6a5ba9c2c799..b4a544da2e91 100644 --- a/script/run-clang-tidy.ts +++ b/script/run-clang-tidy.ts @@ -1,13 +1,14 @@ -import * as childProcess from 'node:child_process'; -import * as fs from 'node:fs'; import * as minimist from 'minimist'; -import * as os from 'node:os'; -import * as path from 'node:path'; import * as streamChain from 'stream-chain'; import * as streamJson from 'stream-json'; import { ignore as streamJsonIgnore } from 'stream-json/filters/Ignore'; import { streamArray as streamJsonStreamArray } from 'stream-json/streamers/StreamArray'; +import * as childProcess from 'node:child_process'; +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; + import { chunkFilenames, findMatchingFiles } from './lib/utils'; const SOURCE_ROOT = path.normalize(path.dirname(__dirname)); diff --git a/script/spec-runner.js b/script/spec-runner.js index 0acffa9479b8..bac0f44f19cc 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -1,19 +1,23 @@ #!/usr/bin/env node const { ElectronVersions, Installer } = require('@electron/fiddle-core'); + const chalk = require('chalk'); +const { hashElement } = require('folder-hash'); +const minimist = require('minimist'); + const childProcess = require('node:child_process'); const crypto = require('node:crypto'); const fs = require('node:fs'); -const { hashElement } = require('folder-hash'); const os = require('node:os'); const path = require('node:path'); + const unknownFlags = []; const pass = chalk.green('✓'); const fail = chalk.red('✗'); -const args = require('minimist')(process.argv, { +const args = minimist(process.argv, { string: ['runners', 'target', 'electronVersion'], unknown: arg => unknownFlags.push(arg) }); diff --git a/script/split-tests.js b/script/split-tests.js index 43a039775815..d91fa2070920 100755 --- a/script/split-tests.js +++ b/script/split-tests.js @@ -1,6 +1,7 @@ -const fs = require('node:fs'); const glob = require('glob'); +const fs = require('node:fs'); + const currentShard = parseInt(process.argv[2], 10); const shardCount = parseInt(process.argv[3], 10); diff --git a/script/start.js b/script/start.js index 6c081a0ccd80..4f158e3f931f 100644 --- a/script/start.js +++ b/script/start.js @@ -1,5 +1,7 @@ const cp = require('node:child_process'); + const utils = require('./lib/utils'); + const electronPath = utils.getAbsoluteElectronExec(); const child = cp.spawn(electronPath, process.argv.slice(2), { stdio: 'inherit' }); diff --git a/spec/api-app-spec.ts b/spec/api-app-spec.ts index 3a23744d7338..65766416c0b0 100644 --- a/spec/api-app-spec.ts +++ b/spec/api-app-spec.ts @@ -1,18 +1,21 @@ +import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main'; + import { assert, expect } from 'chai'; +import * as semver from 'semver'; +import split = require('split') + 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 { once } from 'node:events'; import * as fs from 'node:fs'; +import * as http from 'node:http'; +import * as https from 'node:https'; +import * as net from 'node:net'; import * as path from 'node:path'; import { promisify } from 'node:util'; -import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main'; -import { closeWindow, closeAllWindows } from './lib/window-helpers'; -import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers'; + import { collectStreamBody, getResponse } from './lib/net-helpers'; -import { once } from 'node:events'; -import split = require('split') -import * as semver from 'semver'; +import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers'; +import { closeWindow, closeAllWindows } from './lib/window-helpers'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-auto-updater-spec.ts b/spec/api-auto-updater-spec.ts index e558dbf51755..1174a01fff25 100644 --- a/spec/api-auto-updater-spec.ts +++ b/spec/api-auto-updater-spec.ts @@ -1,8 +1,11 @@ import { autoUpdater } from 'electron/main'; + import { expect } from 'chai'; -import { ifit, ifdescribe } from './lib/spec-helpers'; + import { once } from 'node:events'; +import { ifit, ifdescribe } from './lib/spec-helpers'; + ifdescribe(!process.mas)('autoUpdater module', function () { describe('checkForUpdates', function () { ifit(process.platform === 'win32')('emits an error on Windows if the feed URL is not set', async function () { diff --git a/spec/api-autoupdater-darwin-spec.ts b/spec/api-autoupdater-darwin-spec.ts index e8bc14745b14..24925c503c5b 100644 --- a/spec/api-autoupdater-darwin-spec.ts +++ b/spec/api-autoupdater-darwin-spec.ts @@ -1,16 +1,19 @@ -import { expect } from 'chai'; -import * as cp from 'node:child_process'; -import * as http from 'node:http'; -import * as express from 'express'; -import * as fs from 'node:fs'; -import * as path from 'node:path'; -import * as psList from 'ps-list'; -import { AddressInfo } from 'node:net'; -import { ifdescribe, ifit } from './lib/spec-helpers'; -import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers'; -import * as uuid from 'uuid'; import { autoUpdater, systemPreferences } from 'electron'; + +import { expect } from 'chai'; +import * as express from 'express'; +import * as psList from 'ps-list'; +import * as uuid from 'uuid'; + +import * as cp from 'node:child_process'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; +import { AddressInfo } from 'node:net'; +import * as path from 'node:path'; + +import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers'; import { withTempDirectory } from './lib/fs-helpers'; +import { ifdescribe, ifit } from './lib/spec-helpers'; // We can only test the auto updater on darwin non-component builds ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { diff --git a/spec/api-browser-view-spec.ts b/spec/api-browser-view-spec.ts index 62927d1c8804..2abddf7e7b9b 100644 --- a/spec/api-browser-view-spec.ts +++ b/spec/api-browser-view-spec.ts @@ -1,10 +1,13 @@ -import { expect } from 'chai'; -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 { ScreenCapture } from './lib/screen-helpers'; + +import { expect } from 'chai'; + import { once } from 'node:events'; +import * as path from 'node:path'; + +import { ScreenCapture } from './lib/screen-helpers'; +import { defer, ifit, startRemoteControlApp } from './lib/spec-helpers'; +import { closeWindow } from './lib/window-helpers'; describe('BrowserView module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 64d4de263f91..51386dda5f03 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1,20 +1,22 @@ -import { expect } from 'chai'; -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 { expect } from 'chai'; + +import * as childProcess from 'node:child_process'; +import { once } from 'node:events'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; +import { AddressInfo } from 'node:net'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import * as qs from 'node:querystring'; +import { setTimeout as syncSetTimeout } from 'node:timers'; +import { setTimeout } from 'node:timers/promises'; + import { emittedUntil, emittedNTimes } from './lib/events-helpers'; +import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers'; import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers'; import { closeWindow, closeAllWindows } from './lib/window-helpers'; -import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers'; -import { once } from 'node:events'; -import { setTimeout } from 'node:timers/promises'; -import { setTimeout as syncSetTimeout } from 'node:timers'; const fixtures = path.resolve(__dirname, 'fixtures'); const mainFixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-clipboard-spec.ts b/spec/api-clipboard-spec.ts index 544b7fe5c477..3befd1a95452 100644 --- a/spec/api-clipboard-spec.ts +++ b/spec/api-clipboard-spec.ts @@ -1,9 +1,12 @@ -import { expect } from 'chai'; -import * as path from 'node:path'; -import { Buffer } from 'node:buffer'; -import { ifdescribe, ifit } from './lib/spec-helpers'; import { clipboard, nativeImage } from 'electron/common'; +import { expect } from 'chai'; + +import { Buffer } from 'node:buffer'; +import * as path from 'node:path'; + +import { ifdescribe, ifit } from './lib/spec-helpers'; + // FIXME(zcbenz): Clipboard tests are failing on WOA. ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-content-tracing-spec.ts b/spec/api-content-tracing-spec.ts index a026472b7ce1..b584b1a8182f 100644 --- a/spec/api-content-tracing-spec.ts +++ b/spec/api-content-tracing-spec.ts @@ -1,8 +1,11 @@ -import { expect } from 'chai'; import { app, contentTracing, TraceConfig, TraceCategoriesAndOptions } from 'electron/main'; + +import { expect } from 'chai'; + 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 linux arm/arm64 diff --git a/spec/api-context-bridge-spec.ts b/spec/api-context-bridge-spec.ts index 62609060e8e5..d82470ab8bf6 100644 --- a/spec/api-context-bridge-spec.ts +++ b/spec/api-context-bridge-spec.ts @@ -1,15 +1,17 @@ import { BrowserWindow, ipcMain } from 'electron/main'; import { contextBridge } from 'electron/renderer'; + import { expect } from 'chai'; + +import * as cp from 'node:child_process'; +import { once } from 'node:events'; import * as fs from 'node:fs'; 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 'node:events'; +import { closeWindow } from './lib/window-helpers'; const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'context-bridge'); diff --git a/spec/api-crash-reporter-spec.ts b/spec/api-crash-reporter-spec.ts index 6aad9da1f165..2c008ae8e0c0 100644 --- a/spec/api-crash-reporter-spec.ts +++ b/spec/api-crash-reporter-spec.ts @@ -1,15 +1,18 @@ -import { expect } from 'chai'; -import * as childProcess from 'node:child_process'; -import * as http from 'node:http'; -import * as Busboy from 'busboy'; -import * as path from 'node:path'; -import { ifdescribe, ifit, defer, startRemoteControlApp, repeatedly, listen } from './lib/spec-helpers'; import { app } from 'electron/main'; + +import * as Busboy from 'busboy'; +import { expect } from 'chai'; +import * as uuid from 'uuid'; + +import * as childProcess from 'node:child_process'; import { EventEmitter } from 'node:events'; import * as fs from 'node:fs'; -import * as uuid from 'uuid'; +import * as http from 'node:http'; +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import { ifdescribe, ifit, defer, startRemoteControlApp, repeatedly, listen } from './lib/spec-helpers'; + const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64'; const isLinuxOnArm = process.platform === 'linux' && process.arch.includes('arm'); diff --git a/spec/api-debugger-spec.ts b/spec/api-debugger-spec.ts index c05644c98fa8..b274af9e3eab 100644 --- a/spec/api-debugger-spec.ts +++ b/spec/api-debugger-spec.ts @@ -1,11 +1,14 @@ +import { BrowserWindow } from 'electron/main'; + import { expect } from 'chai'; + +import { once } from 'node:events'; 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 'node:events'; +import { closeAllWindows } from './lib/window-helpers'; describe('debugger module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-desktop-capturer-spec.ts b/spec/api-desktop-capturer-spec.ts index 5c6eadf0d1b2..5bb4943183b1 100644 --- a/spec/api-desktop-capturer-spec.ts +++ b/spec/api-desktop-capturer-spec.ts @@ -1,9 +1,11 @@ -import { expect } from 'chai'; import { screen, desktopCapturer, BrowserWindow } from 'electron/main'; + +import { expect } from 'chai'; + import { once } from 'node:events'; import { setTimeout } from 'node:timers/promises'; -import { ifdescribe, ifit } from './lib/spec-helpers'; +import { ifdescribe, ifit } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('desktopCapturer', () => { diff --git a/spec/api-dialog-spec.ts b/spec/api-dialog-spec.ts index fa9b538c522a..d05200d69107 100644 --- a/spec/api-dialog-spec.ts +++ b/spec/api-dialog-spec.ts @@ -1,9 +1,12 @@ -import { expect } from 'chai'; import { dialog, BrowserWindow } from 'electron/main'; -import { closeAllWindows } from './lib/window-helpers'; -import { ifit } from './lib/spec-helpers'; + +import { expect } from 'chai'; + import { setTimeout } from 'node:timers/promises'; +import { ifit } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; + describe('dialog module', () => { describe('showOpenDialog', () => { afterEach(closeAllWindows); diff --git a/spec/api-global-shortcut-spec.ts b/spec/api-global-shortcut-spec.ts index b1c009329db6..2025c151dda3 100644 --- a/spec/api-global-shortcut-spec.ts +++ b/spec/api-global-shortcut-spec.ts @@ -1,5 +1,7 @@ -import { expect } from 'chai'; import { globalShortcut } from 'electron/main'; + +import { expect } from 'chai'; + import { ifdescribe } from './lib/spec-helpers'; ifdescribe(process.platform !== 'win32')('globalShortcut module', () => { diff --git a/spec/api-in-app-purchase-spec.ts b/spec/api-in-app-purchase-spec.ts index 72b892b2fa94..6092f7ffc494 100644 --- a/spec/api-in-app-purchase-spec.ts +++ b/spec/api-in-app-purchase-spec.ts @@ -1,5 +1,7 @@ -import { expect } from 'chai'; import { inAppPurchase } from 'electron/main'; + +import { expect } from 'chai'; + import { ifdescribe } from './lib/spec-helpers'; describe('inAppPurchase module', function () { diff --git a/spec/api-ipc-main-spec.ts b/spec/api-ipc-main-spec.ts index b9bcb155e3d0..869591f1d78e 100644 --- a/spec/api-ipc-main-spec.ts +++ b/spec/api-ipc-main-spec.ts @@ -1,10 +1,13 @@ -import { expect } from 'chai'; -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 { expect } from 'chai'; + +import * as cp from 'node:child_process'; import { once } from 'node:events'; +import * as path from 'node:path'; + +import { defer } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; describe('ipc main module', () => { const fixtures = path.join(__dirname, 'fixtures'); diff --git a/spec/api-ipc-renderer-spec.ts b/spec/api-ipc-renderer-spec.ts index 333b316366ed..2db75ef3a319 100644 --- a/spec/api-ipc-renderer-spec.ts +++ b/spec/api-ipc-renderer-spec.ts @@ -1,8 +1,11 @@ -import { expect } from 'chai'; import { ipcMain, BrowserWindow } from 'electron/main'; -import { closeWindow } from './lib/window-helpers'; + +import { expect } from 'chai'; + import { once } from 'node:events'; +import { closeWindow } from './lib/window-helpers'; + describe('ipcRenderer module', () => { let w: BrowserWindow; before(async () => { diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts index c650a6195a1c..38ff8f14ae6b 100644 --- a/spec/api-ipc-spec.ts +++ b/spec/api-ipc-spec.ts @@ -1,10 +1,13 @@ -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 'node:path'; + +import { expect } from 'chai'; + +import { EventEmitter, once } from 'node:events'; import * as http from 'node:http'; +import * as path from 'node:path'; + +import { defer, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; const v8Util = process._linkedBinding('electron_common_v8_util'); const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-media-handler-spec.ts b/spec/api-media-handler-spec.ts index 0a0319e1a55e..1d67866ead31 100644 --- a/spec/api-media-handler-spec.ts +++ b/spec/api-media-handler-spec.ts @@ -1,8 +1,11 @@ -import { expect } from 'chai'; import { BrowserWindow, session, desktopCapturer } from 'electron/main'; -import { closeAllWindows } from './lib/window-helpers'; + +import { expect } from 'chai'; + import * as http from 'node:http'; + import { ifit, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; describe('setDisplayMediaRequestHandler', () => { afterEach(closeAllWindows); diff --git a/spec/api-menu-item-spec.ts b/spec/api-menu-item-spec.ts index 0071a3904e10..e385b4773d63 100644 --- a/spec/api-menu-item-spec.ts +++ b/spec/api-menu-item-spec.ts @@ -1,5 +1,7 @@ import { BrowserWindow, app, Menu, MenuItem, MenuItemConstructorOptions } from 'electron/main'; + import { expect } from 'chai'; + import { ifdescribe } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; import { roleList, execute } from '../lib/browser/api/menu-item-roles'; diff --git a/spec/api-menu-spec.ts b/spec/api-menu-spec.ts index 019f5b43a2e4..cc0d1ef35849 100644 --- a/spec/api-menu-spec.ts +++ b/spec/api-menu-spec.ts @@ -1,12 +1,15 @@ -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 { assert, expect } from 'chai'; + +import * as cp from 'node:child_process'; +import { once } from 'node:events'; +import * as path from 'node:path'; +import { setTimeout } from 'node:timers/promises'; + import { ifit } from './lib/spec-helpers'; import { closeWindow } from './lib/window-helpers'; -import { once } from 'node:events'; -import { setTimeout } from 'node:timers/promises'; +import { sortMenuItems } from '../lib/browser/api/menu-utils'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-native-image-spec.ts b/spec/api-native-image-spec.ts index d498214942af..bbd30cff7aa6 100644 --- a/spec/api-native-image-spec.ts +++ b/spec/api-native-image-spec.ts @@ -1,8 +1,11 @@ -import { expect } from 'chai'; import { nativeImage } from 'electron/common'; -import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers'; + +import { expect } from 'chai'; + import * as path from 'node:path'; +import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers'; + describe('nativeImage module', () => { const fixturesPath = path.join(__dirname, 'fixtures'); diff --git a/spec/api-native-theme-spec.ts b/spec/api-native-theme-spec.ts index a6abb6762cc9..2d2a3a3b00d6 100644 --- a/spec/api-native-theme-spec.ts +++ b/spec/api-native-theme-spec.ts @@ -1,5 +1,7 @@ -import { expect } from 'chai'; import { nativeTheme, BrowserWindow, ipcMain } from 'electron/main'; + +import { expect } from 'chai'; + import { once } from 'node:events'; import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; diff --git a/spec/api-net-custom-protocols-spec.ts b/spec/api-net-custom-protocols-spec.ts index d9ffc43d8182..374bea811471 100644 --- a/spec/api-net-custom-protocols-spec.ts +++ b/spec/api-net-custom-protocols-spec.ts @@ -1,7 +1,10 @@ -import { expect } from 'chai'; import { net, protocol } from 'electron/main'; -import * as url from 'node:url'; + +import { expect } from 'chai'; + import * as path from 'node:path'; +import * as url from 'node:url'; + import { defer } from './lib/spec-helpers'; describe('net module custom protocols', () => { diff --git a/spec/api-net-log-spec.ts b/spec/api-net-log-spec.ts index fc570f229759..40781d595496 100644 --- a/spec/api-net-log-spec.ts +++ b/spec/api-net-log-spec.ts @@ -1,13 +1,16 @@ +import { session, net } from 'electron/main'; + import { expect } from 'chai'; -import * as http from 'node:http'; + +import * as ChildProcess from 'node:child_process'; +import { once } from 'node:events'; import * as fs from 'node:fs'; +import * as http from 'node:http'; +import { Socket } from 'node:net'; 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 'node:net'; + import { ifit, listen } from './lib/spec-helpers'; -import { once } from 'node:events'; const appPath = path.join(__dirname, 'fixtures', 'api', 'net-log'); const dumpFile = path.join(os.tmpdir(), 'net_log.json'); diff --git a/spec/api-net-session-spec.ts b/spec/api-net-session-spec.ts index 82d6b5b98530..42525be2c0e3 100644 --- a/spec/api-net-session-spec.ts +++ b/spec/api-net-session-spec.ts @@ -1,6 +1,9 @@ -import { expect } from 'chai'; -import * as dns from 'node:dns'; import { net, session, BrowserWindow, ClientRequestConstructorOptions } from 'electron/main'; + +import { expect } from 'chai'; + +import * as dns from 'node:dns'; + import { collectStreamBody, getResponse, respondNTimes, respondOnce } from './lib/net-helpers'; // See https://github.com/nodejs/node/issues/40702. diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index 7aa6ad863978..5d98385d60f4 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -1,9 +1,12 @@ -import { expect } from 'chai'; import { net, ClientRequest, ClientRequestConstructorOptions, utilityProcess } from 'electron/main'; + +import { expect } from 'chai'; + +import { once } from 'node:events'; import * as http from 'node:http'; import * as path from 'node:path'; -import { once } from 'node:events'; import { setTimeout } from 'node:timers/promises'; + import { collectStreamBody, collectStreamBodyBuffer, getResponse, kOneKiloByte, kOneMegaByte, randomBuffer, randomString, respondNTimes, respondOnce } from './lib/net-helpers'; const utilityFixturePath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process', 'api-net-spec.js'); diff --git a/spec/api-notification-dbus-spec.ts b/spec/api-notification-dbus-spec.ts index d470bbd20c2b..a601296536e7 100644 --- a/spec/api-notification-dbus-spec.ts +++ b/spec/api-notification-dbus-spec.ts @@ -6,13 +6,16 @@ // // See https://pypi.python.org/pypi/python-dbusmock to read about dbusmock. +import { nativeImage } from 'electron/common'; +import { app } from 'electron/main'; + import { expect } from 'chai'; import * as dbus from 'dbus-native'; -import { app } from 'electron/main'; -import { nativeImage } from 'electron/common'; -import { ifdescribe } from './lib/spec-helpers'; -import { promisify } from 'node:util'; + import * as path from 'node:path'; +import { promisify } from 'node:util'; + +import { ifdescribe } from './lib/spec-helpers'; const fixturesPath = path.join(__dirname, 'fixtures'); diff --git a/spec/api-notification-spec.ts b/spec/api-notification-spec.ts index 27188358fbd9..27d7417a13d9 100644 --- a/spec/api-notification-spec.ts +++ b/spec/api-notification-spec.ts @@ -1,6 +1,9 @@ -import { expect } from 'chai'; import { Notification } from 'electron/main'; + +import { expect } from 'chai'; + import { once } from 'node:events'; + import { ifit } from './lib/spec-helpers'; describe('Notification module', () => { diff --git a/spec/api-power-monitor-spec.ts b/spec/api-power-monitor-spec.ts index 8bd6c275725f..47a2e6cdab71 100644 --- a/spec/api-power-monitor-spec.ts +++ b/spec/api-power-monitor-spec.ts @@ -8,10 +8,12 @@ // python-dbusmock. import { expect } from 'chai'; import * as dbus from 'dbus-native'; -import { ifdescribe, startRemoteControlApp } from './lib/spec-helpers'; -import { promisify } from 'node:util'; -import { setTimeout } from 'node:timers/promises'; + import { once } from 'node:events'; +import { setTimeout } from 'node:timers/promises'; +import { promisify } from 'node:util'; + +import { ifdescribe, startRemoteControlApp } from './lib/spec-helpers'; describe('powerMonitor', () => { let logindMock: any, dbusMockPowerMonitor: any, getCalls: any, emitSignal: any, reset: any; diff --git a/spec/api-power-save-blocker-spec.ts b/spec/api-power-save-blocker-spec.ts index 36a35726ad6d..ea5091e0026f 100644 --- a/spec/api-power-save-blocker-spec.ts +++ b/spec/api-power-save-blocker-spec.ts @@ -1,6 +1,7 @@ -import { expect } from 'chai'; import { powerSaveBlocker } from 'electron/main'; +import { expect } from 'chai'; + describe('powerSaveBlocker module', () => { it('can be started and stopped', () => { expect(powerSaveBlocker.isStarted(-1)).to.be.false('is started'); diff --git a/spec/api-process-spec.ts b/spec/api-process-spec.ts index 909f6f5244de..5e3f5995517b 100644 --- a/spec/api-process-spec.ts +++ b/spec/api-process-spec.ts @@ -1,9 +1,12 @@ +import { BrowserWindow } from 'electron'; +import { app } from 'electron/main'; + +import { expect } from 'chai'; + import * as fs from 'node:fs'; import * as path from 'node:path'; -import { expect } from 'chai'; -import { BrowserWindow } from 'electron'; + import { defer } from './lib/spec-helpers'; -import { app } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; describe('process module', () => { diff --git a/spec/api-protocol-spec.ts b/spec/api-protocol-spec.ts index c2c42db0918c..1ebcd855fd34 100644 --- a/spec/api-protocol-spec.ts +++ b/spec/api-protocol-spec.ts @@ -1,20 +1,23 @@ +import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain, net } from 'electron/main'; + import { expect } from 'chai'; import { v4 } from 'uuid'; -import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain, net } from 'electron/main'; + 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 { EventEmitter, once } from 'node:events'; import * as fs from 'node:fs'; +import * as http from 'node:http'; +import * as path from 'node:path'; import * as qs from 'node:querystring'; import * as stream from 'node:stream'; import * as streamConsumers from 'node:stream/consumers'; import * as webStream from 'node:stream/web'; -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 'node:timers/promises'; +import * as url from 'node:url'; + +import { listen, defer, ifit } from './lib/spec-helpers'; +import { WebmGenerator } from './lib/video-helpers'; +import { closeAllWindows, closeWindow } from './lib/window-helpers'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-safe-storage-spec.ts b/spec/api-safe-storage-spec.ts index 721d62275836..b8d9c1358ad5 100644 --- a/spec/api-safe-storage-spec.ts +++ b/spec/api-safe-storage-spec.ts @@ -1,10 +1,13 @@ -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 'node:fs'; + +import * as cp from 'node:child_process'; import { once } from 'node:events'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; + +import { ifdescribe } from './lib/spec-helpers'; describe('safeStorage module', () => { it('safeStorage before and after app is ready', async () => { diff --git a/spec/api-screen-spec.ts b/spec/api-screen-spec.ts index 8ff1b489d390..1c3141c4e67a 100644 --- a/spec/api-screen-spec.ts +++ b/spec/api-screen-spec.ts @@ -1,6 +1,7 @@ -import { expect } from 'chai'; import { Display, screen, desktopCapturer } from 'electron/main'; +import { expect } from 'chai'; + describe('screen module', () => { describe('methods reassignment', () => { it('works for a selected method', () => { diff --git a/spec/api-service-workers-spec.ts b/spec/api-service-workers-spec.ts index c5376130b5e4..2fef6b0d658b 100644 --- a/spec/api-service-workers-spec.ts +++ b/spec/api-service-workers-spec.ts @@ -1,11 +1,14 @@ +import { session, webContents, WebContents } from 'electron/main'; + +import { expect } from 'chai'; +import { v4 } from 'uuid'; + +import { on, once } from 'node:events'; 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 'node:events'; const partition = 'service-workers-spec'; diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts index 12ccd9d273d3..4ac2db9ec3c3 100644 --- a/spec/api-session-spec.ts +++ b/spec/api-session-spec.ts @@ -1,17 +1,20 @@ +import { app, session, BrowserWindow, net, ipcMain, Session, webFrameMain, WebFrameMain } from 'electron/main'; + +import * as auth from 'basic-auth'; import { expect } from 'chai'; +import * as send from 'send'; + +import * as ChildProcess from 'node:child_process'; +import { once } from 'node:events'; +import * as fs from 'node:fs'; 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 'node:events'; import { setTimeout } from 'node:timers/promises'; +import { defer, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; + describe('session module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); const url = 'http://127.0.0.1'; diff --git a/spec/api-shell-spec.ts b/spec/api-shell-spec.ts index 57a652a00701..3883bf79ddde 100644 --- a/spec/api-shell-spec.ts +++ b/spec/api-shell-spec.ts @@ -1,13 +1,16 @@ -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 'node:http'; +import { BrowserWindow, app } from 'electron/main'; + +import { expect } from 'chai'; + +import { once } from 'node:events'; import * as fs from 'node:fs'; +import * as http from 'node:http'; import * as os from 'node:os'; import * as path from 'node:path'; -import { expect } from 'chai'; -import { once } from 'node:events'; + +import { ifdescribe, ifit, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; describe('shell module', () => { describe('shell.openExternal()', () => { diff --git a/spec/api-subframe-spec.ts b/spec/api-subframe-spec.ts index 043141a12c88..66b5dcc00e86 100644 --- a/spec/api-subframe-spec.ts +++ b/spec/api-subframe-spec.ts @@ -1,11 +1,14 @@ -import { expect } from 'chai'; -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 { expect } from 'chai'; + import { once } from 'node:events'; +import * as http from 'node:http'; +import * as path from 'node:path'; + +import { emittedNTimes } from './lib/events-helpers'; +import { ifdescribe, listen } from './lib/spec-helpers'; +import { closeWindow } from './lib/window-helpers'; describe('renderer nodeIntegrationInSubFrames', () => { const generateTests = (description: string, webPreferences: any) => { diff --git a/spec/api-system-preferences-spec.ts b/spec/api-system-preferences-spec.ts index adedba89532f..05de0b91e856 100644 --- a/spec/api-system-preferences-spec.ts +++ b/spec/api-system-preferences-spec.ts @@ -1,5 +1,7 @@ -import { expect } from 'chai'; import { systemPreferences } from 'electron/main'; + +import { expect } from 'chai'; + import { ifdescribe } from './lib/spec-helpers'; describe('systemPreferences module', () => { diff --git a/spec/api-touch-bar-spec.ts b/spec/api-touch-bar-spec.ts index 2d54eef06290..c64583afd64d 100644 --- a/spec/api-touch-bar-spec.ts +++ b/spec/api-touch-bar-spec.ts @@ -1,8 +1,11 @@ -import * as path from 'node:path'; import { BaseWindow, BrowserWindow, TouchBar } from 'electron/main'; -import { closeWindow } from './lib/window-helpers'; + import { expect } from 'chai'; +import * as path from 'node:path'; + +import { closeWindow } from './lib/window-helpers'; + const { TouchBarButton, TouchBarColorPicker, TouchBarGroup, TouchBarLabel, TouchBarOtherItemsProxy, TouchBarPopover, TouchBarScrubber, TouchBarSegmentedControl, TouchBarSlider, TouchBarSpacer } = TouchBar; describe('TouchBar module', () => { diff --git a/spec/api-tray-spec.ts b/spec/api-tray-spec.ts index 067d529330c1..f56ba1e695b3 100644 --- a/spec/api-tray-spec.ts +++ b/spec/api-tray-spec.ts @@ -1,10 +1,13 @@ -import { expect } from 'chai'; -import { Menu, Tray } from 'electron/main'; import { nativeImage } from 'electron/common'; -import { ifdescribe, ifit } from './lib/spec-helpers'; +import { Menu, Tray } from 'electron/main'; + +import { expect } from 'chai'; + import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import { ifdescribe, ifit } from './lib/spec-helpers'; + describe('tray module', () => { let tray: Tray; diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index 9ee9a3595ad0..5044aa068b50 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -1,13 +1,16 @@ -import { expect } from 'chai'; -import * as childProcess from 'node:child_process'; -import * as path from 'node:path'; +import { systemPreferences } from 'electron'; import { BrowserWindow, MessageChannelMain, utilityProcess, app } from 'electron/main'; + +import { expect } from 'chai'; + +import * as childProcess from 'node:child_process'; +import { once } from 'node:events'; +import * as path from 'node:path'; +import { setImmediate } from 'node:timers/promises'; +import { pathToFileURL } from 'node:url'; + import { ifit } from './lib/spec-helpers'; import { closeWindow } from './lib/window-helpers'; -import { once } from 'node:events'; -import { pathToFileURL } from 'node:url'; -import { setImmediate } from 'node:timers/promises'; -import { systemPreferences } from 'electron'; const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process'); const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64'; diff --git a/spec/api-view-spec.ts b/spec/api-view-spec.ts index 27946bd4de92..4d5686c62ce7 100644 --- a/spec/api-view-spec.ts +++ b/spec/api-view-spec.ts @@ -1,7 +1,9 @@ -import { expect } from 'chai'; -import { closeWindow } from './lib/window-helpers'; import { BaseWindow, View } from 'electron/main'; +import { expect } from 'chai'; + +import { closeWindow } from './lib/window-helpers'; + describe('View', () => { let w: BaseWindow; afterEach(async () => { diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index e22ee2bb8ef7..1a4c2886b129 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -1,16 +1,20 @@ +import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents } from 'electron/main'; + import { expect } from 'chai'; -import { AddressInfo } from 'node:net'; -import * as path from 'node:path'; + +import { once } from 'node:events'; import * as fs from 'node:fs'; import * as http from 'node:http'; -import * as url from 'node:url'; -import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents } from 'electron/main'; -import { closeAllWindows } from './lib/window-helpers'; -import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers'; -import { once } from 'node:events'; +import { AddressInfo } from 'node:net'; +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import * as url from 'node:url'; + +import { ifdescribe, defer, waitUntil, listen, ifit } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; const pdfjs = require('pdfjs-dist'); + const fixturesPath = path.resolve(__dirname, 'fixtures'); const features = process._linkedBinding('electron_common_features'); diff --git a/spec/api-web-contents-view-spec.ts b/spec/api-web-contents-view-spec.ts index 29821fd0f210..7e256c24853b 100644 --- a/spec/api-web-contents-view-spec.ts +++ b/spec/api-web-contents-view-spec.ts @@ -1,10 +1,11 @@ -import { closeAllWindows } from './lib/window-helpers'; +import { BaseWindow, BrowserWindow, View, WebContentsView, webContents } from 'electron/main'; + import { expect } from 'chai'; -import { BaseWindow, View, WebContentsView, webContents } from 'electron/main'; import { once } from 'node:events'; + import { defer } from './lib/spec-helpers'; -import { BrowserWindow } from 'electron'; +import { closeAllWindows } from './lib/window-helpers'; describe('WebContentsView', () => { afterEach(closeAllWindows); diff --git a/spec/api-web-frame-main-spec.ts b/spec/api-web-frame-main-spec.ts index e78f1a0876b4..54c95c9ef470 100644 --- a/spec/api-web-frame-main-spec.ts +++ b/spec/api-web-frame-main-spec.ts @@ -1,13 +1,16 @@ +import { BrowserWindow, WebFrameMain, webFrameMain, ipcMain, app, WebContents } from 'electron/main'; + import { expect } from 'chai'; + +import { once } from 'node:events'; import * as http from 'node:http'; import * as path from 'node:path'; +import { setTimeout } from 'node:timers/promises'; 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 'node:events'; -import { setTimeout } from 'node:timers/promises'; +import { closeAllWindows } from './lib/window-helpers'; describe('webFrameMain module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-frame-spec.ts b/spec/api-web-frame-spec.ts index 1a56225eefe3..3aa2e906a2dd 100644 --- a/spec/api-web-frame-spec.ts +++ b/spec/api-web-frame-spec.ts @@ -1,8 +1,11 @@ -import { expect } from 'chai'; -import * as path from 'node:path'; import { BrowserWindow, ipcMain, WebContents } from 'electron/main'; -import { defer } from './lib/spec-helpers'; + +import { expect } from 'chai'; + import { once } from 'node:events'; +import * as path from 'node:path'; + +import { defer } from './lib/spec-helpers'; describe('webFrame module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-request-spec.ts b/spec/api-web-request-spec.ts index e8b17f55b66f..6a7547658851 100644 --- a/spec/api-web-request-spec.ts +++ b/spec/api-web-request-spec.ts @@ -1,16 +1,19 @@ +import { ipcMain, protocol, session, WebContents, webContents } from 'electron/main'; + import { expect } from 'chai'; +import * as WebSocket from 'ws'; + +import { once } from 'node:events'; +import * as fs from 'node:fs'; 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 { Socket } from 'node:net'; -import { listen, defer } from './lib/spec-helpers'; -import { once } from 'node:events'; +import * as path from 'node:path'; +import * as qs from 'node:querystring'; import { ReadableStream } from 'node:stream/web'; +import * as url from 'node:url'; + +import { listen, defer } from './lib/spec-helpers'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-utils-spec.ts b/spec/api-web-utils-spec.ts index a369d15146ee..a9d9411d7ae7 100644 --- a/spec/api-web-utils-spec.ts +++ b/spec/api-web-utils-spec.ts @@ -1,7 +1,11 @@ -import { expect } from 'chai'; -import * as path from 'node:path'; import { BrowserWindow } from 'electron/main'; + +import { expect } from 'chai'; + +import * as path from 'node:path'; + import { defer } from './lib/spec-helpers'; + // import { once } from 'node:events'; describe('webUtils module', () => { diff --git a/spec/asar-integrity-spec.ts b/spec/asar-integrity-spec.ts index 4ecfb33d26b8..eae552b9e649 100644 --- a/spec/asar-integrity-spec.ts +++ b/spec/asar-integrity-spec.ts @@ -1,16 +1,18 @@ +import { getRawHeader } from '@electron/asar'; +import { flipFuses, FuseV1Config, FuseV1Options, FuseVersion } from '@electron/fuses'; +import { resedit } from '@electron/packager/dist/resedit'; + import { expect } from 'chai'; +import * as originalFs from 'node:original-fs'; + import * as cp from 'node:child_process'; import * as nodeCrypto from 'node:crypto'; -import * as originalFs from 'node:original-fs'; import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; -import { ifdescribe } from './lib/spec-helpers'; -import { getRawHeader } from '@electron/asar'; -import { resedit } from '@electron/packager/dist/resedit'; -import { flipFuses, FuseV1Config, FuseV1Options, FuseVersion } from '@electron/fuses'; import { copyApp } from './lib/fs-helpers'; +import { ifdescribe } from './lib/spec-helpers'; const bufferReplace = (haystack: Buffer, needle: string, replacement: string, throwOnMissing = true): Buffer => { const needleBuffer = Buffer.from(needle); diff --git a/spec/asar-spec.ts b/spec/asar-spec.ts index 879ed287b8c5..1fcf630973ca 100644 --- a/spec/asar-spec.ts +++ b/spec/asar-spec.ts @@ -1,12 +1,15 @@ +import { BrowserWindow, ipcMain } from 'electron/main'; + import { expect } from 'chai'; + +import { once } from 'node:events'; +import * as importedFs from 'node:fs'; 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 'node:fs'; -import { once } from 'node:events'; +import { closeAllWindows } from './lib/window-helpers'; describe('asar package', () => { const fixtures = path.join(__dirname, 'fixtures'); diff --git a/spec/autofill-spec.ts b/spec/autofill-spec.ts index 5e551125881e..9868e9d633e6 100644 --- a/spec/autofill-spec.ts +++ b/spec/autofill-spec.ts @@ -1,9 +1,12 @@ import { BrowserWindow } from 'electron'; -import * as path from 'node:path'; + import { expect } from 'chai'; -import { closeAllWindows } from './lib/window-helpers'; + +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import { closeAllWindows } from './lib/window-helpers'; + const fixturesPath = path.resolve(__dirname, 'fixtures'); describe('autofill', () => { diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 2be3358863e8..a7dc8439d03e 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -1,20 +1,23 @@ -import { expect } from 'chai'; -import { BrowserWindow, WebContents, webFrameMain, session, ipcMain, app, protocol, webContents, dialog, MessageBoxOptions } from 'electron/main'; +import { MediaAccessPermissionRequest } from 'electron'; import { clipboard } from 'electron/common'; -import { closeAllWindows } from './lib/window-helpers'; -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 { BrowserWindow, WebContents, webFrameMain, session, ipcMain, app, protocol, webContents, dialog, MessageBoxOptions } from 'electron/main'; + +import { expect } from 'chai'; +import * as ws from 'ws'; + import * as ChildProcess from 'node:child_process'; import { EventEmitter, once } from 'node:events'; -import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers'; -import { PipeTransport } from './pipe-transport'; -import * as ws from 'ws'; -import { setTimeout } from 'node:timers/promises'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; +import * as https from 'node:https'; import { AddressInfo } from 'node:net'; -import { MediaAccessPermissionRequest } from 'electron'; +import * as path from 'node:path'; +import { setTimeout } from 'node:timers/promises'; +import * as url from 'node:url'; + +import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; +import { PipeTransport } from './pipe-transport'; const features = process._linkedBinding('electron_common_features'); diff --git a/spec/crash-spec.ts b/spec/crash-spec.ts index 6a83b3d3aa63..ff8489b050d1 100644 --- a/spec/crash-spec.ts +++ b/spec/crash-spec.ts @@ -1,7 +1,9 @@ import { expect } from 'chai'; + import * as cp from 'node:child_process'; import * as fs from 'node:fs'; import * as path from 'node:path'; + import { ifit } from './lib/spec-helpers'; const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases'); diff --git a/spec/deprecate-spec.ts b/spec/deprecate-spec.ts index b8e3ae9b1d85..3ba8429f6204 100644 --- a/spec/deprecate-spec.ts +++ b/spec/deprecate-spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; + import * as deprecate from '../lib/common/deprecate'; describe('deprecate', () => { diff --git a/spec/esm-spec.ts b/spec/esm-spec.ts index 2a0eb148efa7..da63b686f63c 100644 --- a/spec/esm-spec.ts +++ b/spec/esm-spec.ts @@ -1,6 +1,8 @@ -import { expect } from 'chai'; -import * as cp from 'node:child_process'; import { BrowserWindow } from 'electron'; + +import { expect } from 'chai'; + +import * as cp from 'node:child_process'; import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; diff --git a/spec/extensions-spec.ts b/spec/extensions-spec.ts index 989b6a93ab32..1681e7fe97d1 100644 --- a/spec/extensions-spec.ts +++ b/spec/extensions-spec.ts @@ -1,13 +1,16 @@ -import { expect } from 'chai'; import { app, session, BrowserWindow, ipcMain, WebContents, Extension, Session } from 'electron/main'; -import { closeAllWindows, closeWindow } from './lib/window-helpers'; + +import { expect } from 'chai'; +import * as WebSocket from 'ws'; + +import { once } from 'node:events'; +import * as fs from 'node:fs/promises'; import * as http from 'node:http'; import * as path from 'node:path'; -import * as fs from 'node:fs/promises'; -import * as WebSocket from 'ws'; + import { emittedNTimes, emittedUntil } from './lib/events-helpers'; import { ifit, listen } from './lib/spec-helpers'; -import { once } from 'node:events'; +import { closeAllWindows, closeWindow } from './lib/window-helpers'; const uuid = require('uuid'); diff --git a/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js b/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js index 3422a3fd56e6..41e4ac1222f6 100644 --- a/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js +++ b/spec/fixtures/api/context-bridge/context-bridge-mutability/main.js @@ -1,4 +1,5 @@ const { app, BrowserWindow } = require('electron'); + const path = require('node:path'); let win; diff --git a/spec/fixtures/api/mixed-sandbox-app/main.js b/spec/fixtures/api/mixed-sandbox-app/main.js index 5182dd66dc64..b4fd323b93c6 100644 --- a/spec/fixtures/api/mixed-sandbox-app/main.js +++ b/spec/fixtures/api/mixed-sandbox-app/main.js @@ -1,4 +1,5 @@ const { app, BrowserWindow, ipcMain } = require('electron'); + const net = require('node:net'); const path = require('node:path'); diff --git a/spec/fixtures/api/relaunch/main.js b/spec/fixtures/api/relaunch/main.js index d66d30921bfd..c566dd5cefc4 100644 --- a/spec/fixtures/api/relaunch/main.js +++ b/spec/fixtures/api/relaunch/main.js @@ -1,4 +1,5 @@ const { app } = require('electron'); + const net = require('node:net'); const socketPath = process.platform === 'win32' ? '\\\\.\\pipe\\electron-app-relaunch' : '/tmp/electron-app-relaunch'; diff --git a/spec/fixtures/api/safe-storage/decrypt-app/main.js b/spec/fixtures/api/safe-storage/decrypt-app/main.js index 3476034455d0..fe983e4d5498 100644 --- a/spec/fixtures/api/safe-storage/decrypt-app/main.js +++ b/spec/fixtures/api/safe-storage/decrypt-app/main.js @@ -1,4 +1,5 @@ const { app, safeStorage } = require('electron'); + const { promises: fs } = require('node:fs'); const path = require('node:path'); diff --git a/spec/fixtures/api/safe-storage/encrypt-app/main.js b/spec/fixtures/api/safe-storage/encrypt-app/main.js index a9f6d261c025..1bb90b65d3b6 100644 --- a/spec/fixtures/api/safe-storage/encrypt-app/main.js +++ b/spec/fixtures/api/safe-storage/encrypt-app/main.js @@ -1,4 +1,5 @@ const { app, safeStorage } = require('electron'); + const { promises: fs } = require('node:fs'); const path = require('node:path'); diff --git a/spec/fixtures/api/singleton-userdata/main.js b/spec/fixtures/api/singleton-userdata/main.js index 2d4a4878663a..a0ec2f90a233 100644 --- a/spec/fixtures/api/singleton-userdata/main.js +++ b/spec/fixtures/api/singleton-userdata/main.js @@ -1,4 +1,5 @@ const { app } = require('electron'); + const fs = require('node:fs'); const path = require('node:path'); diff --git a/spec/fixtures/api/utility-process/api-net-spec.js b/spec/fixtures/api/utility-process/api-net-spec.js index a97259cdf7fc..cc0628273df1 100644 --- a/spec/fixtures/api/utility-process/api-net-spec.js +++ b/spec/fixtures/api/utility-process/api-net-spec.js @@ -2,15 +2,18 @@ /* eslint-disable camelcase */ require('ts-node/register'); -const chai_1 = require('chai'); const main_1 = require('electron/main'); -const http = require('node:http'); -const url = require('node:url'); + +const chai_1 = require('chai'); + const node_events_1 = require('node:events'); +const http = require('node:http'); const promises_1 = require('node:timers/promises'); -const net_helpers_1 = require('../../../lib/net-helpers'); +const url = require('node:url'); const v8 = require('node:v8'); +const net_helpers_1 = require('../../../lib/net-helpers'); + v8.setFlagsFromString('--expose_gc'); chai_1.use(require('chai-as-promised')); chai_1.use(require('dirty-chai')); diff --git a/spec/fixtures/api/utility-process/dns-result-order.js b/spec/fixtures/api/utility-process/dns-result-order.js index 74d1219003c6..413aaec58134 100644 --- a/spec/fixtures/api/utility-process/dns-result-order.js +++ b/spec/fixtures/api/utility-process/dns-result-order.js @@ -1,3 +1,4 @@ const dns = require('node:dns'); + console.log(dns.getDefaultResultOrder()); process.exit(0); diff --git a/spec/fixtures/api/utility-process/env-app/main.js b/spec/fixtures/api/utility-process/env-app/main.js index 5edb3ea82315..c03f28d1750c 100644 --- a/spec/fixtures/api/utility-process/env-app/main.js +++ b/spec/fixtures/api/utility-process/env-app/main.js @@ -1,4 +1,5 @@ const { app, utilityProcess } = require('electron'); + const path = require('node:path'); app.whenReady().then(() => { diff --git a/spec/fixtures/api/utility-process/inherit-stderr/main.js b/spec/fixtures/api/utility-process/inherit-stderr/main.js index 80fbaff5cc5b..5c9c7331ff07 100644 --- a/spec/fixtures/api/utility-process/inherit-stderr/main.js +++ b/spec/fixtures/api/utility-process/inherit-stderr/main.js @@ -1,4 +1,5 @@ const { app, utilityProcess } = require('electron'); + const path = require('node:path'); app.whenReady().then(() => { diff --git a/spec/fixtures/api/utility-process/inherit-stdout/main.js b/spec/fixtures/api/utility-process/inherit-stdout/main.js index 80fbaff5cc5b..5c9c7331ff07 100644 --- a/spec/fixtures/api/utility-process/inherit-stdout/main.js +++ b/spec/fixtures/api/utility-process/inherit-stdout/main.js @@ -1,4 +1,5 @@ const { app, utilityProcess } = require('electron'); + const path = require('node:path'); app.whenReady().then(() => { diff --git a/spec/fixtures/api/utility-process/net.js b/spec/fixtures/api/utility-process/net.js new file mode 100644 index 000000000000..c5dae1928490 --- /dev/null +++ b/spec/fixtures/api/utility-process/net.js @@ -0,0 +1,45 @@ +const { net } = require('electron'); + +const serverUrl = process.argv[2].split('=')[1]; +let configurableArg = null; +if (process.argv[3]) { + configurableArg = process.argv[3].split('=')[0]; +} +const data = []; + +let request = null; +if (configurableArg === '--omit-credentials') { + request = net.request({ method: 'GET', url: serverUrl, credentials: 'omit' }); +} else if (configurableArg === '--use-fetch-api') { + net.fetch(serverUrl).then((response) => { + process.parentPort.postMessage([response.status, response.headers]); + }); +} else { + request = net.request({ method: 'GET', url: serverUrl }); +} + +if (request) { + if (configurableArg === '--use-net-login-event') { + request.on('login', (authInfo, provideCredentials) => { + process.parentPort.postMessage(authInfo); + provideCredentials('user', 'pass'); + }); + } + request.on('response', (response) => { + process.parentPort.postMessage([response.statusCode, response.headers]); + response.on('data', (chunk) => data.push(chunk)); + response.on('end', (chunk) => { + if (chunk) data.push(chunk); + process.parentPort.postMessage(Buffer.concat(data).toString()); + }); + }); + if (configurableArg === '--request-data') { + process.parentPort.on('message', (e) => { + request.write(e.data); + request.end(); + }); + process.parentPort.postMessage('get-request-data'); + } else { + request.end(); + } +} diff --git a/spec/fixtures/api/utility-process/suid.js b/spec/fixtures/api/utility-process/suid.js index 714a288f44ee..69d4d018c10b 100644 --- a/spec/fixtures/api/utility-process/suid.js +++ b/spec/fixtures/api/utility-process/suid.js @@ -1,2 +1,3 @@ const result = require('node:child_process').execSync('sudo --help'); + process.parentPort.postMessage(result); diff --git a/spec/fixtures/apps/crash/fork.js b/spec/fixtures/apps/crash/fork.js index 2b0cb8be0c8b..db984154ffb0 100644 --- a/spec/fixtures/apps/crash/fork.js +++ b/spec/fixtures/apps/crash/fork.js @@ -1,5 +1,5 @@ -const path = require('node:path'); const childProcess = require('node:child_process'); +const path = require('node:path'); const crashPath = path.join(__dirname, 'node-crash.js'); const child = childProcess.fork(crashPath, { silent: true }); diff --git a/spec/fixtures/apps/crash/main.js b/spec/fixtures/apps/crash/main.js index cabedbb1aa00..dcae6b79bbb9 100644 --- a/spec/fixtures/apps/crash/main.js +++ b/spec/fixtures/apps/crash/main.js @@ -1,6 +1,7 @@ const { app, BrowserWindow, crashReporter } = require('electron'); -const path = require('node:path'); + const childProcess = require('node:child_process'); +const path = require('node:path'); app.setVersion('0.1.0'); diff --git a/spec/fixtures/apps/libuv-hang/main.js b/spec/fixtures/apps/libuv-hang/main.js index 55a65ca93a0e..ca7272ff4039 100644 --- a/spec/fixtures/apps/libuv-hang/main.js +++ b/spec/fixtures/apps/libuv-hang/main.js @@ -1,4 +1,5 @@ const { app, BrowserWindow, ipcMain } = require('electron'); + const path = require('node:path'); async function createWindow () { diff --git a/spec/fixtures/apps/open-new-window-from-link/main.js b/spec/fixtures/apps/open-new-window-from-link/main.js index 4f4d4999d09c..6f0b188a1878 100644 --- a/spec/fixtures/apps/open-new-window-from-link/main.js +++ b/spec/fixtures/apps/open-new-window-from-link/main.js @@ -1,4 +1,5 @@ const { app, BrowserWindow } = require('electron'); + const path = require('node:path'); async function createWindow () { diff --git a/spec/fixtures/apps/refresh-page/main.js b/spec/fixtures/apps/refresh-page/main.js index f4ada26db399..d317fa37a70b 100644 --- a/spec/fixtures/apps/refresh-page/main.js +++ b/spec/fixtures/apps/refresh-page/main.js @@ -1,8 +1,9 @@ -const path = require('node:path'); -const { once } = require('node:events'); -const { pathToFileURL } = require('node:url'); const { BrowserWindow, app, protocol, net, session } = require('electron'); +const { once } = require('node:events'); +const path = require('node:path'); +const { pathToFileURL } = require('node:url'); + if (process.argv.length < 4) { console.error('Must pass allow_code_cache code_cache_dir'); process.exit(1); diff --git a/spec/fixtures/apps/remote-control/main.js b/spec/fixtures/apps/remote-control/main.js index b2b6f4b4fb8e..8ea8d17def69 100644 --- a/spec/fixtures/apps/remote-control/main.js +++ b/spec/fixtures/apps/remote-control/main.js @@ -1,11 +1,12 @@ // eslint-disable-next-line camelcase const electron_1 = require('electron'); + // eslint-disable-next-line camelcase const { app } = electron_1; const http = require('node:http'); -const v8 = require('node:v8'); // eslint-disable-next-line camelcase,@typescript-eslint/no-unused-vars const promises_1 = require('node:timers/promises'); +const v8 = require('node:v8'); if (app.commandLine.hasSwitch('boot-eval')) { // eslint-disable-next-line no-eval diff --git a/spec/fixtures/apps/set-path/main.js b/spec/fixtures/apps/set-path/main.js index abde44095727..7dd0cd30d9a8 100644 --- a/spec/fixtures/apps/set-path/main.js +++ b/spec/fixtures/apps/set-path/main.js @@ -1,6 +1,7 @@ -const http = require('node:http'); const { app, ipcMain, BrowserWindow } = require('electron'); +const http = require('node:http'); + if (process.argv.length > 3) { app.setPath(process.argv[2], process.argv[3]); } diff --git a/spec/fixtures/apps/xwindow-icon/main.js b/spec/fixtures/apps/xwindow-icon/main.js index f5e23deda9c8..292abe12ce63 100644 --- a/spec/fixtures/apps/xwindow-icon/main.js +++ b/spec/fixtures/apps/xwindow-icon/main.js @@ -1,4 +1,5 @@ const { app, BrowserWindow } = require('electron'); + const path = require('node:path'); app.whenReady().then(() => { diff --git a/spec/fixtures/auto-update/update-json/index.js b/spec/fixtures/auto-update/update-json/index.js index 320dbffe229d..3db01f553cfb 100644 --- a/spec/fixtures/auto-update/update-json/index.js +++ b/spec/fixtures/auto-update/update-json/index.js @@ -1,3 +1,5 @@ +const { app, autoUpdater } = require('electron'); + const fs = require('node:fs'); const path = require('node:path'); @@ -6,8 +8,6 @@ process.on('uncaughtException', (err) => { process.exit(1); }); -const { app, autoUpdater } = require('electron'); - autoUpdater.on('error', (err) => { console.error(err); process.exit(1); diff --git a/spec/fixtures/auto-update/update-stack/index.js b/spec/fixtures/auto-update/update-stack/index.js index 245273186261..487ef591b474 100644 --- a/spec/fixtures/auto-update/update-stack/index.js +++ b/spec/fixtures/auto-update/update-stack/index.js @@ -1,3 +1,5 @@ +const { app, autoUpdater } = require('electron'); + const fs = require('node:fs'); const path = require('node:path'); @@ -6,8 +8,6 @@ process.on('uncaughtException', (err) => { process.exit(1); }); -const { app, autoUpdater } = require('electron'); - autoUpdater.on('error', (err) => { console.error(err); process.exit(1); diff --git a/spec/fixtures/auto-update/update/index.js b/spec/fixtures/auto-update/update/index.js index f9d1b1670b07..d9ec2b6ac05c 100644 --- a/spec/fixtures/auto-update/update/index.js +++ b/spec/fixtures/auto-update/update/index.js @@ -1,3 +1,5 @@ +const { app, autoUpdater } = require('electron'); + const fs = require('node:fs'); const path = require('node:path'); @@ -6,8 +8,6 @@ process.on('uncaughtException', (err) => { process.exit(1); }); -const { app, autoUpdater } = require('electron'); - autoUpdater.on('error', (err) => { console.error(err); process.exit(1); diff --git a/spec/fixtures/crash-cases/api-browser-destroy/index.js b/spec/fixtures/crash-cases/api-browser-destroy/index.js index 1e87b8d177a4..97198c6eed5c 100644 --- a/spec/fixtures/crash-cases/api-browser-destroy/index.js +++ b/spec/fixtures/crash-cases/api-browser-destroy/index.js @@ -1,4 +1,5 @@ const { app, BrowserWindow, BrowserView } = require('electron'); + const { expect } = require('chai'); function createWindow () { diff --git a/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.js b/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.js index 7e997d030f59..78e630fb54c0 100644 --- a/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.js +++ b/spec/fixtures/crash-cases/fs-promises-renderer-crash/index.js @@ -1,4 +1,5 @@ const { app, BrowserWindow } = require('electron'); + const path = require('node:path'); app.whenReady().then(() => { diff --git a/spec/fixtures/crash-cases/js-execute-iframe/index.js b/spec/fixtures/crash-cases/js-execute-iframe/index.js index 65dba1ef016d..d71cc4e0d41d 100644 --- a/spec/fixtures/crash-cases/js-execute-iframe/index.js +++ b/spec/fixtures/crash-cases/js-execute-iframe/index.js @@ -1,4 +1,5 @@ const { app, BrowserWindow } = require('electron'); + const net = require('node:net'); const path = require('node:path'); diff --git a/spec/fixtures/crash-cases/native-window-open-exit/index.js b/spec/fixtures/crash-cases/native-window-open-exit/index.js index 30ff075ecdea..af5f062b4ec6 100644 --- a/spec/fixtures/crash-cases/native-window-open-exit/index.js +++ b/spec/fixtures/crash-cases/native-window-open-exit/index.js @@ -1,6 +1,7 @@ const { app, ipcMain, BrowserWindow } = require('electron'); -const path = require('node:path'); + const http = require('node:http'); +const path = require('node:path'); function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/spec/fixtures/crash-cases/safe-storage/index.js b/spec/fixtures/crash-cases/safe-storage/index.js index 151751820a8d..08bdede4dae5 100644 --- a/spec/fixtures/crash-cases/safe-storage/index.js +++ b/spec/fixtures/crash-cases/safe-storage/index.js @@ -1,4 +1,5 @@ const { app, safeStorage } = require('electron'); + const { expect } = require('chai'); (async () => { diff --git a/spec/fixtures/crash-cases/setimmediate-renderer-crash/index.js b/spec/fixtures/crash-cases/setimmediate-renderer-crash/index.js index be1cb3f3d1c0..3ee66640b8af 100644 --- a/spec/fixtures/crash-cases/setimmediate-renderer-crash/index.js +++ b/spec/fixtures/crash-cases/setimmediate-renderer-crash/index.js @@ -1,4 +1,5 @@ const { app, BrowserWindow } = require('electron'); + const path = require('node:path'); app.whenReady().then(() => { diff --git a/spec/fixtures/crash-cases/webcontents-create-leak-exit/index.js b/spec/fixtures/crash-cases/webcontents-create-leak-exit/index.js index 0059a5c3df17..643594da500c 100644 --- a/spec/fixtures/crash-cases/webcontents-create-leak-exit/index.js +++ b/spec/fixtures/crash-cases/webcontents-create-leak-exit/index.js @@ -1,4 +1,5 @@ const { app, webContents } = require('electron'); + app.whenReady().then(function () { webContents.create(); diff --git a/spec/fixtures/crash-cases/webcontentsview-create-leak-exit/index.js b/spec/fixtures/crash-cases/webcontentsview-create-leak-exit/index.js index 3d491cabbddb..99297eed49e7 100644 --- a/spec/fixtures/crash-cases/webcontentsview-create-leak-exit/index.js +++ b/spec/fixtures/crash-cases/webcontentsview-create-leak-exit/index.js @@ -1,4 +1,5 @@ const { WebContentsView, app } = require('electron'); + app.whenReady().then(function () { // eslint-disable-next-line no-new new WebContentsView(); diff --git a/spec/fixtures/module/asar.js b/spec/fixtures/module/asar.js index ab13554fb878..7b196e533943 100644 --- a/spec/fixtures/module/asar.js +++ b/spec/fixtures/module/asar.js @@ -1,4 +1,5 @@ const fs = require('node:fs'); + process.on('message', function (file) { process.send(fs.readFileSync(file).toString()); }); diff --git a/spec/fixtures/module/check-arguments.js b/spec/fixtures/module/check-arguments.js index 8a5ef8dde197..dccbe2d314b0 100644 --- a/spec/fixtures/module/check-arguments.js +++ b/spec/fixtures/module/check-arguments.js @@ -1,4 +1,5 @@ const { ipcRenderer } = require('electron'); + window.onload = function () { ipcRenderer.send('answer', process.argv); }; diff --git a/spec/fixtures/module/create_socket.js b/spec/fixtures/module/create_socket.js index 64c059b2f24f..abcc0e66be20 100644 --- a/spec/fixtures/module/create_socket.js +++ b/spec/fixtures/module/create_socket.js @@ -1,4 +1,5 @@ const net = require('node:net'); + const server = net.createServer(function () {}); server.listen(process.argv[2]); process.exit(0); diff --git a/spec/fixtures/module/echo.js b/spec/fixtures/module/echo.js index ae1b31dd9bed..56ba812a0d99 100644 --- a/spec/fixtures/module/echo.js +++ b/spec/fixtures/module/echo.js @@ -3,4 +3,5 @@ process.on('uncaughtException', function (err) { }); const echo = require('@electron-ci/echo'); + process.send(echo('ok')); diff --git a/spec/fixtures/module/fork_ping.js b/spec/fixtures/module/fork_ping.js index 33ed47051c62..857211280d23 100644 --- a/spec/fixtures/module/fork_ping.js +++ b/spec/fixtures/module/fork_ping.js @@ -1,10 +1,12 @@ +const childProcess = require('node:child_process'); const path = require('node:path'); process.on('uncaughtException', function (error) { process.send(error.stack); }); -const child = require('node:child_process').fork(path.join(__dirname, '/ping.js')); +const child = childProcess.fork(path.join(__dirname, '/ping.js')); + process.on('message', function (msg) { child.send(msg); }); diff --git a/spec/fixtures/module/isolated-ping.js b/spec/fixtures/module/isolated-ping.js index 90392e46fe4d..e7d5980d5356 100644 --- a/spec/fixtures/module/isolated-ping.js +++ b/spec/fixtures/module/isolated-ping.js @@ -1,2 +1,3 @@ const { ipcRenderer } = require('electron'); + ipcRenderer.send('pong'); diff --git a/spec/fixtures/module/module-paths.js b/spec/fixtures/module/module-paths.js index 895168dd3972..fc5d6cb1ca91 100644 --- a/spec/fixtures/module/module-paths.js +++ b/spec/fixtures/module/module-paths.js @@ -1,2 +1,3 @@ const Module = require('node:module'); + process.send(Module._nodeModulePaths(process.resourcesPath + '/test.js')); diff --git a/spec/fixtures/module/preload-ipc.js b/spec/fixtures/module/preload-ipc.js index 390fa920dfa0..465b7152edee 100644 --- a/spec/fixtures/module/preload-ipc.js +++ b/spec/fixtures/module/preload-ipc.js @@ -1,4 +1,5 @@ const { ipcRenderer } = require('electron'); + ipcRenderer.on('ping', function (event, message) { ipcRenderer.sendToHost('pong', message); }); diff --git a/spec/fixtures/module/send-later.js b/spec/fixtures/module/send-later.js index 5b4a22097275..feef5d903aef 100644 --- a/spec/fixtures/module/send-later.js +++ b/spec/fixtures/module/send-later.js @@ -1,4 +1,5 @@ const { ipcRenderer } = require('electron'); + window.onload = function () { ipcRenderer.send('answer', typeof window.process, typeof window.Buffer); }; diff --git a/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js b/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js new file mode 100644 index 000000000000..ff2c1a8e7210 --- /dev/null +++ b/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js @@ -0,0 +1,5 @@ +'use strict'; + +const binding = require('../build/Release/external_ab.node'); + +binding.createBuffer(); diff --git a/spec/fixtures/native-addon/uv-dlopen/index.js b/spec/fixtures/native-addon/uv-dlopen/index.js index 6d7e4f8aa7f1..c2761afc4157 100644 --- a/spec/fixtures/native-addon/uv-dlopen/index.js +++ b/spec/fixtures/native-addon/uv-dlopen/index.js @@ -1,4 +1,5 @@ const path = require('node:path'); + const testLoadLibrary = require('./build/Release/test_module'); const lib = (() => { diff --git a/spec/fixtures/no-proprietary-codecs.js b/spec/fixtures/no-proprietary-codecs.js index 40e073470b26..9c8dbdde74db 100644 --- a/spec/fixtures/no-proprietary-codecs.js +++ b/spec/fixtures/no-proprietary-codecs.js @@ -5,6 +5,7 @@ // that does include proprietary codecs. const { app, BrowserWindow, ipcMain } = require('electron'); + const path = require('node:path'); const MEDIA_ERR_SRC_NOT_SUPPORTED = 4; diff --git a/spec/fixtures/test.asar/repack.js b/spec/fixtures/test.asar/repack.js index 5af420a934ee..d85dc01e750c 100644 --- a/spec/fixtures/test.asar/repack.js +++ b/spec/fixtures/test.asar/repack.js @@ -2,6 +2,7 @@ // using a new version of the asar package const asar = require('@electron/asar'); + const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); diff --git a/spec/fuses-spec.ts b/spec/fuses-spec.ts index fe3955732eb1..fb021f955e9d 100644 --- a/spec/fuses-spec.ts +++ b/spec/fuses-spec.ts @@ -1,10 +1,13 @@ -import { expect } from 'chai'; -import { startRemoteControlApp } from './lib/spec-helpers'; -import { once } from 'node:events'; -import { spawn } from 'node:child_process'; import { BrowserWindow } from 'electron'; + +import { expect } from 'chai'; + +import { spawn } from 'node:child_process'; +import { once } from 'node:events'; import path = require('node:path'); +import { startRemoteControlApp } from './lib/spec-helpers'; + describe('fuses', () => { it('can be enabled by command-line argument during testing', async () => { const child0 = spawn(process.execPath, ['-v'], { env: { NODE_OPTIONS: '-e 0' } }); diff --git a/spec/get-files.ts b/spec/get-files.ts index e6e59c1da434..69f1c7dc19f7 100644 --- a/spec/get-files.ts +++ b/spec/get-files.ts @@ -1,6 +1,7 @@ -import { once } from 'node:events'; import * as walkdir from 'walkdir'; +import { once } from 'node:events'; + export async function getFiles (directoryPath: string, { filter = null }: {filter?: ((file: string) => boolean) | null} = {}) { const files: string[] = []; const walker = walkdir(directoryPath, { diff --git a/spec/guest-window-manager-spec.ts b/spec/guest-window-manager-spec.ts index 39b62409237c..de1201fff5cf 100644 --- a/spec/guest-window-manager-spec.ts +++ b/spec/guest-window-manager-spec.ts @@ -1,11 +1,14 @@ import { BrowserWindow, screen } from 'electron'; + import { expect, assert } from 'chai'; + +import { once } from 'node:events'; +import * as http from 'node:http'; +import { setTimeout as setTimeoutAsync } from 'node:timers/promises'; + import { HexColors, ScreenCapture } from './lib/screen-helpers'; import { ifit, listen } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; -import { once } from 'node:events'; -import { setTimeout as setTimeoutAsync } from 'node:timers/promises'; -import * as http from 'node:http'; describe('webContents.setWindowOpenHandler', () => { describe('native window', () => { diff --git a/spec/index.js b/spec/index.js index 0f5a55098628..a8e43bd27623 100644 --- a/spec/index.js +++ b/spec/index.js @@ -1,3 +1,5 @@ +const { app, protocol } = require('electron'); + const fs = require('node:fs'); const path = require('node:path'); const v8 = require('node:v8'); @@ -12,8 +14,6 @@ process.on('uncaughtException', (err) => { process.env.TS_NODE_PROJECT = path.resolve(__dirname, '../tsconfig.spec.json'); process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'; -const { app, protocol } = require('electron'); - // Some Linux machines have broken hardware acceleration support. if (process.env.ELECTRON_TEST_DISABLE_HARDWARE_ACCELERATION) { app.disableHardwareAcceleration(); diff --git a/spec/lib/artifacts.ts b/spec/lib/artifacts.ts index 5b1b66aba6a4..433a119507e7 100644 --- a/spec/lib/artifacts.ts +++ b/spec/lib/artifacts.ts @@ -1,6 +1,6 @@ -import path = require('node:path'); -import fs = require('node:fs/promises'); import { randomBytes } from 'node:crypto'; +import fs = require('node:fs/promises'); +import path = require('node:path'); const IS_CI = !!process.env.CI; const ARTIFACT_DIR = path.join(__dirname, '..', 'artifacts'); diff --git a/spec/lib/codesign-helpers.ts b/spec/lib/codesign-helpers.ts index 2de425e5453b..9e43f482192a 100644 --- a/spec/lib/codesign-helpers.ts +++ b/spec/lib/codesign-helpers.ts @@ -1,7 +1,8 @@ +import { expect } from 'chai'; + import * as cp from 'node:child_process'; import * as fs from 'node:fs'; import * as path from 'node:path'; -import { expect } from 'chai'; const features = process._linkedBinding('electron_common_features'); const fixturesPath = path.resolve(__dirname, '..', 'fixtures'); diff --git a/spec/lib/fs-helpers.ts b/spec/lib/fs-helpers.ts index 26949079d6b7..7c1966c90594 100644 --- a/spec/lib/fs-helpers.ts +++ b/spec/lib/fs-helpers.ts @@ -1,5 +1,6 @@ -import * as cp from 'node:child_process'; import * as fs from 'original-fs'; + +import * as cp from 'node:child_process'; import * as os from 'node:os'; import * as path from 'node:path'; diff --git a/spec/lib/net-helpers.ts b/spec/lib/net-helpers.ts index 350885278ce6..7500ac755e05 100644 --- a/spec/lib/net-helpers.ts +++ b/spec/lib/net-helpers.ts @@ -1,7 +1,9 @@ import { expect } from 'chai'; + import * as dns from 'node:dns'; import * as http from 'node:http'; import { Socket } from 'node:net'; + import { defer, listen } from './spec-helpers'; // See https://github.com/nodejs/node/issues/40702. diff --git a/spec/lib/screen-helpers.ts b/spec/lib/screen-helpers.ts index 3dc84bbd80db..a232c95a7c38 100644 --- a/spec/lib/screen-helpers.ts +++ b/spec/lib/screen-helpers.ts @@ -1,7 +1,9 @@ import { screen, desktopCapturer, NativeImage } from 'electron'; -import { createArtifactWithRandomId } from './artifacts'; + import { AssertionError } from 'chai'; +import { createArtifactWithRandomId } from './artifacts'; + export enum HexColors { GREEN = '#00b140', PURPLE = '#6a0dad', diff --git a/spec/lib/spec-helpers.ts b/spec/lib/spec-helpers.ts index b12ca77b5574..42046e85eeeb 100644 --- a/spec/lib/spec-helpers.ts +++ b/spec/lib/spec-helpers.ts @@ -1,14 +1,16 @@ -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 http2 from 'node:http2'; -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'; +import { SuiteFunction, TestFunction } from 'mocha'; + +import * as childProcess from 'node:child_process'; +import * as http from 'node:http'; +import * as http2 from 'node:http2'; +import * as https from 'node:https'; +import * as net from 'node:net'; +import * as path from 'node:path'; +import * as url from 'node:url'; +import * as v8 from 'node:v8'; const addOnly = (fn: Function): T => { const wrapped = (...args: any[]) => { diff --git a/spec/lib/window-helpers.ts b/spec/lib/window-helpers.ts index 6571d74189e8..77a8913df7dc 100644 --- a/spec/lib/window-helpers.ts +++ b/spec/lib/window-helpers.ts @@ -1,5 +1,7 @@ -import { expect } from 'chai'; import { BaseWindow, BrowserWindow } from 'electron/main'; + +import { expect } from 'chai'; + import { once } from 'node:events'; async function ensureWindowIsClosed (window: BaseWindow | null) { diff --git a/spec/logging-spec.ts b/spec/logging-spec.ts index dfa2538bc2ae..46fa410a07d2 100644 --- a/spec/logging-spec.ts +++ b/spec/logging-spec.ts @@ -1,11 +1,13 @@ import { app } from 'electron'; -import { expect } from 'chai'; -import { startRemoteControlApp, ifdescribe } from './lib/spec-helpers'; +import { expect } from 'chai'; +import * as uuid from 'uuid'; + +import { once } from 'node:events'; import * as fs from 'node:fs/promises'; import * as path from 'node:path'; -import * as uuid from 'uuid'; -import { once } from 'node:events'; + +import { startRemoteControlApp, ifdescribe } from './lib/spec-helpers'; function isTestingBindingAvailable () { try { diff --git a/spec/modules-spec.ts b/spec/modules-spec.ts index 22cf62804310..de79012fac38 100644 --- a/spec/modules-spec.ts +++ b/spec/modules-spec.ts @@ -1,11 +1,14 @@ -import { expect } from 'chai'; -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 { expect } from 'chai'; + import * as childProcess from 'node:child_process'; import { once } from 'node:events'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; + +import { ifdescribe, ifit } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; const Module = require('node:module') as NodeJS.ModuleInternal; diff --git a/spec/node-spec.ts b/spec/node-spec.ts index 9c5059172c83..d3f68030a2ab 100644 --- a/spec/node-spec.ts +++ b/spec/node-spec.ts @@ -1,14 +1,17 @@ +import { webContents } from 'electron/main'; + import { expect } from 'chai'; + import * as childProcess from 'node:child_process'; +import { once } from 'node:events'; 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 { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers'; -import { webContents } from 'electron/main'; import { EventEmitter } from 'node:stream'; -import { once } from 'node:events'; +import * as util from 'node:util'; + +import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers'; import { withTempDirectory } from './lib/fs-helpers'; +import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers'; const mainFixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/parse-features-string-spec.ts b/spec/parse-features-string-spec.ts index be561064b507..1392ae1582b8 100644 --- a/spec/parse-features-string-spec.ts +++ b/spec/parse-features-string-spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; + import { parseCommaSeparatedKeyValue } from '../lib/browser/parse-features-string'; describe('feature-string parsing', () => { diff --git a/spec/process-binding-spec.ts b/spec/process-binding-spec.ts index 343e7536cbd5..db734208e5f1 100644 --- a/spec/process-binding-spec.ts +++ b/spec/process-binding-spec.ts @@ -1,5 +1,7 @@ -import { expect } from 'chai'; import { BrowserWindow } from 'electron/main'; + +import { expect } from 'chai'; + import { closeAllWindows } from './lib/window-helpers'; describe('process._linkedBinding', () => { diff --git a/spec/release-notes-spec.ts b/spec/release-notes-spec.ts index c2631113cdad..30d5329ed436 100644 --- a/spec/release-notes-spec.ts +++ b/spec/release-notes-spec.ts @@ -1,9 +1,11 @@ -import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite'; import { expect } from 'chai'; -import * as notes from '../script/release/notes/notes'; -import * as path from 'node:path'; +import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite'; import * as sinon from 'sinon'; +import * as path from 'node:path'; + +import * as notes from '../script/release/notes/notes'; + /* Fake a Dugite GitProcess that only returns the specific commits that we want to test */ diff --git a/spec/security-warnings-spec.ts b/spec/security-warnings-spec.ts index ea356e0d016f..19e563b41dbf 100644 --- a/spec/security-warnings-spec.ts +++ b/spec/security-warnings-spec.ts @@ -1,14 +1,15 @@ -import { expect } from 'chai'; -import * as http from 'node:http'; -import * as fs from 'node:fs/promises'; -import * as path from 'node:path'; - import { BrowserWindow, WebPreferences } from 'electron/main'; -import { closeWindow } from './lib/window-helpers'; +import { expect } from 'chai'; + +import * as fs from 'node:fs/promises'; +import * as http from 'node:http'; +import * as path from 'node:path'; +import { setTimeout } from 'node:timers/promises'; + import { emittedUntil } from './lib/events-helpers'; import { listen } from './lib/spec-helpers'; -import { setTimeout } from 'node:timers/promises'; +import { closeWindow } from './lib/window-helpers'; const messageContainsSecurityWarning = (event: Event, level: number, message: string) => { return message.includes('Electron Security Warning'); diff --git a/spec/spellchecker-spec.ts b/spec/spellchecker-spec.ts index 3d92fedc7335..25341e4bddc9 100644 --- a/spec/spellchecker-spec.ts +++ b/spec/spellchecker-spec.ts @@ -1,14 +1,16 @@ import { BrowserWindow, Session, session } from 'electron/main'; import { expect } from 'chai'; -import * as path from 'node:path'; + +import { once } from 'node:events'; import * as fs from 'node:fs/promises'; import * as http from 'node:http'; -import { closeWindow } from './lib/window-helpers'; -import { ifit, ifdescribe, listen } from './lib/spec-helpers'; -import { once } from 'node:events'; +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import { ifit, ifdescribe, listen } from './lib/spec-helpers'; +import { closeWindow } from './lib/window-helpers'; + const features = process._linkedBinding('electron_common_features'); const v8Util = process._linkedBinding('electron_common_v8_util'); diff --git a/spec/ts-smoke/runner.js b/spec/ts-smoke/runner.js index 2584c98b9d3b..9099e42866d3 100644 --- a/spec/ts-smoke/runner.js +++ b/spec/ts-smoke/runner.js @@ -1,5 +1,5 @@ -const path = require('node:path'); const childProcess = require('node:child_process'); +const path = require('node:path'); const typeCheck = () => { const tscExec = path.resolve(require.resolve('typescript'), '../../bin/tsc'); diff --git a/spec/version-bump-spec.ts b/spec/version-bump-spec.ts index c1117707096d..e84d4a82ac53 100644 --- a/spec/version-bump-spec.ts +++ b/spec/version-bump-spec.ts @@ -1,8 +1,9 @@ import { expect } from 'chai'; import { GitProcess, IGitExecutionOptions, IGitResult } from 'dugite'; -import { nextVersion } from '../script/release/version-bumper'; import * as sinon from 'sinon'; + import { ifdescribe } from './lib/spec-helpers'; +import { nextVersion } from '../script/release/version-bumper'; class GitFake { branches: { diff --git a/spec/visibility-state-spec.ts b/spec/visibility-state-spec.ts index 6edfcdf12695..2f23420d803c 100644 --- a/spec/visibility-state-spec.ts +++ b/spec/visibility-state-spec.ts @@ -1,13 +1,15 @@ -import { expect } from 'chai'; -import * as cp from 'node:child_process'; import { BaseWindow, BrowserWindow, BrowserWindowConstructorOptions, ipcMain, WebContents, WebContentsView } from 'electron/main'; -import * as path from 'node:path'; -import { closeWindow } from './lib/window-helpers'; -import { ifdescribe } from './lib/spec-helpers'; +import { expect } from 'chai'; + +import * as cp from 'node:child_process'; import { once } from 'node:events'; +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import { ifdescribe } from './lib/spec-helpers'; +import { closeWindow } from './lib/window-helpers'; + // visibilityState specs pass on linux with a real window manager but on CI // the environment does not let these specs pass ifdescribe(process.platform !== 'linux')('document.visibilityState', () => { diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts index 1a099d2688f0..18981551be5b 100644 --- a/spec/webview-spec.ts +++ b/spec/webview-spec.ts @@ -1,15 +1,18 @@ -import * as path from 'node:path'; -import * as url from 'node:url'; import { BrowserWindow, session, ipcMain, app, WebContents } from 'electron/main'; -import { closeAllWindows } from './lib/window-helpers'; -import { emittedUntil } from './lib/events-helpers'; -import { ifit, ifdescribe, defer, itremote, useRemoteContext, listen } from './lib/spec-helpers'; -import { expect } from 'chai'; -import * as http from 'node:http'; + import * as auth from 'basic-auth'; +import { expect } from 'chai'; + import { once } from 'node:events'; +import * as http from 'node:http'; +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +import * as url from 'node:url'; + +import { emittedUntil } from './lib/events-helpers'; import { HexColors, ScreenCapture } from './lib/screen-helpers'; +import { ifit, ifdescribe, defer, itremote, useRemoteContext, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; declare let WebView: any; const features = process._linkedBinding('electron_common_features');