sha,author,date,commit_message,git_diff,type f72e6551f093e7f9f02531c6a69f390521463bf8,Webster Xu,2022-12-15 01:37:28,"fix: use the process cache to reduce the memory for asar file (#36600) * fix: use the process cache to reduce the memory for asar file * Update shell/common/api/electron_api_asar.cc Co-authored-by: webster.xu Co-authored-by: Jeremy Rose ","diff --git a/shell/common/api/electron_api_asar.cc b/shell/common/api/electron_api_asar.cc index 0b2397ff2c..dc98314cb3 100644 --- a/shell/common/api/electron_api_asar.cc +++ b/shell/common/api/electron_api_asar.cc @@ -39,7 +39,7 @@ class Archive : public node::ObjectWrap { Archive& operator=(const Archive&) = delete; protected: - explicit Archive(std::unique_ptr archive) + explicit Archive(std::shared_ptr archive) : archive_(std::move(archive)) {} static void New(const v8::FunctionCallbackInfo& args) { @@ -52,8 +52,8 @@ class Archive : public node::ObjectWrap { return; } - auto archive = std::make_unique(path); - if (!archive->Init()) { + std::shared_ptr archive = asar::GetOrCreateAsarArchive(path); + if (!archive) { isolate->ThrowException(v8::Exception::Error(node::FIXED_ONE_BYTE_STRING( isolate, ""failed to initialize archive""))); return; @@ -190,7 +190,7 @@ class Archive : public node::ObjectWrap { isolate, wrap->archive_ ? wrap->archive_->GetUnsafeFD() : -1)); } - std::unique_ptr archive_; + std::shared_ptr archive_; }; static void InitAsarSupport(const v8::FunctionCallbackInfo& args) {",fix 81a454d148efa3e272bd04630f664398e4eba210,Milan Burda,2023-06-26 19:51:59,"chore: re-enable node/no-deprecated-api linting (#38899) * chore: re-enable node/no-deprecated-api linting * chore: re-enable no-global-assign linting","diff --git a/.eslintrc.json b/.eslintrc.json index 74e61c612d..44fd89858b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,7 +10,6 @@ ""semi"": [""error"", ""always""], ""no-var"": ""error"", ""no-unused-vars"": ""off"", - ""no-global-assign"": ""off"", ""guard-for-in"": ""error"", ""@typescript-eslint/no-unused-vars"": [""error"", { ""vars"": ""all"", @@ -20,8 +19,7 @@ ""prefer-const"": [""error"", { ""destructuring"": ""all"" }], - ""standard/no-callback-literal"": ""off"", - ""node/no-deprecated-api"": ""off"" + ""standard/no-callback-literal"": ""off"" }, ""parserOptions"": { ""ecmaVersion"": 6, diff --git a/lib/browser/api/net-client-request.ts b/lib/browser/api/net-client-request.ts index 49476db8c5..cf37d60826 100644 --- a/lib/browser/api/net-client-request.ts +++ b/lib/browser/api/net-client-request.ts @@ -209,6 +209,7 @@ type ExtraURLLoaderOptions = { allowNonHttpProtocols: boolean; } function parseOptions (optionsIn: ClientRequestConstructorOptions | string): NodeJS.CreateURLLoaderOptions & ExtraURLLoaderOptions { + // eslint-disable-next-line node/no-deprecated-api const options: any = typeof optionsIn === 'string' ? url.parse(optionsIn) : { ...optionsIn }; let urlStr: string = options.url; @@ -241,6 +242,7 @@ function parseOptions (optionsIn: ClientRequestConstructorOptions | string): Nod // an invalid request. throw new TypeError('Request path contains unescaped characters'); } + // eslint-disable-next-line node/no-deprecated-api const pathObj = url.parse(options.path || '/'); urlObj.pathname = pathObj.pathname; urlObj.search = pathObj.search; diff --git a/lib/browser/devtools.ts b/lib/browser/devtools.ts index 89422f80a2..b6189e4001 100644 --- a/lib/browser/devtools.ts +++ b/lib/browser/devtools.ts @@ -1,6 +1,5 @@ import { dialog, Menu } from 'electron/main'; import * as fs from 'fs'; -import * as url from 'url'; import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; @@ -49,7 +48,7 @@ const getEditMenuItems = function (): Electron.MenuItemConstructorOptions[] { }; const isChromeDevTools = function (pageURL: string) { - const { protocol } = url.parse(pageURL); + const { protocol } = new URL(pageURL); return protocol === 'devtools:'; }; ",chore a867503af63bcf24f935ae32fc8d88fe5e7a786a,Milan Burda,2023-10-23 11:30:08,test: add spec for `child-process-gone` event for utility process (#40281),"diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index 8880f3d693..f5e2542a21 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -29,7 +29,7 @@ Process: [Main](../glossary.md#main-process)
* `inherit`: equivalent to \['ignore', 'inherit', 'inherit'] * `serviceName` string (optional) - Name of the process that will appear in `name` property of [`child-process-gone` event of `app`](app.md#event-child-process-gone). - Default is `node.mojom.NodeService`. + Default is `Node Utility Process`. * `allowLoadingUnsignedLibraries` boolean (optional) _macOS_ - With this flag, the utility process will be launched via the `Electron Helper (Plugin).app` helper executable on macOS, which can be codesigned with `com.apple.security.cs.disable-library-validation` and diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index f8b1280a31..b87920d354 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as childProcess from 'node:child_process'; import * as path from 'node:path'; -import { BrowserWindow, MessageChannelMain, utilityProcess } from 'electron/main'; +import { BrowserWindow, MessageChannelMain, utilityProcess, app } from 'electron/main'; import { ifit } from './lib/spec-helpers'; import { closeWindow } from './lib/window-helpers'; import { once } from 'node:events'; @@ -93,6 +93,26 @@ describe('utilityProcess module', () => { }); }); + describe('app \'child-process-gone\' event', () => { + it('with default serviceName', async () => { + utilityProcess.fork(path.join(fixturesPath, 'crash.js')); + const [, details] = await once(app, 'child-process-gone') as [any, Electron.Details]; + expect(details.type).to.equal('Utility'); + expect(details.serviceName).to.equal('node.mojom.NodeService'); + expect(details.name).to.equal('Node Utility Process'); + expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']); + }); + + it('with custom serviceName', async () => { + utilityProcess.fork(path.join(fixturesPath, 'crash.js'), [], { serviceName: 'Hello World!' }); + const [, details] = await once(app, 'child-process-gone') as [any, Electron.Details]; + expect(details.type).to.equal('Utility'); + expect(details.serviceName).to.equal('node.mojom.NodeService'); + expect(details.name).to.equal('Hello World!'); + expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']); + }); + }); + describe('kill() API', () => { it('terminates the child process gracefully', async () => { const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'), [], {",test c6b4bde7b5b989d4e584fa106ff1404aa18611de,Niklas Wenzel,2024-12-02 19:50:35,"docs: clarify what session.clearData() with data type 'cache' deletes (#44852) * docs: clarify what session.clearData() with data type 'cache' deletes * docs: include `shadercache`, too Co-authored-by: John Kleinschmidt --------- Co-authored-by: John Kleinschmidt ","diff --git a/docs/api/session.md b/docs/api/session.md index cb897adf5f..e560d27fc2 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -1513,7 +1513,7 @@ session is persisted on disk. For in memory sessions this returns `null`. can potentially include data types not explicitly listed here. (See Chromium's [`BrowsingDataRemover`][browsing-data-remover] for the full list.) * `backgroundFetch` - Background Fetch - * `cache` - Cache + * `cache` - Cache (includes `cachestorage` and `shadercache`) * `cookies` - Cookies * `downloads` - Downloads * `fileSystems` - File Systems",docs 0128a072d6a3d445adf77c3c02cf2f78b214eb7c,Peter Xu,2024-05-08 17:21:26,docs: make corrections for BrowserViews since it is deprecated (#42030),"diff --git a/docs/tutorial/web-embeds.md b/docs/tutorial/web-embeds.md index aa273ec333..e92cbe8fce 100644 --- a/docs/tutorial/web-embeds.md +++ b/docs/tutorial/web-embeds.md @@ -4,7 +4,7 @@ If you want to embed (third-party) web content in an Electron `BrowserWindow`, there are three options available to you: ``); - await setTimeout(1000); - w.webContents.debugger.attach('1.1'); - const targets = await w.webContents.debugger.sendCommand('Target.getTargets'); - const iframeTarget = targets.targetInfos.find((t: any) => t.type === 'iframe'); - const { sessionId } = await w.webContents.debugger.sendCommand('Target.attachToTarget', { - targetId: iframeTarget.targetId, - flatten: true - }); - let willNavigateEmitted = false; - w.webContents.on('will-navigate', () => { - willNavigateEmitted = true; + w.loadURL(`data:text/html,`); + await emittedUntil(w.webContents, 'did-frame-finish-load', (e: any, isMainFrame: boolean) => !isMainFrame); + let initiator: WebFrameMain | undefined; + w.webContents.on('will-navigate', (e) => { + initiator = e.initiator; }); - await w.webContents.debugger.sendCommand('Input.dispatchMouseEvent', { - type: 'mousePressed', - x: 10, - y: 10, - clickCount: 1, - button: 'left' - }, sessionId); - await w.webContents.debugger.sendCommand('Input.dispatchMouseEvent', { - type: 'mouseReleased', - x: 10, - y: 10, - clickCount: 1, - button: 'left' - }, sessionId); + const subframe = w.webContents.mainFrame.frames[0]; + subframe.executeJavaScript('document.getElementsByTagName(""a"")[0].click()', true); await once(w.webContents, 'did-navigate'); - expect(willNavigateEmitted).to.be.true(); + expect(initiator).not.to.be.undefined(); + expect(initiator).to.equal(subframe); }); }); ",feat 768ece6b54f78e65efbea2c3fd39eea30e48332b,Shelley Vohr,2024-02-06 11:30:35,"feat: add `BrowserWindow.isOccluded()` (#38982) feat: add BrowserWindow.isOccluded()","diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 2abb6f1c34..f6a0884bbc 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -644,6 +644,14 @@ Shows the window but doesn't focus on it. Hides the window. +#### `win.isOccluded()` + +Returns `boolean` - Whether the window is covered by other windows. + +On macOS, a `BrowserWindow` is occluded if the entire window is obscured by other windows. A completely transparent window may also be considered non-occluded. See [docs](https://developer.apple.com/documentation/appkit/nswindowocclusionstate?language=objc) for more details. + +On Windows and Linux, a window is occluded if it or one of its descendants is visible, and all visible windows have their bounds completely covered by fully opaque windows. A window is considered ""fully opaque"" if it is visible, it is not transparent, and its combined opacity is 1. See [Chromium Source](https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:ui/aura/window.h;l=124-151;drc=7d2d8ccab2b68fbbfc5e1611d45bd4ecf87090b8) for more details. + #### `win.isVisible()` Returns `boolean` - Whether the window is visible to the user in the foreground of the app. diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 7b040f8cad..2c2dcdde7f 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -355,6 +355,10 @@ bool BaseWindow::IsVisible() const { return window_->IsVisible(); } +bool BaseWindow::IsOccluded() const { + return window_->IsOccluded(); +} + bool BaseWindow::IsEnabled() const { return window_->IsEnabled(); } @@ -1086,6 +1090,7 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate, .SetMethod(""showInactive"", &BaseWindow::ShowInactive) .SetMethod(""hide"", &BaseWindow::Hide) .SetMethod(""isVisible"", &BaseWindow::IsVisible) + .SetMethod(""isOccluded"", &BaseWindow::IsOccluded) .SetMethod(""isEnabled"", &BaseWindow::IsEnabled) .SetMethod(""setEnabled"", &BaseWindow::SetEnabled) .SetMethod(""maximize"", &BaseWindow::Maximize) diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index 7bff94b776..d3c583e2c9 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -98,6 +98,7 @@ class BaseWindow : public gin_helper::TrackableObject, void ShowInactive(); void Hide(); bool IsVisible() const; + bool IsOccluded() const; bool IsEnabled() const; void SetEnabled(bool enable); void Maximize(); diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index bc7868cc07..1b907eae7f 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -87,6 +87,7 @@ class NativeWindow : public base::SupportsUserData, virtual void Show() = 0; virtual void ShowInactive() = 0; virtual void Hide() = 0; + virtual bool IsOccluded() const = 0; virtual bool IsVisible() const = 0; virtual bool IsEnabled() const = 0; virtual void SetEnabled(bool enable) = 0; diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index fd359e9cce..aa76169936 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -44,6 +44,7 @@ class NativeWindowMac : public NativeWindow, void Show() override; void ShowInactive() override; void Hide() override; + bool IsOccluded() const override; bool IsVisible() const override; bool IsEnabled() const override; void SetEnabled(bool enable) override; diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 14438b7eb2..3d13a2008a 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -561,9 +561,12 @@ void NativeWindowMac::Hide() { [window_ orderOut:nil]; } +bool NativeWindowMac::IsOccluded() const { + return !([window_ occlusionState] & NSWindowOcclusionStateVisible); +} + bool NativeWindowMac::IsVisible() const { - bool occluded = [window_ occlusionState] == NSWindowOcclusionStateVisible; - return [window_ isVisible] && !occluded && !IsMinimized(); + return [window_ isVisible] && !IsMinimized(); } bool NativeWindowMac::IsEnabled() const { diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 4292c0cafe..f3afe1d84e 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -562,6 +562,14 @@ void NativeWindowViews::Hide() { #endif } +bool NativeWindowViews::IsOccluded() const { + if (!GetNativeWindow()) + return false; + auto occlusion_state = + GetNativeWindow()->GetHost()->GetNativeWindowOcclusionState(); + return occlusion_state == aura::Window::OcclusionState::OCCLUDED; +} + bool NativeWindowViews::IsVisible() const { #if BUILDFLAG(IS_WIN) // widget()->IsVisible() calls ::IsWindowVisible, which returns non-zero if a diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index e5683cecf0..ee0c13c888 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -56,6 +56,7 @@ class NativeWindowViews : public NativeWindow, void Hide() override; bool IsVisible() const override; bool IsEnabled() const override; + bool IsOccluded() const override; void SetEnabled(bool enable) override; void Maximize() override; void Unmaximize() override; diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index a8a1fc9380..11e73beff1 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -4164,6 +4164,65 @@ describe('BrowserWindow module', () => { }); }); + describe('BrowserWindow.isOccluded()', () => { + afterEach(closeAllWindows); + + it('returns false for a visible window', async () => { + const w = new BrowserWindow({ show: false }); + + const shown = once(w, 'show'); + w.show(); + await shown; + + expect(w.isOccluded()).to.be.false('window is occluded'); + }); + + it('returns false when the window is only partially obscured', async () => { + const w1 = new BrowserWindow({ width: 400, height: 400 }); + const w2 = new BrowserWindow({ show: false, width: 450, height: 450 }); + + const focused = once(w2, 'focus'); + w2.show(); + await focused; + + await setTimeout(1000); + expect(w1.isOccluded()).to.be.true('window is not occluded'); + + const pos = w2.getPosition(); + const move = once(w2, 'move'); + w2.setPosition(pos[0] - 100, pos[1]); + await move; + + await setTimeout(1000); + expect(w1.isOccluded()).to.be.false('window is occluded'); + }); + + // FIXME: this test fails on Linux CI due to windowing issues. + ifit(process.platform !== 'linux')('returns false for a visible window covered by a transparent window', async () => { + const w1 = new BrowserWindow({ width: 200, height: 200 }); + const w2 = new BrowserWindow({ show: false, transparent: true, frame: false }); + + const focused = once(w2, 'focus'); + w2.show(); + await focused; + + await setTimeout(1000); + expect(w1.isOccluded()).to.be.false('window is occluded'); + }); + + it('returns true for an obscured window', async () => { + const w1 = new BrowserWindow({ width: 200, height: 200 }); + const w2 = new BrowserWindow({ show: false }); + + const focused = once(w2, 'focus'); + w2.show(); + await focused; + + await setTimeout(1000); + expect(w1.isOccluded()).to.be.true('visible window'); + }); + }); + // TODO(codebytere): figure out how to make these pass in CI on Windows. ifdescribe(process.platform !== 'win32')('document.visibilityState/hidden', () => { afterEach(closeAllWindows);",feat e991c1868e301fab1fa9c160cc1317a47a468e8c,Sergei Chestakov,2023-07-03 04:30:45,"docs: fix misleading code sample for handling deeplinks on Linux (#38862) Fix misleading docs for handling deeplinks in Linux","diff --git a/docs/tutorial/launch-app-from-url-in-another-app.md b/docs/tutorial/launch-app-from-url-in-another-app.md index 4fe2212d04..d386858348 100644 --- a/docs/tutorial/launch-app-from-url-in-another-app.md +++ b/docs/tutorial/launch-app-from-url-in-another-app.md @@ -63,9 +63,9 @@ const createWindow = () => { In this next step, we will create our `BrowserWindow` and tell our application how to handle an event in which an external protocol is clicked. -This code will be different in Windows compared to MacOS and Linux. This is due to Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](../api/app.md#apprequestsingleinstancelockadditionaldata). +This code will be different in Windows and Linux compared to MacOS. This is due to both platforms emitting the `second-instance` event rather than the `open-url` event and Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](../api/app.md#apprequestsingleinstancelockadditionaldata). -#### Windows code: +#### Windows and Linux code: ```javascript @ts-type={mainWindow:Electron.BrowserWindow} @ts-type={createWindow:()=>void} const gotTheLock = app.requestSingleInstanceLock() @@ -80,8 +80,7 @@ if (!gotTheLock) { mainWindow.focus() } // the commandLine is array of strings in which last element is deep link url - // the url str ends with / - dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop().slice(0, -1)}`) + dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop()}`) }) // Create mainWindow, load the rest of the app, etc... @@ -91,7 +90,7 @@ if (!gotTheLock) { } ``` -#### MacOS and Linux code: +#### MacOS code: ```javascript @ts-type={createWindow:()=>void} // This method will be called when Electron has finished",docs e929b2140d4a1b8bce621f8826639e38cb3f3c6d,David Sanders,2023-04-10 23:27:07,chore: change some for loops to range-based (#37857),"diff --git a/shell/browser/api/electron_api_service_worker_context.cc b/shell/browser/api/electron_api_service_worker_context.cc index 402f900d38..959a87bc68 100644 --- a/shell/browser/api/electron_api_service_worker_context.cc +++ b/shell/browser/api/electron_api_service_worker_context.cc @@ -115,10 +115,10 @@ v8::Local ServiceWorkerContext::GetAllRunningWorkerInfo( gin::DataObjectBuilder builder(isolate); const base::flat_map& info_map = service_worker_context_->GetRunningServiceWorkerInfos(); - for (auto iter = info_map.begin(); iter != info_map.end(); ++iter) { + for (const auto& iter : info_map) { builder.Set( - std::to_string(iter->first), - ServiceWorkerRunningInfoToDict(isolate, std::move(iter->second))); + std::to_string(iter.first), + ServiceWorkerRunningInfoToDict(isolate, std::move(iter.second))); } return builder.Build(); } diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index 173813354b..4faf28cce4 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -240,8 +240,8 @@ std::vector MessagePort::DisentanglePorts( // Passed-in ports passed validity checks, so we can disentangle them. std::vector channels; channels.reserve(ports.size()); - for (unsigned i = 0; i < ports.size(); ++i) - channels.push_back(ports[i]->Disentangle()); + for (auto port : ports) + channels.push_back(port->Disentangle()); return channels; } diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index f7b6c37b08..4df91635ea 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -578,8 +578,7 @@ bool Converter>::FromV8( return false; base::Value::List& list = list_value.GetList(); *out = base::MakeRefCounted(); - for (size_t i = 0; i < list.size(); ++i) { - base::Value& dict_value = list[i]; + for (base::Value& dict_value : list) { if (!dict_value.is_dict()) return false; base::Value::Dict& dict = dict_value.GetDict();",chore 46af43db495f334c5e56697392b552e30777a12f,Shelley Vohr,2024-08-20 22:49:02,chore: cherry-pick 9797576 from v8 (#43376),"diff --git a/patches/v8/.patches b/patches/v8/.patches index 886a2ec1a3..7ab46bcb82 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -1,3 +1,4 @@ chore_allow_customizing_microtask_policy_per_context.patch deps_add_v8_object_setinternalfieldfornodecore.patch fix_disable_scope_reuse_associated_dchecks.patch +spill_all_loop_inputs_before_entering_loop.patch diff --git a/patches/v8/spill_all_loop_inputs_before_entering_loop.patch b/patches/v8/spill_all_loop_inputs_before_entering_loop.patch new file mode 100644 index 0000000000..c9c42f7693 --- /dev/null +++ b/patches/v8/spill_all_loop_inputs_before_entering_loop.patch @@ -0,0 +1,104 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Clemens Backes +Date: Tue, 20 Aug 2024 12:25:40 +0200 +Subject: Spill all loop inputs before entering loop + +This avoids having to load the value back into a register if it was +spilled inside of the loop. + +R=jkummerow@chromium.org + +Fixed: chromium:360700873 +Change-Id: I24f5deacebc893293e8a3c007e9f070c7fa0ccd2 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5797073 +Reviewed-by: Jakob Kummerow +Commit-Queue: Clemens Backes +Cr-Commit-Position: refs/heads/main@{#95711} + +diff --git a/src/wasm/baseline/liftoff-assembler.cc b/src/wasm/baseline/liftoff-assembler.cc +index ffc8dbb4f99ff8d340efd705f2059e39e046a47f..e1ca02f7adc84ae9e82e9f9b668abde9eb37b94a 100644 +--- a/src/wasm/baseline/liftoff-assembler.cc ++++ b/src/wasm/baseline/liftoff-assembler.cc +@@ -424,29 +424,10 @@ void LiftoffAssembler::DropExceptionValueAtOffset(int offset) { + cache_state_.stack_state.pop_back(); + } + +-void LiftoffAssembler::PrepareLoopArgs(int num) { +- for (int i = 0; i < num; ++i) { +- VarState& slot = cache_state_.stack_state.end()[-1 - i]; +- if (slot.is_stack()) continue; +- RegClass rc = reg_class_for(slot.kind()); +- if (slot.is_reg()) { +- if (cache_state_.get_use_count(slot.reg()) > 1) { +- // If the register is used more than once, we cannot use it for the +- // merge. Move it to an unused register instead. +- LiftoffRegList pinned; +- pinned.set(slot.reg()); +- LiftoffRegister dst_reg = GetUnusedRegister(rc, pinned); +- Move(dst_reg, slot.reg(), slot.kind()); +- cache_state_.dec_used(slot.reg()); +- cache_state_.inc_used(dst_reg); +- slot.MakeRegister(dst_reg); +- } +- continue; +- } +- LiftoffRegister reg = GetUnusedRegister(rc, {}); +- LoadConstant(reg, slot.constant()); +- slot.MakeRegister(reg); +- cache_state_.inc_used(reg); ++void LiftoffAssembler::SpillLoopArgs(int num) { ++ for (VarState& slot : ++ base::VectorOf(cache_state_.stack_state.end() - num, num)) { ++ Spill(&slot); + } + } + +@@ -664,14 +645,14 @@ void LiftoffAssembler::Spill(VarState* slot) { + } + + void LiftoffAssembler::SpillLocals() { +- for (uint32_t i = 0; i < num_locals_; ++i) { +- Spill(&cache_state_.stack_state[i]); ++ for (VarState& local_slot : ++ base::VectorOf(cache_state_.stack_state.data(), num_locals_)) { ++ Spill(&local_slot); + } + } + + void LiftoffAssembler::SpillAllRegisters() { +- for (uint32_t i = 0, e = cache_state_.stack_height(); i < e; ++i) { +- auto& slot = cache_state_.stack_state[i]; ++ for (VarState& slot : cache_state_.stack_state) { + if (!slot.is_reg()) continue; + Spill(slot.offset(), slot.reg(), slot.kind()); + slot.MakeStack(); +diff --git a/src/wasm/baseline/liftoff-assembler.h b/src/wasm/baseline/liftoff-assembler.h +index 2fb62ff39c65ad2a621b51628716265b11cb4bd0..274c78c2ed4b9d8968df19915d33caf96c5017e0 100644 +--- a/src/wasm/baseline/liftoff-assembler.h ++++ b/src/wasm/baseline/liftoff-assembler.h +@@ -477,9 +477,9 @@ class LiftoffAssembler : public MacroAssembler { + // the bottom of the stack. + void DropExceptionValueAtOffset(int offset); + +- // Ensure that the loop inputs are either in a register or spilled to the +- // stack, so that we can merge different values on the back-edge. +- void PrepareLoopArgs(int num); ++ // Spill all loop inputs to the stack to free registers and to ensure that we ++ // can merge different values on the back-edge. ++ void SpillLoopArgs(int num); + + V8_INLINE static int NextSpillOffset(ValueKind kind, int top_spill_offset); + V8_INLINE int NextSpillOffset(ValueKind kind); +diff --git a/src/wasm/baseline/liftoff-compiler.cc b/src/wasm/baseline/liftoff-compiler.cc +index e4a894d2b364c4546d92819ab1ce8fb11eabfaff..71c3ad9aa1742b93bb4bf5fc707077dff7f0e92e 100644 +--- a/src/wasm/baseline/liftoff-compiler.cc ++++ b/src/wasm/baseline/liftoff-compiler.cc +@@ -1395,7 +1395,7 @@ class LiftoffCompiler { + // pre-analysis of the function. + __ SpillLocals(); + +- __ PrepareLoopArgs(loop->start_merge.arity); ++ __ SpillLoopArgs(loop->start_merge.arity); + + // Loop labels bind at the beginning of the block. + __ bind(loop->label.get());",chore 4d6f230d2108c19ac862577e83443a2eec53a183,Keeley Hammond,2023-02-14 07:44:39,"build: re-bake node v18.12.1 image for asset upload (#37254) * debug: peek node version * build: force uninstall/reinstall 18.12.1 * build: update image, re-comment out deps * build: remove nodejs-lts uninstall, node debug line","diff --git a/appveyor.yml b/appveyor.yml index aea2e340d2..57a550769c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-110.0.5451.0 +image: e-111.0.5560.0-node18 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/script/setup-win-for-dev.bat b/script/setup-win-for-dev.bat index c1a050f0dc..d311c0fc62 100644 --- a/script/setup-win-for-dev.bat +++ b/script/setup-win-for-dev.bat @@ -56,7 +56,7 @@ REM Install Windows SDK choco install windows-sdk-10-version-2104-all REM Install nodejs python git and yarn needed dependencies -choco install -y --force nodejs@v18.12.1 +choco install -y --force nodejs --version=18.12.1 choco install -y python2 git yarn choco install python --version 3.7.9 call C:\ProgramData\chocolatey\bin\RefreshEnv.cmd",build ee8d97d7febb70ace0da79fda476a6d0513335fe,tr2-harada,2023-12-05 17:53:52,"build: update typescript-definitions to 8.15.2 (#40670) * build: update typescript-definitions to 8.15.2 * chore: update yarn.lock --------- Co-authored-by: John Kleinschmidt ","diff --git a/package.json b/package.json index a42a8ec951..e119e99144 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ ""@electron/fiddle-core"": ""^1.0.4"", ""@electron/github-app-auth"": ""^2.0.0"", ""@electron/lint-roller"": ""^1.9.0"", - ""@electron/typescript-definitions"": ""^8.15.1"", + ""@electron/typescript-definitions"": ""^8.15.2"", ""@octokit/rest"": ""^19.0.7"", ""@primer/octicons"": ""^10.0.0"", ""@types/basic-auth"": ""^1.1.3"", diff --git a/yarn.lock b/yarn.lock index 499d64e6bb..517c919626 100644 --- a/yarn.lock +++ b/yarn.lock @@ -219,10 +219,10 @@ vscode-languageserver-textdocument ""^1.0.8"" vscode-uri ""^3.0.7"" -""@electron/typescript-definitions@^8.15.1"": - version ""8.15.1"" - resolved ""https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.15.1.tgz#9d4ff7361e8a4dee65d353e2884e7733c1c12dad"" - integrity sha512-R8Kl8J+o+q3Pn1tM4fU4Qan63g1Oyd1meAlHwIPAJ8LfYC/N09SYJcNuwgvaxb/SHFIcr4BWZKHOVa4makuo6A== +""@electron/typescript-definitions@^8.15.2"": + version ""8.15.2"" + resolved ""https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.15.2.tgz#1152e3d3731d236b50a3dee5a108176ce43fd703"" + integrity sha512-6vlWnnNfZrg9QFOGgoLaQZ/nTCg+Y1laz02pUsRRmCJIpJZOY3HnWnIuav7e8g5IIwHMVc8JSohR+YRgiRk/eA== dependencies: ""@types/node"" ""^11.13.7"" chalk ""^2.4.2""",build dd7395ebedf0cfef3129697f9585035a4ddbde63,Bruno Pitrus,2023-09-28 18:50:58,chore: add missing include for std::variant (#40007),"diff --git a/shell/browser/electron_browser_context.h b/shell/browser/electron_browser_context.h index a758d72fed..80581f2d3f 100644 --- a/shell/browser/electron_browser_context.h +++ b/shell/browser/electron_browser_context.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h""",chore 8d689c565a6168fbeb68a2d971f9d1a2f1666375,Shelley Vohr,2023-06-05 14:08:10,fix: file selection when disallowed on macOS (#38557),"diff --git a/shell/browser/ui/file_dialog_mac.mm b/shell/browser/ui/file_dialog_mac.mm index 30f56219f4..0a268365b5 100644 --- a/shell/browser/ui/file_dialog_mac.mm +++ b/shell/browser/ui/file_dialog_mac.mm @@ -281,11 +281,29 @@ void ReadDialogPathsWithBookmarks(NSOpenPanel* dialog, std::vector* paths, std::vector* bookmarks) { NSArray* urls = [dialog URLs]; - for (NSURL* url in urls) - if ([url isFileURL]) { - paths->emplace_back(base::SysNSStringToUTF8([url path])); - bookmarks->push_back(GetBookmarkDataFromNSURL(url)); + for (NSURL* url in urls) { + if (![url isFileURL]) + continue; + + NSString* path = [url path]; + + // There's a bug in macOS where despite a request to disallow file + // selection, files/packages can be selected. If file selection + // was disallowed, drop any files selected. See crbug.com/1357523. + if (![dialog canChooseFiles]) { + BOOL is_directory; + BOOL exists = + [[NSFileManager defaultManager] fileExistsAtPath:path + isDirectory:&is_directory]; + BOOL is_package = + [[NSWorkspace sharedWorkspace] isFilePackageAtPath:path]; + if (!exists || !is_directory || is_package) + continue; } + + paths->emplace_back(base::SysNSStringToUTF8(path)); + bookmarks->push_back(GetBookmarkDataFromNSURL(url)); + } } void ReadDialogPaths(NSOpenPanel* dialog, std::vector* paths) {",fix dad6e130f500bbf478176211f3e1c012b082ea2b,Charles Kerr,2024-06-19 09:10:16,"build: remove fs-extra devdep (#42533) * build: remove fs-extra dependency from script/gen-filenames.ts * build: remove fs-extra dependency from script/spec-runner.js * build: remove fs-extra dependency from script/gn-asar.js * build: remove fs-extra dependency from spec/api-autoupdater-darwin-spec.ts * build: remove fs-extra dependency from spec/api-safe-storage-spec.ts * build: remove fs-extra dependency from spec/lib/codesign-helpers.ts * build: remove fs-extra dependency from spec/api-app-spec.ts * build: remove fs-extra dependency from spec/esm-spec.ts * build: remove fs-extra dependency from spec/lib/fs-helpers.ts * build: remove fs-extra dependency from spec/lib/api-shell-spec.ts * build: remove fs-extra dependency from spec/api-context-bridge-spec.ts * build: remove fs-extra dependency from spec/asar-integrity-spec.ts * build: remove fs-extra dependency from spec/node-spec.ts * build: remove fs-extra devdiv * fixup! build: remove fs-extra dependency from spec/api-context-bridge-spec.ts * fix: use force: true when removing directories * chore: reduce diffs to main","diff --git a/package.json b/package.json index 3abbf4aefe..577b78d1dc 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ ""@types/chai-as-promised"": ""^7.1.3"", ""@types/dirty-chai"": ""^2.0.2"", ""@types/express"": ""^4.17.13"", - ""@types/fs-extra"": ""^9.0.1"", ""@types/minimist"": ""^1.2.0"", ""@types/mocha"": ""^7.0.2"", ""@types/node"": ""^20.9.0"", @@ -50,7 +49,6 @@ ""events"": ""^3.2.0"", ""express"": ""^4.19.2"", ""folder-hash"": ""^2.1.1"", - ""fs-extra"": ""^9.0.1"", ""got"": ""^11.8.5"", ""husky"": ""^8.0.1"", ""lint"": ""^1.1.2"", diff --git a/script/gen-filenames.ts b/script/gen-filenames.ts index cb2d0e6511..72754d24e2 100644 --- a/script/gen-filenames.ts +++ b/script/gen-filenames.ts @@ -1,5 +1,5 @@ import * as cp from 'node:child_process'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; @@ -48,7 +48,7 @@ const main = async () => { ]; const webpackTargetsWithDeps = await Promise.all(webpackTargets.map(async webpackTarget => { - const tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-filenames-')); + const tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-filenames-')); const child = cp.spawn('node', [ './node_modules/webpack-cli/bin/cli.js', '--config', `./build/webpack/${webpackTarget.config}`, @@ -89,7 +89,7 @@ const main = async () => { // Make the generated list easier to read .sort() }; - await fs.remove(tmpDir); + await fs.promises.rm(tmpDir, { force: true, recursive: true }); return webpackTargetWithDeps; })); diff --git a/script/gn-asar.js b/script/gn-asar.js index f7dd9db2db..29a1b99108 100644 --- a/script/gn-asar.js +++ b/script/gn-asar.js @@ -1,6 +1,6 @@ const asar = require('@electron/asar'); const assert = require('node:assert'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const os = require('node:os'); const path = require('node:path'); @@ -41,12 +41,12 @@ try { // Copy all files to a tmp dir to avoid including scrap files in the ASAR for (const file of files) { const newLocation = path.resolve(tmpPath, path.relative(base[0], file)); - fs.mkdirsSync(path.dirname(newLocation)); + fs.mkdirSync(path.dirname(newLocation), { recursive: true }); fs.writeFileSync(newLocation, fs.readFileSync(file)); } } catch (err) { console.error('Unexpected error while generating ASAR', err); - fs.remove(tmpPath) + fs.promises.rm(tmpPath, { force: true, recursive: true }) .then(() => process.exit(1)) .catch(() => process.exit(1)); return; @@ -59,5 +59,5 @@ asar.createPackageWithOptions(tmpPath, out[0], {}) console.error('Unexpected error while generating ASAR', err); process.exit(1); }; - fs.remove(tmpPath).then(exit).catch(exit); - }).then(() => fs.remove(tmpPath)); + fs.promises.rm(tmpPath, { force: true, recursive: true }).then(exit).catch(exit); + }).then(() => fs.promises.rm(tmpPath, { force: true, recursive: true })); diff --git a/script/spec-runner.js b/script/spec-runner.js index 4fb1badc49..2f6289e908 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -3,7 +3,7 @@ const { ElectronVersions, Installer } = require('@electron/fiddle-core'); const childProcess = require('node:child_process'); const crypto = require('node:crypto'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const { hashElement } = require('folder-hash'); const os = require('node:os'); const path = require('node:path'); @@ -216,7 +216,7 @@ async function installSpecModules (dir) { env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); } if (fs.existsSync(path.resolve(dir, 'node_modules'))) { - await fs.remove(path.resolve(dir, 'node_modules')); + await fs.promises.rm(path.resolve(dir, 'node_modules'), { force: true, recursive: true }); } const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], { env, diff --git a/spec/api-app-spec.ts b/spec/api-app-spec.ts index 277cf38084..b8fc8e3bcc 100644 --- a/spec/api-app-spec.ts +++ b/spec/api-app-spec.ts @@ -3,7 +3,7 @@ import * as cp from 'node:child_process'; import * as https from 'node:https'; import * as http from 'node:http'; import * as net from 'node:net'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as path from 'node:path'; import { promisify } from 'node:util'; import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main'; @@ -1118,7 +1118,7 @@ describe('app module', () => { describe('sessionData', () => { const appPath = path.join(__dirname, 'fixtures', 'apps', 'set-path'); - const appName = fs.readJsonSync(path.join(appPath, 'package.json')).name; + const appName = JSON.parse(fs.readFileSync(path.join(appPath, 'package.json'), 'utf8')).name; const userDataPath = path.join(app.getPath('appData'), appName); const tempBrowserDataPath = path.join(app.getPath('temp'), appName); @@ -1139,8 +1139,8 @@ describe('app module', () => { }; beforeEach(() => { - fs.removeSync(userDataPath); - fs.removeSync(tempBrowserDataPath); + fs.rmSync(userDataPath, { force: true, recursive: true }); + fs.rmSync(tempBrowserDataPath, { force: true, recursive: true }); }); it('writes to userData by default', () => { diff --git a/spec/api-autoupdater-darwin-spec.ts b/spec/api-autoupdater-darwin-spec.ts index 48084c7b85..e8bc14745b 100644 --- a/spec/api-autoupdater-darwin-spec.ts +++ b/spec/api-autoupdater-darwin-spec.ts @@ -2,7 +2,7 @@ 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 'fs-extra'; +import * as fs from 'node:fs'; import * as path from 'node:path'; import * as psList from 'ps-list'; import { AddressInfo } from 'node:net'; @@ -68,14 +68,14 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { await withTempDirectory(async (dir) => { const secondAppPath = await copyMacOSFixtureApp(dir, fixture); const appPJPath = path.resolve(secondAppPath, 'Contents', 'Resources', 'app', 'package.json'); - await fs.writeFile( + await fs.promises.writeFile( appPJPath, - (await fs.readFile(appPJPath, 'utf8')).replace('1.0.0', version) + (await fs.promises.readFile(appPJPath, 'utf8')).replace('1.0.0', version) ); const infoPath = path.resolve(secondAppPath, 'Contents', 'Info.plist'); - await fs.writeFile( + await fs.promises.writeFile( infoPath, - (await fs.readFile(infoPath, 'utf8')).replace(/(CFBundleShortVersionString<\/key>\s+)[^<]+/g, `$1${version}`) + (await fs.promises.readFile(infoPath, 'utf8')).replace(/(CFBundleShortVersionString<\/key>\s+)[^<]+/g, `$1${version}`) ); await mutateAppPreSign?.mutate(secondAppPath); await signApp(secondAppPath, identity); @@ -221,9 +221,9 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { const appPath = await copyMacOSFixtureApp(dir, opts.startFixture); await opts.mutateAppPreSign?.mutate(appPath); const infoPath = path.resolve(appPath, 'Contents', 'Info.plist'); - await fs.writeFile( + await fs.promises.writeFile( infoPath, - (await fs.readFile(infoPath, 'utf8')).replace(/(CFBundleShortVersionString<\/key>\s+)[^<]+/g, '$11.0.0') + (await fs.promises.readFile(infoPath, 'utf8')).replace(/(CFBundleShortVersionString<\/key>\s+)[^<]+/g, '$11.0.0') ); await signApp(appPath, identity); @@ -378,9 +378,9 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { mutationKey: 'prevent-downgrades', mutate: async (appPath) => { const infoPath = path.resolve(appPath, 'Contents', 'Info.plist'); - await fs.writeFile( + await fs.promises.writeFile( infoPath, - (await fs.readFile(infoPath, 'utf8')).replace('NSSupportsAutomaticGraphicsSwitching', 'ElectronSquirrelPreventDowngradesNSSupportsAutomaticGraphicsSwitching') + (await fs.promises.readFile(infoPath, 'utf8')).replace('NSSupportsAutomaticGraphicsSwitching', 'ElectronSquirrelPreventDowngradesNSSupportsAutomaticGraphicsSwitching') ); } } @@ -418,9 +418,9 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { mutationKey: 'prevent-downgrades', mutate: async (appPath) => { const infoPath = path.resolve(appPath, 'Contents', 'Info.plist'); - await fs.writeFile( + await fs.promises.writeFile( infoPath, - (await fs.readFile(infoPath, 'utf8')).replace('NSSupportsAutomaticGraphicsSwitching', 'ElectronSquirrelPreventDowngradesNSSupportsAutomaticGraphicsSwitching') + (await fs.promises.readFile(infoPath, 'utf8')).replace('NSSupportsAutomaticGraphicsSwitching', 'ElectronSquirrelPreventDowngradesNSSupportsAutomaticGraphicsSwitching') ); } } @@ -558,7 +558,7 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { await shipItFlipFlopPromise; expect(requests).to.have.lengthOf(2, 'should not have relaunched the updated app'); - expect(JSON.parse(await fs.readFile(path.resolve(appPath, 'Contents/Resources/app/package.json'), 'utf8')).version).to.equal('1.0.0', 'should still be the old version on disk'); + expect(JSON.parse(await fs.promises.readFile(path.resolve(appPath, 'Contents/Resources/app/package.json'), 'utf8')).version).to.equal('1.0.0', 'should still be the old version on disk'); retainerHandle.kill('SIGINT'); }); @@ -631,7 +631,7 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { mutationKey: 'add-resource', mutate: async (appPath) => { const resourcesPath = path.resolve(appPath, 'Contents', 'Resources', 'app', 'injected.txt'); - await fs.writeFile(resourcesPath, 'demo'); + await fs.promises.writeFile(resourcesPath, 'demo'); } } }, async (appPath, updateZipPath) => { @@ -669,8 +669,8 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { mutationKey: 'modify-shipit', mutate: async (appPath) => { const shipItPath = path.resolve(appPath, 'Contents', 'Frameworks', 'Squirrel.framework', 'Resources', 'ShipIt'); - await fs.remove(shipItPath); - await fs.symlink('/tmp/ShipIt', shipItPath, 'file'); + await fs.promises.rm(shipItPath, { force: true, recursive: true }); + await fs.promises.symlink('/tmp/ShipIt', shipItPath, 'file'); } } }, async (appPath, updateZipPath) => { @@ -708,7 +708,7 @@ ifdescribe(shouldRunCodesignTests)('autoUpdater behavior', function () { mutationKey: 'modify-eframework', mutate: async (appPath) => { const shipItPath = path.resolve(appPath, 'Contents', 'Frameworks', 'Electron Framework.framework', 'Electron Framework'); - await fs.appendFile(shipItPath, Buffer.from('123')); + await fs.promises.appendFile(shipItPath, Buffer.from('123')); } } }, async (appPath, updateZipPath) => { diff --git a/spec/api-context-bridge-spec.ts b/spec/api-context-bridge-spec.ts index 4b5952c55f..79d17cc618 100644 --- a/spec/api-context-bridge-spec.ts +++ b/spec/api-context-bridge-spec.ts @@ -1,7 +1,7 @@ import { BrowserWindow, ipcMain } from 'electron/main'; import { contextBridge } from 'electron/renderer'; import { expect } from 'chai'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as http from 'node:http'; import * as os from 'node:os'; import * as path from 'node:path'; @@ -34,7 +34,7 @@ describe('contextBridge', () => { afterEach(async () => { await closeWindow(w); - if (dir) await fs.remove(dir); + if (dir) await fs.promises.rm(dir, { force: true, recursive: true }); }); it('should not be accessible when contextIsolation is disabled', async () => { @@ -85,9 +85,9 @@ describe('contextBridge', () => { });`} (${bindingCreator.toString()})();`; - const tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-spec-preload-')); + const tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-spec-preload-')); dir = tmpDir; - await fs.writeFile(path.resolve(tmpDir, 'preload.js'), worldId === 0 ? preloadContentForMainWorld : preloadContentForIsolatedWorld); + await fs.promises.writeFile(path.resolve(tmpDir, 'preload.js'), worldId === 0 ? preloadContentForMainWorld : preloadContentForIsolatedWorld); w = new BrowserWindow({ show: false, webPreferences: { diff --git a/spec/api-safe-storage-spec.ts b/spec/api-safe-storage-spec.ts index 740e916f13..721d622758 100644 --- a/spec/api-safe-storage-spec.ts +++ b/spec/api-safe-storage-spec.ts @@ -3,7 +3,7 @@ import * as path from 'node:path'; import { safeStorage } from 'electron/main'; import { expect } from 'chai'; import { ifdescribe } from './lib/spec-helpers'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import { once } from 'node:events'; describe('safeStorage module', () => { @@ -33,8 +33,8 @@ describe('safeStorage module', () => { after(async () => { const pathToEncryptedString = path.resolve(__dirname, 'fixtures', 'api', 'safe-storage', 'encrypted.txt'); - if (await fs.pathExists(pathToEncryptedString)) { - await fs.remove(pathToEncryptedString); + if (fs.existsSync(pathToEncryptedString)) { + await fs.promises.rm(pathToEncryptedString, { force: true, recursive: true }); } }); diff --git a/spec/api-shell-spec.ts b/spec/api-shell-spec.ts index a2e9cef96f..57a652a007 100644 --- a/spec/api-shell-spec.ts +++ b/spec/api-shell-spec.ts @@ -3,7 +3,7 @@ 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 * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { expect } from 'chai'; @@ -79,9 +79,9 @@ describe('shell module', () => { afterEach(closeAllWindows); it('moves an item to the trash', async () => { - const dir = await fs.mkdtemp(path.resolve(app.getPath('temp'), 'electron-shell-spec-')); + const dir = await fs.promises.mkdtemp(path.resolve(app.getPath('temp'), 'electron-shell-spec-')); const filename = path.join(dir, 'temp-to-be-deleted'); - await fs.writeFile(filename, 'dummy-contents'); + await fs.promises.writeFile(filename, 'dummy-contents'); await shell.trashItem(filename); expect(fs.existsSync(filename)).to.be.false(); }); diff --git a/spec/asar-integrity-spec.ts b/spec/asar-integrity-spec.ts index e7cefbb0c3..4ecfb33d26 100644 --- a/spec/asar-integrity-spec.ts +++ b/spec/asar-integrity-spec.ts @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as cp from 'node:child_process'; import * as nodeCrypto from 'node:crypto'; import * as originalFs from 'node:original-fs'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { ifdescribe } from './lib/spec-helpers'; @@ -82,7 +82,7 @@ describe('fuses', function () { }; beforeEach(async () => { - tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-asar-integrity-spec-')); + tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-asar-integrity-spec-')); appPath = await copyApp(tmpDir); }); diff --git a/spec/esm-spec.ts b/spec/esm-spec.ts index c967634a04..2a0eb148ef 100644 --- a/spec/esm-spec.ts +++ b/spec/esm-spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import * as cp from 'node:child_process'; import { BrowserWindow } from 'electron'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { pathToFileURL } from 'node:url'; @@ -72,15 +72,15 @@ describe('esm', () => { if (w) w.close(); w = null; while (tempDirs.length) { - await fs.remove(tempDirs.pop()!); + await fs.promises.rm(tempDirs.pop()!, { force: true, recursive: true }); } }); async function loadWindowWithPreload (preload: string, webPreferences: Electron.WebPreferences) { - const tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'e-spec-preload-')); + const tmpDir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'e-spec-preload-')); tempDirs.push(tmpDir); const preloadPath = path.resolve(tmpDir, 'preload.mjs'); - await fs.writeFile(preloadPath, preload); + await fs.promises.writeFile(preloadPath, preload); w = new BrowserWindow({ show: false, diff --git a/spec/lib/codesign-helpers.ts b/spec/lib/codesign-helpers.ts index ca5caa5147..6b0cf7c43b 100644 --- a/spec/lib/codesign-helpers.ts +++ b/spec/lib/codesign-helpers.ts @@ -1,5 +1,5 @@ import * as cp from 'node:child_process'; -import * as fs from 'fs-extra'; +import * as fs from 'node:fs'; import * as path from 'node:path'; import { expect } from 'chai'; @@ -37,13 +37,13 @@ export async function copyMacOSFixtureApp (newDir: string, fixture: string | nul cp.spawnSync('cp', ['-R', appBundlePath, path.dirname(newPath)]); if (fixture) { const appDir = path.resolve(newPath, 'Contents/Resources/app'); - await fs.mkdirp(appDir); - await fs.copy(path.resolve(fixturesPath, 'auto-update', fixture), appDir); + await fs.promises.mkdir(appDir, { recursive: true }); + await fs.promises.cp(path.resolve(fixturesPath, 'auto-update', fixture), appDir, { recursive: true }); } const plistPath = path.resolve(newPath, 'Contents', 'Info.plist'); - await fs.writeFile( + await fs.promises.writeFile( plistPath, - (await fs.readFile(plistPath, 'utf8')).replace('BuildMachineOSBuild', `NSAppTransportSecurity + (await fs.promises.readFile(plistPath, 'utf8')).replace('BuildMachineOSBuild', `NSAppTransportSecurity NSAllowsArbitraryLoads diff --git a/spec/lib/fs-helpers.ts b/spec/lib/fs-helpers.ts index 0367bccf47..26949079d6 100644 --- a/spec/lib/fs-helpers.ts +++ b/spec/lib/fs-helpers.ts @@ -1,6 +1,5 @@ import * as cp from 'node:child_process'; import * as fs from 'original-fs'; -import * as fsExtra from 'fs-extra'; import * as os from 'node:os'; import * as path from 'node:path'; @@ -20,7 +19,7 @@ export async function copyApp (targetDir: string): Promise { const filesToCopy = (fs.readFileSync(zipManifestPath, 'utf-8')).split('\n').filter(f => f !== 'LICENSE' && f !== 'LICENSES.chromium.html' && f !== 'version' && f.trim()); await Promise.all( filesToCopy.map(async rel => { - await fsExtra.mkdirp(path.dirname(path.resolve(targetDir, rel))); + await fs.promises.mkdir(path.dirname(path.resolve(targetDir, rel)), { recursive: true }); fs.copyFileSync(path.resolve(baseDir, rel), path.resolve(targetDir, rel)); }) ); @@ -29,7 +28,7 @@ export async function copyApp (targetDir: string): Promise { } export async function withTempDirectory (fn: (dir: string) => Promise, autoCleanUp = true) { - const dir = await fsExtra.mkdtemp(path.resolve(os.tmpdir(), 'electron-update-spec-')); + const dir = await fs.promises.mkdtemp(path.resolve(os.tmpdir(), 'electron-update-spec-')); try { await fn(dir); } finally { diff --git a/spec/node-spec.ts b/spec/node-spec.ts index 00141b9fa0..f146d077a0 100644 --- a/spec/node-spec.ts +++ b/spec/node-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as childProcess from 'node:child_process'; -import * as fs from 'fs-extra'; +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'; @@ -706,7 +706,7 @@ describe('node feature', () => { return; } const alienBinary = path.join(appPath, 'Contents/MacOS/node'); - await fs.copy(path.join(nodePath, 'node'), alienBinary); + await fs.promises.cp(path.join(nodePath, 'node'), alienBinary, { recursive: true }); // Try to execute electron app from the alien node in app bundle. const { code, out } = await spawn(alienBinary, [script, path.join(appPath, 'Contents/MacOS/Electron')]); expect(code).to.equal(0); diff --git a/yarn.lock b/yarn.lock index 09c95b2fc4..8f4a9f43d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -810,13 +810,6 @@ ""@types/qs"" ""*"" ""@types/serve-static"" ""*"" -""@types/fs-extra@^9.0.1"": - version ""9.0.1"" - resolved ""https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.1.tgz#91c8fc4c51f6d5dbe44c2ca9ab09310bd00c7918"" - integrity sha512-B42Sxuaz09MhC3DDeW5kubRcQ5by4iuVQ0cRRWM2lggLzAa/KVom0Aft/208NgMvNQQZ86s5rVcqDdn/SH0/mg== - dependencies: - ""@types/node"" ""*"" - ""@types/glob@^7.1.1"": version ""7.1.1"" resolved ""https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"" @@ -1573,11 +1566,6 @@ asynckit@^0.4.0: resolved ""https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"" integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= -at-least-node@^1.0.0: - version ""1.0.0"" - resolved ""https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"" - integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== - available-typed-arrays@^1.0.5: version ""1.0.5"" resolved ""https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7"" @@ -3105,16 +3093,6 @@ fs-extra@^8.1.0: jsonfile ""^4.0.0"" universalify ""^0.1.0"" -fs-extra@^9.0.1: - version ""9.0.1"" - resolved ""https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"" - integrity sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ== - dependencies: - at-least-node ""^1.0.0"" - graceful-fs ""^4.2.0"" - jsonfile ""^6.0.1"" - universalify ""^1.0.0"" - fs-minipass@^2.0.0: version ""2.1.0"" resolved ""https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb""",build fceeb64e7c835868bec48442cfb4c7450bddf959,Shelley Vohr,2023-04-13 11:28:22,fix: swipe event emission on macOS (#37946),"diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 03cde56de4..656235e0d7 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -25,7 +25,6 @@ int ScopedDisableResize::disable_resize_ = 0; - (int64_t)_resizeDirectionForMouseLocation:(CGPoint)location; @end -#if IS_MAS_BUILD() // See components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm @interface NSView (CRFrameViewAdditions) - (void)cr_mouseDownOnFrameView:(NSEvent*)event; @@ -40,10 +39,10 @@ MouseDownImpl g_nsnextstepframe_mousedown; // This class is never instantiated, it's just a container for our swizzled // mouseDown method. -@interface SwizzledMouseDownHolderClass : NSView +@interface SwizzledMethodsClass : NSView @end -@implementation SwizzledMouseDownHolderClass +@implementation SwizzledMethodsClass - (void)swiz_nsthemeframe_mouseDown:(NSEvent*)event { if ([self.window respondsToSelector:@selector(shell)]) { electron::NativeWindowMac* shell = @@ -64,22 +63,53 @@ MouseDownImpl g_nsnextstepframe_mousedown; g_nsnextstepframe_mousedown(self, @selector(mouseDown:), event); } } + +- (void)swiz_nsview_swipeWithEvent:(NSEvent*)event { + if ([self.window respondsToSelector:@selector(shell)]) { + electron::NativeWindowMac* shell = + (electron::NativeWindowMac*)[(id)self.window shell]; + if (shell) { + if (event.deltaY == 1.0) { + shell->NotifyWindowSwipe(""up""); + } else if (event.deltaX == -1.0) { + shell->NotifyWindowSwipe(""right""); + } else if (event.deltaY == -1.0) { + shell->NotifyWindowSwipe(""down""); + } else if (event.deltaX == 1.0) { + shell->NotifyWindowSwipe(""left""); + } + } + } +} @end namespace { +#if IS_MAS_BUILD() void SwizzleMouseDown(NSView* frame_view, SEL swiz_selector, MouseDownImpl* orig_impl) { Method original_mousedown = class_getInstanceMethod([frame_view class], @selector(mouseDown:)); *orig_impl = (MouseDownImpl)method_getImplementation(original_mousedown); - Method new_mousedown = class_getInstanceMethod( - [SwizzledMouseDownHolderClass class], swiz_selector); + Method new_mousedown = + class_getInstanceMethod([SwizzledMethodsClass class], swiz_selector); method_setImplementation(original_mousedown, method_getImplementation(new_mousedown)); } +#else +// components/remote_cocoa/app_shim/bridged_content_view.h overrides +// swipeWithEvent, so we can't just override the implementation +// in ElectronNSWindow like we do with for ex. rotateWithEvent. +void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) { + Method original_swipe_with_event = + class_getInstanceMethod([view class], @selector(swipeWithEvent:)); + Method new_swipe_with_event = + class_getInstanceMethod([SwizzledMethodsClass class], swiz_selector); + method_setImplementation(original_swipe_with_event, + method_getImplementation(new_swipe_with_event)); +} +#endif } // namespace -#endif // IS_MAS_BUILD @implementation ElectronNSWindow @@ -125,8 +155,10 @@ void SwizzleMouseDown(NSView* frame_view, &g_nsnextstepframe_mousedown); } } +#else + NSView* view = [[self contentView] superview]; + SwizzleSwipeWithEvent(view, @selector(swiz_nsview_swipeWithEvent:)); #endif // IS_MAS_BUILD - shell_ = shell; } return self; @@ -156,18 +188,6 @@ void SwizzleMouseDown(NSView* frame_view, // NSWindow overrides. -- (void)swipeWithEvent:(NSEvent*)event { - if (event.deltaY == 1.0) { - shell_->NotifyWindowSwipe(""up""); - } else if (event.deltaX == -1.0) { - shell_->NotifyWindowSwipe(""right""); - } else if (event.deltaY == -1.0) { - shell_->NotifyWindowSwipe(""down""); - } else if (event.deltaX == 1.0) { - shell_->NotifyWindowSwipe(""left""); - } -} - - (void)rotateWithEvent:(NSEvent*)event { shell_->NotifyWindowRotateGesture(event.rotation); }",fix 2affecd4dd26b9f0cf2644ec115635559f920480,Shelley Vohr,2023-08-24 17:01:59,"feat: allow generating accessible pdf with `printToPDF` (#39563) * feat: allow generating accessible pdf with printToPDF * docs: mark generateTaggedPDF experimental","diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 715885369a..035da986f9 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1626,6 +1626,7 @@ win.webContents.print(options, (success, errorType) => { * `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `` would generate span containing the title. * `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`. * `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. + * `generateTaggedPDF` boolean (optional) _Experimental_ - Whether or not to generate a tagged (accessible) PDF. Defaults to false. As this property is experimental, the generated PDF may not adhere fully to PDF/UA and WCAG standards. Returns `Promise` - Resolves with the generated PDF data. diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 825921b9be..1c3ea20d13 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -607,6 +607,7 @@ Prints `webview`'s web page. Same as `webContents.print([options])`. * `headerTemplate` string (optional) - HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: `date` (formatted print date), `title` (document title), `url` (document location), `pageNumber` (current page number) and `totalPages` (total pages in the document). For example, `` would generate span containing the title. * `footerTemplate` string (optional) - HTML template for the print footer. Should use the same format as the `headerTemplate`. * `preferCSSPageSize` boolean (optional) - Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size. + * `generateTaggedPDF` boolean (optional) _Experimental_ - Whether or not to generate a tagged (accessible) PDF. Defaults to false. As this property is experimental, the generated PDF may not adhere fully to PDF/UA and WCAG standards. Returns `Promise` - Resolves with the generated PDF data. diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 8f0f53aa2b..44ceb6b8c4 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -206,7 +206,8 @@ WebContents.prototype.printToPDF = async function (options) { marginLeft: 0.4, marginRight: 0.4, pageRanges: '', - preferCSSPageSize: false + preferCSSPageSize: false, + shouldGenerateTaggedPDF: false }; if (options.landscape !== undefined) { @@ -322,6 +323,13 @@ WebContents.prototype.printToPDF = async function (options) { printSettings.preferCSSPageSize = options.preferCSSPageSize; } + if (options.generateTaggedPDF !== undefined) { + if (typeof options.generateTaggedPDF !== 'boolean') { + throw new Error('generateTaggedPDF must be a Boolean'); + } + printSettings.shouldGenerateTaggedPDF = options.generateTaggedPDF; + } + if (this._printToPDF) { if (pendingPromise) { pendingPromise = pendingPromise.then(() => this._printToPDF(printSettings)); diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index c53115c636..ac11521e98 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -2081,6 +2081,28 @@ describe('webContents module', () => { // Check that correct # of pages are rendered. expect(doc.numPages).to.equal(3); }); + + it('does not tag PDFs by default', async () => { + await w.loadFile(path.join(__dirname, 'fixtures', 'api', 'print-to-pdf-small.html')); + + const data = await w.webContents.printToPDF({}); + const doc = await pdfjs.getDocument(data).promise; + const markInfo = await doc.getMarkInfo(); + expect(markInfo).to.be.null(); + }); + + it('can generate tag data for PDFs', async () => { + await w.loadFile(path.join(__dirname, 'fixtures', 'api', 'print-to-pdf-small.html')); + + const data = await w.webContents.printToPDF({ generateTaggedPDF: true }); + const doc = await pdfjs.getDocument(data).promise; + const markInfo = await doc.getMarkInfo(); + expect(markInfo).to.deep.equal({ + Marked: true, + UserProperties: false, + Suspects: false + }); + }); }); describe('PictureInPicture video', () => { diff --git a/spec/package.json b/spec/package.json index 0cd30efaef..4aa39d1e05 100644 --- a/spec/package.json +++ b/spec/package.json @@ -25,7 +25,7 @@ ""mocha"": ""^10.0.0"", ""mocha-junit-reporter"": ""^1.18.0"", ""mocha-multi-reporters"": ""^1.1.7"", - ""pdfjs-dist"": ""^2.2.228"", + ""pdfjs-dist"": ""^2.16.105"", ""ps-list"": ""^7.0.0"", ""q"": ""^1.5.1"", ""send"": ""^0.16.2"", diff --git a/spec/yarn.lock b/spec/yarn.lock index 86b2553e88..b97e450d38 100644 --- a/spec/yarn.lock +++ b/spec/yarn.lock @@ -129,21 +129,6 @@ abstract-socket@^2.0.0: bindings ""^1.2.1"" nan ""^2.12.1"" -ajv-keywords@^3.1.0: - version ""3.4.1"" - resolved ""https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da"" - integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ== - -ajv@^6.1.0: - version ""6.12.6"" - resolved ""https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"" - integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== - dependencies: - fast-deep-equal ""^3.1.1"" - fast-json-stable-stringify ""^2.0.0"" - json-schema-traverse ""^0.4.1"" - uri-js ""^4.2.2"" - ansi-colors@4.1.1: version ""4.1.1"" resolved ""https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"" @@ -196,11 +181,6 @@ basic-auth@^2.0.1: dependencies: safe-buffer ""5.1.2"" -big.js@^5.2.2: - version ""5.2.2"" - resolved ""https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - binary-extensions@^2.0.0: version ""2.2.0"" resolved ""https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"" @@ -443,6 +423,11 @@ dirty-chai@^2.0.1: resolved ""https://registry.yarnpkg.com/dirty-chai/-/dirty-chai-2.0.1.tgz#6b2162ef17f7943589da840abc96e75bda01aff3"" integrity sha512-ys79pWKvDMowIDEPC6Fig8d5THiC0DJ2gmTeGzVAoEH18J8OzLud0Jh7I9IWg3NSk8x2UocznUuFmfHCXYZx9w== +dommatrix@^1.0.3: + version ""1.0.3"" + resolved ""https://registry.yarnpkg.com/dommatrix/-/dommatrix-1.0.3.tgz#e7c18e8d6f3abdd1fef3dd4aa74c4d2e620a0525"" + integrity sha512-l32Xp/TLgWb8ReqbVJAFIvXmY7go4nTxxlWiAFyhoQw9RKEOHBZNnyGvJWqDVSPmq3Y9HlM4npqF/T6VMOXhww== + duplexer@^0.1.1, duplexer@~0.1.1: version ""0.1.2"" resolved ""https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"" @@ -458,11 +443,6 @@ emoji-regex@^8.0.0: resolved ""https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emojis-list@^3.0.0: - version ""3.0.0"" - resolved ""https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - encodeurl@~1.0.2: version ""1.0.2"" resolved ""https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"" @@ -508,16 +488,6 @@ event-stream@^4.0.0: stream-combiner ""^0.2.2"" through ""^2.3.8"" -fast-deep-equal@^3.1.1: - version ""3.1.3"" - resolved ""https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stable-stringify@^2.0.0: - version ""2.1.0"" - resolved ""https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"" - integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== - file-uri-to-path@1.0.0: version ""1.0.0"" resolved ""https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"" @@ -757,18 +727,6 @@ json-buffer@3.0.1: resolved ""https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13"" integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== -json-schema-traverse@^0.4.1: - version ""0.4.1"" - resolved ""https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"" - integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== - -json5@^1.0.1: - version ""1.0.2"" - resolved ""https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593"" - integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== - dependencies: - minimist ""^1.2.0"" - just-extend@^4.0.2: version ""4.1.0"" resolved ""https://registry.yarnpkg.com/just-extend/-/just-extend-4.1.0.tgz#7278a4027d889601640ee0ce0e5a00b992467da4"" @@ -781,15 +739,6 @@ keyv@^4.0.0: dependencies: json-buffer ""3.0.1"" -loader-utils@^1.0.0: - version ""1.4.2"" - resolved ""https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.2.tgz#29a957f3a63973883eb684f10ffd3d151fec01a3"" - integrity sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg== - dependencies: - big.js ""^5.2.2"" - emojis-list ""^3.0.0"" - json5 ""^1.0.1"" - locate-path@^6.0.0: version ""6.0.0"" resolved ""https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"" @@ -875,7 +824,7 @@ minimatch@^3.0.4, minimatch@^3.1.1: dependencies: brace-expansion ""^1.1.7"" -minimist@1.2.7, minimist@^1.2.0, minimist@^1.2.6, minimist@~0.0.1: +minimist@1.2.7, minimist@^1.2.6, minimist@~0.0.1: version ""1.2.7"" resolved ""https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"" integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== @@ -968,11 +917,6 @@ nise@^4.0.1: just-extend ""^4.0.2"" path-to-regexp ""^1.7.0"" -node-ensure@^0.0.0: - version ""0.0.0"" - resolved ""https://registry.yarnpkg.com/node-ensure/-/node-ensure-0.0.0.tgz#ecae764150de99861ec5c810fd5d096b183932a7"" - integrity sha1-7K52QVDemYYexcgQ/V0Jaxg5Mqc= - normalize-path@^3.0.0, normalize-path@~3.0.0: version ""3.0.0"" resolved ""https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"" @@ -1053,13 +997,13 @@ pause-stream@^0.0.11: dependencies: through ""~2.3"" -pdfjs-dist@^2.2.228: - version ""2.2.228"" - resolved ""https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-2.2.228.tgz#777b068a0a16c96418433303807c183058b47aaa"" - integrity sha512-W5LhYPMS2UKX0ELIa4u+CFCMoox5qQNQElt0bAK2mwz1V8jZL0rvLao+0tBujce84PK6PvWG36Nwr7agCCWFGQ== +pdfjs-dist@^2.16.105: + version ""2.16.105"" + resolved ""https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-2.16.105.tgz#937b9c4a918f03f3979c88209d84c1ce90122c2a"" + integrity sha512-J4dn41spsAwUxCpEoVf6GVoz908IAA3mYiLmNxg8J9kfRXc2jxpbUepcP0ocp0alVNLFthTAM8DZ1RaHh8sU0A== dependencies: - node-ensure ""^0.0.0"" - worker-loader ""^2.0.0"" + dommatrix ""^1.0.3"" + web-streams-polyfill ""^3.2.1"" picomatch@^2.0.4, picomatch@^2.2.1: version ""2.3.1"" @@ -1079,11 +1023,6 @@ pump@^3.0.0: end-of-stream ""^1.1.0"" once ""^1.3.1"" -punycode@^2.1.0: - version ""2.1.1"" - resolved ""https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - q@^1.5.1: version ""1.5.1"" resolved ""https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"" @@ -1152,14 +1091,6 @@ sax@>=0.6.0: resolved ""https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -schema-utils@^0.4.0: - version ""0.4.7"" - resolved ""https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"" - integrity sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ== - dependencies: - ajv ""^6.1.0"" - ajv-keywords ""^3.1.0"" - send@^0.16.2: version ""0.16.2"" resolved ""https://registry.yarnpkg.com/send/-/send-0.16.2.tgz#6ecca1e0f8c156d141597559848df64730a6bbc1"" @@ -1301,13 +1232,6 @@ type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8: resolved ""https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -uri-js@^4.2.2: - version ""4.4.1"" - resolved ""https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode ""^2.1.0"" - uuid@^3.3.3: version ""3.4.0"" resolved ""https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"" @@ -1318,6 +1242,11 @@ walkdir@^0.3.2: resolved ""https://registry.yarnpkg.com/walkdir/-/walkdir-0.3.2.tgz#ac8437a288c295656848ebc19981ebc677a5f590"" integrity sha512-0Twghia4Z5wDGDYWURlhZmI47GvERMCsXIu0QZWVVZyW9ZjpbbZvD9Zy9M6cWiQQRRbAcYajIyKNavaZZDt1Uw== +web-streams-polyfill@^3.2.1: + version ""3.2.1"" + resolved ""https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6"" + integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== + winreg@^1.2.4: version ""1.2.4"" resolved ""https://registry.yarnpkg.com/winreg/-/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b"" @@ -1328,14 +1257,6 @@ wordwrap@~0.0.2: resolved ""https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"" integrity sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw== -worker-loader@^2.0.0: - version ""2.0.0"" - resolved ""https://registry.yarnpkg.com/worker-loader/-/worker-loader-2.0.0.tgz#45fda3ef76aca815771a89107399ee4119b430ac"" - integrity sha512-tnvNp4K3KQOpfRnD20m8xltE3eWh89Ye+5oj7wXEEHKac1P4oZ6p9oTj8/8ExqoSBnk9nu5Pr4nKfQ1hn2APJw== - dependencies: - loader-utils ""^1.0.0"" - schema-utils ""^0.4.0"" - workerpool@6.2.1: version ""6.2.1"" resolved ""https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343""",feat 7995c56fb0b20b254b379a43e1435a81695a3c7d,Charles Kerr,2023-12-20 17:44:17,refactor: use a FixedFlatMap for v8 converting ui::MenuSourceType (#40786),"diff --git a/shell/common/gin_converters/content_converter.cc b/shell/common/gin_converters/content_converter.cc index 59581baadc..202071d8a2 100644 --- a/shell/common/gin_converters/content_converter.cc +++ b/shell/common/gin_converters/content_converter.cc @@ -69,80 +69,39 @@ namespace { namespace gin { +static constexpr auto MenuSourceTypes = + base::MakeFixedFlatMap({ + {""adjustSelection"", ui::MENU_SOURCE_ADJUST_SELECTION}, + {""adjustSelectionReset"", ui::MENU_SOURCE_ADJUST_SELECTION_RESET}, + {""keyboard"", ui::MENU_SOURCE_KEYBOARD}, + {""longPress"", ui::MENU_SOURCE_LONG_PRESS}, + {""longTap"", ui::MENU_SOURCE_LONG_TAP}, + {""mouse"", ui::MENU_SOURCE_MOUSE}, + {""none"", ui::MENU_SOURCE_NONE}, + {""stylus"", ui::MENU_SOURCE_STYLUS}, + {""touch"", ui::MENU_SOURCE_TOUCH}, + {""touchHandle"", ui::MENU_SOURCE_TOUCH_HANDLE}, + {""touchMenu"", ui::MENU_SOURCE_TOUCH_EDIT_MENU}, + }); + +// let us know when upstream changes & we need to update MenuSourceTypes +static_assert(std::size(MenuSourceTypes) == ui::MENU_SOURCE_TYPE_LAST + 1U); + // static v8::Local Converter::ToV8( v8::Isolate* isolate, const ui::MenuSourceType& in) { - switch (in) { - case ui::MENU_SOURCE_MOUSE: - return StringToV8(isolate, ""mouse""); - case ui::MENU_SOURCE_KEYBOARD: - return StringToV8(isolate, ""keyboard""); - case ui::MENU_SOURCE_TOUCH: - return StringToV8(isolate, ""touch""); - case ui::MENU_SOURCE_TOUCH_EDIT_MENU: - return StringToV8(isolate, ""touchMenu""); - case ui::MENU_SOURCE_LONG_PRESS: - return StringToV8(isolate, ""longPress""); - case ui::MENU_SOURCE_LONG_TAP: - return StringToV8(isolate, ""longTap""); - case ui::MENU_SOURCE_TOUCH_HANDLE: - return StringToV8(isolate, ""touchHandle""); - case ui::MENU_SOURCE_STYLUS: - return StringToV8(isolate, ""stylus""); - case ui::MENU_SOURCE_ADJUST_SELECTION: - return StringToV8(isolate, ""adjustSelection""); - case ui::MENU_SOURCE_ADJUST_SELECTION_RESET: - return StringToV8(isolate, ""adjustSelectionReset""); - case ui::MENU_SOURCE_NONE: - return StringToV8(isolate, ""none""); - } + for (auto const& [key, val] : MenuSourceTypes) + if (in == val) + return StringToV8(isolate, key); + return {}; } // static bool Converter::FromV8(v8::Isolate* isolate, v8::Local val, ui::MenuSourceType* out) { - std::string type; - if (!ConvertFromV8(isolate, val, &type)) - return false; - - if (type == ""mouse"") { - *out = ui::MENU_SOURCE_MOUSE; - return true; - } else if (type == ""keyboard"") { - *out = ui::MENU_SOURCE_KEYBOARD; - return true; - } else if (type == ""touch"") { - *out = ui::MENU_SOURCE_TOUCH; - return true; - } else if (type == ""touchMenu"") { - *out = ui::MENU_SOURCE_TOUCH_EDIT_MENU; - return true; - } else if (type == ""longPress"") { - *out = ui::MENU_SOURCE_LONG_PRESS; - return true; - } else if (type == ""longTap"") { - *out = ui::MENU_SOURCE_LONG_TAP; - return true; - } else if (type == ""touchHandle"") { - *out = ui::MENU_SOURCE_TOUCH_HANDLE; - return true; - } else if (type == ""stylus"") { - *out = ui::MENU_SOURCE_STYLUS; - return true; - } else if (type == ""adjustSelection"") { - *out = ui::MENU_SOURCE_ADJUST_SELECTION; - return true; - } else if (type == ""adjustSelectionReset"") { - *out = ui::MENU_SOURCE_ADJUST_SELECTION_RESET; - return true; - } else if (type == ""none"") { - *out = ui::MENU_SOURCE_NONE; - return true; - } - - return false; + return FromV8WithLookup(isolate, val, MenuSourceTypes, out); } // static",refactor 355f322dbdba4cacd6a15e4c7d64adb2da9500d8,Milan Burda,2023-01-25 22:00:51,"chore: remove unused fixture_support.md (#37011) Co-authored-by: Milan Burda ","diff --git a/spec/fixtures/version-bumper/fixture_support.md b/spec/fixtures/version-bumper/fixture_support.md deleted file mode 100644 index f709b7ea12..0000000000 --- a/spec/fixtures/version-bumper/fixture_support.md +++ /dev/null @@ -1,122 +0,0 @@ -# Electron Support - -## Finding Support - -If you have a security concern, -please see the [security document](https://github.com/electron/electron/tree/master/SECURITY.md). - -If you're looking for programming help, -for answers to questions, -or to join in discussion with other developers who use Electron, -you can interact with the community in these locations: - -* [`Electron's Discord`](https://discord.com/invite/electron) has channels for: - * Getting help - * Ecosystem apps like [Electron Forge](https://github.com/electron-userland/electron-forge) and [Electron Fiddle](https://github.com/electron/fiddle) - * Sharing ideas with other Electron app developers - * And more! -* [`electron`](https://discuss.atom.io/c/electron) category on the Atom forums -* `#atom-shell` channel on Freenode -* `#electron` channel on [Atom's Slack](https://discuss.atom.io/t/join-us-on-slack/16638?source_topic_id=25406) -* [`electron-ru`](https://telegram.me/electron_ru) *(Russian)* -* [`electron-br`](https://electron-br.slack.com) *(Brazilian Portuguese)* -* [`electron-kr`](https://electron-kr.github.io/electron-kr) *(Korean)* -* [`electron-jp`](https://electron-jp.slack.com) *(Japanese)* -* [`electron-tr`](https://electron-tr.herokuapp.com) *(Turkish)* -* [`electron-id`](https://electron-id.slack.com) *(Indonesia)* -* [`electron-pl`](https://electronpl.github.io) *(Poland)* - -If you'd like to contribute to Electron, -see the [contributing document](https://github.com/electron/electron/blob/master/CONTRIBUTING.md). - -If you've found a bug in a [supported version](#supported-versions) of Electron, -please report it with the [issue tracker](../development/issues.md). - -[awesome-electron](https://github.com/sindresorhus/awesome-electron) -is a community-maintained list of useful example apps, -tools and resources. - -## Supported Versions - -The latest three *stable* major versions are supported by the Electron team. -For example, if the latest release is 6.1.x, then the 5.0.x as well -as the 4.2.x series are supported. We only support the latest minor release -for each stable release series. This means that in the case of a security fix -6.1.x will receive the fix, but we will not release a new version of 6.0.x. - -The latest stable release unilaterally receives all fixes from `master`, -and the version prior to that receives the vast majority of those fixes -as time and bandwidth warrants. The oldest supported release line will receive -only security fixes directly. - -All supported release lines will accept external pull requests to backport -fixes previously merged to `master`, though this may be on a case-by-case -basis for some older supported lines. All contested decisions around release -line backports will be resolved by the [Releases Working Group](https://github.com/electron/governance/tree/master/wg-releases) as an agenda item at their weekly meeting the week the backport PR is raised. - -When an API is changed or removed in a way that breaks existing functionality, the -previous functionality will be supported for a minimum of two major versions when -possible before being removed. For example, if a function takes three arguments, -and that number is reduced to two in major version 10, the three-argument version would -continue to work until, at minimum, major version 12. Past the minimum two-version -threshold, we will attempt to support backwards compatibility beyond two versions -until the maintainers feel the maintenance burden is too high to continue doing so. - -### Currently supported versions - -* 4.x.y -* 3.x.y -* 2.x.y -* 1.x.y - -### End-of-life - -When a release branch reaches the end of its support cycle, the series -will be deprecated in NPM and a final end-of-support release will be -made. This release will add a warning to inform that an unsupported -version of Electron is in use. - -These steps are to help app developers learn when a branch they're -using becomes unsupported, but without being excessively intrusive -to end users. - -If an application has exceptional circumstances and needs to stay -on an unsupported series of Electron, developers can silence the -end-of-support warning by omitting the final release from the app's -`package.json` `devDependencies`. For example, since the 1-6-x series -ended with an end-of-support 1.6.18 release, developers could choose -to stay in the 1-6-x series without warnings with `devDependency` of -`""electron"": 1.6.0 - 1.6.17`. - -## Supported Platforms - -Following platforms are supported by Electron: - -### macOS - -Only 64bit binaries are provided for macOS, and the minimum macOS version -supported is macOS 10.11 (El Capitan). - -Native support for Apple Silicon (`arm64`) devices was added in Electron 11.0.0. - -### Windows - -Windows 10 and later are supported, older operating systems are not supported -(and do not work). - -Both `ia32` (`x86`) and `x64` (`amd64`) binaries are provided for Windows. -[Native support for Windows on Arm (`arm64`) devices was added in Electron 6.0.8.](windows-arm.md). -Running apps packaged with previous versions is possible using the ia32 binary. - -### Linux - -The prebuilt binaries of Electron are built on Ubuntu 18.04. - -Whether the prebuilt binary can run on a distribution depends on whether the -distribution includes the libraries that Electron is linked to on the building -platform, so only Ubuntu 18.04 is guaranteed to work, but following platforms -are also verified to be able to run the prebuilt binaries of Electron: - -* Ubuntu 14.04 and newer -* Fedora 24 and newer -* Debian 8 and newer",chore b35adaee2d521af5e34a6fea7897ac53c3752799,Shelley Vohr,2024-06-17 19:47:59,build: fix clang format location helper (#42527),"diff --git a/script/lib/util.py b/script/lib/util.py index 1446b99b82..d77f98cd58 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -4,6 +4,7 @@ import contextlib import errno import json import os +import platform import shutil import subprocess import sys @@ -184,13 +185,16 @@ def get_electron_exec(): def get_buildtools_executable(name): buildtools = os.path.realpath(os.path.join(ELECTRON_DIR, '..', 'buildtools')) - chromium_platform = { - 'darwin': 'mac', - 'linux': 'linux64', - 'linux2': 'linux64', - 'win32': 'win', - 'cygwin': 'win', - }[sys.platform] + + if sys.platform == 'darwin': + chromium_platform = 'mac_arm64' if platform.machine() == 'arm64' else 'mac' + elif sys.platform in ['win32', 'cygwin']: + chromium_platform = 'win' + elif sys.platform in ['linux', 'linux2']: + chromium_platform = 'linux64' + else: + raise Exception(f""Unsupported platform: {sys.platform}"") + if name == 'clang-format': path = os.path.join(buildtools, chromium_platform, 'format', name) else:",build 9ec13afeaff39767538f08102b69ddf03dcfc1fb,David Sanders,2023-02-05 21:40:16,docs: add missing ipcRenderer require to example code (#37134),"diff --git a/docs/api/context-bridge.md b/docs/api/context-bridge.md index fa5ce0a54f..738de98bb6 100644 --- a/docs/api/context-bridge.md +++ b/docs/api/context-bridge.md @@ -65,7 +65,7 @@ the API become immutable and updates on either side of the bridge do not result An example of a complex API is shown below: ```javascript -const { contextBridge } = require('electron') +const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInMainWorld( 'electron',",docs c6b9340b8952a041373f694c6ee2f22f447464de,Shelley Vohr,2023-01-26 07:43:57,"chore: fix memory leak in `v8.serialize()` (#37021) chore: fix memory leak in v8.serialize()","diff --git a/patches/node/fixup_for_wc_98-compat-extra-semi.patch b/patches/node/fixup_for_wc_98-compat-extra-semi.patch index 59286b5160..f3e585f58e 100644 --- a/patches/node/fixup_for_wc_98-compat-extra-semi.patch +++ b/patches/node/fixup_for_wc_98-compat-extra-semi.patch @@ -7,7 +7,7 @@ Wc++98-compat-extra-semi is turned on for Electron so this patch fixes that error in node. diff --git a/src/node_serdes.cc b/src/node_serdes.cc -index 0cd76078218433b46c17f350e3ba6073987438cf..ba13061b6aa7fd8f877aa456db9d352a847e682a 100644 +index 97917c91c06dc47dfa6be2c194944cdc93e6bd7f..177390a24eb6490b128e22c104014e80f338c9d9 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -32,7 +32,7 @@ namespace serdes { diff --git a/patches/node/support_v8_sandboxed_pointers.patch b/patches/node/support_v8_sandboxed_pointers.patch index 9855b3539c..d3da23d7a4 100644 --- a/patches/node/support_v8_sandboxed_pointers.patch +++ b/patches/node/support_v8_sandboxed_pointers.patch @@ -155,7 +155,7 @@ index efbdbeabf5a6afb658cbdc7888f94952e55f4f71..8b37639361e8902d7e1481071d3ec24b // Delegate to V8's allocator for compatibility with the V8 memory cage. diff --git a/src/node_serdes.cc b/src/node_serdes.cc -index 45a16d9de43703c2115dde85c9faae3a04be2a88..0cd76078218433b46c17f350e3ba6073987438cf 100644 +index 45a16d9de43703c2115dde85c9faae3a04be2a88..97917c91c06dc47dfa6be2c194944cdc93e6bd7f 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -29,6 +29,11 @@ using v8::ValueSerializer; @@ -219,17 +219,32 @@ index 45a16d9de43703c2115dde85c9faae3a04be2a88..0cd76078218433b46c17f350e3ba6073 Maybe SerializerContext::WriteHostObject(Isolate* isolate, Local input) { MaybeLocal ret; -@@ -211,7 +240,12 @@ void SerializerContext::ReleaseBuffer(const FunctionCallbackInfo& args) { +@@ -209,9 +238,14 @@ void SerializerContext::ReleaseBuffer(const FunctionCallbackInfo& args) { + // Note: Both ValueSerializer and this Buffer::New() variant use malloc() + // as the underlying allocator. std::pair ret = ctx->serializer_.Release(); - auto buf = Buffer::New(ctx->env(), - reinterpret_cast(ret.first), +- auto buf = Buffer::New(ctx->env(), +- reinterpret_cast(ret.first), - ret.second); -+ ret.second, -+ [](char* data, void* hint){ -+ if (data) -+ GetAllocator()->Free(data, reinterpret_cast(hint)); -+ }, -+ reinterpret_cast(ctx->last_length_)); ++ std::unique_ptr bs = ++ v8::ArrayBuffer::NewBackingStore(reinterpret_cast(ret.first), ret.second, ++ [](void* data, size_t length, void* deleter_data) { ++ if (data) GetAllocator()->Free(reinterpret_cast(data), length); ++ }, nullptr); ++ Local ab = v8::ArrayBuffer::New(ctx->env()->isolate(), std::move(bs)); ++ ++ auto buf = Buffer::New(ctx->env(), ab, 0, ret.second); if (!buf.IsEmpty()) { args.GetReturnValue().Set(buf.ToLocalChecked()); +diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js +index a90c398adcdaf30491a0fecdcf00895038d62e69..f5b8a1430ad2033eae06ca0157af2fb51d3f36a5 100644 +--- a/test/parallel/test-v8-serialize-leak.js ++++ b/test/parallel/test-v8-serialize-leak.js +@@ -23,5 +23,5 @@ const after = process.memoryUsage.rss(); + if (process.config.variables.asan) { + assert(after < before * 10, `asan: before=${before} after=${after}`); + } else { +- assert(after < before * 2, `before=${before} after=${after}`); ++ assert(after < before * 3, `before=${before} after=${after}`); + } diff --git a/script/node-disabled-tests.json b/script/node-disabled-tests.json index bcfc42d59a..d3bba00b0c 100644 --- a/script/node-disabled-tests.json +++ b/script/node-disabled-tests.json @@ -137,7 +137,6 @@ ""parallel/test-worker-debug"", ""parallel/test-worker-init-failure"", ""parallel/test-worker-stdio"", - ""parallel/test-v8-serialize-leak"", ""parallel/test-zlib-unused-weak"", ""report/test-report-fatalerror-oomerror-set"", ""report/test-report-fatalerror-oomerror-directory"",",chore 943bfa89ceab95dd4435482d69d5c79bf97abcb2,John Kleinschmidt,2023-09-25 16:23:05,test: fixup parallel/test-node-output-error test (#39972),"diff --git a/patches/node/chore_update_fixtures_errors_force_colors_snapshot.patch b/patches/node/chore_update_fixtures_errors_force_colors_snapshot.patch index 08f301ecbd..cd5f4df647 100644 --- a/patches/node/chore_update_fixtures_errors_force_colors_snapshot.patch +++ b/patches/node/chore_update_fixtures_errors_force_colors_snapshot.patch @@ -11,7 +11,7 @@ trying to see whether or not the lines are greyed out. One possibility would be to upstream a changed test that doesn't hardcode line numbers. diff --git a/test/fixtures/errors/force_colors.snapshot b/test/fixtures/errors/force_colors.snapshot -index 4c33acbc2d5c12ac8750b72e0796284176af3da2..5ba11dadad6d905a1eb67ed1c89c59f3c3f686ec 100644 +index 4c33acbc2d5c12ac8750b72e0796284176af3da2..56fae731aeec1f3a2870fba56eb0fb24e5d4b87f 100644 --- a/test/fixtures/errors/force_colors.snapshot +++ b/test/fixtures/errors/force_colors.snapshot @@ -4,11 +4,12 @@ throw new Error('Should include grayed stack trace') @@ -27,7 +27,7 @@ index 4c33acbc2d5c12ac8750b72e0796284176af3da2..5ba11dadad6d905a1eb67ed1c89c59f3 + at Module._extensions..js (node:internal*modules*cjs*loader:1326:10) + at Module.load (node:internal*modules*cjs*loader:1126:32) + at Module._load (node:internal*modules*cjs*loader:967:12) -+ at Module._load (node:electron*js2c*asar_bundle:777:32) ++ at Module._load (node:electron*js2c*asar_bundle:763:32) + at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:101:12)  at node:internal*main*run_main_module:23:47 ",test 122685194a5642b73367e823aadf3942b0290099,Samuel Attard,2024-10-02 19:10:44,"build: add import/order eslint rule (#44085) * build: add import/order eslint rule * chore: run lint:js --fix","diff --git a/.eslintrc.json b/.eslintrc.json index 0e448b6bd3..2bec582ff6 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 9a8a164dd6..b806e43535 100644 --- a/build/webpack/webpack.config.base.js +++ b/build/webpack/webpack.config.base.js @@ -1,9 +1,10 @@ -const fs = require('node:fs'); -const path = require('node:path'); -const webpack = require('webpack'); 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 electronRoot = path.resolve(__dirname, '../..'); class AccessDependenciesPlugin { diff --git a/default_app/default_app.ts b/default_app/default_app.ts index 6a521b9d62..6cd280bb55 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 9062cfca8e..4c3f35719c 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 8c60d6d2a0..ff024def5e 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 4b2bac16c0..255049cec3 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.ts +++ b/lib/browser/api/auto-updater/auto-updater-win.ts @@ -1,6 +1,8 @@ +import * as squirrelUpdate from '@electron/internal/browser/api/auto-updater/squirrel-update-win'; + import { app } from 'electron/main'; + import { EventEmitter } from 'events'; -import * as squirrelUpdate from '@electron/internal/browser/api/auto-updater/squirrel-update-win'; class AutoUpdater extends EventEmitter implements Electron.AutoUpdater { updateAvailable: boolean = false; diff --git a/lib/browser/api/auto-updater/squirrel-update-win.ts b/lib/browser/api/auto-updater/squirrel-update-win.ts index 07dead8ad7..12f26fe25a 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 8d9c5899da..d12c0f5ad5 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 ec6b99e141..19a98c1756 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 036ab47906..ae7744d5c6 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 3ea4d6198c..42a8fd8ab9 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, isDisplayMediaSystemPickerAvailable } = 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 d7d79ca9ae..04d95238c8 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 904de54f69..d4bc2b5cd9 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 ae74948064..1ff4836caf 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 48a7f475b1..c0244cc3c1 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 93fe3e83fc..1a6b967e35 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 4f44f2cc42..54fdc788d6 100644 --- a/lib/browser/api/net-fetch.ts +++ b/lib/browser/api/net-fetch.ts @@ -1,6 +1,8 @@ +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'; -import { allowAnyProtocol } from '@electron/internal/common/api/net-client-request'; function createDeferredPromise (): { promise: Promise; resolve: (x: T) => void; reject: (e: E) => void; } { let res: (x: T) => void; diff --git a/lib/browser/api/net.ts b/lib/browser/api/net.ts index dd824c990f..b806aef95e 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 1b7f00b433..cb6a1492eb 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 27a2c32f1a..169f1d1eea 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'); const { isDisplayMediaSystemPickerAvailable } = process._linkedBinding('electron_browser_desktop_capturer'); diff --git a/lib/browser/api/share-menu.ts b/lib/browser/api/share-menu.ts index 1a339a1661..a296500390 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/system-preferences.ts b/lib/browser/api/system-preferences.ts index 33c1a4eb7d..b5485a7361 100644 --- a/lib/browser/api/system-preferences.ts +++ b/lib/browser/api/system-preferences.ts @@ -1,4 +1,5 @@ import * as deprecate from '@electron/internal/common/deprecate'; + const { systemPreferences } = process._linkedBinding('electron_browser_system_preferences'); if ('getEffectiveAppearance' in systemPreferences) { diff --git a/lib/browser/api/utility-process.ts b/lib/browser/api/utility-process.ts index bee8f1032a..626ba1643c 100644 --- a/lib/browser/api/utility-process.ts +++ b/lib/browser/api/utility-process.ts @@ -1,7 +1,9 @@ +import { MessagePortMain } from '@electron/internal/browser/message-port-main'; + import { EventEmitter } from 'events'; -import { Duplex, PassThrough } from 'stream'; import { Socket } from 'net'; -import { MessagePortMain } from '@electron/internal/browser/message-port-main'; +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 2cdf5b5904..581b937d7e 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 490e2ece80..4bde139eeb 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 9212c797cb..ce6023f843 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 16eef15fbe..0cef9aa5c8 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 47e9272a7b..f9cd52077a 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 e054409394..f05d51b8ca 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, navigationHistorySyncMethods } 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, navigationHistorySyncMethods } 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 65526e1c5a..3f7ddc3036 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 39fdc8cf80..50327911aa 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 f3088d93a5..e80739104b 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 48e6ca16b5..4eef7baa1f 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 05622af6a8..1a087ae476 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 9032ed9994..d6ad120eb9 100644 --- a/lib/common/init.ts +++ b/lib/common/init.ts @@ -1,7 +1,7 @@ +import timers = require('timers'); import * as util from 'util'; -import type * as stream from 'stream'; -import timers = require('timers'); +import type * as stream from 'stream'; type AnyFn = (...args: any[]) => any diff --git a/lib/node/init.ts b/lib/node/init.ts index 12c908a607..8857eabb6b 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 13ea2fc57a..d50bc9edbd 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 4910ca6671..c944125f9f 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 8be38b26e5..7d53e0b792 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 8dd941d306..023c4ee36b 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 619641d20e..1065048a45 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 ac4db7f9a7..47bf2ea281 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 e6d25d5179..ba38adfefa 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 66d17209a2..18cc238d3f 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 7d2dd14a3f..6f64197698 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 f5ca329d63..a82e86af43 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 29ca6cc959..c918800273 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 9dc539edb6..9f48ea3941 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 83ddf4a1bd..6762945a62 100644 --- a/lib/sandboxed_renderer/init.ts +++ b/lib/sandboxed_renderer/init.ts @@ -1,9 +1,9 @@ -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'; +import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils'; + +import * as events from 'events'; +import { setImmediate, clearImmediate } from 'timers'; declare const binding: { get: (name: string) => any; diff --git a/lib/utility/api/net.ts b/lib/utility/api/net.ts index b5237e8233..70228ee0e5 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 ddd935f483..1c7e5e8a4b 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 1ce54aac5d..3cb484e3ad 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 09f4677bc9..7dbb3d5a3c 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 fcd7653133..a0c177dea4 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 4f3b5ecfc2..26198efc26 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 ace463d484..20333382e6 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 dcd69e2d11..df01d640bc 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 ad341cb2cd..86337d669e 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 29a1b99108..717f7aaa2c 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 a437fbab4d..542b1fbdeb 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 3879c4feb4..c2a986e424 100644 --- a/script/lib/azput.js +++ b/script/lib/azput.js @@ -1,5 +1,8 @@ /* eslint-disable camelcase */ + const { BlobServiceClient } = require('@azure/storage-blob'); +const minimist = require('minimist'); + const path = require('node:path'); const { ELECTRON_ARTIFACTS_BLOB_STORAGE } = process.env; @@ -10,7 +13,7 @@ if (!ELECTRON_ARTIFACTS_BLOB_STORAGE) { const blobServiceClient = BlobServiceClient.fromConnectionString(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 3684812ecd..25521af9b4 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 25f4642cb3..20a2da96f5 100755 --- a/script/lint.js +++ b/script/lint.js @@ -1,13 +1,15 @@ #!/usr/bin/env node -const crypto = require('node:crypto'); +const { getCodeBlocks } = require('@electron/lint-roller/dist/lib/markdown'); + const { GitProcess } = require('dugite'); -const childProcess = require('node:child_process'); const { ESLint } = require('eslint'); -const fs = require('node:fs'); 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 { getCodeBlocks } = require('@electron/lint-roller/dist/lib/markdown'); const { chunkFilenames, findMatchingFiles } = require('./lib/utils'); diff --git a/script/nan-spec-runner.js b/script/nan-spec-runner.js index 3d01cbb28c..b5b9da3f69 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 3d904e9a66..6056413791 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 9c9591ae86..d1f6104004 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 8a0296c4b9..b32f46c3eb 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 8f1420d2e3..a659031c39 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 9026384cb2..484bece93c 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 semver from 'semver'; +import * as temp from 'temp'; + 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 { 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 4b625a05b1..830501e7e0 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 0a129f84c3..bc0ca69343 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 19e3fb3a6c..b4fc10b053 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 d993d1ba1d..a6e7ebf01c 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 { basename } from 'node:path'; +import { parseArgs } from 'node:util'; -import { Octokit } from '@octokit/rest'; +import { get, render } from './notes'; +import { ELECTRON_DIR } from '../../lib/utils'; import { createGitHubTokenStrategy } from '../github-token'; -import { parseArgs } from 'node:util'; 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 7e73d5203c..2c5e97f333 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 269e3ea7ed..b58e476369 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 4fc9d1396c..1438577fae 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 { gte } from 'semver'; +import { track as trackTemp } from 'temp'; + 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 { 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 6799314f24..c4f6acc5ef 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 43a1dcbf24..b801ded782 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 ef86e22298..c7ae8bb052 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 8ebb22e38b..67ffac650d 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 6a5ba9c2c7..b4a544da2e 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 c0cf857948..9829528614 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 43a0397758..d91fa20709 100644 --- 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 6c081a0ccd..4f158e3f93 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 b9101965f9..7eb6c4260c 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 { 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 fs from 'node:fs'; 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 e558dbf517..1174a01fff 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 e8bc14745b..24925c503c 100644 --- a/spec/api-autoupdater-darwin-spec.ts +++ b/spec/api-autoupdater-darwin-spec.ts @@ -1,16 +1,19 @@ +import { autoUpdater, systemPreferences } from 'electron'; + 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 * 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 { ifdescribe, ifit } from './lib/spec-helpers'; +import * as path from 'node:path'; + import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers'; -import * as uuid from 'uuid'; -import { autoUpdater, systemPreferences } from 'electron'; 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 dc193b083e..93a0f830a0 100644 --- a/spec/api-browser-view-spec.ts +++ b/spec/api-browser-view-spec.ts @@ -1,10 +1,13 @@ +import { BrowserView, BrowserWindow, screen, webContents } from 'electron/main'; + import { expect } from 'chai'; + +import { once } from 'node:events'; 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, hasCapturableScreen } from './lib/screen-helpers'; -import { once } from 'node:events'; +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 06b63046fb..5a200a5885 100755 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1,22 +1,24 @@ +import { nativeImage } from 'electron'; +import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, net, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main'; + import { expect } from 'chai'; + import * as childProcess from 'node:child_process'; -import * as path from 'node:path'; +import { once } from 'node:events'; import * as fs from 'node:fs'; -import * as qs from 'node:querystring'; import * as http from 'node:http'; -import * as nodeUrl from 'node:url'; -import * as os from 'node:os'; import { AddressInfo } from 'node:net'; -import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, net, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main'; +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 * as nodeUrl from 'node:url'; 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'; -import { nativeImage } from 'electron'; 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 544b7fe5c4..3befd1a954 100644 --- a/spec/api-clipboard-spec.ts +++ b/spec/api-clipboard-spec.ts @@ -1,8 +1,11 @@ +import { clipboard, nativeImage } from 'electron/common'; + import { expect } from 'chai'; -import * as path from 'node:path'; + import { Buffer } from 'node:buffer'; +import * as path from 'node:path'; + import { ifdescribe, ifit } from './lib/spec-helpers'; -import { clipboard, nativeImage } from 'electron/common'; // FIXME(zcbenz): Clipboard tests are failing on WOA. ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard module', () => { diff --git a/spec/api-content-tracing-spec.ts b/spec/api-content-tracing-spec.ts index a026472b7c..b584b1a818 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 62609060e8..d82470ab8b 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 fe7e7cb5ed..7dd31a9917 100644 --- a/spec/api-crash-reporter-spec.ts +++ b/spec/api-crash-reporter-spec.ts @@ -1,15 +1,18 @@ +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 * 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 { 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 c05644c98f..b274af9e3e 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 5c6eadf0d1..5bb4943183 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 a375c87164..b38118820e 100644 --- a/spec/api-dialog-spec.ts +++ b/spec/api-dialog-spec.ts @@ -1,9 +1,12 @@ -import { expect } from 'chai'; import { dialog, BaseWindow, 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 b1c009329d..2025c151dd 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 72b892b2fa..6092f7ffc4 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 b9bcb155e3..869591f1d7 100644 --- a/spec/api-ipc-main-spec.ts +++ b/spec/api-ipc-main-spec.ts @@ -1,10 +1,13 @@ +import { ipcMain, BrowserWindow } from 'electron/main'; + 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 { 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 333b316366..2db75ef3a3 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 c650a6195a..38ff8f14ae 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 0a0319e1a5..1d67866ead 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 0071a3904e..e385b4773d 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 019f5b43a2..cc0d1ef358 100644 --- a/spec/api-menu-spec.ts +++ b/spec/api-menu-spec.ts @@ -1,12 +1,15 @@ +import { BrowserWindow, Menu, MenuItem } from 'electron/main'; + +import { assert, expect } from 'chai'; + import * as cp from 'node:child_process'; +import { once } from 'node:events'; 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 { 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 d498214942..bbd30cff7a 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 a6abb6762c..2d2a3a3b00 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 d9ffc43d81..374bea8114 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 fc570f2297..40781d5954 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 82d6b5b985..42525be2c0 100644 --- a/spec/api-net-session-spec.ts +++ b/spec/api-net-session-spec.ts @@ -1,6 +1,9 @@ +import { net, session, BrowserWindow, ClientRequestConstructorOptions } from 'electron/main'; + import { expect } from 'chai'; + import * as dns from 'node:dns'; -import { net, session, BrowserWindow, ClientRequestConstructorOptions } from 'electron/main'; + 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 7aa6ad8639..5d98385d60 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 d470bbd20c..a601296536 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 27188358fb..27d7417a13 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 8bd6c27572..47a2e6cdab 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 36a35726ad..ea5091e002 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 3a9a068cee..156bb6b410 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 c2c42db091..1ebcd855fd 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 721d622758..b8d9c1358a 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 8ff1b489d3..1c3141c4e6 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 c5376130b5..2fef6b0d65 100644 --- a/spec/api-service-workers-spec.ts +++ b/spec/api-service-workers-spec.ts @@ -1,11 +1,14 @@ -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'; +import * as fs from 'node:fs'; +import * as http from 'node:http'; +import * as path from 'node:path'; + +import { listen } from './lib/spec-helpers'; const partition = 'service-workers-spec'; diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts index 2a169f70dc..aa7cf11836 100644 --- a/spec/api-session-spec.ts +++ b/spec/api-session-spec.ts @@ -1,18 +1,21 @@ +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 * as crypto from 'node:crypto'; +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 57a652a007..3883bf79dd 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 043141a12c..66b5dcc00e 100644 --- a/spec/api-subframe-spec.ts +++ b/spec/api-subframe-spec.ts @@ -1,11 +1,14 @@ +import { app, BrowserWindow, ipcMain } from 'electron/main'; + import { expect } from 'chai'; -import * as path from 'node:path'; + +import { once } from 'node:events'; import * as http from 'node:http'; +import * as path from 'node:path'; + import { emittedNTimes } from './lib/events-helpers'; -import { closeWindow } from './lib/window-helpers'; -import { app, BrowserWindow, ipcMain } from 'electron/main'; import { ifdescribe, listen } from './lib/spec-helpers'; -import { once } from 'node:events'; +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 adedba8953..05de0b91e8 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 2d54eef062..c64583afd6 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 067d529330..f56ba1e695 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 d283b41f4c..2a12a45790 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -1,14 +1,17 @@ +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 { BrowserWindow, MessageChannelMain, utilityProcess, app } from 'electron/main'; +import { setImmediate } from 'node:timers/promises'; +import { pathToFileURL } from 'node:url'; + +import { respondOnce, randomString, kOneKiloByte } from './lib/net-helpers'; import { ifit, startRemoteControlApp } from './lib/spec-helpers'; import { closeWindow } from './lib/window-helpers'; -import { respondOnce, randomString, kOneKiloByte } from './lib/net-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 9d7f39bf4d..4faebbd648 100644 --- a/spec/api-view-spec.ts +++ b/spec/api-view-spec.ts @@ -1,6 +1,8 @@ +import { BaseWindow, View } from 'electron/main'; + import { expect } from 'chai'; + import { closeWindow } from './lib/window-helpers'; -import { BaseWindow, View } from 'electron/main'; describe('View', () => { let w: BaseWindow; diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index 42764b66a8..2e584c309c 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -1,16 +1,19 @@ +import { BrowserWindow, ipcMain, webContents, session, app, BrowserView, WebContents } from 'electron/main'; + import { expect } from 'chai'; -import { AddressInfo } from 'node:net'; + import * as cp from 'node:child_process'; -import * as path from 'node:path'; +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 { setTimeout } from 'node:timers/promises'; 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 { setTimeout } from 'node:timers/promises'; +import { closeAllWindows } from './lib/window-helpers'; 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 1525986b77..958775067e 100644 --- a/spec/api-web-contents-view-spec.ts +++ b/spec/api-web-contents-view-spec.ts @@ -1,10 +1,12 @@ -import { expect } from 'chai'; import { BaseWindow, BrowserWindow, View, WebContentsView, webContents, screen } from 'electron/main'; + +import { expect } from 'chai'; + import { once } from 'node:events'; -import { closeAllWindows } from './lib/window-helpers'; -import { defer, ifdescribe, waitUntil } from './lib/spec-helpers'; import { HexColors, ScreenCapture, hasCapturableScreen, nextFrameTime } from './lib/screen-helpers'; +import { defer, ifdescribe, waitUntil } from './lib/spec-helpers'; +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 e78f1a0876..54c95c9ef4 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 1a56225eef..3aa2e906a2 100644 --- a/spec/api-web-frame-spec.ts +++ b/spec/api-web-frame-spec.ts @@ -1,8 +1,11 @@ +import { BrowserWindow, ipcMain, WebContents } from 'electron/main'; + import { expect } from 'chai'; + +import { once } from 'node:events'; import * as path from 'node:path'; -import { BrowserWindow, ipcMain, WebContents } from 'electron/main'; + import { defer } from './lib/spec-helpers'; -import { once } from 'node:events'; describe('webFrame module', () => { const fixtures = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-request-spec.ts b/spec/api-web-request-spec.ts index e8b17f55b6..6a75476588 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 { Socket } from 'node:net'; import * as path from 'node:path'; -import * as fs from 'node:fs'; +import * as qs from 'node:querystring'; +import { ReadableStream } from 'node:stream/web'; 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 { ReadableStream } from 'node:stream/web'; const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/api-web-utils-spec.ts b/spec/api-web-utils-spec.ts index a369d15146..a9d9411d7a 100644 --- a/spec/api-web-utils-spec.ts +++ b/spec/api-web-utils-spec.ts @@ -1,7 +1,11 @@ +import { BrowserWindow } from 'electron/main'; + import { expect } from 'chai'; + import * as path from 'node:path'; -import { BrowserWindow } from 'electron/main'; + 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 388ca273f2..cec2d19c10 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 879ed287b8..1fcf630973 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 5e55112588..9868e9d633 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 91ba65b6a7..5f49ff5559 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 { 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 * as fs from 'node:fs'; import * as http from 'node:http'; +import * as https from 'node:https'; +import { AddressInfo } from 'node:net'; import * as path from 'node:path'; -import * as fs from 'node:fs'; +import { setTimeout } from 'node:timers/promises'; import * as url from 'node:url'; -import * as ChildProcess from 'node:child_process'; -import { EventEmitter, once } from 'node:events'; + import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers'; +import { closeAllWindows } from './lib/window-helpers'; import { PipeTransport } from './pipe-transport'; -import * as ws from 'ws'; -import { setTimeout } from 'node:timers/promises'; -import { AddressInfo } from 'node:net'; -import { MediaAccessPermissionRequest } from 'electron'; const features = process._linkedBinding('electron_common_features'); diff --git a/spec/crash-spec.ts b/spec/crash-spec.ts index 6a83b3d3aa..ff8489b050 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 b8e3ae9b1d..3ba8429f62 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 2a0eb148ef..da63b686f6 100644 --- a/spec/esm-spec.ts +++ b/spec/esm-spec.ts @@ -1,6 +1,8 @@ +import { BrowserWindow } from 'electron'; + import { expect } from 'chai'; + import * as cp from 'node:child_process'; -import { BrowserWindow } from 'electron'; 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 fdde8341c3..6d78104cde 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, waitUntil } 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 3422a3fd56..41e4ac1222 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 5182dd66dc..b4fd323b93 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 d66d30921b..c566dd5cef 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 3476034455..fe983e4d54 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 a9f6d261c0..1bb90b65d3 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 2d4a487866..a0ec2f90a2 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 a97259cdf7..cc0628273d 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 74d1219003..413aaec581 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 5edb3ea823..c03f28d175 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 80fbaff5cc..5c9c7331ff 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 80fbaff5cc..5c9c7331ff 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 index 7b5544a903..c5dae19284 100644 --- a/spec/fixtures/api/utility-process/net.js +++ b/spec/fixtures/api/utility-process/net.js @@ -1,4 +1,5 @@ const { net } = require('electron'); + const serverUrl = process.argv[2].split('=')[1]; let configurableArg = null; if (process.argv[3]) { diff --git a/spec/fixtures/api/utility-process/suid.js b/spec/fixtures/api/utility-process/suid.js index 714a288f44..69d4d018c1 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 2b0cb8be0c..db984154ff 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 cabedbb1aa..dcae6b79bb 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 55a65ca93a..ca7272ff40 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 4f4d4999d0..6f0b188a18 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 f4ada26db3..d317fa37a7 100644 --- a/spec/fixtures/apps/refresh-page/main.js +++ b/spec/fixtures/apps/refresh-page/main.js @@ -1,7 +1,8 @@ -const path = require('node:path'); +const { BrowserWindow, app, protocol, net, session } = require('electron'); + const { once } = require('node:events'); +const path = require('node:path'); const { pathToFileURL } = require('node:url'); -const { BrowserWindow, app, protocol, net, session } = require('electron'); if (process.argv.length < 4) { console.error('Must pass allow_code_cache code_cache_dir'); diff --git a/spec/fixtures/apps/remote-control/main.js b/spec/fixtures/apps/remote-control/main.js index b2b6f4b4fb..8ea8d17def 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 abde440957..7dd0cd30d9 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 f5e23deda9..292abe12ce 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 320dbffe22..3db01f553c 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 2452731862..487ef591b4 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 f9d1b1670b..d9ec2b6ac0 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 1e87b8d177..97198c6eed 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 7e997d030f..78e630fb54 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 65dba1ef01..d71cc4e0d4 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 30ff075ecd..af5f062b4e 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 151751820a..08bdede4da 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 be1cb3f3d1..3ee66640b8 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 0059a5c3df..643594da50 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 3d491cabbd..99297eed49 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 ab13554fb8..7b196e5339 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 8a5ef8dde1..dccbe2d314 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 64c059b2f2..abcc0e66be 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 ae1b31dd9b..56ba812a0d 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 33ed47051c..857211280d 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 90392e46fe..e7d5980d53 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 895168dd39..fc5d6cb1ca 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 390fa920df..465b7152ed 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 5b4a220972..feef5d903a 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 index 97b49e7693..ff2c1a8e72 100644 --- a/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js +++ b/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js @@ -1,4 +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 6d7e4f8aa7..c2761afc41 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 40e073470b..9c8dbdde74 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 5af420a934..d85dc01e75 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 5fb0013c0e..29409f7cc0 100644 --- a/spec/fuses-spec.ts +++ b/spec/fuses-spec.ts @@ -1,10 +1,13 @@ +import { BrowserWindow } from 'electron'; + import { expect } from 'chai'; -import { startRemoteControlApp } from './lib/spec-helpers'; -import { once } from 'node:events'; + import { spawn, spawnSync } from 'node:child_process'; -import { BrowserWindow } from 'electron'; +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/guest-window-manager-spec.ts b/spec/guest-window-manager-spec.ts index bd5bab5bd9..88daa4cfae 100644 --- a/spec/guest-window-manager-spec.ts +++ b/spec/guest-window-manager-spec.ts @@ -1,10 +1,13 @@ import { BrowserWindow, screen } from 'electron'; + import { expect, assert } from 'chai'; + +import { once } from 'node:events'; +import * as http from 'node:http'; + import { HexColors, ScreenCapture, hasCapturableScreen } from './lib/screen-helpers'; import { ifit, listen } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; -import { once } from 'node:events'; -import * as http from 'node:http'; describe('webContents.setWindowOpenHandler', () => { describe('native window', () => { diff --git a/spec/index.js b/spec/index.js index 34967e8f39..fe5ef6abf1 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 5b1b66aba6..433a119507 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 2de425e545..9e43f48219 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 26949079d6..7c1966c905 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 350885278c..7500ac755e 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 7548849795..0fb3128611 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 c2ecb4b16a..85a31ddd3b 100644 --- a/spec/lib/spec-helpers.ts +++ b/spec/lib/spec-helpers.ts @@ -1,15 +1,17 @@ +import { BrowserWindow } from 'electron/main'; + +import { AssertionError } from 'chai'; +import { SuiteFunction, TestFunction } from 'mocha'; + 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 https from 'node:https'; import * as net from 'node:net'; -import * as v8 from 'node:v8'; -import * as url from 'node:url'; -import { SuiteFunction, TestFunction } from 'mocha'; -import { BrowserWindow } from 'electron/main'; -import { AssertionError } from 'chai'; +import * as path from 'node:path'; import { setTimeout } from 'node:timers/promises'; +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 6571d74189..77a8913df7 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 dfa2538bc2..46fa410a07 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 * 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 8fd2c7dbe3..ecfdf1a9e8 100644 --- a/spec/modules-spec.ts +++ b/spec/modules-spec.ts @@ -1,11 +1,14 @@ +import { BrowserWindow } from 'electron/main'; + import { expect } from 'chai'; -import * as path from 'node:path'; + +import * as childProcess from 'node:child_process'; +import { once } from 'node:events'; import * as fs from 'node:fs'; -import { BrowserWindow } from 'electron/main'; +import * as path from 'node:path'; + import { ifdescribe, ifit } from './lib/spec-helpers'; import { closeAllWindows } from './lib/window-helpers'; -import * as childProcess from 'node:child_process'; -import { once } from 'node:events'; const Module = require('node:module') as NodeJS.ModuleInternal; diff --git a/spec/node-spec.ts b/spec/node-spec.ts index 9c5059172c..d3f68030a2 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 { EventEmitter } from 'node:stream'; 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 { 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 be561064b5..1392ae1582 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 343e7536cb..db734208e5 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 a20a45f817..be34d0608c 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 ea356e0d01..19e563b41d 100644 --- a/spec/security-warnings-spec.ts +++ b/spec/security-warnings-spec.ts @@ -1,14 +1,15 @@ +import { BrowserWindow, WebPreferences } from 'electron/main'; + import { expect } from 'chai'; -import * as http from 'node:http'; + 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 { BrowserWindow, WebPreferences } from 'electron/main'; - -import { closeWindow } from './lib/window-helpers'; import { emittedUntil } from './lib/events-helpers'; import { listen } from './lib/spec-helpers'; -import { setTimeout } from '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 3d92fedc73..25341e4bdd 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 2584c98b9d..9099e42866 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 c111770709..e84d4a82ac 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 6edfcdf126..2f23420d80 100644 --- a/spec/visibility-state-spec.ts +++ b/spec/visibility-state-spec.ts @@ -1,12 +1,14 @@ +import { BaseWindow, BrowserWindow, BrowserWindowConstructorOptions, ipcMain, WebContents, WebContentsView } from 'electron/main'; + import { expect } from 'chai'; + import * as cp from 'node:child_process'; -import { BaseWindow, BrowserWindow, BrowserWindowConstructorOptions, ipcMain, WebContents, WebContentsView } from 'electron/main'; +import { once } from 'node:events'; import * as path from 'node:path'; +import { setTimeout } from 'node:timers/promises'; -import { closeWindow } from './lib/window-helpers'; import { ifdescribe } from './lib/spec-helpers'; -import { once } from 'node:events'; -import { setTimeout } from 'node:timers/promises'; +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 diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts index 5b7a9bd4be..377e119278 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, hasCapturableScreen } 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');",build 32a74b094218bf477dfaf2a150eeda39ff029b30,Charles Kerr,2024-07-19 11:48:52,"chore: remove unused field `ElectronBrowserClient::browser_main_parts_` (#42956) chore: remove unused field ElectronBrowserClient::browser_main_parts_ caller removed in 48d0b09a","diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 23caaa737f..e31e6117d4 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -829,13 +829,7 @@ ElectronBrowserClient::GetSystemNetworkContext() { std::unique_ptr ElectronBrowserClient::CreateBrowserMainParts(bool /* is_integration_test */) { - auto browser_main_parts = std::make_unique(); - -#if BUILDFLAG(IS_MAC) - browser_main_parts_ = browser_main_parts.get(); -#endif - - return browser_main_parts; + return std::make_unique(); } void ElectronBrowserClient::WebNotificationAllowed( diff --git a/shell/browser/electron_browser_client.h b/shell/browser/electron_browser_client.h index 2ad408c27d..24eb34621b 100644 --- a/shell/browser/electron_browser_client.h +++ b/shell/browser/electron_browser_client.h @@ -340,10 +340,6 @@ class ElectronBrowserClient : public content::ContentBrowserClient, std::unique_ptr hid_delegate_; std::unique_ptr web_authentication_delegate_; - -#if BUILDFLAG(IS_MAC) - raw_ptr browser_main_parts_ = nullptr; -#endif }; } // namespace electron",chore dd50afa8c2d82f4a448bd66675fcde2d64642031,Shelley Vohr,2024-11-18 10:06:27,"fix: `utilityProcess` pid should be `undefined` after exit (#44677) fix: utilityProcess pid should be undefined after exit","diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index bed1dd23f7..5a660bef41 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -92,6 +92,8 @@ the child process exits, then the value is `undefined` after the `exit` event is ```js const child = utilityProcess.fork(path.join(__dirname, 'test.js')) +console.log(child.pid) // undefined + child.on('spawn', () => { console.log(child.pid) // Integer }) @@ -101,6 +103,8 @@ child.on('exit', () => { }) ``` +**Note:** You can use the `pid` to determine if the process is currently running. + #### `child.stdout` A `NodeJS.ReadableStream | null` that represents the child process's stdout. diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc index 29e5f719d9..5c1fd14be0 100644 --- a/shell/browser/api/electron_api_utility_process.cc +++ b/shell/browser/api/electron_api_utility_process.cc @@ -255,6 +255,8 @@ void UtilityProcessWrapper::HandleTermination(uint64_t exit_code) { if (pid_ != base::kNullProcessId) GetAllUtilityProcessWrappers().Remove(pid_); + + pid_ = base::kNullProcessId; CloseConnectorPort(); EmitWithoutEvent(""exit"", exit_code); Unpin(); diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index 9e2dad10df..9967303214 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -240,13 +240,31 @@ describe('utilityProcess module', () => { it('is valid when child process launches successfully', async () => { const child = utilityProcess.fork(path.join(fixturesPath, 'empty.js')); await once(child, 'spawn'); - expect(child.pid).to.not.be.null(); + expect(child).to.have.property('pid').that.is.a('number'); }); it('is undefined when child process fails to launch', async () => { const child = utilityProcess.fork(path.join(fixturesPath, 'does-not-exist.js')); expect(child.pid).to.be.undefined(); }); + + it('is undefined before the child process is spawned succesfully', async () => { + const child = utilityProcess.fork(path.join(fixturesPath, 'empty.js')); + expect(child.pid).to.be.undefined(); + await once(child, 'spawn'); + child.kill(); + }); + + it('is undefined when child process is killed', async () => { + const child = utilityProcess.fork(path.join(fixturesPath, 'empty.js')); + await once(child, 'spawn'); + + expect(child).to.have.property('pid').that.is.a('number'); + expect(child.kill()).to.be.true(); + + await once(child, 'exit'); + expect(child.pid).to.be.undefined(); + }); }); describe('stdout property', () => {",fix d4413a8e53590b43d622ad9dce4259be89acbb8c,Shelley Vohr,2024-02-16 17:31:34,chore: remove unused anonymous namespace methods (#41333),"diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 69ef9fc5ba..240f69d0c6 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -118,52 +118,10 @@ namespace electron { namespace { -bool IsFramelessWindow(NSView* view) { - NSWindow* nswindow = [view window]; - if (![nswindow respondsToSelector:@selector(shell)]) - return false; - NativeWindow* window = [static_cast(nswindow) shell]; - return window && !window->has_frame(); -} - bool IsPanel(NSWindow* window) { return [window isKindOfClass:[NSPanel class]]; } -IMP original_set_frame_size = nullptr; -IMP original_view_did_move_to_superview = nullptr; - -// This method is directly called by NSWindow during a window resize on OSX -// 10.10.0, beta 2. We must override it to prevent the content view from -// shrinking. -void SetFrameSize(NSView* self, SEL _cmd, NSSize size) { - if (!IsFramelessWindow(self)) { - auto original = - reinterpret_cast(original_set_frame_size); - return original(self, _cmd, size); - } - // For frameless window, resize the view to cover full window. - if ([self superview]) - size = [[self superview] bounds].size; - auto super_impl = reinterpret_cast( - [[self superclass] instanceMethodForSelector:_cmd]); - super_impl(self, _cmd, size); -} - -// The contentView gets moved around during certain full-screen operations. -// This is less than ideal, and should eventually be removed. -void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { - if (!IsFramelessWindow(self)) { - // [BridgedContentView viewDidMoveToSuperview]; - auto original = reinterpret_cast( - original_view_did_move_to_superview); - if (original) - original(self, _cmd); - return; - } - [self setFrame:[[self superview] bounds]]; -} - // -[NSWindow orderWindow] does not handle reordering for children // windows. Their order is fixed to the attachment order (the last attached // window is on the top). Therefore, work around it by re-parenting in our",chore 0e5fe3fa604e6eef5e7c73739f64391fafe5143b,Shelley Vohr,2025-01-20 09:54:12,"fix: `getAsFileSystemHandle` failure when drag-dropping two directories (#45234) fix: drag-dropping two directories","diff --git a/shell/browser/file_system_access/file_system_access_permission_context.cc b/shell/browser/file_system_access/file_system_access_permission_context.cc index 0d9aaba692..bafc1851e5 100644 --- a/shell/browser/file_system_access/file_system_access_permission_context.cc +++ b/shell/browser/file_system_access/file_system_access_permission_context.cc @@ -588,7 +588,7 @@ void FileSystemAccessPermissionContext::ConfirmSensitiveEntryAccess( content::GlobalRenderFrameHostId frame_id, base::OnceCallback callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - callback_ = std::move(callback); + callback_map_[path_info.path] = std::move(callback); auto after_blocklist_check_callback = base::BindOnce( &FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist, @@ -632,16 +632,18 @@ void FileSystemAccessPermissionContext::PerformAfterWriteChecks( } void FileSystemAccessPermissionContext::RunRestrictedPathCallback( + const base::FilePath& file_path, SensitiveEntryResult result) { - if (callback_) - std::move(callback_).Run(result); + if (base::Contains(callback_map_, file_path)) + std::move(callback_map_[file_path]).Run(result); } void FileSystemAccessPermissionContext::OnRestrictedPathResult( + const base::FilePath& file_path, gin::Arguments* args) { SensitiveEntryResult result = SensitiveEntryResult::kAbort; args->GetNext(&result); - RunRestrictedPathCallback(result); + RunRestrictedPathCallback(file_path, result); } void FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist( @@ -654,8 +656,9 @@ void FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist( DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (user_action == UserAction::kNone) { - RunRestrictedPathCallback(should_block ? SensitiveEntryResult::kAbort - : SensitiveEntryResult::kAllowed); + auto result = should_block ? SensitiveEntryResult::kAbort + : SensitiveEntryResult::kAllowed; + RunRestrictedPathCallback(path_info.path, result); return; } @@ -674,11 +677,11 @@ void FileSystemAccessPermissionContext::DidCheckPathAgainstBlocklist( ""file-system-access-restricted"", details, base::BindRepeating( &FileSystemAccessPermissionContext::OnRestrictedPathResult, - weak_factory_.GetWeakPtr())); + weak_factory_.GetWeakPtr(), path_info.path)); return; } - RunRestrictedPathCallback(SensitiveEntryResult::kAllowed); + RunRestrictedPathCallback(path_info.path, SensitiveEntryResult::kAllowed); } void FileSystemAccessPermissionContext::MaybeEvictEntries( diff --git a/shell/browser/file_system_access/file_system_access_permission_context.h b/shell/browser/file_system_access/file_system_access_permission_context.h index 9fe2f38807..db60e43210 100644 --- a/shell/browser/file_system_access/file_system_access_permission_context.h +++ b/shell/browser/file_system_access/file_system_access_permission_context.h @@ -144,9 +144,11 @@ class FileSystemAccessPermissionContext content::GlobalRenderFrameHostId frame_id, bool should_block); - void RunRestrictedPathCallback(SensitiveEntryResult result); + void RunRestrictedPathCallback(const base::FilePath& file_path, + SensitiveEntryResult result); - void OnRestrictedPathResult(gin::Arguments* args); + void OnRestrictedPathResult(const base::FilePath& file_path, + gin::Arguments* args); void MaybeEvictEntries(base::Value::Dict& dict); @@ -170,7 +172,8 @@ class FileSystemAccessPermissionContext std::map id_pathinfo_map_; - base::OnceCallback callback_; + std::map> + callback_map_; base::WeakPtrFactory weak_factory_{this}; };",fix 22c359ac4f2c3bfa3c0c4b03543007dc6c5942da,Michaela Laurencin,2023-08-15 10:57:48,docs: update timelines for E27 (#39493),"diff --git a/docs/tutorial/electron-timelines.md b/docs/tutorial/electron-timelines.md index bc6421c917..bcabbfc984 100644 --- a/docs/tutorial/electron-timelines.md +++ b/docs/tutorial/electron-timelines.md @@ -9,10 +9,11 @@ check out our [Electron Versioning](./electron-versioning.md) doc. | Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported | | ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- | -| 26.0.0 | 2023-Jun-01 | 2023-Jun-27 | 2023-Aug-15 | TBD | M116 | TBD | ✅ | +| 27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | TBD | M118 | TBD | ✅ | +| 26.0.0 | 2023-Jun-01 | 2023-Jun-27 | 2023-Aug-15 | 2024-Feb-27 | M116 | v18.16 | ✅ | | 25.0.0 | 2023-Apr-10 | 2023-May-02 | 2023-May-30 | 2024-Jan-02 | M114 | v18.15 | ✅ | | 24.0.0 | 2022-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-10 | M112 | v18.14 | ✅ | -| 23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | 2023-Aug-15 | M110 | v18.12 | ✅ | +| 23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | 2023-Aug-15 | M110 | v18.12 | 🚫 | | 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | ✅ | | 21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | 2023-Apr-04 | M106 | v16.16 | 🚫 | | 20.0.0 | 2022-May-26 | 2022-Jun-21 | 2022-Aug-02 | 2023-Feb-07 | M104 | v16.15 | 🚫 |",docs 95bf9d8adb33bc2aaf988977b18663f9a770ef77,Shelley Vohr,2023-08-21 02:41:00,"fix: `chrome://gpu` failing to load (#39556) fix: chrome://gpu failing to load","diff --git a/electron_paks.gni b/electron_paks.gni index c3a257ab0f..bc6950bee7 100644 --- a/electron_paks.gni +++ b/electron_paks.gni @@ -61,6 +61,7 @@ template(""electron_extra_paks"") { ""$root_gen_dir/content/browser/tracing/tracing_resources.pak"", ""$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak"", ""$root_gen_dir/content/content_resources.pak"", + ""$root_gen_dir/content/gpu_resources.pak"", ""$root_gen_dir/mojo/public/js/mojo_bindings_resources.pak"", ""$root_gen_dir/net/net_resources.pak"", ""$root_gen_dir/third_party/blink/public/resources/blink_resources.pak"", @@ -74,6 +75,7 @@ template(""electron_extra_paks"") { ""//chrome/common:resources"", ""//components/resources"", ""//content:content_resources"", + ""//content/browser/resources/gpu:resources"", ""//content/browser/resources/media:resources"", ""//content/browser/tracing:resources"", ""//content/browser/webrtc/resources"", diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index f9ebb1f4ef..da937aa454 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -2050,10 +2050,32 @@ describe('chromium features', () => { }); }); + describe('chrome://accessibility', () => { + it('loads the page successfully', async () => { + const w = new BrowserWindow({ show: false }); + await w.loadURL('chrome://accessibility'); + const pageExists = await w.webContents.executeJavaScript( + ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" + ); + expect(pageExists).to.be.true(); + }); + }); + + describe('chrome://gpu', () => { + it('loads the page successfully', async () => { + const w = new BrowserWindow({ show: false }); + await w.loadURL('chrome://gpu'); + const pageExists = await w.webContents.executeJavaScript( + ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" + ); + expect(pageExists).to.be.true(); + }); + }); + describe('chrome://media-internals', () => { it('loads the page successfully', async () => { const w = new BrowserWindow({ show: false }); - w.loadURL('chrome://media-internals'); + await w.loadURL('chrome://media-internals'); const pageExists = await w.webContents.executeJavaScript( ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" ); @@ -2064,7 +2086,7 @@ describe('chromium features', () => { describe('chrome://webrtc-internals', () => { it('loads the page successfully', async () => { const w = new BrowserWindow({ show: false }); - w.loadURL('chrome://webrtc-internals'); + await w.loadURL('chrome://webrtc-internals'); const pageExists = await w.webContents.executeJavaScript( ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" );",fix 7ec813732aff4bc428e4946efb1934cc9f6a1fd6,Keeley Hammond,2024-05-23 07:20:13,chore: cherry-pick 3e037e195e50 from v8 (#42253),"diff --git a/patches/v8/.patches b/patches/v8/.patches index 7704cdbd32..e1772bc5cc 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -3,3 +3,4 @@ deps_add_v8_object_setinternalfieldfornodecore.patch revert_heap_add_checks_position_info.patch cherry-pick-f320600cd1f4.patch cherry-pick-b3c01ac1e60a.patch +cherry-pick-3e037e195e50.patch diff --git a/patches/v8/cherry-pick-3e037e195e50.patch b/patches/v8/cherry-pick-3e037e195e50.patch new file mode 100644 index 0000000000..d1c938e7a7 --- /dev/null +++ b/patches/v8/cherry-pick-3e037e195e50.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shu-yu Guo +Date: Tue, 21 May 2024 10:06:20 -0700 +Subject: Using FunctionParsingScope for parsing class static blocks + +Class static blocks contain statements, don't inherit the +ExpressionScope stack. + +Bug: 341663589 +Change-Id: Id52a60d77781201a706fcf2290d7d103f39bed83 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5553030 +Commit-Queue: Shu-yu Guo +Commit-Queue: Adam Klein +Reviewed-by: Adam Klein +Cr-Commit-Position: refs/heads/main@{#94014} + +diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc +index 660fdd2e9ad30b9487eafd351b1e517d2a489204..de4df35c0addc53c5620a19e3e06a8f9eff2a8fb 100644 +--- a/src/ast/scopes.cc ++++ b/src/ast/scopes.cc +@@ -2447,7 +2447,7 @@ bool Scope::MustAllocate(Variable* var) { + var->set_is_used(); + if (inner_scope_calls_eval_ && !var->is_this()) var->SetMaybeAssigned(); + } +- DCHECK(!var->has_forced_context_allocation() || var->is_used()); ++ CHECK(!var->has_forced_context_allocation() || var->is_used()); + // Global variables do not need to be allocated. + return !var->IsGlobalObjectProperty() && var->is_used(); + } +diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h +index 78bad16404d31505e34d4d69a948ad7a689776cc..7ccf203fadcf256b4dba40f66d8e5b4d3780282c 100644 +--- a/src/parsing/parser-base.h ++++ b/src/parsing/parser-base.h +@@ -2661,6 +2661,7 @@ typename ParserBase::BlockT ParserBase::ParseClassStaticBlock( + } + + FunctionState initializer_state(&function_state_, &scope_, initializer_scope); ++ FunctionParsingScope body_parsing_scope(impl()); + AcceptINScope accept_in(this, true); + + // Each static block has its own var and lexical scope, so make a new var",chore dc707ee93835b279ff67dbd5f80ce28a4b9df3e1,Shelley Vohr,2023-08-07 09:52:18,fix: macOS tray button selection with VoiceOver (#39352),"diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index 9d6d6d4bd0..ba66aed141 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -54,7 +54,12 @@ NSStatusItem* item = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; statusItem_ = item; - [[statusItem_ button] addSubview:self]; // inject custom view + [[statusItem_ button] addSubview:self]; + + // We need to set the target and action on the button, otherwise + // VoiceOver doesn't know where to send the select action. + [[statusItem_ button] setTarget:self]; + [[statusItem_ button] setAction:@selector(mouseDown:)]; [self updateDimensions]; } return self; @@ -190,6 +195,25 @@ } - (void)mouseDown:(NSEvent*)event { + // If |event| does not respond to locationInWindow, we've + // arrived here from VoiceOver, which does not pass an event. + // Create a synthetic event to pass to the click handler. + if (![event respondsToSelector:@selector(locationInWindow)]) { + event = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:NSApp.currentEvent.timestamp + windowNumber:0 + context:nil + eventNumber:0 + clickCount:1 + pressure:1.0]; + + // We also need to explicitly call the click handler here, since + // VoiceOver won't trigger mouseUp. + [self handleClickNotifications:event]; + } + trayIcon_->NotifyMouseDown( gfx::ScreenPointFromNSPoint([event locationInWindow]), ui::EventFlagsFromModifiers([event modifierFlags]));",fix eecfaec8c94b2490cff8ae09219d3c16ec2b4c88,Robo,2023-08-08 17:45:03,"fix: crash when closing active macOS native tab (#39394) fix: crash when closing current active macOS native tab","diff --git a/shell/browser/ui/inspectable_web_contents_view_mac.mm b/shell/browser/ui/inspectable_web_contents_view_mac.mm index 175678f037..7f465e173b 100644 --- a/shell/browser/ui/inspectable_web_contents_view_mac.mm +++ b/shell/browser/ui/inspectable_web_contents_view_mac.mm @@ -24,6 +24,7 @@ InspectableWebContentsViewMac::InspectableWebContentsViewMac( initWithInspectableWebContentsViewMac:this]) {} InspectableWebContentsViewMac::~InspectableWebContentsViewMac() { + [[NSNotificationCenter defaultCenter] removeObserver:view_]; CloseDevTools(); } ",fix e66c1f6c562a9cbd361e17f816cab0a0827d38b4,Milan Burda,2023-08-30 17:07:41,refactor: generate 'chrome:// pages' specs to remove duplicate code (#39684),"diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index fb3907089f..c2b39e4337 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -2050,48 +2050,27 @@ describe('chromium features', () => { }); }); - describe('chrome://accessibility', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://accessibility'); - const pageExists = await w.webContents.executeJavaScript( - ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" - ); - expect(pageExists).to.be.true(); - }); - }); - - describe('chrome://gpu', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://gpu'); - const pageExists = await w.webContents.executeJavaScript( - ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" - ); - expect(pageExists).to.be.true(); - }); - }); - - describe('chrome://media-internals', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://media-internals'); - const pageExists = await w.webContents.executeJavaScript( - ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" - ); - expect(pageExists).to.be.true(); - }); - }); + describe('chrome:// pages', () => { + const urls = [ + 'chrome://accessibility', + 'chrome://gpu', + 'chrome://media-internals', + 'chrome://tracing', + 'chrome://webrtc-internals' + ]; - describe('chrome://webrtc-internals', () => { - it('loads the page successfully', async () => { - const w = new BrowserWindow({ show: false }); - await w.loadURL('chrome://webrtc-internals'); - const pageExists = await w.webContents.executeJavaScript( - ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" - ); - expect(pageExists).to.be.true(); - }); + for (const url of urls) { + describe(url, () => { + it('loads the page successfully', async () => { + const w = new BrowserWindow({ show: false }); + await w.loadURL(url); + const pageExists = await w.webContents.executeJavaScript( + ""window.hasOwnProperty('chrome') && window.chrome.hasOwnProperty('send')"" + ); + expect(pageExists).to.be.true(); + }); + }); + } }); describe('document.hasFocus', () => {",refactor 7cdf1a01b800f6270c1fce1b7b45522e0e0ed79b,Charles Kerr,2024-10-30 14:56:10,"docs: fix win.setContentView() arg type (#44478) fix: setContentView type","diff --git a/docs/api/base-window.md b/docs/api/base-window.md index d1ed1a82d0..c6cc7c878b 100644 --- a/docs/api/base-window.md +++ b/docs/api/base-window.md @@ -506,7 +506,7 @@ labeled as such. #### `win.setContentView(view)` -* `view` [`View`](view.md) +* `view` [View](view.md) Sets the content view of the window. ",docs 3fa15ebb7e8aef2029cd23370fdc96f382c9d161,Cheng Zhao,2023-07-06 00:02:05,fix: use Chromium's way to compute min/max sizes (#38974),"diff --git a/patches/chromium/.patches b/patches/chromium/.patches index f07d408448..90cc77fa80 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -129,5 +129,4 @@ chore_patch_out_profile_methods_in_titlebar_config.patch fix_crash_on_nativetheme_change_during_context_menu_close.patch fix_select_the_first_menu_item_when_opened_via_keyboard.patch fix_return_v8_value_from_localframe_requestexecutescript.patch -revert_simplify_dwm_transitions_on_windows.patch fix_harden_blink_scriptstate_maybefrom.patch diff --git a/patches/chromium/revert_simplify_dwm_transitions_on_windows.patch b/patches/chromium/revert_simplify_dwm_transitions_on_windows.patch deleted file mode 100644 index 63cd6ffa47..0000000000 --- a/patches/chromium/revert_simplify_dwm_transitions_on_windows.patch +++ /dev/null @@ -1,368 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: deepak1556 -Date: Tue, 27 Jun 2023 22:05:17 +0900 -Subject: Revert ""Simplify DWM transitions on Windows"" - -This reverts commit 392e5f43aae8d225a118145cbc5f5bb104cbe541. - -Can be removed once https://github.com/electron/electron/issues/38937 is resolved. - -diff --git a/chrome/app/chrome_command_ids.h b/chrome/app/chrome_command_ids.h -index 15f4aac24744228c0e74ec521c18eb6ab5f59c5b..b9a71c9063d8ee573424a9161cc127af169944a9 100644 ---- a/chrome/app/chrome_command_ids.h -+++ b/chrome/app/chrome_command_ids.h -@@ -59,6 +59,7 @@ - #define IDC_MOVE_TAB_NEXT 34032 - #define IDC_MOVE_TAB_PREVIOUS 34033 - #define IDC_SEARCH 34035 -+#define IDC_DEBUG_FRAME_TOGGLE 34038 - #define IDC_WINDOW_MENU 34045 - #define IDC_MINIMIZE_WINDOW 34046 - #define IDC_MAXIMIZE_WINDOW 34047 -diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc -index b198e41661d459302ddccfab70ac3de8cd2c48b5..405c0ac7c41ef4cb6a8804c8a34a7328d796d7bd 100644 ---- a/chrome/browser/ui/browser_command_controller.cc -+++ b/chrome/browser/ui/browser_command_controller.cc -@@ -1184,6 +1184,7 @@ void BrowserCommandController::InitCommandState() { - IDC_DUPLICATE_TAB, !browser_->is_type_picture_in_picture()); - UpdateTabRestoreCommandState(); - command_updater_.UpdateCommandEnabled(IDC_EXIT, true); -+ command_updater_.UpdateCommandEnabled(IDC_DEBUG_FRAME_TOGGLE, true); - command_updater_.UpdateCommandEnabled(IDC_NAME_WINDOW, true); - #if BUILDFLAG(IS_CHROMEOS) - command_updater_.UpdateCommandEnabled( -diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc -index fa718692b769c3bbcf83f700718cf88dc631d058..c8ed066b698ab08d5cfbc644ca1f66f23c0fbeec 100644 ---- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc -+++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.cc -@@ -397,6 +397,13 @@ void BrowserDesktopWindowTreeHostWin::HandleDestroying() { - DesktopWindowTreeHostWin::HandleDestroying(); - } - -+void BrowserDesktopWindowTreeHostWin::HandleFrameChanged() { -+ // Reinitialize the status bubble, since it needs to be initialized -+ // differently depending on whether or not DWM composition is enabled -+ browser_view_->InitStatusBubble(); -+ DesktopWindowTreeHostWin::HandleFrameChanged(); -+} -+ - void BrowserDesktopWindowTreeHostWin::HandleWindowScaleFactorChanged( - float window_scale_factor) { - DesktopWindowTreeHostWin::HandleWindowScaleFactorChanged(window_scale_factor); -diff --git a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h -index 28412d00adf463a1453aecc82ca1179f0521822d..a3bd2e0cae1d341adfe9dd498886ae5914e1cba7 100644 ---- a/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h -+++ b/chrome/browser/ui/views/frame/browser_desktop_window_tree_host_win.h -@@ -66,6 +66,7 @@ class BrowserDesktopWindowTreeHostWin - bool GetDwmFrameInsetsInPixels(gfx::Insets* insets) const override; - void HandleCreate() override; - void HandleDestroying() override; -+ void HandleFrameChanged() override; - void HandleWindowScaleFactorChanged(float window_scale_factor) override; - bool PreHandleMSG(UINT message, - WPARAM w_param, -diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc -index 6920106ba91e0d1c0c1706a28b4ce5a14b5f3aed..306affc1d9573acd475d79f30a3583f0e716f33e 100644 ---- a/chrome/browser/ui/views/frame/browser_view.cc -+++ b/chrome/browser/ui/views/frame/browser_view.cc -@@ -927,8 +927,7 @@ BrowserView::BrowserView(std::unique_ptr browser) - infobar_container_ = - AddChildView(std::make_unique(this)); - -- status_bubble_ = std::make_unique(contents_web_view_); -- contents_web_view_->SetStatusBubble(status_bubble_.get()); -+ InitStatusBubble(); - - // Create do-nothing view for the sake of controlling the z-order of the find - // bar widget. -@@ -1049,6 +1048,11 @@ void BrowserView::SetDisableRevealerDelayForTesting(bool disable) { - g_disable_revealer_delay_for_testing = disable; - } - -+void BrowserView::InitStatusBubble() { -+ status_bubble_ = std::make_unique(contents_web_view_); -+ contents_web_view_->SetStatusBubble(status_bubble_.get()); -+} -+ - gfx::Rect BrowserView::GetFindBarBoundingBox() const { - gfx::Rect contents_bounds = contents_container_->ConvertRectToWidget( - contents_container_->GetLocalBounds()); -@@ -3397,6 +3401,11 @@ ui::ImageModel BrowserView::GetWindowIcon() { - } - - bool BrowserView::ExecuteWindowsCommand(int command_id) { -+ // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. -+#if BUILDFLAG(IS_WIN) -+ if (command_id == IDC_DEBUG_FRAME_TOGGLE) -+ GetWidget()->DebugToggleFrameType(); -+#endif - // Translate WM_APPCOMMAND command ids into a command id that the browser - // knows how to handle. - int command_id_from_app_command = GetCommandIDForAppCommandID(command_id); -diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h -index d80a6df7380e5aec6ecba092315c905a09d7e2cc..bde91001c6f75f9918b9063eb0eaff5d56ea06c1 100644 ---- a/chrome/browser/ui/views/frame/browser_view.h -+++ b/chrome/browser/ui/views/frame/browser_view.h -@@ -164,6 +164,12 @@ class BrowserView : public BrowserWindow, - - void SetDownloadShelfForTest(DownloadShelf* download_shelf); - -+ // Initializes (or re-initializes) the status bubble. We try to only create -+ // the bubble once and re-use it for the life of the browser, but certain -+ // events (such as changing enabling/disabling Aero on Win) can force a need -+ // to change some of the bubble's creation parameters. -+ void InitStatusBubble(); -+ - // Returns the constraining bounding box that should be used to lay out the - // FindBar within. This is _not_ the size of the find bar, just the bounding - // box it should be laid out within. The coordinate system of the returned -diff --git a/chrome/browser/ui/views/frame/system_menu_model_builder.cc b/chrome/browser/ui/views/frame/system_menu_model_builder.cc -index 984929bb899dbd791443bf3ccd841f5a975a7dbd..75719ef6280ce46c176cb3277e602a11d99a45e0 100644 ---- a/chrome/browser/ui/views/frame/system_menu_model_builder.cc -+++ b/chrome/browser/ui/views/frame/system_menu_model_builder.cc -@@ -69,6 +69,7 @@ void SystemMenuModelBuilder::BuildMenu(ui::SimpleMenuModel* model) { - BuildSystemMenuForBrowserWindow(model); - else - BuildSystemMenuForAppOrPopupWindow(model); -+ AddFrameToggleItems(model); - } - - void SystemMenuModelBuilder::BuildSystemMenuForBrowserWindow( -@@ -157,6 +158,14 @@ void SystemMenuModelBuilder::BuildSystemMenuForAppOrPopupWindow( - AppendTeleportMenu(model); - } - -+void SystemMenuModelBuilder::AddFrameToggleItems(ui::SimpleMenuModel* model) { -+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( -+ switches::kDebugEnableFrameToggle)) { -+ model->AddSeparator(ui::NORMAL_SEPARATOR); -+ model->AddItem(IDC_DEBUG_FRAME_TOGGLE, u""Toggle Frame Type""); -+ } -+} -+ - #if BUILDFLAG(IS_CHROMEOS) - void SystemMenuModelBuilder::AppendMoveToDesksMenu(ui::SimpleMenuModel* model) { - gfx::NativeWindow window = -diff --git a/chrome/browser/ui/views/frame/system_menu_model_builder.h b/chrome/browser/ui/views/frame/system_menu_model_builder.h -index 8f69eab1fc2b9c81d14f7b547b4f434c722b98aa..8acaa2816a03f41b19ec364eea2658682737798c 100644 ---- a/chrome/browser/ui/views/frame/system_menu_model_builder.h -+++ b/chrome/browser/ui/views/frame/system_menu_model_builder.h -@@ -47,6 +47,9 @@ class SystemMenuModelBuilder { - void BuildSystemMenuForBrowserWindow(ui::SimpleMenuModel* model); - void BuildSystemMenuForAppOrPopupWindow(ui::SimpleMenuModel* model); - -+ // Adds items for toggling the frame type (if necessary). -+ void AddFrameToggleItems(ui::SimpleMenuModel* model); -+ - #if BUILDFLAG(IS_CHROMEOS) - // Add the submenu for move to desks. - void AppendMoveToDesksMenu(ui::SimpleMenuModel* model); -diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc -index b23fbffea35f1f9936b998bbe501c9e5acdecf6a..4d635764d6c5db0b493aba9d3b2add095fc9ebe4 100644 ---- a/chrome/common/chrome_switches.cc -+++ b/chrome/common/chrome_switches.cc -@@ -143,6 +143,10 @@ const char kCredits[] = ""credits""; - // devtools://devtools/bundled/ - const char kCustomDevtoolsFrontend[] = ""custom-devtools-frontend""; - -+// Enables a frame context menu item that toggles the frame in and out of glass -+// mode (Windows Vista and up only). -+const char kDebugEnableFrameToggle[] = ""debug-enable-frame-toggle""; -+ - // Adds debugging entries such as Inspect Element to context menus of packed - // apps. - const char kDebugPackedApps[] = ""debug-packed-apps""; -diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h -index be1f7824d85a6705aa8c220578ac62f0d1a4114e..7ce3dd85d1cab1fbd5aff6104ea0d1b864ebcb0c 100644 ---- a/chrome/common/chrome_switches.h -+++ b/chrome/common/chrome_switches.h -@@ -61,6 +61,7 @@ extern const char kCrashOnHangThreads[]; - extern const char kCreateBrowserOnStartupForTests[]; - extern const char kCredits[]; - extern const char kCustomDevtoolsFrontend[]; -+extern const char kDebugEnableFrameToggle[]; - extern const char kDebugPackedApps[]; - extern const char kDevToolsFlags[]; - extern const char kDiagnostics[]; -diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc -index d0dc2b4993891837c6ac76e095833126db461032..ba1bcbc63475b7151e2335c9237124ca8ca31dc7 100644 ---- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc -+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc -@@ -136,6 +136,30 @@ TEST_F(DesktopNativeWidgetAuraTest, WidgetNotVisibleOnlyWindowTreeHostShown) { - } - #endif - -+TEST_F(DesktopNativeWidgetAuraTest, DesktopAuraWindowShowFrameless) { -+ Widget widget; -+ Widget::InitParams init_params = -+ CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); -+ init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; -+ widget.Init(std::move(init_params)); -+ -+ // Make sure that changing frame type doesn't crash when there's no non-client -+ // view. -+ ASSERT_EQ(nullptr, widget.non_client_view()); -+ widget.DebugToggleFrameType(); -+ widget.Show(); -+ -+#if BUILDFLAG(IS_WIN) -+ // On Windows also make sure that handling WM_SYSCOMMAND doesn't crash with -+ // custom frame. Frame type needs to be toggled again if Aero Glass is -+ // disabled. -+ if (widget.ShouldUseNativeFrame()) -+ widget.DebugToggleFrameType(); -+ SendMessage(widget.GetNativeWindow()->GetHost()->GetAcceleratedWidget(), -+ WM_SYSCOMMAND, SC_RESTORE, 0); -+#endif // BUILDFLAG(IS_WIN) -+} -+ - #if BUILDFLAG(IS_CHROMEOS_ASH) - // TODO(crbug.com/916272): investigate fixing and enabling on Chrome OS. - #define MAYBE_GlobalCursorState DISABLED_GlobalCursorState -diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc -index 73e76c0d940f09336bbec6db47f1afee5153ced0..61673ac08ca19816dc01c89b6687f5b2a7c289e2 100644 ---- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc -+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc -@@ -1028,6 +1028,8 @@ void DesktopWindowTreeHostWin::HandleClientSizeChanged( - } - - void DesktopWindowTreeHostWin::HandleFrameChanged() { -+ CheckForMonitorChange(); -+ desktop_native_widget_aura_->UpdateWindowTransparency(); - // Replace the frame and layout the contents. - if (GetWidget()->non_client_view()) - GetWidget()->non_client_view()->UpdateFrame(); -diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc -index 2b52ad2f63bd6924fcd3d000bbb7ed6fd9f4b0dd..3d7a2f986c38de6b2e69722e63ee3b139d257756 100644 ---- a/ui/views/widget/widget.cc -+++ b/ui/views/widget/widget.cc -@@ -1209,6 +1209,21 @@ bool Widget::ShouldWindowContentsBeTransparent() const { - : false; - } - -+void Widget::DebugToggleFrameType() { -+ if (!native_widget_) -+ return; -+ -+ if (frame_type_ == FrameType::kDefault) { -+ frame_type_ = ShouldUseNativeFrame() ? FrameType::kForceCustom -+ : FrameType::kForceNative; -+ } else { -+ frame_type_ = frame_type_ == FrameType::kForceCustom -+ ? FrameType::kForceNative -+ : FrameType::kForceCustom; -+ } -+ FrameTypeChanged(); -+} -+ - void Widget::FrameTypeChanged() { - if (native_widget_) - native_widget_->FrameTypeChanged(); -diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h -index 51017b6f5dd9a9d5f26723c7ec7a6e0404c93b65..54b9e676c9423b78184fc63b80299dd7529cbd28 100644 ---- a/ui/views/widget/widget.h -+++ b/ui/views/widget/widget.h -@@ -922,6 +922,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, - // (for example, so that they can overhang onto the window title bar). - bool ShouldWindowContentsBeTransparent() const; - -+ // Forces the frame into the alternate frame type (custom or native) depending -+ // on its current state. -+ void DebugToggleFrameType(); -+ - // Tell the window that something caused the frame type to change. - void FrameTypeChanged(); - -diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc -index 9aced70287c3ac877310457c1aad3b2544a85800..35f435d3d4d5eda44b69e5e66ec9480534d3ef44 100644 ---- a/ui/views/widget/widget_unittest.cc -+++ b/ui/views/widget/widget_unittest.cc -@@ -1317,6 +1317,10 @@ TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, Deactivate) { - widget()->Deactivate(); - } - -+TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, DebugToggleFrameType) { -+ widget()->DebugToggleFrameType(); -+} -+ - TEST_P(WidgetWithDestroyedNativeViewOrNativeWidgetTest, DraggedView) { - widget()->dragged_view(); - } -diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 575877b4fb0929d0cdd22af399f7078fcd713584..90dd6487fdf438a61672a81f08b545742045944a 100644 ---- a/ui/views/win/hwnd_message_handler.cc -+++ b/ui/views/win/hwnd_message_handler.cc -@@ -1741,6 +1741,20 @@ void HWNDMessageHandler::ResetWindowRegion(bool force, bool redraw) { - } - } - -+void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() { -+ if (IsFullscreen()) -+ return; -+ -+ DWMNCRENDERINGPOLICY policy = -+ custom_window_region_.is_valid() || -+ delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN -+ ? DWMNCRP_DISABLED -+ : DWMNCRP_ENABLED; -+ -+ DwmSetWindowAttribute(hwnd(), DWMWA_NCRENDERING_POLICY, &policy, -+ sizeof(DWMNCRENDERINGPOLICY)); -+} -+ - LRESULT HWNDMessageHandler::DefWindowProcWithRedrawLock(UINT message, - WPARAM w_param, - LPARAM l_param) { -@@ -3607,10 +3621,34 @@ bool HWNDMessageHandler::IsSynthesizedMouseMessage(unsigned int message, - } - - void HWNDMessageHandler::PerformDwmTransition() { -- CHECK(IsFrameSystemDrawn()); -- - dwm_transition_desired_ = false; -+ -+ UpdateDwmNcRenderingPolicy(); -+ // Don't redraw the window here, because we need to hide and show the window -+ // which will also trigger a redraw. -+ ResetWindowRegion(true, false); -+ // The non-client view needs to update too. - delegate_->HandleFrameChanged(); -+ // This calls DwmExtendFrameIntoClientArea which must be called when DWM -+ // composition state changes. -+ UpdateDwmFrame(); -+ -+ if (IsVisible() && IsFrameSystemDrawn()) { -+ // For some reason, we need to hide the window after we change from a custom -+ // frame to a native frame. If we don't, the client area will be filled -+ // with black. This seems to be related to an interaction between DWM and -+ // SetWindowRgn, but the details aren't clear. Additionally, we need to -+ // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows -+ // open they will re-appear with a non-deterministic Z-order. -+ // Note: caused http://crbug.com/895855, where a laptop lid close+reopen -+ // puts window in the background but acts like a foreground window. Fixed by -+ // not calling this unless DWM composition actually changes. Finally, since -+ // we don't want windows stealing focus if they're not already active, we -+ // set SWP_NOACTIVATE. -+ UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE; -+ SetWindowPos(hwnd(), nullptr, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); -+ SetWindowPos(hwnd(), nullptr, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); -+ } - } - - void HWNDMessageHandler::UpdateDwmFrame() { -diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h -index 7238af3f51179145a1c1eb9639ca756c2a697554..694945c4f3a62ed13a3b80cc5fba5673e29eef4e 100644 ---- a/ui/views/win/hwnd_message_handler.h -+++ b/ui/views/win/hwnd_message_handler.h -@@ -324,6 +324,11 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl, - // frame windows. - void ResetWindowRegion(bool force, bool redraw); - -+ // Enables or disables rendering of the non-client (glass) area by DWM, -+ // under Vista and above, depending on whether the caller has requested a -+ // custom frame. -+ void UpdateDwmNcRenderingPolicy(); -+ - // Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to - // prevent frame flicker. DefWindowProc handling can otherwise render the - // classic-look window title bar directly. diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index d33973ae9c..1c6a6b0bc7 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -316,47 +316,65 @@ bool NativeWindow::IsNormal() { void NativeWindow::SetSizeConstraints( const extensions::SizeConstraints& window_constraints) { - extensions::SizeConstraints content_constraints(GetContentSizeConstraints()); - if (window_constraints.HasMaximumSize()) { - gfx::Rect max_bounds = WindowBoundsToContentBounds( - gfx::Rect(window_constraints.GetMaximumSize())); - content_constraints.set_maximum_size(max_bounds.size()); - } - if (window_constraints.HasMinimumSize()) { - gfx::Rect min_bounds = WindowBoundsToContentBounds( - gfx::Rect(window_constraints.GetMinimumSize())); - content_constraints.set_minimum_size(min_bounds.size()); - } - SetContentSizeConstraints(content_constraints); + size_constraints_ = window_constraints; + content_size_constraints_.reset(); } extensions::SizeConstraints NativeWindow::GetSizeConstraints() const { - extensions::SizeConstraints content_constraints = GetContentSizeConstraints(); - extensions::SizeConstraints window_constraints; - if (content_constraints.HasMaximumSize()) { + if (size_constraints_) + return *size_constraints_; + if (!content_size_constraints_) + return extensions::SizeConstraints(); + // Convert content size constraints to window size constraints. + extensions::SizeConstraints constraints; + if (content_size_constraints_->HasMaximumSize()) { gfx::Rect max_bounds = ContentBoundsToWindowBounds( - gfx::Rect(content_constraints.GetMaximumSize())); - window_constraints.set_maximum_size(max_bounds.size()); + gfx::Rect(content_size_constraints_->GetMaximumSize())); + constraints.set_maximum_size(max_bounds.size()); } - if (content_constraints.HasMinimumSize()) { + if (content_size_constraints_->HasMinimumSize()) { gfx::Rect min_bounds = ContentBoundsToWindowBounds( - gfx::Rect(content_constraints.GetMinimumSize())); - window_constraints.set_minimum_size(min_bounds.size()); + gfx::Rect(content_size_constraints_->GetMinimumSize())); + constraints.set_minimum_size(min_bounds.size()); } - return window_constraints; + return constraints; } void NativeWindow::SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) { - size_constraints_ = size_constraints; + content_size_constraints_ = size_constraints; + size_constraints_.reset(); } +// The return value of GetContentSizeConstraints will be passed to Chromium +// to set min/max sizes of window. Note that we are returning content size +// instead of window size because that is what Chromium expects, see the +// comment of |WidgetSizeIsClientSize| in Chromium's codebase to learn more. extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const { - return size_constraints_; + if (content_size_constraints_) + return *content_size_constraints_; + if (!size_constraints_) + return extensions::SizeConstraints(); + // Convert window size constraints to content size constraints. + // Note that we are not caching the results, because Chromium reccalculates + // window frame size everytime when min/max sizes are passed, and we must + // do the same otherwise the resulting size with frame included will be wrong. + extensions::SizeConstraints constraints; + if (size_constraints_->HasMaximumSize()) { + gfx::Rect max_bounds = WindowBoundsToContentBounds( + gfx::Rect(size_constraints_->GetMaximumSize())); + constraints.set_maximum_size(max_bounds.size()); + } + if (size_constraints_->HasMinimumSize()) { + gfx::Rect min_bounds = WindowBoundsToContentBounds( + gfx::Rect(size_constraints_->GetMinimumSize())); + constraints.set_minimum_size(min_bounds.size()); + } + return constraints; } void NativeWindow::SetMinimumSize(const gfx::Size& size) { - extensions::SizeConstraints size_constraints; + extensions::SizeConstraints size_constraints = GetSizeConstraints(); size_constraints.set_minimum_size(size); SetSizeConstraints(size_constraints); } @@ -366,7 +384,7 @@ gfx::Size NativeWindow::GetMinimumSize() const { } void NativeWindow::SetMaximumSize(const gfx::Size& size) { - extensions::SizeConstraints size_constraints; + extensions::SizeConstraints size_constraints = GetSizeConstraints(); size_constraints.set_maximum_size(size); SetSizeConstraints(size_constraints); } diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index 2394be0016..fcdf419d7e 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -423,6 +423,13 @@ class NativeWindow : public base::SupportsUserData, // The ""titleBarStyle"" option. TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal; + // Minimum and maximum size. + absl::optional size_constraints_; + // Same as above but stored as content size, we are storing 2 types of size + // constraints beacause converting between them will cause rounding errors + // on HiDPI displays on some environments. + absl::optional content_size_constraints_; + std::queue pending_transitions_; FullScreenTransitionState fullscreen_transition_state_ = FullScreenTransitionState::kNone; @@ -450,9 +457,6 @@ class NativeWindow : public base::SupportsUserData, // Whether window is transparent. bool transparent_ = false; - // Minimum and maximum size, stored as content size. - extensions::SizeConstraints size_constraints_; - // Whether window can be resized larger than screen. bool enable_larger_than_screen_ = false; diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index a1581d98d0..028b35c1ce 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -78,6 +78,7 @@ #include ""ui/display/screen.h"" #include ""ui/display/win/screen_win.h"" #include ""ui/gfx/color_utils.h"" +#include ""ui/gfx/win/msg_util.h"" #endif namespace electron { @@ -138,6 +139,25 @@ gfx::Rect DIPToScreenRect(HWND hwnd, const gfx::Rect& pixel_bounds) { return screen_rect; } +// Chromium uses a buggy implementation that converts content rect to window +// rect when calculating min/max size, we should use the same implementation +// when passing min/max size so we can get correct results. +gfx::Size WindowSizeToContentSizeBuggy(HWND hwnd, const gfx::Size& size) { + // Calculate the size of window frame, using same code with the + // HWNDMessageHandler::OnGetMinMaxInfo method. + // The pitfall is, when window is minimized the calculated window frame size + // will be different from other states. + RECT client_rect, rect; + GetClientRect(hwnd, &client_rect); + GetWindowRect(hwnd, &rect); + CR_DEFLATE_RECT(&rect, &client_rect); + // Convert DIP size to pixel size, do calculation and then return DIP size. + gfx::Rect screen_rect = DIPToScreenRect(hwnd, gfx::Rect(size)); + gfx::Size screen_client_size(screen_rect.width() - (rect.right - rect.left), + screen_rect.height() - (rect.bottom - rect.top)); + return ScreenToDIPRect(hwnd, gfx::Rect(screen_client_size)).size(); +} + #endif #if defined(USE_OZONE) @@ -812,6 +832,29 @@ void NativeWindowViews::SetContentSizeConstraints( old_size_constraints_ = size_constraints; } +#if BUILDFLAG(IS_WIN) +// This override does almost the same with its parent, except that it uses +// the WindowSizeToContentSizeBuggy method to convert window size to content +// size. See the comment of the method for the reason behind this. +extensions::SizeConstraints NativeWindowViews::GetContentSizeConstraints() + const { + if (content_size_constraints_) + return *content_size_constraints_; + if (!size_constraints_) + return extensions::SizeConstraints(); + extensions::SizeConstraints constraints; + if (size_constraints_->HasMaximumSize()) { + constraints.set_maximum_size(WindowSizeToContentSizeBuggy( + GetAcceleratedWidget(), size_constraints_->GetMaximumSize())); + } + if (size_constraints_->HasMinimumSize()) { + constraints.set_minimum_size(WindowSizeToContentSizeBuggy( + GetAcceleratedWidget(), size_constraints_->GetMinimumSize())); + } + return constraints; +} +#endif + void NativeWindowViews::SetResizable(bool resizable) { if (resizable != resizable_) { // On Linux there is no ""resizable"" property of a window, we have to set diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index 8a2bf583bd..e97d22ace0 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -78,6 +78,9 @@ class NativeWindowViews : public NativeWindow, SkColor GetBackgroundColor() override; void SetContentSizeConstraints( const extensions::SizeConstraints& size_constraints) override; +#if BUILDFLAG(IS_WIN) + extensions::SizeConstraints GetContentSizeConstraints() const override; +#endif void SetResizable(bool resizable) override; bool MoveAbove(const std::string& sourceId) override; void MoveTop() override;",fix ce138fe96954b23c76583b5c1af3abbff0b2f661,Raymond Zhao,2022-10-13 08:39:40,fix: Windows 7 frame showing for frameless non-resizable windows (#35365),"diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 5bea887422..77ac984a3a 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -115,7 +115,6 @@ chore_allow_chromium_to_handle_synthetic_mouse_events_for_touch.patch add_maximized_parameter_to_linuxui_getwindowframeprovider.patch revert_spellcheck_fully_launch_spell_check_delayed_initialization.patch add_electron_deps_to_license_credits_file.patch -feat_add_set_can_resize_mutator.patch fix_crash_loading_non-standard_schemes_in_iframes.patch disable_optimization_guide_for_preconnect_feature.patch fix_return_v8_value_from_localframe_requestexecutescript.patch @@ -123,3 +122,4 @@ create_browser_v8_snapshot_file_name_fuse.patch feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch cherry-pick-c83640db21b5.patch fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch +fix_remove_caption-removing_style_call.patch diff --git a/patches/chromium/feat_add_set_can_resize_mutator.patch b/patches/chromium/feat_add_set_can_resize_mutator.patch deleted file mode 100644 index b8f40ec800..0000000000 --- a/patches/chromium/feat_add_set_can_resize_mutator.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> -Date: Tue, 2 Aug 2022 09:30:36 -0700 -Subject: feat: Add set_can_resize mutator - -Adds a set_can_resize mutator to WidgetDelegate that -doesn't emit the OnSizeConstraintsChanged event. -This way, we can call set_can_resize from Electron before -the widget is initialized to set the value earlier, -and in turn, avoid showing a frame at startup -for frameless applications. - -diff --git a/ui/views/widget/widget_delegate.h b/ui/views/widget/widget_delegate.h -index 8e15368a19ec68a468ad9834dd6d08b5b30f98a8..9b73c9faf0fa25568d0a278b1e9a1933ba20224f 100644 ---- a/ui/views/widget/widget_delegate.h -+++ b/ui/views/widget/widget_delegate.h -@@ -323,6 +323,10 @@ class VIEWS_EXPORT WidgetDelegate { - // be cycled through with keyboard focus. - virtual void GetAccessiblePanes(std::vector* panes) {} - -+ // A setter for the can_resize parameter that doesn't -+ // emit any events. -+ void set_can_resize(bool can_resize) { params_.can_resize = can_resize; } -+ - // Setters for data parameters of the WidgetDelegate. If you use these - // setters, there is no need to override the corresponding virtual getters. - void SetAccessibleRole(ax::mojom::Role role); diff --git a/patches/chromium/fix_remove_caption-removing_style_call.patch b/patches/chromium/fix_remove_caption-removing_style_call.patch new file mode 100644 index 0000000000..b7923a81dd --- /dev/null +++ b/patches/chromium/fix_remove_caption-removing_style_call.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> +Date: Wed, 17 Aug 2022 13:49:40 -0700 +Subject: fix: Adjust caption-removing style call + +There is a SetWindowLong call that removes WS_CAPTION for frameless +windows, but Electron uses WS_CAPTION even for frameless windows, +unless they are transparent. + +Changing this call only affects frameless windows, and it fixes +a visual glitch where they showed a Windows 7 style frame +during startup. + +The if statement was originally introduced by +https://codereview.chromium.org/9372053/, and it was there to fix +a visual glitch with the close button showing up during startup +or resizing, but Electron does not seem to run into that issue +for opaque frameless windows even with that block commented out. + +diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc +index 400278ab26a4e095fd837fcf84c952a1297b173d..55afa69870f27b877826ea8a442ab20a8b336d74 100644 +--- a/ui/views/win/hwnd_message_handler.cc ++++ b/ui/views/win/hwnd_message_handler.cc +@@ -1731,7 +1731,23 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) { + SendMessage(hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), + 0); + +- if (!delegate_->HasFrame()) { ++ LONG is_popup = ++ GetWindowLong(hwnd(), GWL_STYLE) & static_cast(WS_POPUP); ++ ++ // For transparent windows, Electron removes the WS_CAPTION style, ++ // so we continue to remove it here. If we didn't, an opaque rectangle ++ // would show up. ++ // For non-transparent windows, Electron keeps the WS_CAPTION style, ++ // so we don't remove it in that case. If we did, a Windows 7 frame ++ // would show up. ++ // We also need this block for frameless popup windows. When the user opens ++ // a dropdown in an Electron app, the internal popup menu from ++ // third_party/blink/renderer/core/html/forms/internal_popup_menu.h ++ // is rendered. That menu is actually an HTML page inside of a frameless popup window. ++ // A new popup window is created every time the user opens the dropdown, ++ // and this code path is run. The code block below runs SendFrameChanged, ++ // which gives the dropdown options the proper layout. ++ if (!delegate_->HasFrame() && (is_translucent_ || is_popup)) { + SetWindowLong(hwnd(), GWL_STYLE, + GetWindowLong(hwnd(), GWL_STYLE) & ~WS_CAPTION); + SendFrameChanged(); diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 1b10f9446c..4e80fad3df 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -280,24 +280,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options, new ElectronDesktopWindowTreeHostLinux(this, native_widget); #endif - // Ref https://github.com/electron/electron/issues/30760 - // Set the can_resize param before initializing the widget. - // When resizable_ is true, this causes the WS_THICKFRAME style - // to be passed into CreateWindowEx and SetWindowLong calls in - // WindowImpl::Init and HwndMessageHandler::SizeConstraintsChanged - // respectively. As a result, the Windows 7 frame doesn't show, - // but it isn't clear why this is the case. - // When resizable_ is false, WS_THICKFRAME is not passed into the - // SetWindowLong call, so the Windows 7 frame still shows. - // One workaround would be to call set_can_resize(true) here, - // and then move the SetCanResize(resizable_) call after the - // SetWindowLong call around line 365, but that's a much larger change. - set_can_resize(true); widget()->Init(std::move(params)); - - // When the workaround above is not needed anymore, only this - // call should be necessary. - // With the workaround in place, this call doesn't do anything. SetCanResize(resizable_); bool fullscreen = false;",fix 08236f7a9e9d664513e2b76b54b9bea003101e5d,Charles Kerr,2024-02-05 18:12:34,"refactor: remove deprecated BrowserContext::ResourceContext (#41221) * refactor: remove ResourceContext* arg from GetNSSCertDatabaseForResourceContext() * refactor: remove ResourceContext* arg from CertificateManagerModel::GetCertDBOnIOThread() * refactor: remove BrowserContext* arg from CertificateManagerModel::Create() * refactor: remove unused forward declarations * refactor: rename method to GetNSSCertDatabase() * fixup! refactor: remove BrowserContext* arg from CertificateManagerModel::Create() chore: remove unneeded line","diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index 48c533d42f..8558fc74db 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -1228,13 +1228,10 @@ void App::ImportCertificate(gin_helper::ErrorThrower thrower, return; } - auto* browser_context = ElectronBrowserContext::From("""", false); if (!certificate_manager_model_) { - CertificateManagerModel::Create( - browser_context, - base::BindOnce(&App::OnCertificateManagerModelCreated, - base::Unretained(this), std::move(options), - std::move(callback))); + CertificateManagerModel::Create(base::BindOnce( + &App::OnCertificateManagerModelCreated, base::Unretained(this), + std::move(options), std::move(callback))); return; } diff --git a/shell/browser/certificate_manager_model.cc b/shell/browser/certificate_manager_model.cc index e2c09a5fef..170cbb1fcd 100644 --- a/shell/browser/certificate_manager_model.cc +++ b/shell/browser/certificate_manager_model.cc @@ -7,9 +7,7 @@ #include #include ""base/functional/bind.h"" -#include ""base/logging.h"" -#include ""base/strings/utf_string_conversions.h"" -#include ""content/public/browser/browser_context.h"" +#include ""base/memory/ptr_util.h"" #include ""content/public/browser/browser_task_traits.h"" #include ""content/public/browser/browser_thread.h"" #include ""content/public/browser/resource_context.h"" @@ -25,8 +23,7 @@ namespace { net::NSSCertDatabase* g_nss_cert_database = nullptr; -net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( - content::ResourceContext* context, +net::NSSCertDatabase* GetNSSCertDatabase( base::OnceCallback callback) { // This initialization is not thread safe. This CHECK ensures that this code // is only run on a single thread. @@ -57,7 +54,7 @@ net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( // \--------------------------------------v // CertificateManagerModel::GetCertDBOnIOThread // | -// GetNSSCertDatabaseForResourceContext +// GetNSSCertDatabase // | // CertificateManagerModel::DidGetCertDBOnIOThread // v--------------------------------------/ @@ -68,12 +65,10 @@ net::NSSCertDatabase* GetNSSCertDatabaseForResourceContext( // callback // static -void CertificateManagerModel::Create(content::BrowserContext* browser_context, - CreationCallback callback) { +void CertificateManagerModel::Create(CreationCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); content::GetIOThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce(&CertificateManagerModel::GetCertDBOnIOThread, - browser_context->GetResourceContext(), std::move(callback))); } @@ -151,16 +146,14 @@ void CertificateManagerModel::DidGetCertDBOnIOThread( } // static -void CertificateManagerModel::GetCertDBOnIOThread( - content::ResourceContext* context, - CreationCallback callback) { +void CertificateManagerModel::GetCertDBOnIOThread(CreationCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); auto split_callback = base::SplitOnceCallback(base::BindOnce( &CertificateManagerModel::DidGetCertDBOnIOThread, std::move(callback))); - net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext( - context, std::move(split_callback.first)); + net::NSSCertDatabase* cert_db = + GetNSSCertDatabase(std::move(split_callback.first)); // If the NSS database was already available, |cert_db| is non-null and // |did_get_cert_db_callback| has not been called. Call it explicitly. diff --git a/shell/browser/certificate_manager_model.h b/shell/browser/certificate_manager_model.h index 91f7f3c4dc..afb0eeb231 100644 --- a/shell/browser/certificate_manager_model.h +++ b/shell/browser/certificate_manager_model.h @@ -13,11 +13,6 @@ #include ""base/memory/ref_counted.h"" #include ""net/cert/nss_cert_database.h"" -namespace content { -class BrowserContext; -class ResourceContext; -} // namespace content - // CertificateManagerModel provides the data to be displayed in the certificate // manager dialog, and processes changes from the view. class CertificateManagerModel { @@ -26,10 +21,8 @@ class CertificateManagerModel { base::OnceCallback)>; // Creates a CertificateManagerModel. The model will be passed to the callback - // when it is ready. The caller must ensure the model does not outlive the - // |browser_context|. - static void Create(content::BrowserContext* browser_context, - CreationCallback callback); + // when it is ready. + static void Create(CreationCallback callback); // disable copy CertificateManagerModel(const CertificateManagerModel&) = delete; @@ -105,8 +98,7 @@ class CertificateManagerModel { CreationCallback callback); static void DidGetCertDBOnIOThread(CreationCallback callback, net::NSSCertDatabase* cert_db); - static void GetCertDBOnIOThread(content::ResourceContext* context, - CreationCallback callback); + static void GetCertDBOnIOThread(CreationCallback callback); raw_ptr cert_db_; // Whether the certificate database has a public slot associated with the",refactor 79147e4dd825aa26ea0242470c2bad47c3998fe3,Mikhail Leliakin,2024-02-14 21:12:41,"fix: Ignore `-webkit-app-region: drag;` when window is in full screen mode. (#41307) Co-authored-by: Mikhail Leliakin ","diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index e171ce303f..5d34093a84 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -757,6 +757,11 @@ int NativeWindow::NonClientHitTest(const gfx::Point& point) { } #endif + // This is to disable dragging in HTML5 full screen mode. + // Details: https://github.com/electron/electron/issues/41002 + if (GetWidget()->IsFullscreen()) + return HTNOWHERE; + for (auto* provider : draggable_region_providers_) { int hit = provider->NonClientHitTest(point); if (hit != HTNOWHERE)",fix c9349a2590ab777d558d7305cc6550d52f1f191d,Keeley Hammond,2024-06-05 23:06:25,"build: [GHA] cross-compile x64 MacOS jobs on arm64 (#42370) * build: split x64 mas/darwin to run concurrently * Retry src cache download on failure * build: gate FFMpeg, etc, to release & darwin * build: cross-compile x64 on arm hardware * chore (do not merge): comment out CircleCI config * build: fix FFMpeg conditional but harder * build: add fetch-deps to checkout * build: correctly add target_arch to MAS configs * build: correct target arch * build: consolidate darwin/mas back into single runner per arch * build: re-enable CircleCI * Add missing ELECTRON_OUT_DIR for upload * Add missing ELECTRON_GITHUB_TOKEN to secrets * build: (do not merge) run only darwin * build: remove seperate upload step * build: re-enable mas, remove upload seperate job --------- Co-authored-by: Shelley Vohr ","diff --git a/.github/workflows/config/release/arm64/evm.mas.json b/.github/workflows/config/release/arm64/evm.mas.json new file mode 100644 index 0000000000..d6af529f31 --- /dev/null +++ b/.github/workflows/config/release/arm64/evm.mas.json @@ -0,0 +1,26 @@ +{ + ""root"": ""/Users/runner/work/electron/electron/"", + ""remotes"": { + ""electron"": { + ""origin"": ""https://github.com/electron/electron.git"" + } + }, + ""gen"": { + ""args"": [ + ""import(\""//electron/build/args/release.gn\"")"", + ""use_remoteexec = true"", + ""target_cpu = \""arm64\"""", + ""is_mas_build = true"" + ], + ""out"": ""Default"" + }, + ""env"": { + ""CHROMIUM_BUILDTOOLS_PATH"": ""/Users/runner/work/electron/electron/src/buildtools"", + ""GIT_CACHE_PATH"": ""/Users/runner/work/electron/electron/.git-cache"" + }, + ""$schema"": ""file:///home/builduser/.electron_build_tools/evm-config.schema.json"", + ""configValidationLevel"": ""strict"", + ""reclient"": ""remote_exec"", + ""goma"": ""none"", + ""preserveXcode"": 5 +} diff --git a/.github/workflows/config/release/evm.mas.json b/.github/workflows/config/release/x64/evm.mas.json similarity index 95% rename from .github/workflows/config/release/evm.mas.json rename to .github/workflows/config/release/x64/evm.mas.json index 53cedbfe96..a2f4fc551e 100644 --- a/.github/workflows/config/release/evm.mas.json +++ b/.github/workflows/config/release/x64/evm.mas.json @@ -9,6 +9,7 @@ ""args"": [ ""import(\""//electron/build/args/release.gn\"")"", ""use_remoteexec = true"", + ""target_cpu = \""x64\"""", ""is_mas_build = true"" ], ""out"": ""Default"" diff --git a/.github/workflows/config/testing/evm.mas.json b/.github/workflows/config/testing/arm64/evm.mas.json similarity index 100% rename from .github/workflows/config/testing/evm.mas.json rename to .github/workflows/config/testing/arm64/evm.mas.json diff --git a/.github/workflows/config/testing/x64/evm.mas.json b/.github/workflows/config/testing/x64/evm.mas.json new file mode 100644 index 0000000000..4d2ae3b327 --- /dev/null +++ b/.github/workflows/config/testing/x64/evm.mas.json @@ -0,0 +1,25 @@ +{ + ""root"": ""/Users/runner/work/electron/electron/"", + ""remotes"": { + ""electron"": { + ""origin"": ""https://github.com/electron/electron.git"" + } + }, + ""gen"": { + ""args"": [ + ""import(\""//electron/build/args/testing.gn\"")"", + ""use_remoteexec = true"", + ""is_mas_build = true"" + ], + ""out"": ""Default"" + }, + ""env"": { + ""CHROMIUM_BUILDTOOLS_PATH"": ""/Users/runner/work/electron/electron/src/buildtools"", + ""GIT_CACHE_PATH"": ""/Users/runner/work/electron/electron/.git-cache"" + }, + ""$schema"": ""file:///home/builduser/.electron_build_tools/evm-config.schema.json"", + ""configValidationLevel"": ""strict"", + ""reclient"": ""remote_exec"", + ""goma"": ""none"", + ""preserveXcode"": 5 +} diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index 23f649c2c1..65dbcb5f94 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -25,7 +25,6 @@ on: required: false type: string default: '0' - concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -36,12 +35,14 @@ env: AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} AZURE_STORAGE_CONTAINER_NAME: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }} ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }} + ELECTRON_GITHUB_TOKEN: ${{ secrets.ELECTRON_GITHUB_TOKEN }} GN_CONFIG: ${{ inputs.GN_CONFIG }} # Disable pre-compiled headers to reduce out size - only useful for rebuilds GN_BUILDFLAG_ARGS: 'enable_precompiled_headers = false' GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac' CHECK_DIST_MANIFEST: '1' IS_GHA_RELEASE: true + ELECTRON_OUT_DIR: Default jobs: checkout: @@ -51,6 +52,7 @@ jobs: uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 with: path: src/electron + fetch-depth: 0 - name: Install Azure CLI run: sudo bash ./src/electron/script/azure_cli_deb_install.sh - name: Set GIT_CACHE_PATH to make gclient to use the cache @@ -190,23 +192,24 @@ jobs: build: strategy: fail-fast: false - # macos-large is x64, macos-xlarge is arm64 - # More runner information: https://github.com/actions/runner-images/blob/main/README.md#available-images matrix: - arch: [ macos-14-large, macos-14-xlarge ] - runs-on: ${{ matrix.arch }} + build-arch: [ arm64, x64 ] + # macos-large is x64, macos-xlarge is arm64 + # More runner information: https://github.com/actions/runner-images/blob/main/README.md#available-images + runs-on: macos-14-xlarge needs: checkout steps: - name: Load Build Tools run: | export BUILD_TOOLS_SHA=2bb63e2e7877491b52f972532b52adc979a6ec2f npm i -g @electron/build-tools - e init --root=$(pwd) --out=Default ${{ inputs.GN_BUILD_TYPE }} --import ${{ inputs.GN_BUILD_TYPE }} + e init --root=$(pwd) --out=Default ${{ inputs.GN_BUILD_TYPE }} --import ${{ inputs.GN_BUILD_TYPE }} --target-cpu ${{ matrix.build-arch}} e use ${{ inputs.GN_BUILD_TYPE }} - name: Checkout Electron uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 with: path: src/electron + fetch-depth: 0 - name: Install Azure CLI run: | brew update && brew install azure-cli @@ -222,16 +225,9 @@ jobs: node script/yarn install - name: Load Target Arch & CPU run: | - ARCH=$(uname -m) - if [ ""$ARCH"" == ""x86_64"" ]; then - echo ""TARGET_ARCH=""x64"""" >> $GITHUB_ENV - echo ""target_cpu=""x64"""" >> $GITHUB_ENV - echo ""host_cpu=""x64"""" >> $GITHUB_ENV - else - echo ""TARGET_ARCH=""arm64"""" >> $GITHUB_ENV - echo ""target_cpu=""arm64"""" >> $GITHUB_ENV - echo ""host_cpu=""arm64"""" >> $GITHUB_ENV - fi + echo ""TARGET_ARCH=${{ matrix.build-arch }}"" >> $GITHUB_ENV + echo ""target_cpu=${{ matrix.build-arch }}"" >> $GITHUB_ENV + echo ""host_cpu=${{ matrix.build-arch }}"" >> $GITHUB_ENV - name: Get Depot Tools timeout-minutes: 5 run: | @@ -258,13 +254,18 @@ jobs: # The cache will always exist here as a result of the checkout job # Either it was uploaded to Azure in the checkout job for this commit # or it was uploaded in the checkout job for a previous commit. - run: | - az storage blob download \ - --account-name $AZURE_STORAGE_ACCOUNT \ - --account-key $AZURE_STORAGE_KEY \ - --container-name $AZURE_STORAGE_CONTAINER_NAME \ - --name $DEPSHASH \ - --file $DEPSHASH.tar \ + uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 + with: + timeout_minutes: 20 + max_attempts: 3 + retry_on: error + command: | + az storage blob download \ + --account-name $AZURE_STORAGE_ACCOUNT \ + --account-key $AZURE_STORAGE_KEY \ + --container-name $AZURE_STORAGE_CONTAINER_NAME \ + --name $DEPSHASH \ + --file $DEPSHASH.tar \ - name: Unzip and Ensure Src Cache run: | echo ""Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)"" @@ -508,21 +509,33 @@ jobs: electron/script/zip-symbols.py -b $BUILD_PATH fi - name: Generate FFMpeg - if: github.event.inputs.IS_RELEASE == 'true' + if: ${{ inputs.IS_RELEASE == true }} run: | cd src gn gen out/ffmpeg --args=""import(\""//electron/build/args/ffmpeg.gn\"") use_remoteexec=true $GN_EXTRA_ARGS"" autoninja -C out/ffmpeg electron:electron_ffmpeg_zip -j $NUMBER_OF_NINJA_PROCESSES - name: Generate Hunspell Dictionaries - if: github.event.inputs.IS_RELEASE == 'true' + if: ${{ inputs.IS_RELEASE == true }} run: | cd src autoninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES - name: Generate TypeScript Definitions - if: github.event.inputs.IS_RELEASE == 'true' + if: ${{ inputs.IS_RELEASE == true }} run: | cd src/electron node script/yarn create-typescript-definitions + # TODO(vertedinde): These uploads currently point to a different Azure bucket & GitHub Repo + - name: Publish Electron Dist + run: | + rm -rf src/out/Default/obj + cd src/electron + if [ ${{ inputs.UPLOAD_TO_STORAGE }} == ""1"" ]; then + echo 'Uploading Electron release distribution to Azure' + script/release/uploaders/upload.py --verbose --upload_to_storage + else + echo 'Uploading Electron release distribution to GitHub releases' + script/release/uploaders/upload.py --verbose + fi # The current generated_artifacts_<< artifact.key >> name was taken from CircleCI # to ensure we don't break anything, but we may be able to improve that. - name: Move all Generated Artifacts to Upload Folder @@ -554,7 +567,7 @@ jobs: key: ${{ runner.os }}-build-artifacts-darwin-${{ env.TARGET_ARCH }}-${{ github.sha }} - name: Create MAS Config run: | - mv src/electron/.github/workflows/config/${{ inputs.GN_BUILD_TYPE }}/evm.mas.json $HOME/.electron_build_tools/configs/evm.mas.json + mv src/electron/.github/workflows/config/${{ inputs.GN_BUILD_TYPE }}/${{ matrix.build-arch }}/evm.mas.json $HOME/.electron_build_tools/configs/evm.mas.json echo ""MAS_BUILD=true"" >> $GITHUB_ENV e use mas - name: Build Electron (mas) @@ -615,6 +628,18 @@ jobs: else electron/script/zip-symbols.py -b $BUILD_PATH fi + # TODO(vertedinde): These uploads currently point to a different Azure bucket & GitHub Repo + - name: Publish Electron Dist + run: | + rm -rf src/out/Default/obj + cd src/electron + if [ ${{ inputs.UPLOAD_TO_STORAGE }} == ""1"" ]; then + echo 'Uploading Electron release distribution to Azure' + script/release/uploaders/upload.py --verbose --upload_to_storage + else + echo 'Uploading Electron release distribution to GitHub releases' + script/release/uploaders/upload.py --verbose + fi - name: Move all Generated Artifacts to Upload Folder (mas) run: ./src/electron/script/actions/move-artifacts.sh - name: Upload Generated Artifacts @@ -644,73 +669,6 @@ jobs: src/out/Default/obj/buildtools/third_party src/v8/tools/builtins-pgo key: ${{ runner.os }}-build-artifacts-mas-${{ env.TARGET_ARCH }}-${{ github.sha }} - upload: - runs-on: LargeLinuxRunner - if: ${{ inputs.IS_RELEASE == true }} - needs: build - strategy: - fail-fast: false - matrix: - build-type: [darwin, mas] - arch: [x64, arm64] - steps: - - name: Checkout Electron - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - with: - path: src/electron - - name: Setup Node.js/npm - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 - with: - node-version: 20.11.x - cache: yarn - cache-dependency-path: src/electron/yarn.lock - - name: Load Target Arch - run: echo ""TARGET_ARCH=${{ matrix.arch }}"" >> $GITHUB_ENV - - name: Install Dependencies - run: | - cd src/electron - node script/yarn install - - name: Download Generated Artifacts - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e - with: - name: generated_artifacts_${{ matrix.build-type }}_${{ matrix.arch }} - path: ./generated_artifacts_${{ matrix.build-type }}_${{ matrix.arch }} - - name: Restore Persisted Build Artifacts - uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 - with: - path: | - src/out/Default/gen/node_headers - src/out/Default/overlapped-checker - src/out/Default/ffmpeg - src/out/Default/hunspell_dictionaries - src/electron - src/third_party/electron_node - src/third_party/nan - src/cross-arch-snapshots - src/third_party/llvm-build - src/build/linux - src/buildtools/mac - src/buildtools/third_party/libc++ - src/buildtools/third_party/libc++abi - src/third_party/libc++ - src/third_party/libc++abi - src/out/Default/obj/buildtools/third_party - src/v8/tools/builtins-pgo - key: macOS-build-artifacts-${{ matrix.build-type }}-${{ matrix.arch }}-${{ github.sha }} - - name: Restore Generated Artifacts - run: ./src/electron/script/actions/restore-artifacts.sh - # TODO(vertedinde): These uploads currently point to a different Azure bucket & GitHub Repo - - name: Publish Electron Dist - run: | - rm -rf src/out/Default/obj - cd src/electron - if [ ${{ inputs.UPLOAD_TO_STORAGE }} == ""1"" ]; then - echo 'Uploading Electron release distribution to Azure' - script/release/uploaders/upload.py --verbose --upload_to_storage - else - echo 'Uploading Electron release distribution to GitHub releases' - script/release/uploaders/upload.py --verbose - fi test: if: ${{ inputs.IS_RELEASE == false }} runs-on: macos-14-xlarge @@ -718,7 +676,7 @@ jobs: strategy: fail-fast: false matrix: - build-type: [darwin, mas] + build-type: [ darwin, mas ] env: BUILD_TYPE: ${{ matrix.build-type }} steps: @@ -731,6 +689,7 @@ jobs: uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 with: path: src/electron + fetch-depth: 0 - name: Setup Node.js/npm uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 with:",build 2324c4d8fd6f7b2cd336d4e93591464544e12953,David Sanders,2023-09-11 00:33:39,ci: ignore blocked label removed on closed issues (#39793),"diff --git a/.github/workflows/issue-unlabeled.yml b/.github/workflows/issue-unlabeled.yml index b472eea222..1b87d6b00a 100644 --- a/.github/workflows/issue-unlabeled.yml +++ b/.github/workflows/issue-unlabeled.yml @@ -10,7 +10,7 @@ permissions: jobs: issue-unlabeled-blocked: name: All blocked/* labels removed - if: startsWith(github.event.label.name, 'blocked/') + if: startsWith(github.event.label.name, 'blocked/') && github.event.issue.state == 'open' runs-on: ubuntu-latest steps: - name: Check for any blocked labels",ci 83a928f6e3fa3567462dd90eeb50666af0dd4dff,Milan Burda,2023-10-06 01:57:14,fix: crashed events deprecation (#40090),"diff --git a/lib/browser/api/app.ts b/lib/browser/api/app.ts index c0d34fcfc9..5d7ce57880 100644 --- a/lib/browser/api/app.ts +++ b/lib/browser/api/app.ts @@ -114,5 +114,11 @@ for (const name of events) { } // Deprecation. -deprecate.event(app, 'gpu-process-crashed', 'child-process-gone'); -deprecate.event(app, 'renderer-process-crashed', 'render-process-gone'); +deprecate.event(app, 'gpu-process-crashed', 'child-process-gone', () => { + // the old event is still emitted by App::OnGpuProcessCrashed() + return undefined; +}); + +deprecate.event(app, 'renderer-process-crashed', 'render-process-gone', (event: Electron.Event, webContents: Electron.WebContents, details: Electron.RenderProcessGoneDetails) => { + return [event, webContents, details.reason === 'killed']; +}); diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index b48624ea59..7c876d5317 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -665,8 +665,8 @@ WebContents.prototype._init = function () { ipcMain.emit(channel, event, message); }); - this.on('crashed', (event, ...args) => { - app.emit('renderer-process-crashed', event, this, ...args); + deprecate.event(this, 'crashed', 'render-process-gone', (event: Electron.Event, details: Electron.RenderProcessGoneDetails) => { + return [event, details.reason === 'killed']; }); this.on('render-process-gone', (event, details) => { diff --git a/lib/common/deprecate.ts b/lib/common/deprecate.ts index c6435cc816..dc4e9d80ca 100644 --- a/lib/common/deprecate.ts +++ b/lib/common/deprecate.ts @@ -66,14 +66,17 @@ export function renameFunction (fn: T, newName: string): T { } // change the name of an event -export function event (emitter: NodeJS.EventEmitter, oldName: string, newName: string) { +export function event (emitter: NodeJS.EventEmitter, oldName: string, newName: string, transformer: (...args: any[]) => any[] | undefined = (...args) => args) { const warn = newName.startsWith('-') /* internal event */ ? warnOnce(`${oldName} event`) : warnOnce(`${oldName} event`, `${newName} event`); return emitter.on(newName, function (this: NodeJS.EventEmitter, ...args) { if (this.listenerCount(oldName) !== 0) { warn(); - this.emit(oldName, ...args); + const transformedArgs = transformer(...args); + if (transformedArgs) { + this.emit(oldName, ...transformedArgs); + } } }); } diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index d820fb8ba6..4bd23d5b7b 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1729,13 +1729,6 @@ void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) { void WebContents::PrimaryMainFrameRenderProcessGone( base::TerminationStatus status) { - auto weak_this = GetWeakPtr(); - Emit(""crashed"", status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); - - // User might destroy WebContents in the crashed event. - if (!weak_this || !web_contents()) - return; - v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope handle_scope(isolate); gin_helper::Dictionary details = gin_helper::Dictionary::CreateEmpty(isolate);",fix f2f83a73fc865c61151496096951d8af58889496,Milan Burda,2023-08-28 13:23:10,docs: use electron/main & electron/renderer imports in fiddles (#39666),"diff --git a/docs/fiddles/features/dark-mode/main.js b/docs/fiddles/features/dark-mode/main.js index f28419afd5..00a343c8ac 100644 --- a/docs/fiddles/features/dark-mode/main.js +++ b/docs/fiddles/features/dark-mode/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron') +const { app, BrowserWindow, ipcMain, nativeTheme } = require('electron/main') const path = require('node:path') function createWindow () { diff --git a/docs/fiddles/features/dark-mode/preload.js b/docs/fiddles/features/dark-mode/preload.js index 3def9e06ed..752d9d71a0 100644 --- a/docs/fiddles/features/dark-mode/preload.js +++ b/docs/fiddles/features/dark-mode/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('darkMode', { toggle: () => ipcRenderer.invoke('dark-mode:toggle'), diff --git a/docs/fiddles/features/drag-and-drop/main.js b/docs/fiddles/features/drag-and-drop/main.js index 9ee4431961..0cf045a7c9 100644 --- a/docs/fiddles/features/drag-and-drop/main.js +++ b/docs/fiddles/features/drag-and-drop/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain } = require('electron') +const { app, BrowserWindow, ipcMain } = require('electron/main') const path = require('node:path') const fs = require('node:fs') const https = require('node:https') diff --git a/docs/fiddles/features/drag-and-drop/preload.js b/docs/fiddles/features/drag-and-drop/preload.js index 7e698ebb54..3c02ab61c1 100644 --- a/docs/fiddles/features/drag-and-drop/preload.js +++ b/docs/fiddles/features/drag-and-drop/preload.js @@ -1,7 +1,5 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('electron', { - startDrag: (fileName) => { - ipcRenderer.send('ondragstart', fileName) - } + startDrag: (fileName) => ipcRenderer.send('ondragstart', fileName) }) diff --git a/docs/fiddles/features/keyboard-shortcuts/global/main.js b/docs/fiddles/features/keyboard-shortcuts/global/main.js index 8b43433a4a..991c70d25f 100644 --- a/docs/fiddles/features/keyboard-shortcuts/global/main.js +++ b/docs/fiddles/features/keyboard-shortcuts/global/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, globalShortcut } = require('electron') +const { app, BrowserWindow, globalShortcut } = require('electron/main') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/fiddles/features/keyboard-shortcuts/interception-from-main/main.js b/docs/fiddles/features/keyboard-shortcuts/interception-from-main/main.js index 80e4012c81..62df976ea7 100644 --- a/docs/fiddles/features/keyboard-shortcuts/interception-from-main/main.js +++ b/docs/fiddles/features/keyboard-shortcuts/interception-from-main/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') app.whenReady().then(() => { const win = new BrowserWindow({ width: 800, height: 600 }) diff --git a/docs/fiddles/features/keyboard-shortcuts/local/main.js b/docs/fiddles/features/keyboard-shortcuts/local/main.js index 6abd81b1be..6393f27a22 100644 --- a/docs/fiddles/features/keyboard-shortcuts/local/main.js +++ b/docs/fiddles/features/keyboard-shortcuts/local/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, Menu, MenuItem } = require('electron') +const { app, BrowserWindow, Menu, MenuItem } = require('electron/main') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/fiddles/features/keyboard-shortcuts/web-apis/main.js b/docs/fiddles/features/keyboard-shortcuts/web-apis/main.js index 7803cd859d..cf335b4a84 100644 --- a/docs/fiddles/features/keyboard-shortcuts/web-apis/main.js +++ b/docs/fiddles/features/keyboard-shortcuts/web-apis/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') function createWindow () { // Create the browser window. diff --git a/docs/fiddles/features/macos-dock-menu/main.js b/docs/fiddles/features/macos-dock-menu/main.js index 7809e5459c..5b8b154fe4 100644 --- a/docs/fiddles/features/macos-dock-menu/main.js +++ b/docs/fiddles/features/macos-dock-menu/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, Menu } = require('electron') +const { app, BrowserWindow, Menu } = require('electron/main') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/fiddles/features/notifications/main/main.js b/docs/fiddles/features/notifications/main/main.js index f6e6f867cc..b092c9a6ef 100644 --- a/docs/fiddles/features/notifications/main/main.js +++ b/docs/fiddles/features/notifications/main/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, Notification } = require('electron') +const { app, BrowserWindow, Notification } = require('electron/main') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/fiddles/features/notifications/renderer/main.js b/docs/fiddles/features/notifications/renderer/main.js index e24a66dd52..9f26d370c6 100644 --- a/docs/fiddles/features/notifications/renderer/main.js +++ b/docs/fiddles/features/notifications/renderer/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') function createWindow () { const win = new BrowserWindow({ diff --git a/docs/fiddles/features/offscreen-rendering/main.js b/docs/fiddles/features/offscreen-rendering/main.js index daf4306b8c..6c64afb10f 100644 --- a/docs/fiddles/features/offscreen-rendering/main.js +++ b/docs/fiddles/features/offscreen-rendering/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const fs = require('node:fs') const path = require('node:path') diff --git a/docs/fiddles/features/online-detection/main.js b/docs/fiddles/features/online-detection/main.js index 7bc42d7725..4e9a092cb1 100644 --- a/docs/fiddles/features/online-detection/main.js +++ b/docs/fiddles/features/online-detection/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') function createWindow () { const onlineStatusWindow = new BrowserWindow({ diff --git a/docs/fiddles/features/progress-bar/main.js b/docs/fiddles/features/progress-bar/main.js index c400638359..4bcc1f5536 100644 --- a/docs/fiddles/features/progress-bar/main.js +++ b/docs/fiddles/features/progress-bar/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') let progressInterval diff --git a/docs/fiddles/features/recent-documents/main.js b/docs/fiddles/features/recent-documents/main.js index 628f01f0e0..c4a399a78c 100644 --- a/docs/fiddles/features/recent-documents/main.js +++ b/docs/fiddles/features/recent-documents/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const fs = require('node:fs') const path = require('node:path') diff --git a/docs/fiddles/features/represented-file/main.js b/docs/fiddles/features/represented-file/main.js index 9b107a09db..183b3fc3d1 100644 --- a/docs/fiddles/features/represented-file/main.js +++ b/docs/fiddles/features/represented-file/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const os = require('node:os') function createWindow () { diff --git a/docs/fiddles/features/web-bluetooth/main.js b/docs/fiddles/features/web-bluetooth/main.js index 0821de287e..103c9891ba 100644 --- a/docs/fiddles/features/web-bluetooth/main.js +++ b/docs/fiddles/features/web-bluetooth/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain } = require('electron') +const { app, BrowserWindow, ipcMain } = require('electron/main') const path = require('node:path') let bluetoothPinCallback diff --git a/docs/fiddles/features/web-bluetooth/preload.js b/docs/fiddles/features/web-bluetooth/preload.js index d10666b7ee..6800eaccd9 100644 --- a/docs/fiddles/features/web-bluetooth/preload.js +++ b/docs/fiddles/features/web-bluetooth/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('electronAPI', { cancelBluetoothRequest: (callback) => ipcRenderer.send('cancel-bluetooth-request', callback), diff --git a/docs/fiddles/features/web-hid/main.js b/docs/fiddles/features/web-hid/main.js index b5dcb5aea4..315c39da37 100644 --- a/docs/fiddles/features/web-hid/main.js +++ b/docs/fiddles/features/web-hid/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/docs/fiddles/features/web-serial/main.js b/docs/fiddles/features/web-serial/main.js index c894fc2e2f..1839f4f425 100644 --- a/docs/fiddles/features/web-serial/main.js +++ b/docs/fiddles/features/web-serial/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/docs/fiddles/features/web-usb/main.js b/docs/fiddles/features/web-usb/main.js index 4ebe41e36d..a60de9182a 100644 --- a/docs/fiddles/features/web-usb/main.js +++ b/docs/fiddles/features/web-usb/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') function createWindow () { const mainWindow = new BrowserWindow({ diff --git a/docs/fiddles/ipc/pattern-1/main.js b/docs/fiddles/ipc/pattern-1/main.js index c43937edab..43799d4cb0 100644 --- a/docs/fiddles/ipc/pattern-1/main.js +++ b/docs/fiddles/ipc/pattern-1/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain } = require('electron') +const { app, BrowserWindow, ipcMain } = require('electron/main') const path = require('node:path') function createWindow () { diff --git a/docs/fiddles/ipc/pattern-1/preload.js b/docs/fiddles/ipc/pattern-1/preload.js index 50b3f3d4b1..ce23688245 100644 --- a/docs/fiddles/ipc/pattern-1/preload.js +++ b/docs/fiddles/ipc/pattern-1/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('electronAPI', { setTitle: (title) => ipcRenderer.send('set-title', title) diff --git a/docs/fiddles/ipc/pattern-2/main.js b/docs/fiddles/ipc/pattern-2/main.js index 187a6d83b5..369ddf6557 100644 --- a/docs/fiddles/ipc/pattern-2/main.js +++ b/docs/fiddles/ipc/pattern-2/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain, dialog } = require('electron') +const { app, BrowserWindow, ipcMain, dialog } = require('electron/main') const path = require('node:path') async function handleFileOpen () { diff --git a/docs/fiddles/ipc/pattern-2/preload.js b/docs/fiddles/ipc/pattern-2/preload.js index 5f2f6e2205..32f4acd9da 100644 --- a/docs/fiddles/ipc/pattern-2/preload.js +++ b/docs/fiddles/ipc/pattern-2/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('electronAPI', { openFile: () => ipcRenderer.invoke('dialog:openFile') diff --git a/docs/fiddles/ipc/pattern-3/main.js b/docs/fiddles/ipc/pattern-3/main.js index 91c0c1a646..60e08ba80d 100644 --- a/docs/fiddles/ipc/pattern-3/main.js +++ b/docs/fiddles/ipc/pattern-3/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, Menu, ipcMain } = require('electron') +const { app, BrowserWindow, Menu, ipcMain } = require('electron/main') const path = require('node:path') function createWindow () { diff --git a/docs/fiddles/ipc/pattern-3/preload.js b/docs/fiddles/ipc/pattern-3/preload.js index ad4dd27f1f..0c0402e53f 100644 --- a/docs/fiddles/ipc/pattern-3/preload.js +++ b/docs/fiddles/ipc/pattern-3/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('electronAPI', { handleCounter: (callback) => ipcRenderer.on('update-counter', callback) diff --git a/docs/fiddles/ipc/webview-new-window/main.js b/docs/fiddles/ipc/webview-new-window/main.js index a76c1434c4..8b6aa41883 100644 --- a/docs/fiddles/ipc/webview-new-window/main.js +++ b/docs/fiddles/ipc/webview-new-window/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const path = require('node:path') function createWindow () { diff --git a/docs/fiddles/ipc/webview-new-window/preload.js b/docs/fiddles/ipc/webview-new-window/preload.js index 5b5b6e70a6..99f3e6bc60 100644 --- a/docs/fiddles/ipc/webview-new-window/preload.js +++ b/docs/fiddles/ipc/webview-new-window/preload.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const webview = document.getElementById('webview') ipcRenderer.on('webview-new-window', (e, webContentsId, details) => { console.log('webview-new-window', webContentsId, details) diff --git a/docs/fiddles/media/screenshot/take-screenshot/main.js b/docs/fiddles/media/screenshot/take-screenshot/main.js index cb09498a0d..73b8b97870 100644 --- a/docs/fiddles/media/screenshot/take-screenshot/main.js +++ b/docs/fiddles/media/screenshot/take-screenshot/main.js @@ -1,4 +1,4 @@ -const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron') +const { BrowserWindow, app, screen, ipcMain, desktopCapturer } = require('electron/main') let mainWindow = null diff --git a/docs/fiddles/media/screenshot/take-screenshot/renderer.js b/docs/fiddles/media/screenshot/take-screenshot/renderer.js index fd615325b8..4712a2f0ea 100644 --- a/docs/fiddles/media/screenshot/take-screenshot/renderer.js +++ b/docs/fiddles/media/screenshot/take-screenshot/renderer.js @@ -1,4 +1,4 @@ -const { shell, ipcRenderer } = require('electron') +const { shell, ipcRenderer } = require('electron/renderer') const fs = require('node:fs').promises const os = require('node:os') diff --git a/docs/fiddles/menus/customize-menus/main.js b/docs/fiddles/menus/customize-menus/main.js index 74a7008954..63289526d9 100644 --- a/docs/fiddles/menus/customize-menus/main.js +++ b/docs/fiddles/menus/customize-menus/main.js @@ -6,8 +6,9 @@ const { ipcMain, app, shell, - dialog -} = require('electron') + dialog, + autoUpdater +} = require('electron/main') const menu = new Menu() menu.append(new MenuItem({ label: 'Hello' })) @@ -185,7 +186,7 @@ function addUpdateMenuItems (items, position) { visible: false, key: 'checkForUpdate', click: () => { - require('electron').autoUpdater.checkForUpdates() + autoUpdater.checkForUpdates() } }, { @@ -194,7 +195,7 @@ function addUpdateMenuItems (items, position) { visible: false, key: 'restartToUpdate', click: () => { - require('electron').autoUpdater.quitAndInstall() + autoUpdater.quitAndInstall() } } ] diff --git a/docs/fiddles/menus/customize-menus/renderer.js b/docs/fiddles/menus/customize-menus/renderer.js index 5527e1f200..372db5ce68 100644 --- a/docs/fiddles/menus/customize-menus/renderer.js +++ b/docs/fiddles/menus/customize-menus/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') // Tell main process to show the menu when demo button is clicked const contextMenuBtn = document.getElementById('context-menu') diff --git a/docs/fiddles/menus/shortcuts/main.js b/docs/fiddles/menus/shortcuts/main.js index ff51f59a9a..1b295eef49 100644 --- a/docs/fiddles/menus/shortcuts/main.js +++ b/docs/fiddles/menus/shortcuts/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, globalShortcut, dialog, shell } = require('electron') +const { app, BrowserWindow, globalShortcut, dialog, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/dialogs/error-dialog/main.js b/docs/fiddles/native-ui/dialogs/error-dialog/main.js index 1e26daacd8..bfedd4a3be 100644 --- a/docs/fiddles/native-ui/dialogs/error-dialog/main.js +++ b/docs/fiddles/native-ui/dialogs/error-dialog/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron') +const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/dialogs/error-dialog/renderer.js b/docs/fiddles/native-ui/dialogs/error-dialog/renderer.js index e355e7ee9a..0dff640bf8 100644 --- a/docs/fiddles/native-ui/dialogs/error-dialog/renderer.js +++ b/docs/fiddles/native-ui/dialogs/error-dialog/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const errorBtn = document.getElementById('error-dialog') diff --git a/docs/fiddles/native-ui/dialogs/information-dialog/main.js b/docs/fiddles/native-ui/dialogs/information-dialog/main.js index 187abcfce7..bb0196e817 100644 --- a/docs/fiddles/native-ui/dialogs/information-dialog/main.js +++ b/docs/fiddles/native-ui/dialogs/information-dialog/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron') +const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/dialogs/information-dialog/renderer.js b/docs/fiddles/native-ui/dialogs/information-dialog/renderer.js index 108d8e3241..f6fe51bac7 100644 --- a/docs/fiddles/native-ui/dialogs/information-dialog/renderer.js +++ b/docs/fiddles/native-ui/dialogs/information-dialog/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const informationBtn = document.getElementById('information-dialog') diff --git a/docs/fiddles/native-ui/dialogs/open-file-or-directory/main.js b/docs/fiddles/native-ui/dialogs/open-file-or-directory/main.js index b3f87183a7..52ead02c9d 100644 --- a/docs/fiddles/native-ui/dialogs/open-file-or-directory/main.js +++ b/docs/fiddles/native-ui/dialogs/open-file-or-directory/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron') +const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/dialogs/open-file-or-directory/renderer.js b/docs/fiddles/native-ui/dialogs/open-file-or-directory/renderer.js index 08333444dc..0c5efd6735 100644 --- a/docs/fiddles/native-ui/dialogs/open-file-or-directory/renderer.js +++ b/docs/fiddles/native-ui/dialogs/open-file-or-directory/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const selectDirBtn = document.getElementById('select-directory') diff --git a/docs/fiddles/native-ui/dialogs/save-dialog/main.js b/docs/fiddles/native-ui/dialogs/save-dialog/main.js index b522f27ed6..d33fa33d32 100644 --- a/docs/fiddles/native-ui/dialogs/save-dialog/main.js +++ b/docs/fiddles/native-ui/dialogs/save-dialog/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron') +const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/dialogs/save-dialog/renderer.js b/docs/fiddles/native-ui/dialogs/save-dialog/renderer.js index 075b02e17b..ae06226891 100644 --- a/docs/fiddles/native-ui/dialogs/save-dialog/renderer.js +++ b/docs/fiddles/native-ui/dialogs/save-dialog/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const saveBtn = document.getElementById('save-dialog') diff --git a/docs/fiddles/native-ui/drag-and-drop/main.js b/docs/fiddles/native-ui/drag-and-drop/main.js index 1137ef176a..2186de038c 100644 --- a/docs/fiddles/native-ui/drag-and-drop/main.js +++ b/docs/fiddles/native-ui/drag-and-drop/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, nativeImage, shell } = require('electron') +const { app, BrowserWindow, ipcMain, nativeImage, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow diff --git a/docs/fiddles/native-ui/drag-and-drop/renderer.js b/docs/fiddles/native-ui/drag-and-drop/renderer.js index 859348551e..48df46b460 100644 --- a/docs/fiddles/native-ui/drag-and-drop/renderer.js +++ b/docs/fiddles/native-ui/drag-and-drop/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const dragFileLink = document.getElementById('drag-file-link') diff --git a/docs/fiddles/native-ui/external-links-file-manager/main.js b/docs/fiddles/native-ui/external-links-file-manager/main.js index a2de1b97c8..f3e3c0ec62 100644 --- a/docs/fiddles/native-ui/external-links-file-manager/main.js +++ b/docs/fiddles/native-ui/external-links-file-manager/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, shell } = require('electron') +const { app, BrowserWindow, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/external-links-file-manager/renderer.js b/docs/fiddles/native-ui/external-links-file-manager/renderer.js index 2a059092c9..7bbea2ca1a 100644 --- a/docs/fiddles/native-ui/external-links-file-manager/renderer.js +++ b/docs/fiddles/native-ui/external-links-file-manager/renderer.js @@ -1,4 +1,4 @@ -const { shell } = require('electron') +const { shell } = require('electron/renderer') const os = require('node:os') const exLinksBtn = document.getElementById('open-ex-links') diff --git a/docs/fiddles/native-ui/notifications/main.js b/docs/fiddles/native-ui/notifications/main.js index a2de1b97c8..f3e3c0ec62 100644 --- a/docs/fiddles/native-ui/notifications/main.js +++ b/docs/fiddles/native-ui/notifications/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, shell } = require('electron') +const { app, BrowserWindow, shell } = require('electron/main') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. diff --git a/docs/fiddles/native-ui/tray/main.js b/docs/fiddles/native-ui/tray/main.js index 3d5ce65e02..2a238a265c 100644 --- a/docs/fiddles/native-ui/tray/main.js +++ b/docs/fiddles/native-ui/tray/main.js @@ -1,4 +1,4 @@ -const { app, Tray, Menu, nativeImage } = require('electron') +const { app, Tray, Menu, nativeImage } = require('electron/main') let tray diff --git a/docs/fiddles/quick-start/main.js b/docs/fiddles/quick-start/main.js index 6fda959b7e..c614294e01 100644 --- a/docs/fiddles/quick-start/main.js +++ b/docs/fiddles/quick-start/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const path = require('node:path') function createWindow () { diff --git a/docs/fiddles/screen/fit-screen/main.js b/docs/fiddles/screen/fit-screen/main.js index 559e0f24e4..9b1ffcbbe0 100644 --- a/docs/fiddles/screen/fit-screen/main.js +++ b/docs/fiddles/screen/fit-screen/main.js @@ -3,14 +3,11 @@ // For more info, see: // https://www.electronjs.org/docs/latest/api/screen -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow, screen } = require('electron/main') let mainWindow = null app.whenReady().then(() => { - // We cannot require the screen module until the app is ready. - const { screen } = require('electron') - // Create a window that fills the screen's available work area. const primaryDisplay = screen.getPrimaryDisplay() const { width, height } = primaryDisplay.workAreaSize diff --git a/docs/fiddles/system/clipboard/copy/main.js b/docs/fiddles/system/clipboard/copy/main.js index c68becbd8e..1c76f9d50a 100644 --- a/docs/fiddles/system/clipboard/copy/main.js +++ b/docs/fiddles/system/clipboard/copy/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain, clipboard } = require('electron') +const { app, BrowserWindow, ipcMain, clipboard } = require('electron/main') const path = require('node:path') let mainWindow = null diff --git a/docs/fiddles/system/clipboard/copy/preload.js b/docs/fiddles/system/clipboard/copy/preload.js index f97bfe1fc2..580d386657 100644 --- a/docs/fiddles/system/clipboard/copy/preload.js +++ b/docs/fiddles/system/clipboard/copy/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('clipboard', { writeText: (text) => ipcRenderer.invoke('clipboard:writeText', text) diff --git a/docs/fiddles/system/clipboard/paste/main.js b/docs/fiddles/system/clipboard/paste/main.js index 43f73a14c8..58c2fbb3e8 100644 --- a/docs/fiddles/system/clipboard/paste/main.js +++ b/docs/fiddles/system/clipboard/paste/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain, clipboard } = require('electron') +const { app, BrowserWindow, ipcMain, clipboard } = require('electron/main') const path = require('node:path') let mainWindow = null diff --git a/docs/fiddles/system/clipboard/paste/preload.js b/docs/fiddles/system/clipboard/paste/preload.js index 7ea394192e..31ce721451 100644 --- a/docs/fiddles/system/clipboard/paste/preload.js +++ b/docs/fiddles/system/clipboard/paste/preload.js @@ -1,4 +1,4 @@ -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') contextBridge.exposeInMainWorld('clipboard', { readText: () => ipcRenderer.invoke('clipboard:readText'), diff --git a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js index 6459985a17..84efd0cb97 100644 --- a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js +++ b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, shell, dialog } = require('electron') +const { app, BrowserWindow, ipcMain, shell, dialog } = require('electron/main') const path = require('node:path') let mainWindow diff --git a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/preload.js b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/preload.js index 13e803ad9c..eda1d8c721 100644 --- a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/preload.js +++ b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/preload.js @@ -1,11 +1,5 @@ -// All of the Node.js APIs are available in the preload process. -// It has the same sandbox as a Chrome extension. -const { contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron/renderer') -// Set up context bridge between the renderer process and the main process -contextBridge.exposeInMainWorld( - 'shell', - { - open: () => ipcRenderer.send('shell:open') - } -) +contextBridge.exposeInMainWorld('shell', { + open: () => ipcRenderer.send('shell:open') +}) diff --git a/docs/fiddles/system/system-app-user-information/app-information/main.js b/docs/fiddles/system/system-app-user-information/app-information/main.js index bfbfcfac55..7ec2bd5d32 100644 --- a/docs/fiddles/system/system-app-user-information/app-information/main.js +++ b/docs/fiddles/system/system-app-user-information/app-information/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, ipcMain, shell } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron/main') let mainWindow = null diff --git a/docs/fiddles/system/system-app-user-information/app-information/renderer.js b/docs/fiddles/system/system-app-user-information/app-information/renderer.js index e8a9b1b745..62705b3770 100644 --- a/docs/fiddles/system/system-app-user-information/app-information/renderer.js +++ b/docs/fiddles/system/system-app-user-information/app-information/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const appInfoBtn = document.getElementById('app-info') diff --git a/docs/fiddles/system/system-information/get-version-information/main.js b/docs/fiddles/system/system-information/get-version-information/main.js index 34bdd9e32b..14ffef1acd 100644 --- a/docs/fiddles/system/system-information/get-version-information/main.js +++ b/docs/fiddles/system/system-information/get-version-information/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, shell } = require('electron') +const { app, BrowserWindow, shell } = require('electron/main') let mainWindow = null diff --git a/docs/fiddles/tutorial-first-app/main.js b/docs/fiddles/tutorial-first-app/main.js index fdb092a9d4..8e92734f27 100644 --- a/docs/fiddles/tutorial-first-app/main.js +++ b/docs/fiddles/tutorial-first-app/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const createWindow = () => { const win = new BrowserWindow({ diff --git a/docs/fiddles/tutorial-preload/main.js b/docs/fiddles/tutorial-preload/main.js index 32e5c10d42..f62f401355 100644 --- a/docs/fiddles/tutorial-preload/main.js +++ b/docs/fiddles/tutorial-preload/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow } = require('electron/main') const path = require('node:path') const createWindow = () => { diff --git a/docs/fiddles/tutorial-preload/preload.js b/docs/fiddles/tutorial-preload/preload.js index 4d0213eedb..561df488dc 100644 --- a/docs/fiddles/tutorial-preload/preload.js +++ b/docs/fiddles/tutorial-preload/preload.js @@ -1,4 +1,4 @@ -const { contextBridge } = require('electron') +const { contextBridge } = require('electron/renderer') contextBridge.exposeInMainWorld('versions', { node: () => process.versions.node, diff --git a/docs/fiddles/windows/manage-windows/frameless-window/main.js b/docs/fiddles/windows/manage-windows/frameless-window/main.js index b60f99d224..021679fc5e 100644 --- a/docs/fiddles/windows/manage-windows/frameless-window/main.js +++ b/docs/fiddles/windows/manage-windows/frameless-window/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, shell } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron/main') ipcMain.on('create-frameless-window', (event, { url }) => { const win = new BrowserWindow({ frame: false }) diff --git a/docs/fiddles/windows/manage-windows/frameless-window/renderer.js b/docs/fiddles/windows/manage-windows/frameless-window/renderer.js index 21f91ad561..b8aafe29d1 100644 --- a/docs/fiddles/windows/manage-windows/frameless-window/renderer.js +++ b/docs/fiddles/windows/manage-windows/frameless-window/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const newWindowBtn = document.getElementById('frameless-window') diff --git a/docs/fiddles/windows/manage-windows/manage-window-state/main.js b/docs/fiddles/windows/manage-windows/manage-window-state/main.js index 05fcdd704e..f41240b46f 100644 --- a/docs/fiddles/windows/manage-windows/manage-window-state/main.js +++ b/docs/fiddles/windows/manage-windows/manage-window-state/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, shell } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron/main') ipcMain.on('create-demo-window', (event) => { const win = new BrowserWindow({ width: 400, height: 275 }) diff --git a/docs/fiddles/windows/manage-windows/manage-window-state/renderer.js b/docs/fiddles/windows/manage-windows/manage-window-state/renderer.js index bdf6a54c17..2efe3199a8 100644 --- a/docs/fiddles/windows/manage-windows/manage-window-state/renderer.js +++ b/docs/fiddles/windows/manage-windows/manage-window-state/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const manageWindowBtn = document.getElementById('manage-window') diff --git a/docs/fiddles/windows/manage-windows/new-window/main.js b/docs/fiddles/windows/manage-windows/new-window/main.js index 4e4a4e0ad5..4e2f9c6beb 100644 --- a/docs/fiddles/windows/manage-windows/new-window/main.js +++ b/docs/fiddles/windows/manage-windows/new-window/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, shell } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron/main') ipcMain.on('new-window', (event, { url, width, height }) => { const win = new BrowserWindow({ width, height }) diff --git a/docs/fiddles/windows/manage-windows/new-window/renderer.js b/docs/fiddles/windows/manage-windows/new-window/renderer.js index 0d80d2ee2c..ce4b7a4b51 100644 --- a/docs/fiddles/windows/manage-windows/new-window/renderer.js +++ b/docs/fiddles/windows/manage-windows/new-window/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const newWindowBtn = document.getElementById('new-window') diff --git a/docs/fiddles/windows/manage-windows/window-events/main.js b/docs/fiddles/windows/manage-windows/window-events/main.js index 5abf2cc257..a7fd20cc92 100644 --- a/docs/fiddles/windows/manage-windows/window-events/main.js +++ b/docs/fiddles/windows/manage-windows/window-events/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain, shell } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron/main') function createWindow () { // Create the browser window. diff --git a/docs/fiddles/windows/manage-windows/window-events/renderer.js b/docs/fiddles/windows/manage-windows/window-events/renderer.js index 85460df937..99f9909526 100644 --- a/docs/fiddles/windows/manage-windows/window-events/renderer.js +++ b/docs/fiddles/windows/manage-windows/window-events/renderer.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron/renderer') const listenToWindowBtn = document.getElementById('listen-to-window') const focusModalBtn = document.getElementById('focus-on-modal-window')",docs b35ec4a23ce35e64ee3a786146a690465436f11b,Shelley Vohr,2023-05-17 20:54:26,"build: modify `gclient.py` with unified patch (#38351) * build: modify gclient.py with unified patch * ci: ensure depot_tools does not update * ci: move auto-update disable outside if","diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index feed4be929..f9ab0243b5 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -250,14 +250,27 @@ step-depot-tools-get: &step-depot-tools-get sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja # Remove swift-format dep from cipd on macOS until we send a patch upstream. cd depot_tools - patch gclient.py -R \<<'EOF' - 676,677c676 - < packages = dep_value.get('packages', []) - < for package in (x for x in packages if ""infra/3pp/tools/swift-format"" not in x.get('package')): - --- - > for package in dep_value.get('packages', []): + cat > gclient.diff \<< 'EOF' + diff --git a/gclient.py b/gclient.py + index 3a9c5c6..f222043 100755 + --- a/gclient.py + +++ b/gclient.py + @@ -712,7 +712,8 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): + + if dep_type == 'cipd': + cipd_root = self.GetCipdRoot() + - for package in dep_value.get('packages', []): + + packages = dep_value.get('packages', []) + + for package in (x for x in packages if ""infra/3pp/tools/swift-format"" not in x.get('package')): + deps_to_add.append( + CipdDependency( + parent=self, EOF + git apply --3way gclient.diff fi + # Ensure depot_tools does not update. + test -d depot_tools && cd depot_tools + touch .disable_auto_update step-depot-tools-add-to-path: &step-depot-tools-add-to-path run:",build b8f970c1c710c7e43cff6770fa845b96445cdaf8,Shelley Vohr,2023-03-16 13:48:14,fix: properly bubble up cookie creation failure message (#37586),"diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index 8b2edc8fa5..41115a0db7 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -180,7 +180,7 @@ std::string InclusionStatusToString(net::CookieInclusionStatus status) { return ""Failed to parse cookie""; if (status.HasExclusionReason( net::CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN)) - return ""Failed to get cookie domain""; + return ""Failed to set cookie with an invalid domain attribute""; if (status.HasExclusionReason( net::CookieInclusionStatus::EXCLUDE_INVALID_PREFIX)) return ""Failed because the cookie violated prefix rules.""; @@ -318,19 +318,24 @@ v8::Local Cookies::Set(v8::Isolate* isolate, return handle; } + net::CookieInclusionStatus status; auto canonical_cookie = net::CanonicalCookie::CreateSanitizedCookie( url, name ? *name : """", value ? *value : """", domain ? *domain : """", path ? *path : """", ParseTimeProperty(details.FindDouble(""creationDate"")), ParseTimeProperty(details.FindDouble(""expirationDate"")), ParseTimeProperty(details.FindDouble(""lastAccessDate"")), secure, http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, same_party, - absl::nullopt); + absl::nullopt, &status); + if (!canonical_cookie || !canonical_cookie->IsCanonical()) { - promise.RejectWithErrorMessage( - InclusionStatusToString(net::CookieInclusionStatus( - net::CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE))); + promise.RejectWithErrorMessage(InclusionStatusToString( + !status.IsInclude() + ? status + : net::CookieInclusionStatus( + net::CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE))); return handle; } + net::CookieOptions options; if (http_only) { options.set_include_httponly(); diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index 61c259e7e8..c4cae25689 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -903,6 +903,16 @@ describe('net module', () => { expect(cookies[0].name).to.equal('cookie2'); }); + it('throws when an invalid domain is passed', async () => { + const sess = session.fromPartition(`cookie-tests-${Math.random()}`); + + await expect(sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'wssss.iamabaddomain.fun', + name: 'cookie1' + })).to.eventually.be.rejectedWith(/Failed to set cookie with an invalid domain attribute/); + }); + it('should be able correctly filter out cookies that are session', async () => { const sess = session.fromPartition(`cookie-tests-${Math.random()}`); diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts index 947363e615..f1c587d4d1 100644 --- a/spec/api-session-spec.ts +++ b/spec/api-session-spec.ts @@ -128,7 +128,7 @@ describe('session module', () => { await expect( cookies.set({ url: '', name, value }) - ).to.eventually.be.rejectedWith('Failed to get cookie domain'); + ).to.eventually.be.rejectedWith('Failed to set cookie with an invalid domain attribute'); }); it('yields an error when setting a cookie with an invalid URL', async () => { @@ -138,7 +138,7 @@ describe('session module', () => { await expect( cookies.set({ url: 'asdf', name, value }) - ).to.eventually.be.rejectedWith('Failed to get cookie domain'); + ).to.eventually.be.rejectedWith('Failed to set cookie with an invalid domain attribute'); }); it('should overwrite previous cookies', async () => {",fix 425efb5e47d040e063fdb54eaee377131401eb90,David Sanders,2023-11-01 07:20:32,chore: remove py2 compatibility code (#40375),"diff --git a/build/dump_syms.py b/build/dump_syms.py index 68cea6394b..8b38944928 100644 --- a/build/dump_syms.py +++ b/build/dump_syms.py @@ -1,4 +1,4 @@ -from __future__ import print_function +#!/usr/bin/env python3 import collections import os diff --git a/build/npm-run.py b/build/npm-run.py index 49a6abac65..2fcf649f10 100644 --- a/build/npm-run.py +++ b/build/npm-run.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import subprocess import sys diff --git a/build/profile_toolchain.py b/build/profile_toolchain.py index 6e51a7eaa1..f2ef85e1ca 100755 --- a/build/profile_toolchain.py +++ b/build/profile_toolchain.py @@ -1,4 +1,4 @@ -from __future__ import unicode_literals +#!/usr/bin/env python3 import contextlib import sys diff --git a/build/zip.py b/build/zip.py index 048e40ff7f..6c361b1c2a 100644 --- a/build/zip.py +++ b/build/zip.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import subprocess import sys diff --git a/build/zip_libcxx.py b/build/zip_libcxx.py index 35cc30a78f..77e69e9172 100644 --- a/build/zip_libcxx.py +++ b/build/zip_libcxx.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import os import subprocess import sys diff --git a/script/add-debug-link.py b/script/add-debug-link.py index 68ef0d3fd4..49dda09caa 100755 --- a/script/add-debug-link.py +++ b/script/add-debug-link.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import argparse import os import sys diff --git a/script/copy-debug-symbols.py b/script/copy-debug-symbols.py index 2658f9e0d0..c49d6a4236 100755 --- a/script/copy-debug-symbols.py +++ b/script/copy-debug-symbols.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import argparse import os import sys diff --git a/script/generate-config-gypi.py b/script/generate-config-gypi.py index 8a6f230952..e55e2474db 100755 --- a/script/generate-config-gypi.py +++ b/script/generate-config-gypi.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import ast import os import pprint diff --git a/script/lib/config.py b/script/lib/config.py index 3db917d172..34c8281ba0 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import os import sys diff --git a/script/lib/git.py b/script/lib/git.py index 93e61e6757..7493b85b0f 100644 --- a/script/lib/git.py +++ b/script/lib/git.py @@ -6,8 +6,6 @@ Everything here should be project agnostic: it shouldn't rely on project's structure, or make assumptions about the passed arguments or calls' outcomes. """""" -from __future__ import unicode_literals - import io import os import posixpath @@ -229,14 +227,6 @@ def remove_patch_filename(patch): force_keep_next_line = l.startswith('Subject: ') -def to_utf8(patch): - """"""Python 2/3 compatibility: unicode has been renamed to str in Python3"""""" - if sys.version_info[0] >= 3: - return str(patch, ""utf-8"") - - return unicode(patch, ""utf-8"") - - def export_patches(repo, out_dir, patch_range=None, dry_run=False): if not os.path.exists(repo): sys.stderr.write( @@ -263,7 +253,7 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False): for patch in patches: filename = get_file_name(patch) filepath = posixpath.join(out_dir, filename) - existing_patch = to_utf8(io.open(filepath, 'rb').read()) + existing_patch = str(io.open(filepath, 'rb').read(), 'utf-8') formatted_patch = join_patch(patch) if formatted_patch != existing_patch: bad_patches.append(filename) diff --git a/script/lib/native_tests.py b/script/lib/native_tests.py index ff3a3a74b2..f57a46ecd3 100644 --- a/script/lib/native_tests.py +++ b/script/lib/native_tests.py @@ -1,4 +1,4 @@ -from __future__ import print_function +#!/usr/bin/env python3 import os import subprocess @@ -10,11 +10,6 @@ PYYAML_LIB_DIR = os.path.join(SRC_DIR, 'third_party', 'pyyaml', 'lib') sys.path.append(PYYAML_LIB_DIR) import yaml #pylint: disable=wrong-import-position,wrong-import-order -try: - basestring # Python 2 -except NameError: # Python 3 - basestring = str # pylint: disable=redefined-builtin - class Verbosity: CHATTY = 'chatty' # stdout and stderr @@ -148,7 +143,7 @@ class TestsList(): if isinstance(value, dict): return value - if isinstance(value, basestring): + if isinstance(value, str): return {value: None} raise AssertionError(""unexpected shorthand type: {}"".format(type(value))) diff --git a/script/lib/util.py b/script/lib/util.py index b33828a2a5..762c137879 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import contextlib import errno import json @@ -8,11 +7,7 @@ import os import shutil import subprocess import sys -# Python 3 / 2 compat import -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen +from urllib.request import urlopen import zipfile # from lib.config import is_verbose_mode diff --git a/script/native-tests.py b/script/native-tests.py index 7a577bc75f..5e12aabbd7 100755 --- a/script/native-tests.py +++ b/script/native-tests.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function - import argparse import os import sys diff --git a/script/patches-mtime-cache.py b/script/patches-mtime-cache.py index b173b0bc7f..2f515ed62c 100644 --- a/script/patches-mtime-cache.py +++ b/script/patches-mtime-cache.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function - import argparse import hashlib import json @@ -168,13 +166,7 @@ def main(): traceback.print_exc(file=sys.stderr) return 0 elif args.operation == ""set"": - # Python 2/3 compatibility - try: - user_input = raw_input - except NameError: - user_input = input - - answer = user_input( + answer = input( ""WARNING: Manually setting mtimes could mess up your build. "" ""If you're sure, type yes: "" ) diff --git a/script/release/uploaders/upload-index-json.py b/script/release/uploaders/upload-index-json.py index 348023cf2c..2a33d1ded5 100755 --- a/script/release/uploaders/upload-index-json.py +++ b/script/release/uploaders/upload-index-json.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import json import os import sys diff --git a/script/release/uploaders/upload.py b/script/release/uploaders/upload.py index 641f8ae6f2..d5c3b6a16a 100755 --- a/script/release/uploaders/upload.py +++ b/script/release/uploaders/upload.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import argparse import datetime import hashlib diff --git a/script/run-clang-format.py b/script/run-clang-format.py index 345b504617..9597d4a0d1 100644 --- a/script/run-clang-format.py +++ b/script/run-clang-format.py @@ -7,8 +7,6 @@ It runs over multiple files and directories in parallel. A diff output is produced and a sensible exit code is returned. """""" -from __future__ import print_function, unicode_literals - import argparse import codecs import difflib diff --git a/script/strip-binaries.py b/script/strip-binaries.py index f01e35bf8b..e21fdeb6a6 100755 --- a/script/strip-binaries.py +++ b/script/strip-binaries.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import argparse import os import sys diff --git a/script/verify-chromedriver.py b/script/verify-chromedriver.py index fba6869b0c..880c8a70b7 100644 --- a/script/verify-chromedriver.py +++ b/script/verify-chromedriver.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function - import argparse import os import re diff --git a/script/verify-ffmpeg.py b/script/verify-ffmpeg.py index 0ee4ffe309..84bdf6baa1 100755 --- a/script/verify-ffmpeg.py +++ b/script/verify-ffmpeg.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import argparse import os import platform diff --git a/script/verify-mksnapshot.py b/script/verify-mksnapshot.py index 7efbc59dbe..41114c0402 100755 --- a/script/verify-mksnapshot.py +++ b/script/verify-mksnapshot.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function + import argparse import glob import os diff --git a/script/zip-symbols.py b/script/zip-symbols.py index 969297e597..0f7785ad8b 100755 --- a/script/zip-symbols.py +++ b/script/zip-symbols.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function import argparse import glob import os",chore 5e59ddca1ab75e6092737b4bcd09c099eb25fd85,Shelley Vohr,2023-08-08 22:29:03,"chore: update `chrome.runtime.getPlatformInfo` impl (#39392) chore: update chrome.runtime.getPlatformInfo impl","diff --git a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc index e43a195b9f..976bd56cdb 100644 --- a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc +++ b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc @@ -37,10 +37,13 @@ void ElectronRuntimeAPIDelegate::ReloadExtension( bool ElectronRuntimeAPIDelegate::CheckForUpdates( const std::string& extension_id, UpdateCheckCallback callback) { + LOG(INFO) << ""chrome.runtime.requestUpdateCheck is not supported in Electron""; return false; } -void ElectronRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) {} +void ElectronRuntimeAPIDelegate::OpenURL(const GURL& uninstall_url) { + LOG(INFO) << ""chrome.runtime.openURL is not supported in Electron""; +} bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) { const char* os = update_client::UpdateQueryParams::GetOS(); @@ -74,9 +77,6 @@ bool ElectronRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) { const char* nacl_arch = update_client::UpdateQueryParams::GetNaclArch(); if (strcmp(nacl_arch, ""arm"") == 0) { info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kArm; - } else if (strcmp(nacl_arch, ""arm64"") == 0) { - // Use ARM for ARM64 NaCl, as ARM64 NaCl is not available. - info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kArm; } else if (strcmp(nacl_arch, ""x86-32"") == 0) { info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kX86_32; } else if (strcmp(nacl_arch, ""x86-64"") == 0) {",chore 0e388bce3eb27b67391eb0f75f268608550fbcca,Milan Burda,2025-01-28 14:58:48,"build: add `NSPrefersDisplaySafeAreaCompatibilityMode` = `false` to Info.plist (#45318) build: add NSPrefersDisplaySafeAreaCompatibilityMode = false to Info.plist","diff --git a/shell/browser/resources/mac/Info.plist b/shell/browser/resources/mac/Info.plist index 9e01bf50a2..0ae99ab321 100644 --- a/shell/browser/resources/mac/Info.plist +++ b/shell/browser/resources/mac/Info.plist @@ -64,5 +64,7 @@ ${DEFAULT_APP_ASAR_HEADER_SHA} + NSPrefersDisplaySafeAreaCompatibilityMode + ",build dcf1c65426a88d55a626ace08b00f2b9a631d10f,David Sanders,2023-08-08 04:49:56,chore: fix ipcRenderer.sendTo deprecation warning (#39342),"diff --git a/lib/renderer/api/ipc-renderer.ts b/lib/renderer/api/ipc-renderer.ts index 4e1e7fba21..1977ce4ed3 100644 --- a/lib/renderer/api/ipc-renderer.ts +++ b/lib/renderer/api/ipc-renderer.ts @@ -18,8 +18,9 @@ ipcRenderer.sendToHost = function (channel, ...args) { return ipc.sendToHost(channel, args); }; +const sendToDeprecated = deprecate.warnOnce('ipcRenderer.sendTo'); ipcRenderer.sendTo = function (webContentsId, channel, ...args) { - deprecate.warnOnce('ipcRenderer.sendTo'); + sendToDeprecated(); return ipc.sendTo(webContentsId, channel, args); }; ",chore 34e7c3696a1375080197ebc68c222d221fbc2ef3,Robo,2023-07-13 18:14:33,"feat: expose safestorage backend information on linux (#38873) * feat: expose safestorage backend information on linux * Remove gnome-keyring Refs https://chromium-review.googlesource.com/c/chromium/src/+/4609704","diff --git a/docs/api/safe-storage.md b/docs/api/safe-storage.md index 471351c9c1..c8d370c9b3 100644 --- a/docs/api/safe-storage.md +++ b/docs/api/safe-storage.md @@ -38,3 +38,28 @@ Returns `string` - the decrypted string. Decrypts the encrypted buffer obtained with `safeStorage.encryptString` back into a string. This function will throw an error if decryption fails. + +### `safeStorage.setUsePlainTextEncryption(usePlainText)` + +* `usePlainText` boolean + +This function on Linux will force the module to use an in memory password for creating +symmetric key that is used for encrypt/decrypt functions when a valid OS password +manager cannot be determined for the current active desktop environment. This function +is a no-op on Windows and MacOS. + +### `safeStorage.getSelectedStorageBackend()` _Linux_ + +Returns `string` - User friendly name of the password manager selected on Linux. + +This function will return one of the following values: + +* `basic_text` - When the desktop environment is not recognised or if the following +command line flag is provided `--password-store=""basic""`. +* `gnome_libsecret` - When the desktop environment is `X-Cinnamon`, `Deepin`, `GNOME`, `Pantheon`, `XFCE`, `UKUI`, `unity` or if the following command line flag is provided `--password-store=""gnome-libsecret""`. +* `kwallet` - When the desktop session is `kde4` or if the following command line flag +is provided `--password-store=""kwallet""`. +* `kwallet5` - When the desktop session is `kde5` or if the following command line flag +is provided `--password-store=""kwallet5""`. +* `kwallet6` - When the desktop session is `kde6`. +* `unknown` - When the function is called before app has emitted the `ready` event. diff --git a/shell/browser/api/electron_api_safe_storage.cc b/shell/browser/api/electron_api_safe_storage.cc index 7bdc150439..1eaddeb112 100644 --- a/shell/browser/api/electron_api_safe_storage.cc +++ b/shell/browser/api/electron_api_safe_storage.cc @@ -8,6 +8,7 @@ #include ""components/os_crypt/sync/os_crypt.h"" #include ""shell/browser/browser.h"" +#include ""shell/browser/browser_process_impl.h"" #include ""shell/common/gin_converters/base_converter.h"" #include ""shell/common/gin_converters/callback_converter.h"" #include ""shell/common/gin_helper/dictionary.h"" @@ -18,14 +19,7 @@ namespace electron::safestorage { static const char* kEncryptionVersionPrefixV10 = ""v10""; static const char* kEncryptionVersionPrefixV11 = ""v11""; - -#if DCHECK_IS_ON() -static bool electron_crypto_ready = false; - -void SetElectronCryptoReady(bool ready) { - electron_crypto_ready = ready; -} -#endif +static bool use_password_v10 = false; bool IsEncryptionAvailable() { #if BUILDFLAG(IS_LINUX) @@ -34,9 +28,27 @@ bool IsEncryptionAvailable() { // Refs: https://github.com/electron/electron/issues/32206. if (!Browser::Get()->is_ready()) return false; -#endif + return OSCrypt::IsEncryptionAvailable() || + (use_password_v10 && + static_cast(g_browser_process) + ->GetLinuxStorageBackend() == ""basic_text""); +#else return OSCrypt::IsEncryptionAvailable(); +#endif +} + +void SetUsePasswordV10(bool use) { + use_password_v10 = use; +} + +#if BUILDFLAG(IS_LINUX) +std::string GetSelectedLinuxBackend() { + if (!Browser::Get()->is_ready()) + return ""unknown""; + return static_cast(g_browser_process) + ->GetLinuxStorageBackend(); } +#endif v8::Local EncryptString(v8::Isolate* isolate, const std::string& plaintext) { @@ -47,8 +59,8 @@ v8::Local EncryptString(v8::Isolate* isolate, return v8::Local(); } gin_helper::ErrorThrower(isolate).ThrowError( - ""Error while decrypting the ciphertext provided to "" - ""safeStorage.decryptString. "" + ""Error while encrypting the text provided to "" + ""safeStorage.encryptString. "" ""Encryption is not available.""); return v8::Local(); } @@ -128,6 +140,12 @@ void Initialize(v8::Local exports, &electron::safestorage::IsEncryptionAvailable); dict.SetMethod(""encryptString"", &electron::safestorage::EncryptString); dict.SetMethod(""decryptString"", &electron::safestorage::DecryptString); + dict.SetMethod(""setUsePlainTextEncryption"", + &electron::safestorage::SetUsePasswordV10); +#if BUILDFLAG(IS_LINUX) + dict.SetMethod(""getSelectedStorageBackend"", + &electron::safestorage::GetSelectedLinuxBackend); +#endif } NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_safe_storage, Initialize) diff --git a/shell/browser/browser_process_impl.cc b/shell/browser/browser_process_impl.cc index 6f96095992..ad2f6ee294 100644 --- a/shell/browser/browser_process_impl.cc +++ b/shell/browser/browser_process_impl.cc @@ -305,6 +305,36 @@ const std::string& BrowserProcessImpl::GetSystemLocale() const { return system_locale_; } +#if BUILDFLAG(IS_LINUX) +void BrowserProcessImpl::SetLinuxStorageBackend( + os_crypt::SelectedLinuxBackend selected_backend) { + switch (selected_backend) { + case os_crypt::SelectedLinuxBackend::BASIC_TEXT: + selected_linux_storage_backend_ = ""basic_text""; + break; + case os_crypt::SelectedLinuxBackend::GNOME_LIBSECRET: + selected_linux_storage_backend_ = ""gnome_libsecret""; + break; + case os_crypt::SelectedLinuxBackend::KWALLET: + selected_linux_storage_backend_ = ""kwallet""; + break; + case os_crypt::SelectedLinuxBackend::KWALLET5: + selected_linux_storage_backend_ = ""kwallet5""; + break; + case os_crypt::SelectedLinuxBackend::KWALLET6: + selected_linux_storage_backend_ = ""kwallet6""; + break; + case os_crypt::SelectedLinuxBackend::DEFER: + NOTREACHED(); + break; + } +} + +const std::string& BrowserProcessImpl::GetLinuxStorageBackend() const { + return selected_linux_storage_backend_; +} +#endif // BUILDFLAG(IS_LINUX) + void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { locale_ = locale; } diff --git a/shell/browser/browser_process_impl.h b/shell/browser/browser_process_impl.h index 44ebba4342..0e8e2c79d7 100644 --- a/shell/browser/browser_process_impl.h +++ b/shell/browser/browser_process_impl.h @@ -23,6 +23,10 @@ #include ""services/network/public/cpp/shared_url_loader_factory.h"" #include ""shell/browser/net/system_network_context_manager.h"" +#if BUILDFLAG(IS_LINUX) +#include ""components/os_crypt/sync/key_storage_util_linux.h"" +#endif + namespace printing { class PrintJobManager; } @@ -53,6 +57,11 @@ class BrowserProcessImpl : public BrowserProcess { void SetSystemLocale(const std::string& locale); const std::string& GetSystemLocale() const; +#if BUILDFLAG(IS_LINUX) + void SetLinuxStorageBackend(os_crypt::SelectedLinuxBackend selected_backend); + const std::string& GetLinuxStorageBackend() const; +#endif + void EndSession() override {} void FlushLocalStateAndReply(base::OnceClosure reply) override {} bool IsShuttingDown() override; @@ -120,6 +129,9 @@ class BrowserProcessImpl : public BrowserProcess { std::unique_ptr local_state_; std::string locale_; std::string system_locale_; +#if BUILDFLAG(IS_LINUX) + std::string selected_linux_storage_backend_; +#endif embedder_support::OriginTrialsSettingsStorage origin_trials_settings_storage_; std::unique_ptr network_quality_tracker_; diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 8795668266..b11b7c02ce 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -14,6 +14,7 @@ #include ""base/feature_list.h"" #include ""base/i18n/rtl.h"" #include ""base/metrics/field_trial.h"" +#include ""base/nix/xdg_util.h"" #include ""base/path_service.h"" #include ""base/run_loop.h"" #include ""base/strings/string_number_conversions.h"" @@ -23,8 +24,8 @@ #include ""chrome/browser/ui/color/chrome_color_mixers.h"" #include ""chrome/common/chrome_paths.h"" #include ""chrome/common/chrome_switches.h"" -#include ""components/embedder_support/origin_trials/origin_trials_settings_storage.h"" #include ""components/os_crypt/sync/key_storage_config_linux.h"" +#include ""components/os_crypt/sync/key_storage_util_linux.h"" #include ""components/os_crypt/sync/os_crypt.h"" #include ""content/browser/browser_main_loop.h"" // nogncheck #include ""content/public/browser/browser_child_process_host_delegate.h"" @@ -192,18 +193,6 @@ void UpdateDarkThemeSetting() { } #endif -// A fake BrowserProcess object that used to feed the source code from chrome. -class FakeBrowserProcessImpl : public BrowserProcessImpl { - public: - embedder_support::OriginTrialsSettingsStorage* - GetOriginTrialsSettingsStorage() override { - return &origin_trials_settings_storage_; - } - - private: - embedder_support::OriginTrialsSettingsStorage origin_trials_settings_storage_; -}; - } // namespace #if BUILDFLAG(IS_LINUX) @@ -578,6 +567,15 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() { config->should_use_preference = command_line.HasSwitch(::switches::kEnableEncryptionSelection); base::PathService::Get(DIR_SESSION_DATA, &config->user_data_path); + + bool use_backend = !config->should_use_preference || + os_crypt::GetBackendUse(config->user_data_path); + std::unique_ptr env(base::Environment::Create()); + base::nix::DesktopEnvironment desktop_env = + base::nix::GetDesktopEnvironment(env.get()); + os_crypt::SelectedLinuxBackend selected_backend = + os_crypt::SelectBackend(config->store, use_backend, desktop_env); + fake_browser_process_->SetLinuxStorageBackend(selected_backend); OSCrypt::SetConfig(std::move(config)); #endif #if BUILDFLAG(IS_MAC) diff --git a/shell/browser/net/system_network_context_manager.cc b/shell/browser/net/system_network_context_manager.cc index b548d38a99..209c368cb5 100644 --- a/shell/browser/net/system_network_context_manager.cc +++ b/shell/browser/net/system_network_context_manager.cc @@ -35,7 +35,6 @@ #include ""services/network/public/cpp/features.h"" #include ""services/network/public/cpp/shared_url_loader_factory.h"" #include ""services/network/public/mojom/network_context.mojom.h"" -#include ""shell/browser/api/electron_api_safe_storage.h"" #include ""shell/browser/browser.h"" #include ""shell/browser/electron_browser_client.h"" #include ""shell/common/application_info.h"" @@ -291,10 +290,6 @@ void SystemNetworkContextManager::OnNetworkServiceCreated( electron::fuses::IsCookieEncryptionEnabled()) { network_service->SetEncryptionKey(OSCrypt::GetRawEncryptionKey()); } - -#if DCHECK_IS_ON() - electron::safestorage::SetElectronCryptoReady(true); -#endif } network::mojom::NetworkContextParamsPtr diff --git a/spec/api-safe-storage-spec.ts b/spec/api-safe-storage-spec.ts index 1f48175017..740e916f13 100644 --- a/spec/api-safe-storage-spec.ts +++ b/spec/api-safe-storage-spec.ts @@ -6,15 +6,6 @@ import { ifdescribe } from './lib/spec-helpers'; import * as fs from 'fs-extra'; import { once } from 'node:events'; -/* isEncryptionAvailable returns false in Linux when running CI due to a mocked dbus. This stops -* Chrome from reaching the system's keyring or libsecret. When running the tests with config.store -* set to basic-text, a nullptr is returned from chromium, defaulting the available encryption to false. -* -* Because all encryption methods are gated by isEncryptionAvailable, the methods will never return the correct values -* when run on CI and linux. -* Refs: https://github.com/electron/electron/issues/30424. -*/ - describe('safeStorage module', () => { it('safeStorage before and after app is ready', async () => { const appPath = path.join(__dirname, 'fixtures', 'crash-cases', 'safe-storage'); @@ -33,7 +24,13 @@ describe('safeStorage module', () => { }); }); -ifdescribe(process.platform !== 'linux')('safeStorage module', () => { +describe('safeStorage module', () => { + before(() => { + if (process.platform === 'linux') { + safeStorage.setUsePlainTextEncryption(true); + } + }); + after(async () => { const pathToEncryptedString = path.resolve(__dirname, 'fixtures', 'api', 'safe-storage', 'encrypted.txt'); if (await fs.pathExists(pathToEncryptedString)) { @@ -47,6 +44,12 @@ ifdescribe(process.platform !== 'linux')('safeStorage module', () => { }); }); + ifdescribe(process.platform === 'linux')('SafeStorage.getSelectedStorageBackend()', () => { + it('should return a valid backend', () => { + expect(safeStorage.getSelectedStorageBackend()).to.equal('basic_text'); + }); + }); + describe('SafeStorage.encryptString()', () => { it('valid input should correctly encrypt string', () => { const plaintext = 'plaintext'; @@ -87,6 +90,7 @@ ifdescribe(process.platform !== 'linux')('safeStorage module', () => { }).to.throw(Error); }); }); + describe('safeStorage persists encryption key across app relaunch', () => { it('can decrypt after closing and reopening app', async () => { const fixturesPath = path.resolve(__dirname, 'fixtures'); diff --git a/spec/fixtures/api/safe-storage/decrypt-app/main.js b/spec/fixtures/api/safe-storage/decrypt-app/main.js index 72eee87044..3476034455 100644 --- a/spec/fixtures/api/safe-storage/decrypt-app/main.js +++ b/spec/fixtures/api/safe-storage/decrypt-app/main.js @@ -6,6 +6,9 @@ const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt'); const readFile = fs.readFile; app.whenReady().then(async () => { + if (process.platform === 'linux') { + safeStorage.setUsePlainTextEncryption(true); + } const encryptedString = await readFile(pathToEncryptedString); const decrypted = safeStorage.decryptString(encryptedString); console.log(decrypted); diff --git a/spec/fixtures/api/safe-storage/encrypt-app/main.js b/spec/fixtures/api/safe-storage/encrypt-app/main.js index ae4a11bff8..a9f6d261c0 100644 --- a/spec/fixtures/api/safe-storage/encrypt-app/main.js +++ b/spec/fixtures/api/safe-storage/encrypt-app/main.js @@ -6,6 +6,9 @@ const pathToEncryptedString = path.resolve(__dirname, '..', 'encrypted.txt'); const writeFile = fs.writeFile; app.whenReady().then(async () => { + if (process.platform === 'linux') { + safeStorage.setUsePlainTextEncryption(true); + } const encrypted = safeStorage.encryptString('plaintext'); await writeFile(pathToEncryptedString, encrypted); app.quit();",feat 5b34138db8b338d6192d17f74fa9119d0667b245,Samuel Attard,2024-10-01 17:09:57,build: fix relative file read during npm publish (#44088),"diff --git a/script/release/bin/publish-to-npm.ts b/script/release/bin/publish-to-npm.ts index 85a293a444..9026384cb2 100644 --- a/script/release/bin/publish-to-npm.ts +++ b/script/release/bin/publish-to-npm.ts @@ -12,7 +12,7 @@ import { getAssetContents } from '../get-asset'; import { createGitHubTokenStrategy } from '../github-token'; import { ELECTRON_ORG, ELECTRON_REPO, ElectronReleaseRepo, NIGHTLY_REPO } from '../types'; -const rootPackageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf-8')); +const rootPackageJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../../package.json'), 'utf-8')); if (!process.env.ELECTRON_NPM_OTP) { console.error('Please set ELECTRON_NPM_OTP');",build 701a09d44f93831fc723d72dcc88251a15d283b3,Samuel Attard,2024-08-05 12:42:41,build: use smaller instances for gn-check (#43187),"diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c9ed328ae..becc12f312 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -137,6 +137,7 @@ jobs: needs: checkout-macos with: build-runs-on: macos-14-xlarge + check-runs-on: macos-14 test-runs-on: macos-13 target-platform: macos target-arch: x64 @@ -155,6 +156,7 @@ jobs: needs: checkout-macos with: build-runs-on: macos-14-xlarge + check-runs-on: macos-14 test-runs-on: macos-14 target-platform: macos target-arch: arm64 @@ -173,6 +175,7 @@ jobs: needs: checkout-linux with: build-runs-on: electron-arc-linux-amd64-32core + check-runs-on: electron-arc-linux-amd64-8core test-runs-on: electron-arc-linux-amd64-4core build-container: '{""image"":""ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root"",""volumes"":[""/mnt/cross-instance-cache:/mnt/cross-instance-cache""]}' test-container: '{""image"":""ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root --privileged --init""}' @@ -193,6 +196,7 @@ jobs: needs: checkout-linux with: build-runs-on: electron-arc-linux-amd64-32core + check-runs-on: electron-arc-linux-amd64-8core test-runs-on: electron-arc-linux-amd64-4core build-container: '{""image"":""ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root"",""volumes"":[""/mnt/cross-instance-cache:/mnt/cross-instance-cache""]}' test-container: '{""image"":""ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root --privileged --init""}' @@ -214,6 +218,7 @@ jobs: needs: checkout-linux with: build-runs-on: electron-arc-linux-amd64-32core + check-runs-on: electron-arc-linux-amd64-8core test-runs-on: electron-arc-linux-arm64-4core build-container: '{""image"":""ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root"",""volumes"":[""/mnt/cross-instance-cache:/mnt/cross-instance-cache""]}' test-container: '{""image"":""ghcr.io/electron/test:arm32v7-${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root --privileged --init"",""volumes"":[""/home/runner/externals:/mnt/runner-externals""]}' @@ -234,6 +239,7 @@ jobs: needs: checkout-linux with: build-runs-on: electron-arc-linux-amd64-32core + check-runs-on: electron-arc-linux-amd64-8core test-runs-on: electron-arc-linux-arm64-4core build-container: '{""image"":""ghcr.io/electron/build:${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root"",""volumes"":[""/mnt/cross-instance-cache:/mnt/cross-instance-cache""]}' test-container: '{""image"":""ghcr.io/electron/test:arm64v8-${{ needs.checkout-linux.outputs.build-image-sha }}"",""options"":""--user root --privileged --init""}' diff --git a/.github/workflows/pipeline-electron-build-and-test-and-nan.yml b/.github/workflows/pipeline-electron-build-and-test-and-nan.yml index 2e0792d5cb..543eac3a52 100644 --- a/.github/workflows/pipeline-electron-build-and-test-and-nan.yml +++ b/.github/workflows/pipeline-electron-build-and-test-and-nan.yml @@ -15,6 +15,10 @@ on: type: string description: 'What host to run the build' required: true + check-runs-on: + type: string + description: 'What host to run the gn-check' + required: true test-runs-on: type: string description: 'What host to run the tests on' @@ -77,7 +81,7 @@ jobs: with: target-platform: ${{ inputs.target-platform }} target-arch: ${{ inputs.target-arch }} - check-runs-on: ${{ inputs.build-runs-on }} + check-runs-on: ${{ inputs.check-runs-on }} check-container: ${{ inputs.build-container }} gn-build-type: ${{ inputs.gn-build-type }} is-asan: ${{ inputs.is-asan }} diff --git a/.github/workflows/pipeline-electron-build-and-test.yml b/.github/workflows/pipeline-electron-build-and-test.yml index 51eb9bd46c..9667b3143e 100644 --- a/.github/workflows/pipeline-electron-build-and-test.yml +++ b/.github/workflows/pipeline-electron-build-and-test.yml @@ -15,6 +15,10 @@ on: type: string description: 'What host to run the build' required: true + check-runs-on: + type: string + description: 'What host to run the gn-check' + required: true test-runs-on: type: string description: 'What host to run the tests on' @@ -83,7 +87,7 @@ jobs: with: target-platform: ${{ inputs.target-platform }} target-arch: ${{ inputs.target-arch }} - check-runs-on: ${{ inputs.build-runs-on }} + check-runs-on: ${{ inputs.check-runs-on }} check-container: ${{ inputs.build-container }} gn-build-type: ${{ inputs.gn-build-type }} is-asan: ${{ inputs.is-asan }}",build 1ffe7ee76b8c61d7ef6a0fc03eaff7debc2accc0,Alexey Kuzmin,2023-04-17 17:02:43,build: fix building with no PDF support (#38003),"diff --git a/shell/browser/extensions/api/resources_private/resources_private_api.cc b/shell/browser/extensions/api/resources_private/resources_private_api.cc index e6246ad8be..101293316f 100644 --- a/shell/browser/extensions/api/resources_private/resources_private_api.cc +++ b/shell/browser/extensions/api/resources_private/resources_private_api.cc @@ -9,7 +9,6 @@ #include ""base/values.h"" #include ""chrome/browser/browser_process.h"" -#include ""chrome/browser/pdf/pdf_extension_util.h"" #include ""chrome/common/extensions/api/resources_private.h"" #include ""chrome/grit/generated_resources.h"" #include ""components/strings/grit/components_strings.h"" @@ -20,6 +19,7 @@ #include ""ui/base/webui/web_ui_util.h"" #if BUILDFLAG(ENABLE_PDF) +#include ""chrome/browser/pdf/pdf_extension_util.h"" #include ""pdf/pdf_features.h"" #endif // BUILDFLAG(ENABLE_PDF) ",build 1eb398b328d304f227deef0e89ca0be7b9e20755,Shelley Vohr,2023-08-16 13:28:29,"fix: crash when calling `BrowserWindow.moveTop()` on modal children (#39499) fix: crash when calling moveTop() on modal children","diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 7c44cfbed1..b6ce683db3 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -812,7 +812,7 @@ bool NativeWindowMac::MoveAbove(const std::string& sourceId) { if (!webrtc::GetWindowOwnerPid(window_id)) return false; - if (!parent()) { + if (!parent() || is_modal()) { [window_ orderWindow:NSWindowAbove relativeTo:window_id]; } else { NSWindow* other_window = [NSApp windowWithWindowNumber:window_id]; @@ -823,10 +823,11 @@ bool NativeWindowMac::MoveAbove(const std::string& sourceId) { } void NativeWindowMac::MoveTop() { - if (!parent()) + if (!parent() || is_modal()) { [window_ orderWindow:NSWindowAbove relativeTo:0]; - else + } else { ReorderChildWindowAbove(window_, nullptr); + } } void NativeWindowMac::SetResizable(bool resizable) { diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index bf7ddada85..c2057bce7b 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1283,6 +1283,8 @@ describe('BrowserWindow module', () => { }); describe('BrowserWindow.moveTop()', () => { + afterEach(closeAllWindows); + it('should not steal focus', async () => { const posDelta = 50; const wShownInactive = once(w, 'show'); @@ -1324,6 +1326,15 @@ describe('BrowserWindow module', () => { await closeWindow(otherWindow, { assertNotWindows: false }); expect(BrowserWindow.getAllWindows()).to.have.lengthOf(1); }); + + it('should not crash when called on a modal child window', async () => { + const shown = once(w, 'show'); + w.show(); + await shown; + + const child = new BrowserWindow({ modal: true, parent: w }); + expect(() => { child.moveTop(); }).to.not.throw(); + }); }); describe('BrowserWindow.moveAbove(mediaSourceId)', () => {",fix 47beca1d2af622ffe33a0c5261f1e54cae40cdbb,Jade Flute,2023-10-10 18:43:18,"docs: fix typo in session docs (#40138) Fix typos for doc Signed-off-by: zhangdiandian <1635468471@qq.com>","diff --git a/docs/api/session.md b/docs/api/session.md index 4a77828fac..8eb65c582d 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -1050,7 +1050,7 @@ To clear the handler, call `setDevicePermissionHandler(null)`. This handler can be used to provide default permissioning to devices without first calling for permission to devices (eg via `navigator.hid.requestDevice`). If this handler is not defined, the default device permissions as granted through device selection (eg via `navigator.hid.requestDevice`) will be used. -Additionally, the default behavior of Electron is to store granted device permision in memory. +Additionally, the default behavior of Electron is to store granted device permission in memory. If longer term storage is needed, a developer can store granted device permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`. ",docs 6395898a7925cb288b5746042ad85f7cc37d6f2c,Shelley Vohr,2023-02-22 10:03:46,"refactor: use associated `v8::Context` for event setup (#37355) refactor: use associated v8::Context for event setup","diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index dafe1a932c..96cebf0553 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -270,7 +270,7 @@ void ElectronBrowserMainParts::PostEarlyInitialization() { v8::HandleScope scope(js_env_->isolate()); - node_bindings_->Initialize(); + node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext()); // Create the global environment. node::Environment* env = node_bindings_->CreateEnvironment( js_env_->isolate()->GetCurrentContext(), js_env_->platform()); diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 922840dc0d..28447a2775 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -415,7 +415,7 @@ void NodeBindings::SetNodeCliFlags() { } } -void NodeBindings::Initialize() { +void NodeBindings::Initialize(v8::Local context) { TRACE_EVENT0(""electron"", ""NodeBindings::Initialize""); // Open node's error reporting system for browser process. @@ -463,8 +463,7 @@ void NodeBindings::Initialize() { SetErrorMode(GetErrorMode() & ~SEM_NOGPFAULTERRORBOX); #endif - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - gin_helper::internal::Event::GetConstructor(isolate->GetCurrentContext()); + gin_helper::internal::Event::GetConstructor(context); g_is_initialized = true; } diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index 1f559f6e39..5476434f96 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -85,7 +85,7 @@ class NodeBindings { virtual ~NodeBindings(); // Setup V8, libuv. - void Initialize(); + void Initialize(v8::Local context); void SetNodeCliFlags(); diff --git a/shell/renderer/electron_renderer_client.cc b/shell/renderer/electron_renderer_client.cc index bb1fd5f748..bbdea3035c 100644 --- a/shell/renderer/electron_renderer_client.cc +++ b/shell/renderer/electron_renderer_client.cc @@ -76,7 +76,7 @@ void ElectronRendererClient::DidCreateScriptContext( if (!node_integration_initialized_) { node_integration_initialized_ = true; - node_bindings_->Initialize(); + node_bindings_->Initialize(renderer_context); node_bindings_->PrepareEmbedThread(); } diff --git a/shell/services/node/node_service.cc b/shell/services/node/node_service.cc index 7ce0fcb552..58a1a9a2e0 100644 --- a/shell/services/node/node_service.cc +++ b/shell/services/node/node_service.cc @@ -47,7 +47,7 @@ void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) { v8::HandleScope scope(js_env_->isolate()); - node_bindings_->Initialize(); + node_bindings_->Initialize(js_env_->isolate()->GetCurrentContext()); // Append program path for process.argv0 auto program = base::CommandLine::ForCurrentProcess()->GetProgram();",refactor e8fd5fd3a8250d44a0665ca18da34cb09ea30677,Samuel Maddock,2023-06-09 12:57:57,"fix: WCO transparent background (#38693) * fix: WCO transparency * doc: wco color transparency * fix: transparent buttons when calling setTitleBarOverlay","diff --git a/docs/tutorial/window-customization.md b/docs/tutorial/window-customization.md index 6f32158811..1b013f426f 100644 --- a/docs/tutorial/window-customization.md +++ b/docs/tutorial/window-customization.md @@ -115,7 +115,7 @@ const win = new BrowserWindow({ }) ``` -On either platform `titleBarOverlay` can also be an object. On both macOS and Windows, the height of the overlay can be specified with the `height` property. On Windows, the color of the overlay and its symbols can be specified using the `color` and `symbolColor` properties respectively. +On either platform `titleBarOverlay` can also be an object. On both macOS and Windows, the height of the overlay can be specified with the `height` property. On Windows, the color of the overlay and its symbols can be specified using the `color` and `symbolColor` properties respectively. `rgba()`, `hsla()`, and `#RRGGBBAA` color formats are supported to apply transparency. If a color option is not specified, the color will default to its system color for the window control buttons. Similarly, if the height option is not specified it will default to the default height: @@ -136,10 +136,6 @@ const win = new BrowserWindow({ > color and dimension values from a renderer using a set of readonly > [JavaScript APIs][overlay-javascript-apis] and [CSS Environment Variables][overlay-css-env-vars]. -### Limitations - -* Transparent colors are currently not supported. Progress updates for this feature can be found in PR [#33567](https://github.com/electron/electron/issues/33567). - ## Create transparent windows By setting the `transparent` option to `true`, you can make a fully transparent window. diff --git a/shell/browser/ui/views/win_caption_button_container.cc b/shell/browser/ui/views/win_caption_button_container.cc index 99a7fc4bc0..004416dbec 100644 --- a/shell/browser/ui/views/win_caption_button_container.cc +++ b/shell/browser/ui/views/win_caption_button_container.cc @@ -13,6 +13,7 @@ #include ""shell/browser/ui/views/win_caption_button.h"" #include ""shell/browser/ui/views/win_frame_view.h"" #include ""ui/base/l10n/l10n_util.h"" +#include ""ui/compositor/layer.h"" #include ""ui/strings/grit/ui_strings.h"" #include ""ui/views/background.h"" #include ""ui/views/layout/flex_layout.h"" @@ -129,9 +130,7 @@ void WinCaptionButtonContainer::AddedToWidget() { UpdateButtons(); if (frame_view_->window()->IsWindowControlsOverlayEnabled()) { - SetBackground(views::CreateSolidBackground( - frame_view_->window()->overlay_button_color())); - SetPaintToLayer(); + UpdateBackground(); } } @@ -146,6 +145,16 @@ void WinCaptionButtonContainer::OnWidgetBoundsChanged( UpdateButtons(); } +void WinCaptionButtonContainer::UpdateBackground() { + const SkColor bg_color = frame_view_->window()->overlay_button_color(); + const SkAlpha theme_alpha = SkColorGetA(bg_color); + SetBackground(views::CreateSolidBackground(bg_color)); + SetPaintToLayer(); + + if (theme_alpha < SK_AlphaOPAQUE) + layer()->SetFillsBoundsOpaquely(false); +} + void WinCaptionButtonContainer::UpdateButtons() { const bool is_maximized = frame_view_->frame()->IsMaximized(); restore_button_->SetVisible(is_maximized); diff --git a/shell/browser/ui/views/win_caption_button_container.h b/shell/browser/ui/views/win_caption_button_container.h index 90c5973491..0c106dd8e4 100644 --- a/shell/browser/ui/views/win_caption_button_container.h +++ b/shell/browser/ui/views/win_caption_button_container.h @@ -41,6 +41,9 @@ class WinCaptionButtonContainer : public views::View, gfx::Size GetButtonSize() const; void SetButtonSize(gfx::Size size); + // Sets caption button container background color. + void UpdateBackground(); + // Sets caption button visibility and enabled state based on window state. // Only one of maximize or restore button should ever be visible at the same // time, and both are disabled in tablet UI mode. diff --git a/shell/browser/ui/views/win_frame_view.cc b/shell/browser/ui/views/win_frame_view.cc index 6e5cfe5b6b..7525a5fd1c 100644 --- a/shell/browser/ui/views/win_frame_view.cc +++ b/shell/browser/ui/views/win_frame_view.cc @@ -59,8 +59,7 @@ void WinFrameView::InvalidateCaptionButtons() { if (!caption_button_container_) return; - caption_button_container_->SetBackground( - views::CreateSolidBackground(window()->overlay_button_color())); + caption_button_container_->UpdateBackground(); caption_button_container_->InvalidateLayout(); caption_button_container_->SchedulePaint(); }",fix bc957e394594642c0f49b5e9ef5841622c2f50d7,Alexey Kuzmin,2023-05-04 00:14:46,"test: use `await` to call ""closeWindow"" (#38166) * test: wait for an async ""closeWindow"" call * fixup! test: wait for an async ""closeWindow"" call","diff --git a/spec/api-web-contents-view-spec.ts b/spec/api-web-contents-view-spec.ts index 5fe8f849a7..21ce0779f8 100644 --- a/spec/api-web-contents-view-spec.ts +++ b/spec/api-web-contents-view-spec.ts @@ -4,7 +4,11 @@ import { BaseWindow, WebContentsView } from 'electron/main'; describe('WebContentsView', () => { let w: BaseWindow; - afterEach(() => closeWindow(w as any).then(() => { w = null as unknown as BaseWindow; })); + + afterEach(async () => { + await closeWindow(w as any); + w = null as unknown as BaseWindow; + }); it('can be used as content view', () => { w = new BaseWindow({ show: false }); diff --git a/spec/extensions-spec.ts b/spec/extensions-spec.ts index 5e4db3b3d2..72e5827735 100644 --- a/spec/extensions-spec.ts +++ b/spec/extensions-spec.ts @@ -559,9 +559,10 @@ describe('chrome extensions', () => { }); }); - afterEach(() => { + afterEach(async () => { removeAllExtensions(); - return closeWindow(w).then(() => { w = null as unknown as BrowserWindow; }); + await closeWindow(w); + w = null as unknown as BrowserWindow; }); it('should run content script at document_start', async () => {",test 7621e7cff7efea4c348cb2d1c0ca8b8ed6b8c832,South Drifted,2024-04-24 01:14:26,"docs: Windows typo in Tutorial document (#41896) Update tutorial-6-publishing-updating.md","diff --git a/docs/tutorial/tutorial-6-publishing-updating.md b/docs/tutorial/tutorial-6-publishing-updating.md index 81fb7deda1..a57196b1d1 100644 --- a/docs/tutorial/tutorial-6-publishing-updating.md +++ b/docs/tutorial/tutorial-6-publishing-updating.md @@ -152,7 +152,7 @@ command that can handle the version bumping and tagging for you. #### Bonus: Publishing in GitHub Actions Publishing locally can be painful, especially because you can only create distributables -for your host operating system (i.e. you can't publish a Window `.exe` file from macOS). +for your host operating system (i.e. you can't publish a Windows `.exe` file from macOS). A solution for this would be to publish your app via automation workflows such as [GitHub Actions][], which can run tasks in the",docs bf1cc1aeb2a55a07d8ed794df1e6a630221bd69a,Jeremy Spiegel,2023-03-14 06:41:34,"fix: don't set delegate for `QLPreviewPanel` (#37530) fix: don't set delegate for QLPreviewPanel","diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 8a0c776761..03cde56de4 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -276,12 +276,10 @@ void SwizzleMouseDown(NSView* frame_view, } - (void)beginPreviewPanelControl:(QLPreviewPanel*)panel { - panel.delegate = [self delegate]; panel.dataSource = static_cast>([self delegate]); } - (void)endPreviewPanelControl:(QLPreviewPanel*)panel { - panel.delegate = nil; panel.dataSource = nil; } diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 298379a9fd..f41a8b5a52 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -5275,6 +5275,22 @@ describe('BrowserWindow module', () => { w.closeFilePreview(); }).to.not.throw(); }); + + it('should not call BrowserWindow show event', async () => { + const w = new BrowserWindow({ show: false }); + const shown = once(w, 'show'); + w.show(); + await shown; + + let showCalled = false; + w.on('show', () => { + showCalled = true; + }); + + w.previewFile(__filename); + await setTimeout(500); + expect(showCalled).to.equal(false, 'should not have called show twice'); + }); }); // TODO (jkleinsc) renable these tests on mas arm64",fix 865b0499bbdd918708b6b1b66fcabf07d3d2fdbb,Shelley Vohr,2024-05-09 15:51:42,"refactor: use `//ui/shell_dialogs` on Linux (#42045) * refactor: use //ui/shell_dialogs on Linux * fix: add proper filtering * fix: add support for missing dialog features to //shell_dialogs * fix: parent_window could be null * chore: cleanup patch * fix: use a OnceCallback in the sync implementation * chore: remove stray debuglog * Apply suggestions from code review Co-authored-by: Charles Kerr * refactor: use settings struct * fix: show hidden file property checking * chore: changes from review * fix: multi selection for dialogs --------- Co-authored-by: Charles Kerr ","diff --git a/BUILD.gn b/BUILD.gn index 8873185b6a..5cfa6d959d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -81,18 +81,11 @@ if (is_linux) { ] } - # Generates electron_gtk_stubs.h header which contains - # stubs for extracting function ptrs from the gtk library. - # Function signatures for which stubs are required should be - # declared in electron_gtk.sigs, currently this file contains - # signatures for the functions used with native file chooser - # implementation. In future, this file can be extended to contain - # gtk4 stubs to switch gtk version in runtime. + # Generates headers which contain stubs for extracting function ptrs + # from the gtk library. Function signatures for which stubs are + # required should be declared in the sig files. generate_stubs(""electron_gtk_stubs"") { - sigs = [ - ""shell/browser/ui/electron_gdk_pixbuf.sigs"", - ""shell/browser/ui/electron_gtk.sigs"", - ] + sigs = [ ""shell/browser/ui/electron_gdk_pixbuf.sigs"" ] extra_header = ""shell/browser/ui/electron_gtk.fragment"" output_name = ""electron_gtk_stubs"" public_deps = [ ""//ui/gtk:gtk_config"" ] diff --git a/filenames.gni b/filenames.gni index e25ed8ea48..a8fce610ab 100644 --- a/filenames.gni +++ b/filenames.gni @@ -34,7 +34,7 @@ filenames = { ""shell/browser/notifications/linux/notification_presenter_linux.h"", ""shell/browser/relauncher_linux.cc"", ""shell/browser/ui/electron_desktop_window_tree_host_linux.cc"", - ""shell/browser/ui/file_dialog_gtk.cc"", + ""shell/browser/ui/file_dialog_linux.cc"", ""shell/browser/ui/gtk/menu_gtk.cc"", ""shell/browser/ui/gtk/menu_gtk.h"", ""shell/browser/ui/gtk/menu_util.cc"", diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 1e3a430f36..cd97a83b93 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,3 +128,4 @@ fix_getcursorscreenpoint_wrongly_returns_0_0.patch fix_add_support_for_skipping_first_2_no-op_refreshes_in_thumb_cap.patch refactor_expose_file_system_access_blocklist.patch revert_power_update_trace_counter_in_power_monitor.patch +feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch diff --git a/patches/chromium/feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch b/patches/chromium/feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch new file mode 100644 index 0000000000..860e930fe1 --- /dev/null +++ b/patches/chromium/feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch @@ -0,0 +1,243 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Sun, 5 May 2024 09:17:17 +0000 +Subject: feat: add support for missing dialog features to //shell_dialogs + +This CL adds support for the following features to //shell_dialogs: +* buttonLabel - Custom label for the confirmation button. +* showHiddenFiles - Show hidden files in dialog. +* showOverwriteConfirmation - Whether the user will be presented a confirmation dialog if the user types a file name that already exists. + +This may be partially upstreamed to Chromium in the future. + +diff --git a/ui/gtk/select_file_dialog_linux_gtk.cc b/ui/gtk/select_file_dialog_linux_gtk.cc +index 698f97b23f851c02af037880585c82d4494da63f..0a3b701a701289a2124214e7421a6383ff7f0320 100644 +--- a/ui/gtk/select_file_dialog_linux_gtk.cc ++++ b/ui/gtk/select_file_dialog_linux_gtk.cc +@@ -243,6 +243,10 @@ void SelectFileDialogLinuxGtk::SelectFileImpl( + + std::string title_string = base::UTF16ToUTF8(title); + ++ ExtraSettings extra_settings; ++ if (params) ++ extra_settings = *(static_cast(params)); ++ + set_file_type_index(file_type_index); + if (file_types) + set_file_types(*file_types); +@@ -261,23 +265,23 @@ void SelectFileDialogLinuxGtk::SelectFileImpl( + case SELECT_UPLOAD_FOLDER: + case SELECT_EXISTING_FOLDER: + dialog = CreateSelectFolderDialog(type, title_string, default_path, +- owning_window); ++ owning_window, extra_settings); + connect(""response"", + &SelectFileDialogLinuxGtk::OnSelectSingleFolderDialogResponse); + break; + case SELECT_OPEN_FILE: +- dialog = CreateFileOpenDialog(title_string, default_path, owning_window); ++ dialog = CreateFileOpenDialog(title_string, default_path, owning_window, extra_settings); + connect(""response"", + &SelectFileDialogLinuxGtk::OnSelectSingleFileDialogResponse); + break; + case SELECT_OPEN_MULTI_FILE: + dialog = +- CreateMultiFileOpenDialog(title_string, default_path, owning_window); ++ CreateMultiFileOpenDialog(title_string, default_path, owning_window, extra_settings); + connect(""response"", + &SelectFileDialogLinuxGtk::OnSelectMultiFileDialogResponse); + break; + case SELECT_SAVEAS_FILE: +- dialog = CreateSaveAsDialog(title_string, default_path, owning_window); ++ dialog = CreateSaveAsDialog(title_string, default_path, owning_window, extra_settings); + connect(""response"", + &SelectFileDialogLinuxGtk::OnSelectSingleFileDialogResponse); + break; +@@ -412,10 +416,14 @@ void SelectFileDialogLinuxGtk::FileNotSelected(GtkWidget* dialog) { + GtkWidget* SelectFileDialogLinuxGtk::CreateFileOpenHelper( + const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent) { ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings) { ++ const char* button_label = settings.button_label.empty() ++ ? GetOpenLabel() ++ : settings.button_label.c_str(); + GtkWidget* dialog = GtkFileChooserDialogNew( + title.c_str(), nullptr, GTK_FILE_CHOOSER_ACTION_OPEN, GetCancelLabel(), +- GTK_RESPONSE_CANCEL, GetOpenLabel(), GTK_RESPONSE_ACCEPT); ++ GTK_RESPONSE_CANCEL, button_label, GTK_RESPONSE_ACCEPT); + SetGtkTransientForAura(dialog, parent); + AddFilters(GTK_FILE_CHOOSER(dialog)); + +@@ -431,6 +439,8 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateFileOpenHelper( + GtkFileChooserSetCurrentFolder(GTK_FILE_CHOOSER(dialog), + *last_opened_path()); + } ++ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), ++ settings.show_hidden); + return dialog; + } + +@@ -438,7 +448,8 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateSelectFolderDialog( + Type type, + const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent) { ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings) { + std::string title_string = title; + if (title_string.empty()) { + title_string = +@@ -446,11 +457,14 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateSelectFolderDialog( + ? l10n_util::GetStringUTF8(IDS_SELECT_UPLOAD_FOLDER_DIALOG_TITLE) + : l10n_util::GetStringUTF8(IDS_SELECT_FOLDER_DIALOG_TITLE); + } +- std::string accept_button_label = +- (type == SELECT_UPLOAD_FOLDER) +- ? l10n_util::GetStringUTF8( +- IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) +- : GetOpenLabel(); ++ ++ std::string accept_button_label = settings.button_label; ++ if (accept_button_label.empty()) { ++ accept_button_label = (type == SELECT_UPLOAD_FOLDER) ++ ? l10n_util::GetStringUTF8( ++ IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) ++ : GetOpenLabel(); ++ } + + GtkWidget* dialog = GtkFileChooserDialogNew( + title_string.c_str(), nullptr, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, +@@ -472,19 +486,21 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateSelectFolderDialog( + gtk_file_filter_add_mime_type(only_folders, ""inode/directory""); + gtk_file_filter_add_mime_type(only_folders, ""text/directory""); + gtk_file_chooser_add_filter(chooser, only_folders); +- gtk_file_chooser_set_select_multiple(chooser, FALSE); ++ gtk_file_chooser_set_select_multiple(chooser, settings.allow_multiple_selection); ++ gtk_file_chooser_set_show_hidden(chooser, settings.show_hidden); + return dialog; + } + + GtkWidget* SelectFileDialogLinuxGtk::CreateFileOpenDialog( + const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent) { ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings) { + std::string title_string = + !title.empty() ? title + : l10n_util::GetStringUTF8(IDS_OPEN_FILE_DIALOG_TITLE); + +- GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent); ++ GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent, settings); + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); + return dialog; + } +@@ -492,12 +508,14 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateFileOpenDialog( + GtkWidget* SelectFileDialogLinuxGtk::CreateMultiFileOpenDialog( + const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent) { ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings) { + std::string title_string = + !title.empty() ? title + : l10n_util::GetStringUTF8(IDS_OPEN_FILES_DIALOG_TITLE); + +- GtkWidget* dialog = CreateFileOpenHelper(title_string, default_path, parent); ++ GtkWidget* dialog = ++ CreateFileOpenHelper(title_string, default_path, parent, settings); + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); + return dialog; + } +@@ -505,14 +523,17 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateMultiFileOpenDialog( + GtkWidget* SelectFileDialogLinuxGtk::CreateSaveAsDialog( + const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent) { ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings) { + std::string title_string = + !title.empty() ? title + : l10n_util::GetStringUTF8(IDS_SAVE_AS_DIALOG_TITLE); +- ++ const char* button_label = settings.button_label.empty() ++ ? GetSaveLabel() ++ : settings.button_label.c_str(); + GtkWidget* dialog = GtkFileChooserDialogNew( + title_string.c_str(), nullptr, GTK_FILE_CHOOSER_ACTION_SAVE, +- GetCancelLabel(), GTK_RESPONSE_CANCEL, GetSaveLabel(), ++ GetCancelLabel(), GTK_RESPONSE_CANCEL, button_label, + GTK_RESPONSE_ACCEPT); + SetGtkTransientForAura(dialog, parent); + +@@ -538,9 +559,10 @@ GtkWidget* SelectFileDialogLinuxGtk::CreateSaveAsDialog( + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE); + // Overwrite confirmation is always enabled in GTK4. + if (!GtkCheckVersion(4)) { +- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), +- TRUE); ++ gtk_file_chooser_set_do_overwrite_confirmation( ++ GTK_FILE_CHOOSER(dialog), settings.show_overwrite_confirmation); + } ++ gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), settings.show_hidden); + return dialog; + } + +diff --git a/ui/gtk/select_file_dialog_linux_gtk.h b/ui/gtk/select_file_dialog_linux_gtk.h +index 53ae15f14c45ee72abdae172fc4555c9e4b3ff9a..af181afd9db1351cd886ba24dd651c7bf2f8a716 100644 +--- a/ui/gtk/select_file_dialog_linux_gtk.h ++++ b/ui/gtk/select_file_dialog_linux_gtk.h +@@ -15,6 +15,13 @@ + + namespace gtk { + ++struct ExtraSettings { ++ std::string button_label; ++ bool show_overwrite_confirmation = true; ++ bool show_hidden = false; ++ bool allow_multiple_selection = false; ++}; ++ + // Implementation of SelectFileDialog that shows a Gtk common dialog for + // choosing a file or folder. This acts as a modal dialog. + class SelectFileDialogLinuxGtk : public ui::SelectFileDialogLinux, +@@ -90,19 +97,23 @@ class SelectFileDialogLinuxGtk : public ui::SelectFileDialogLinux, + GtkWidget* CreateSelectFolderDialog(Type type, + const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent); ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings); + + GtkWidget* CreateFileOpenDialog(const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent); ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings); + + GtkWidget* CreateMultiFileOpenDialog(const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent); ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings); + + GtkWidget* CreateSaveAsDialog(const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent); ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings); + + // Removes and returns the |params| associated with |dialog| from + // |params_map_|. +@@ -121,7 +132,8 @@ class SelectFileDialogLinuxGtk : public ui::SelectFileDialogLinux, + // Common function for CreateFileOpenDialog and CreateMultiFileOpenDialog. + GtkWidget* CreateFileOpenHelper(const std::string& title, + const base::FilePath& default_path, +- gfx::NativeWindow parent); ++ gfx::NativeWindow parent, ++ const ExtraSettings& settings); + + // Callback for when the user responds to a Save As or Open File dialog. + void OnSelectSingleFileDialogResponse(GtkWidget* dialog, int response_id); diff --git a/patches/chromium/make_gtk_getlibgtk_public.patch b/patches/chromium/make_gtk_getlibgtk_public.patch index 3bd5bad153..a63d5783f1 100644 --- a/patches/chromium/make_gtk_getlibgtk_public.patch +++ b/patches/chromium/make_gtk_getlibgtk_public.patch @@ -1,13 +1,13 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 7 Apr 2022 20:30:16 +0900 -Subject: Make gtk::GetLibGtk and gtk::GetLibGdkPixbuf public +Subject: Make gtk::GetLibGdkPixbuf public -Allows embedders to get a handle to the gtk and -gdk_pixbuf libraries already loaded in the process. +Allows embedders to get a handle to the gdk_pixbuf +library already loaded in the process. diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc -index 3a4b856ec5c2f5c3ede6e8f6db7858498b737702..a308249c66c01856df84e64bda0411dbcbd96457 100644 +index 3a4b856ec5c2f5c3ede6e8f6db7858498b737702..e410998c4197c98947d2e1ad8bebe12c70379358 100644 --- a/ui/gtk/gtk_compat.cc +++ b/ui/gtk/gtk_compat.cc @@ -66,11 +66,6 @@ void* GetLibGio() { @@ -22,20 +22,7 @@ index 3a4b856ec5c2f5c3ede6e8f6db7858498b737702..a308249c66c01856df84e64bda0411db void* GetLibGdk3() { static void* libgdk3 = DlOpen(""libgdk-3.so.0""); return libgdk3; -@@ -86,12 +81,6 @@ void* GetLibGtk4(bool check = true) { - return libgtk4; - } - --void* GetLibGtk() { -- if (GtkCheckVersion(4)) -- return GetLibGtk4(); -- return GetLibGtk3(); --} -- - bool LoadGtk3() { - if (!GetLibGtk3(false)) - return false; -@@ -134,6 +123,17 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { +@@ -134,6 +129,11 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) { } // namespace @@ -43,29 +30,20 @@ index 3a4b856ec5c2f5c3ede6e8f6db7858498b737702..a308249c66c01856df84e64bda0411db + static void* libgdk_pixbuf = DlOpen(""libgdk_pixbuf-2.0.so.0""); + return libgdk_pixbuf; +} -+ -+void* GetLibGtk() { -+ if (GtkCheckVersion(4)) -+ return GetLibGtk4(); -+ return GetLibGtk3(); -+} + bool LoadGtk() { static bool loaded = LoadGtkImpl(); return loaded; diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h -index 19f73cc179d82a3729c5fe37883460ac05f4d0c3..cdb67c98291f145f89f76a50b31bf00318648518 100644 +index 19f73cc179d82a3729c5fe37883460ac05f4d0c3..17aa0b95bd6158ed02c03095c1687185a057fe62 100644 --- a/ui/gtk/gtk_compat.h +++ b/ui/gtk/gtk_compat.h -@@ -41,6 +41,12 @@ using SkColor = uint32_t; +@@ -41,6 +41,9 @@ using SkColor = uint32_t; namespace gtk { +// Get handle to the currently loaded gdk_pixbuf library in the process. +void* GetLibGdkPixbuf(); -+ -+// Get handle to the currently loaded gtk library in the process. -+void* GetLibGtk(); + // Loads libgtk and related libraries and returns true on success. bool LoadGtk(); diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index c843ecbbce..842d730839 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -398,12 +398,6 @@ void ElectronBrowserMainParts::ToolkitInitialized() { CHECK(linux_ui); linux_ui_getter_ = std::make_unique(); - // Try loading gtk symbols used by Electron. - electron::InitializeElectron_gtk(gtk::GetLibGtk()); - if (!electron::IsElectron_gtkInitialized()) { - electron::UninitializeElectron_gtk(); - } - electron::InitializeElectron_gdk_pixbuf(gtk::GetLibGdkPixbuf()); CHECK(electron::IsElectron_gdk_pixbufInitialized()) << ""Failed to initialize libgdk_pixbuf-2.0.so.0""; diff --git a/shell/browser/ui/file_dialog_gtk.cc b/shell/browser/ui/file_dialog_gtk.cc deleted file mode 100644 index ffe2e7a86f..0000000000 --- a/shell/browser/ui/file_dialog_gtk.cc +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include -#include - -#include ""base/files/file_util.h"" -#include ""base/functional/bind.h"" -#include ""base/functional/callback.h"" -#include ""base/memory/raw_ptr.h"" -#include ""base/memory/raw_ptr_exclusion.h"" -#include ""base/strings/string_util.h"" -#include ""electron/electron_gtk_stubs.h"" -#include ""shell/browser/javascript_environment.h"" -#include ""shell/browser/native_window_views.h"" -#include ""shell/browser/ui/file_dialog.h"" -#include ""shell/browser/ui/gtk_util.h"" -#include ""shell/common/gin_converters/file_path_converter.h"" -#include ""shell/common/thread_restrictions.h"" -#include ""ui/base/glib/scoped_gsignal.h"" -#include ""ui/gtk/gtk_ui.h"" // nogncheck -#include ""ui/gtk/gtk_util.h"" // nogncheck - -namespace file_dialog { - -DialogSettings::DialogSettings() = default; -DialogSettings::DialogSettings(const DialogSettings&) = default; -DialogSettings::~DialogSettings() = default; - -namespace { - -static const int kPreviewWidth = 256; -static const int kPreviewHeight = 512; - -std::string MakeCaseInsensitivePattern(const std::string& extension) { - // If the extension is the ""all files"" extension, no change needed. - if (extension == ""*"") - return extension; - - std::string pattern(""*.""); - for (char ch : extension) { - if (!base::IsAsciiAlpha(ch)) { - pattern.push_back(ch); - continue; - } - - pattern.push_back('['); - pattern.push_back(base::ToLowerASCII(ch)); - pattern.push_back(base::ToUpperASCII(ch)); - pattern.push_back(']'); - } - - return pattern; -} - -class FileChooserDialog { - public: - FileChooserDialog(GtkFileChooserAction action, const DialogSettings& settings) - : parent_( - static_cast(settings.parent_window)), - filters_(settings.filters) { - auto label = settings.button_label; - - if (electron::IsElectron_gtkInitialized()) { - dialog_ = GTK_FILE_CHOOSER(gtk_file_chooser_native_new( - settings.title.c_str(), nullptr, action, - label.empty() ? nullptr : label.c_str(), nullptr)); - } else { - const char* confirm_text = gtk_util::GetOkLabel(); - if (!label.empty()) - confirm_text = label.c_str(); - else if (action == GTK_FILE_CHOOSER_ACTION_SAVE) - confirm_text = gtk_util::GetSaveLabel(); - else if (action == GTK_FILE_CHOOSER_ACTION_OPEN) - confirm_text = gtk_util::GetOpenLabel(); - - dialog_ = GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new( - settings.title.c_str(), nullptr, action, gtk_util::GetCancelLabel(), - GTK_RESPONSE_CANCEL, confirm_text, GTK_RESPONSE_ACCEPT, nullptr)); - } - - if (parent_) { - parent_->SetEnabled(false); - if (electron::IsElectron_gtkInitialized()) { - gtk_native_dialog_set_modal(GTK_NATIVE_DIALOG(dialog_), TRUE); - } else { - gtk::SetGtkTransientForAura(GTK_WIDGET(dialog_), - parent_->GetNativeWindow()); - gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE); - } - } - - if (action == GTK_FILE_CHOOSER_ACTION_SAVE) - gtk_file_chooser_set_do_overwrite_confirmation(dialog_, TRUE); - if (action != GTK_FILE_CHOOSER_ACTION_OPEN) - gtk_file_chooser_set_create_folders(dialog_, TRUE); - - if (!settings.default_path.empty()) { - electron::ScopedAllowBlockingForElectron allow_blocking; - if (base::DirectoryExists(settings.default_path)) { - gtk_file_chooser_set_current_folder( - dialog_, settings.default_path.value().c_str()); - } else { - if (settings.default_path.IsAbsolute()) { - gtk_file_chooser_set_current_folder( - dialog_, settings.default_path.DirName().value().c_str()); - } - - gtk_file_chooser_set_current_name( - GTK_FILE_CHOOSER(dialog_), - settings.default_path.BaseName().value().c_str()); - } - } - - if (!settings.filters.empty()) - AddFilters(settings.filters); - - // GtkFileChooserNative does not support preview widgets through the - // org.freedesktop.portal.FileChooser portal. In the case of running through - // the org.freedesktop.portal.FileChooser portal, anything having to do with - // the update-preview signal or the preview widget will just be ignored. - if (!electron::IsElectron_gtkInitialized()) { - preview_ = gtk_image_new(); - signals_.emplace_back( - dialog_, ""update-preview"", - base::BindRepeating(&FileChooserDialog::OnUpdatePreview, - base::Unretained(this))); - gtk_file_chooser_set_preview_widget(dialog_, preview_); - } - } - - ~FileChooserDialog() { - if (electron::IsElectron_gtkInitialized()) { - gtk_native_dialog_destroy(GTK_NATIVE_DIALOG(dialog_)); - } else { - gtk_widget_destroy(GTK_WIDGET(dialog_)); - } - - if (parent_) - parent_->SetEnabled(true); - } - - // disable copy - FileChooserDialog(const FileChooserDialog&) = delete; - FileChooserDialog& operator=(const FileChooserDialog&) = delete; - - void SetupOpenProperties(int properties) { - const auto hasProp = [properties](OpenFileDialogProperty prop) { - return gboolean((properties & prop) != 0); - }; - auto* file_chooser = dialog(); - gtk_file_chooser_set_select_multiple(file_chooser, - hasProp(OPEN_DIALOG_MULTI_SELECTIONS)); - gtk_file_chooser_set_show_hidden(file_chooser, - hasProp(OPEN_DIALOG_SHOW_HIDDEN_FILES)); - } - - void SetupSaveProperties(int properties) { - const auto hasProp = [properties](SaveFileDialogProperty prop) { - return gboolean((properties & prop) != 0); - }; - auto* file_chooser = dialog(); - gtk_file_chooser_set_show_hidden(file_chooser, - hasProp(SAVE_DIALOG_SHOW_HIDDEN_FILES)); - gtk_file_chooser_set_do_overwrite_confirmation( - file_chooser, hasProp(SAVE_DIALOG_SHOW_OVERWRITE_CONFIRMATION)); - } - - void RunAsynchronous() { - signals_.emplace_back( - GTK_WIDGET(dialog_), ""response"", - base::BindRepeating(&FileChooserDialog::OnFileDialogResponse, - base::Unretained(this))); - if (electron::IsElectron_gtkInitialized()) { - gtk_native_dialog_show(GTK_NATIVE_DIALOG(dialog_)); - } else { - gtk_widget_show_all(GTK_WIDGET(dialog_)); - gtk::GtkUi::GetPlatform()->ShowGtkWindow(GTK_WINDOW(dialog_)); - } - } - - void RunSaveAsynchronous( - gin_helper::Promise promise) { - save_promise_ = - std::make_unique>( - std::move(promise)); - RunAsynchronous(); - } - - void RunOpenAsynchronous( - gin_helper::Promise promise) { - open_promise_ = - std::make_unique>( - std::move(promise)); - RunAsynchronous(); - } - - base::FilePath GetFileName() const { - gchar* filename = gtk_file_chooser_get_filename(dialog_); - const base::FilePath path(filename); - g_free(filename); - return path; - } - - std::vector GetFileNames() const { - std::vector paths; - auto* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog_)); - for (auto* iter = filenames; iter != nullptr; iter = iter->next) { - auto* filename = static_cast(iter->data); - paths.emplace_back(filename); - g_free(filename); - } - g_slist_free(filenames); - return paths; - } - - void OnFileDialogResponse(GtkWidget* widget, int response); - - GtkFileChooser* dialog() const { return dialog_; } - - private: - void AddFilters(const Filters& filters); - - raw_ptr parent_; - - RAW_PTR_EXCLUSION GtkFileChooser* dialog_; - RAW_PTR_EXCLUSION GtkWidget* preview_; - - Filters filters_; - std::unique_ptr> save_promise_; - std::unique_ptr> open_promise_; - - // Callback for when we update the preview for the selection. - void OnUpdatePreview(GtkFileChooser* chooser); - - std::vector signals_; -}; - -void FileChooserDialog::OnFileDialogResponse(GtkWidget* widget, int response) { - if (electron::IsElectron_gtkInitialized()) { - gtk_native_dialog_hide(GTK_NATIVE_DIALOG(dialog_)); - } else { - gtk_widget_hide(GTK_WIDGET(dialog_)); - } - v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); - v8::HandleScope scope(isolate); - if (save_promise_) { - auto dict = gin_helper::Dictionary::CreateEmpty(save_promise_->isolate()); - if (response == GTK_RESPONSE_ACCEPT) { - dict.Set(""canceled"", false); - dict.Set(""filePath"", GetFileName()); - } else { - dict.Set(""canceled"", true); - dict.Set(""filePath"", base::FilePath()); - } - save_promise_->Resolve(dict); - } else if (open_promise_) { - auto dict = gin_helper::Dictionary::CreateEmpty(open_promise_->isolate()); - if (response == GTK_RESPONSE_ACCEPT) { - dict.Set(""canceled"", false); - dict.Set(""filePaths"", GetFileNames()); - } else { - dict.Set(""canceled"", true); - dict.Set(""filePaths"", std::vector()); - } - open_promise_->Resolve(dict); - } - delete this; -} - -void FileChooserDialog::AddFilters(const Filters& filters) { - for (const auto& filter : filters) { - GtkFileFilter* gtk_filter = gtk_file_filter_new(); - - for (const auto& extension : filter.second) { - std::string pattern = MakeCaseInsensitivePattern(extension); - gtk_file_filter_add_pattern(gtk_filter, pattern.c_str()); - } - - gtk_file_filter_set_name(gtk_filter, filter.first.c_str()); - gtk_file_chooser_add_filter(dialog_, gtk_filter); - } -} - -bool CanPreview(const struct stat& st) { - // Only preview regular files; pipes may hang. - // See https://crbug.com/534754. - if (!S_ISREG(st.st_mode)) { - return false; - } - - // Don't preview huge files; they may crash. - // https://github.com/electron/electron/issues/31630 - // Setting an arbitrary filesize max t at 100 MB here. - constexpr off_t ArbitraryMax = 100000000ULL; - return st.st_size < ArbitraryMax; -} - -void FileChooserDialog::OnUpdatePreview(GtkFileChooser* chooser) { - CHECK(!electron::IsElectron_gtkInitialized()); - gchar* filename = gtk_file_chooser_get_preview_filename(chooser); - if (!filename) { - gtk_file_chooser_set_preview_widget_active(chooser, FALSE); - return; - } - - struct stat sb; - if (stat(filename, &sb) != 0 || !CanPreview(sb)) { - g_free(filename); - gtk_file_chooser_set_preview_widget_active(chooser, FALSE); - return; - } - - // This will preserve the image's aspect ratio. - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_size(filename, kPreviewWidth, - kPreviewHeight, nullptr); - g_free(filename); - if (pixbuf) { - gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); - g_object_unref(pixbuf); - } - gtk_file_chooser_set_preview_widget_active(chooser, pixbuf ? TRUE : FALSE); -} - -} // namespace - -void ShowFileDialog(const FileChooserDialog& dialog) { - // gtk_native_dialog_run() will call gtk_native_dialog_show() for us. - if (!electron::IsElectron_gtkInitialized()) { - gtk_widget_show_all(GTK_WIDGET(dialog.dialog())); - } -} - -int RunFileDialog(const FileChooserDialog& dialog) { - int response = 0; - if (electron::IsElectron_gtkInitialized()) { - response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(dialog.dialog())); - } else { - response = gtk_dialog_run(GTK_DIALOG(dialog.dialog())); - } - - return response; -} - -bool ShowOpenDialogSync(const DialogSettings& settings, - std::vector* paths) { - GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; - if (settings.properties & OPEN_DIALOG_OPEN_DIRECTORY) - action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; - FileChooserDialog open_dialog(action, settings); - open_dialog.SetupOpenProperties(settings.properties); - - ShowFileDialog(open_dialog); - - const int response = RunFileDialog(open_dialog); - if (response == GTK_RESPONSE_ACCEPT) { - *paths = open_dialog.GetFileNames(); - return true; - } - return false; -} - -void ShowOpenDialog(const DialogSettings& settings, - gin_helper::Promise promise) { - GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; - if (settings.properties & OPEN_DIALOG_OPEN_DIRECTORY) - action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; - FileChooserDialog* open_dialog = new FileChooserDialog(action, settings); - open_dialog->SetupOpenProperties(settings.properties); - open_dialog->RunOpenAsynchronous(std::move(promise)); -} - -bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path) { - FileChooserDialog save_dialog(GTK_FILE_CHOOSER_ACTION_SAVE, settings); - save_dialog.SetupSaveProperties(settings.properties); - - ShowFileDialog(save_dialog); - - const int response = RunFileDialog(save_dialog); - if (response == GTK_RESPONSE_ACCEPT) { - *path = save_dialog.GetFileName(); - return true; - } - return false; -} - -void ShowSaveDialog(const DialogSettings& settings, - gin_helper::Promise promise) { - FileChooserDialog* save_dialog = - new FileChooserDialog(GTK_FILE_CHOOSER_ACTION_SAVE, settings); - save_dialog->RunSaveAsynchronous(std::move(promise)); -} - -} // namespace file_dialog diff --git a/shell/browser/ui/file_dialog_linux.cc b/shell/browser/ui/file_dialog_linux.cc new file mode 100644 index 0000000000..336825a866 --- /dev/null +++ b/shell/browser/ui/file_dialog_linux.cc @@ -0,0 +1,258 @@ +// Copyright (c) 2024 Microsoft, GmbH. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include +#include + +#include ""base/files/file_util.h"" +#include ""base/functional/bind.h"" +#include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" +#include ""base/memory/raw_ptr_exclusion.h"" +#include ""base/run_loop.h"" +#include ""base/strings/string_util.h"" +#include ""base/strings/utf_string_conversions.h"" +#include ""shell/browser/javascript_environment.h"" +#include ""shell/browser/native_window_views.h"" +#include ""shell/browser/ui/file_dialog.h"" +#include ""shell/common/gin_converters/callback_converter.h"" +#include ""shell/common/gin_converters/file_path_converter.h"" +#include ""ui/gtk/select_file_dialog_linux_gtk.h"" // nogncheck +#include ""ui/shell_dialogs/select_file_dialog.h"" +#include ""ui/shell_dialogs/selected_file_info.h"" + +namespace file_dialog { + +DialogSettings::DialogSettings() = default; +DialogSettings::DialogSettings(const DialogSettings&) = default; +DialogSettings::~DialogSettings() = default; + +namespace { + +ui::SelectFileDialog::Type GetDialogType(int properties) { + if (properties & OPEN_DIALOG_OPEN_DIRECTORY) + return ui::SelectFileDialog::SELECT_FOLDER; + + if (properties & OPEN_DIALOG_MULTI_SELECTIONS) + return ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE; + + return ui::SelectFileDialog::SELECT_OPEN_FILE; +} + +ui::SelectFileDialog::FileTypeInfo GetFilterInfo(const Filters& filters) { + ui::SelectFileDialog::FileTypeInfo file_type_info; + + for (const auto& [name, extension_group] : filters) { + file_type_info.extension_description_overrides.push_back( + base::UTF8ToUTF16(name)); + + const bool has_all_files_wildcard = base::ranges::any_of( + extension_group, [](const auto& ext) { return ext == ""*""; }); + if (has_all_files_wildcard) { + file_type_info.include_all_files = true; + } else { + file_type_info.extensions.emplace_back(extension_group); + } + } + + return file_type_info; +} + +class FileChooserDialog : public ui::SelectFileDialog::Listener { + public: + enum class DialogType { OPEN, SAVE }; + + FileChooserDialog() { dialog_ = ui::SelectFileDialog::Create(this, nullptr); } + + ~FileChooserDialog() override = default; + + gtk::ExtraSettings GetExtraSettings(const DialogSettings& settings) { + gtk::ExtraSettings extra; + extra.button_label = settings.button_label; + extra.show_overwrite_confirmation = + settings.properties & SAVE_DIALOG_SHOW_OVERWRITE_CONFIRMATION; + extra.allow_multiple_selection = + settings.properties & OPEN_DIALOG_MULTI_SELECTIONS; + if (type_ == DialogType::SAVE) { + extra.show_hidden = settings.properties & SAVE_DIALOG_SHOW_HIDDEN_FILES; + } else { + extra.show_hidden = settings.properties & OPEN_DIALOG_SHOW_HIDDEN_FILES; + } + + return extra; + } + + void RunSaveDialogImpl(const DialogSettings& settings) { + type_ = DialogType::SAVE; + ui::SelectFileDialog::FileTypeInfo file_info = + GetFilterInfo(settings.filters); + auto extra_settings = GetExtraSettings(settings); + dialog_->SelectFile( + ui::SelectFileDialog::SELECT_SAVEAS_FILE, + base::UTF8ToUTF16(settings.title), settings.default_path, + &file_info /* file_types */, 0 /* file_type_index */, + base::FilePath::StringType() /* default_extension */, + settings.parent_window ? settings.parent_window->GetNativeWindow() + : nullptr, + static_cast(&extra_settings)); + } + + void RunSaveDialog(gin_helper::Promise promise, + const DialogSettings& settings) { + promise_ = std::move(promise); + RunSaveDialogImpl(settings); + } + + void RunSaveDialog(base::OnceCallback callback, + const DialogSettings& settings) { + callback_ = std::move(callback); + RunSaveDialogImpl(settings); + } + + void RunOpenDialogImpl(const DialogSettings& settings) { + type_ = DialogType::OPEN; + ui::SelectFileDialog::FileTypeInfo file_info = + GetFilterInfo(settings.filters); + auto extra_settings = GetExtraSettings(settings); + dialog_->SelectFile( + GetDialogType(settings.properties), base::UTF8ToUTF16(settings.title), + settings.default_path, &file_info, 0 /* file_type_index */, + base::FilePath::StringType() /* default_extension */, + settings.parent_window ? settings.parent_window->GetNativeWindow() + : nullptr, + static_cast(&extra_settings)); + } + + void RunOpenDialog(gin_helper::Promise promise, + const DialogSettings& settings) { + promise_ = std::move(promise); + RunOpenDialogImpl(settings); + } + + void RunOpenDialog(base::OnceCallback callback, + const DialogSettings& settings) { + callback_ = std::move(callback); + RunOpenDialogImpl(settings); + } + + void FileSelected(const ui::SelectedFileInfo& file, + int index, + void* params) override { + v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); + v8::HandleScope scope(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); + dict.Set(""canceled"", false); + if (type_ == DialogType::SAVE) { + dict.Set(""filePath"", file.file_path); + } else { + dict.Set(""filePaths"", std::vector{file.file_path}); + } + + if (callback_) { + std::move(callback_).Run(dict); + } else { + promise_.Resolve(dict); + } + + delete this; + } + + void MultiFilesSelected(const std::vector& files, + void* params) override { + v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); + v8::HandleScope scope(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); + dict.Set(""canceled"", false); + dict.Set(""filePaths"", ui::SelectedFileInfoListToFilePathList(files)); + + if (callback_) { + std::move(callback_).Run(dict); + } else { + promise_.Resolve(dict); + } + + delete this; + } + + void FileSelectionCanceled(void* params) override { + v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); + v8::HandleScope scope(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); + dict.Set(""canceled"", true); + if (type_ == DialogType::SAVE) { + dict.Set(""filePath"", base::FilePath()); + } else { + dict.Set(""filePaths"", std::vector()); + } + + if (callback_) { + std::move(callback_).Run(dict); + } else { + promise_.Resolve(dict); + } + + delete this; + } + + private: + DialogType type_; + scoped_refptr dialog_; + base::OnceCallback callback_; + gin_helper::Promise promise_; +}; + +} // namespace + +bool ShowOpenDialogSync(const DialogSettings& settings, + std::vector* paths) { + v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Promise promise(isolate); + + base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); + auto cb = base::BindOnce( + [](base::RepeatingClosure cb, std::vector* file_paths, + gin_helper::Dictionary result) { + result.Get(""filePaths"", file_paths); + std::move(cb).Run(); + }, + run_loop.QuitClosure(), paths); + + FileChooserDialog* dialog = new FileChooserDialog(); + dialog->RunOpenDialog(std::move(cb), settings); + + run_loop.Run(); + return !paths->empty(); +} + +void ShowOpenDialog(const DialogSettings& settings, + gin_helper::Promise promise) { + FileChooserDialog* dialog = new FileChooserDialog(); + dialog->RunOpenDialog(std::move(promise), settings); +} + +bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path) { + base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); + v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate(); + gin_helper::Promise promise(isolate); + auto cb = base::BindOnce( + [](base::RepeatingClosure cb, base::FilePath* file_path, + gin_helper::Dictionary result) { + result.Get(""filePath"", file_path); + std::move(cb).Run(); + }, + run_loop.QuitClosure(), path); + + FileChooserDialog* dialog = new FileChooserDialog(); + dialog->RunSaveDialog(std::move(promise), settings); + run_loop.Run(); + return !path->empty(); +} + +void ShowSaveDialog(const DialogSettings& settings, + gin_helper::Promise promise) { + FileChooserDialog* dialog = new FileChooserDialog(); + dialog->RunSaveDialog(std::move(promise), settings); +} + +} // namespace file_dialog",refactor a8d89b3d5267030ea52de0b47dd49408aa2f43c0,Shelley Vohr,2022-10-18 06:46:19,fix: headless job tracking in printToPDF (#36046),"diff --git a/shell/browser/printing/print_view_manager_electron.cc b/shell/browser/printing/print_view_manager_electron.cc index abacb87baf..3b0fb78348 100644 --- a/shell/browser/printing/print_view_manager_electron.cc +++ b/shell/browser/printing/print_view_manager_electron.cc @@ -126,6 +126,7 @@ void PrintViewManagerElectron::PrintToPdf( printing_rfh_ = rfh; print_pages_params->pages = absl::get(parsed_ranges); + headless_jobs_.emplace_back(print_pages_params->params->document_cookie); callback_ = std::move(callback); // There is no need for a weak pointer here since the mojo proxy is held @@ -152,7 +153,9 @@ void PrintViewManagerElectron::OnDidPrintWithParams( } } - auto& content = *result->get_params()->content; + printing::mojom::DidPrintDocumentParamsPtr& params = result->get_params(); + + auto& content = *params->content; if (!content.metafile_data_region.IsValid()) { FailJob(kInvalidMemoryHandle); return; @@ -168,7 +171,7 @@ void PrintViewManagerElectron::OnDidPrintWithParams( std::string(static_cast(map.memory()), map.size()); std::move(callback_).Run(kPrintSuccess, base::RefCountedString::TakeString(&data)); - + base::Erase(headless_jobs_, params->document_cookie); Reset(); } ",fix da449b00dde8ff9e999389e6ea5994d71cd47397,Samuel Attard,2024-09-22 23:10:23,build: stop dependabot doing things (#43871),"diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6f212e561d..5f87388878 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -52,7 +52,7 @@ updates: interval: daily labels: - ""no-backport"" - open-pull-requests-limit: 5 + open-pull-requests-limit: 2 target-branch: 33-x-y - package-ecosystem: npm directories: @@ -63,7 +63,7 @@ updates: interval: daily labels: - ""no-backport"" - open-pull-requests-limit: 5 + open-pull-requests-limit: 0 target-branch: main - package-ecosystem: npm directories: @@ -74,7 +74,7 @@ updates: interval: daily labels: - ""no-backport"" - open-pull-requests-limit: 5 + open-pull-requests-limit: 0 target-branch: 32-x-y - package-ecosystem: npm directories: @@ -85,7 +85,7 @@ updates: interval: daily labels: - ""no-backport"" - open-pull-requests-limit: 5 + open-pull-requests-limit: 0 target-branch: 31-x-y - package-ecosystem: npm directories: @@ -96,5 +96,5 @@ updates: interval: daily labels: - ""no-backport"" - open-pull-requests-limit: 5 + open-pull-requests-limit: 0 target-branch: 30-x-y \ No newline at end of file",build 692876c73740d039ac840c91c719f7e9cf3b7e76,Kevin Law,2023-03-02 19:24:59,"docs(clipboard): fix an issue of demo code (#37438) doc(clipboard): fix an issue of demo code","diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index 813065fa30..b0602c40d3 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -226,7 +226,7 @@ clipboard.writeBuffer('public/utf8-plain-text', buffer) const ret = clipboard.readBuffer('public/utf8-plain-text') -console.log(buffer.equals(out)) +console.log(buffer.equals(ret)) // true ``` ",docs 93f49d118956932ef051eeefe6b377239b10d75c,Charles Kerr,2024-11-25 09:50:33,fix: modernize-use-using clang-tidy warnings (#44806),"diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index d020a9ef74..80ec117244 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -91,15 +91,14 @@ namespace electron::api { // FrameTreeNodeId -> WebFrameMain* // Using FrameTreeNode allows us to track frame across navigations. This // is most similar to how `; @@ -3037,7 +3033,7 @@ describe('iframe using HTML fullscreen API while window is OS-fullscreened', () // TODO: Re-enable for windows on GitHub Actions, // fullscreen tests seem to hang on GHA specifically - ifit(process.platform !== 'win32' || process.arch === 'arm64')('can fullscreen from in-process iframes', async () => { + it('can fullscreen from in-process iframes', async () => { if (process.platform === 'darwin') await once(w, 'enter-full-screen'); const fullscreenChange = once(ipcMain, 'fullscreenChange');",test 478ce969143cd8d069ab4def0992e8d5719445cf,Shelley Vohr,2023-02-09 08:48:49,"fix: avoid using v8 on Isolate termination (#35766) * fix: avoid using v8 on Isolate termination * chore: refactor for review --------- Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com>","diff --git a/patches/node/.patches b/patches/node/.patches index a222f4a950..5aa0d6dc93 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -34,4 +34,5 @@ fix_expose_lookupandcompile_with_parameters.patch fix_prevent_changing_functiontemplateinfo_after_publish.patch enable_crashpad_linux_node_processes.patch allow_embedder_to_control_codegenerationfromstringscallback.patch +src_allow_optional_isolation_termination_in_node.patch test_mark_cpu_prof_tests_as_flaky_in_electron.patch diff --git a/patches/node/src_allow_optional_isolation_termination_in_node.patch b/patches/node/src_allow_optional_isolation_termination_in_node.patch new file mode 100644 index 0000000000..f9ff03d5c1 --- /dev/null +++ b/patches/node/src_allow_optional_isolation_termination_in_node.patch @@ -0,0 +1,75 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Tue, 7 Feb 2023 10:53:11 +0100 +Subject: src: allow optional isolation termination in node + +This patch allows for node::Stop() to conditionally call +V8:Isolate::TerminateExecution(). + +We do not want to invoke a termination exception at exit when +we're running with only_terminate_in_safe_scope set to false. Heap and +coverage profilers run after environment exit and if there is a pending +exception at this stage then they will fail to generate the appropriate +profiles. Node.js does not call node::Stop(), which previously always +called isolate->TerminateExecution(), and therefore does not have this +issue when also running with only_terminate_in_safe_scope set to false. + +diff --git a/src/env.cc b/src/env.cc +index 837a879864c46d6f500684444ec38583c05f8be2..69a8b9ea405a400254041734b037c00aff4758f7 100644 +--- a/src/env.cc ++++ b/src/env.cc +@@ -902,10 +902,11 @@ void Environment::InitializeLibuv() { + StartProfilerIdleNotifier(); + } + +-void Environment::ExitEnv() { ++void Environment::ExitEnv(bool terminate) { + // Should not access non-thread-safe methods here. + set_stopping(true); +- isolate_->TerminateExecution(); ++ if (terminate) ++ isolate_->TerminateExecution(); + SetImmediateThreadsafe([](Environment* env) { + env->set_can_call_into_js(false); + uv_stop(env->event_loop()); +diff --git a/src/env.h b/src/env.h +index 562610e6827d8302f146b81d599dd366ba25cd74..c358c139aafcd7c958915b036f8d176909341556 100644 +--- a/src/env.h ++++ b/src/env.h +@@ -628,7 +628,7 @@ class Environment : public MemoryRetainer { + void RegisterHandleCleanups(); + void CleanupHandles(); + void Exit(int code); +- void ExitEnv(); ++ void ExitEnv(bool terminate); + + // Register clean-up cb to be called on environment destruction. + inline void RegisterHandleCleanup(uv_handle_t* handle, +diff --git a/src/node.cc b/src/node.cc +index 1067dee74c8877d9a3a0da6527c4c37faf9bd15f..b550fd4aa8488c6d721db3dee94cc4ce1346c708 100644 +--- a/src/node.cc ++++ b/src/node.cc +@@ -1229,8 +1229,8 @@ int Start(int argc, char** argv) { + return LoadSnapshotDataAndRun(&snapshot_data, result.get()); + } + +-int Stop(Environment* env) { +- env->ExitEnv(); ++int Stop(Environment* env, bool terminate) { ++ env->ExitEnv(terminate); + return 0; + } + +diff --git a/src/node.h b/src/node.h +index 5a849f047feca5d4d101c21c125e1c0500150077..db9a9c5c54f176ffdfc67e045b970729341eee7f 100644 +--- a/src/node.h ++++ b/src/node.h +@@ -316,7 +316,7 @@ NODE_EXTERN int Start(int argc, char* argv[]); + + // Tear down Node.js while it is running (there are active handles + // in the loop and / or actively executing JavaScript code). +-NODE_EXTERN int Stop(Environment* env); ++NODE_EXTERN int Stop(Environment* env, bool terminate = true); + + // This runs a subset of the initialization performed by + // InitializeOncePerProcess(), which supersedes this function. diff --git a/patches/v8/.patches b/patches/v8/.patches index 55e5198889..bd2409a468 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -6,8 +6,6 @@ workaround_an_undefined_symbol_error.patch do_not_export_private_v8_symbols_on_windows.patch fix_build_deprecated_attribute_for_older_msvc_versions.patch fix_disable_implies_dcheck_for_node_stream_array_buffers.patch -revert_runtime_dhceck_terminating_exception_in_microtasks.patch -chore_disable_is_execution_terminating_dcheck.patch force_cppheapcreateparams_to_be_noncopyable.patch chore_allow_customizing_microtask_policy_per_context.patch disable_the_use_of_preserve_most_on_arm64_windows.patch diff --git a/patches/v8/chore_disable_is_execution_terminating_dcheck.patch b/patches/v8/chore_disable_is_execution_terminating_dcheck.patch deleted file mode 100644 index 9fe3917362..0000000000 --- a/patches/v8/chore_disable_is_execution_terminating_dcheck.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Tue, 31 May 2022 19:58:01 +0200 -Subject: chore: disable is_execution_terminating DCHECK - -This causes a slew of crashes in Node.js. - -Upstream issue opened at https://github.com/nodejs/node-v8/issues/227. - -diff --git a/src/api/api-macros.h b/src/api/api-macros.h -index 149dd0555a69be576fd1eb97aa79b8aedafcac04..233e6d2ac511c4a7fa45d47bb7448beead52faf1 100644 ---- a/src/api/api-macros.h -+++ b/src/api/api-macros.h -@@ -97,8 +97,6 @@ - - // Lightweight version for APIs that don't require an active context. - #define DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate) \ -- /* Embedders should never enter V8 after terminating it */ \ -- DCHECK(!i_isolate->is_execution_terminating()); \ - DCHECK_NO_SCRIPT_NO_EXCEPTION_MAYBE_TEARDOWN(i_isolate) - - #define ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate) \ -diff --git a/src/execution/microtask-queue.cc b/src/execution/microtask-queue.cc -index ac48de9b499aed29a09ba918ddabfa67cd5485da..aa50aeb1d4f3943f83ded5e328b4a65bcfbc7317 100644 ---- a/src/execution/microtask-queue.cc -+++ b/src/execution/microtask-queue.cc -@@ -180,7 +180,7 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) { - - if (isolate->is_execution_terminating()) { - DCHECK(isolate->has_scheduled_exception()); -- DCHECK(maybe_result.is_null()); -+ // DCHECK(maybe_result.is_null()); - delete[] ring_buffer_; - ring_buffer_ = nullptr; - capacity_ = 0; diff --git a/patches/v8/revert_runtime_dhceck_terminating_exception_in_microtasks.patch b/patches/v8/revert_runtime_dhceck_terminating_exception_in_microtasks.patch deleted file mode 100644 index f48f9e576e..0000000000 --- a/patches/v8/revert_runtime_dhceck_terminating_exception_in_microtasks.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jeremy Rose -Date: Mon, 9 May 2022 17:09:21 -0700 -Subject: Revert ""[runtime] DHCECK terminating exception in Microtasks"" - -This reverts commit bccb536c98181e8a6e9cf0b6342311adbbf61aca. - -diff --git a/src/builtins/builtins-microtask-queue-gen.cc b/src/builtins/builtins-microtask-queue-gen.cc -index f58636fee555d782e18b7521c0c4f28ed60b3a52..6b0c63b34ff09f70cb9a4fe419f3b9bb0adf6790 100644 ---- a/src/builtins/builtins-microtask-queue-gen.cc -+++ b/src/builtins/builtins-microtask-queue-gen.cc -@@ -118,7 +118,6 @@ void MicrotaskQueueBuiltinsAssembler::PrepareForContext( - void MicrotaskQueueBuiltinsAssembler::RunSingleMicrotask( - TNode current_context, TNode microtask) { - CSA_DCHECK(this, TaggedIsNotSmi(microtask)); -- CSA_DCHECK(this, Word32BinaryNot(IsExecutionTerminating())); - - StoreRoot(RootIndex::kCurrentMicrotask, microtask); - TNode saved_entered_context_count = GetEnteredContextCount(); -diff --git a/src/codegen/code-stub-assembler.cc b/src/codegen/code-stub-assembler.cc -index 7d47afa2c92c1da43657702d5a85251646d680fd..10c3ec8387522ce2e35b77a7e6eb04de22597349 100644 ---- a/src/codegen/code-stub-assembler.cc -+++ b/src/codegen/code-stub-assembler.cc -@@ -6417,12 +6417,6 @@ void CodeStubAssembler::SetPendingMessage(TNode message) { - StoreFullTaggedNoWriteBarrier(pending_message, message); - } - --TNode CodeStubAssembler::IsExecutionTerminating() { -- TNode pending_message = GetPendingMessage(); -- return TaggedEqual(pending_message, -- LoadRoot(RootIndex::kTerminationException)); --} -- - TNode CodeStubAssembler::InstanceTypeEqual(TNode instance_type, - int type) { - return Word32Equal(instance_type, Int32Constant(type)); -diff --git a/src/codegen/code-stub-assembler.h b/src/codegen/code-stub-assembler.h -index fdd6da601705f72bd5d1a9101171048bdf408b9d..496c73225f8641e78793ba74d80e2e8b1e3f5c02 100644 ---- a/src/codegen/code-stub-assembler.h -+++ b/src/codegen/code-stub-assembler.h -@@ -2550,7 +2550,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler - - TNode GetPendingMessage(); - void SetPendingMessage(TNode message); -- TNode IsExecutionTerminating(); - - // Type checks. - // Check whether the map is for an object with special properties, such as a diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index 44bae67d56..bb025dbc5a 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -226,7 +226,8 @@ int NodeMain(int argc, char* argv[]) { uint64_t env_flags = node::EnvironmentFlags::kDefaultFlags | node::EnvironmentFlags::kHideConsoleWindows; env = node::CreateEnvironment( - isolate_data, gin_env.context(), result->args(), result->exec_args(), + isolate_data, isolate->GetCurrentContext(), result->args(), + result->exec_args(), static_cast(env_flags)); CHECK_NE(nullptr, env); @@ -293,7 +294,8 @@ int NodeMain(int argc, char* argv[]) { node::ResetStdio(); - node::Stop(env); + node::Stop(env, false); + node::FreeEnvironment(env); node::FreeIsolateData(isolate_data); } diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 0cd475694e..ef72790a57 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -273,7 +273,7 @@ void ElectronBrowserMainParts::PostEarlyInitialization() { node_bindings_->Initialize(); // Create the global environment. node::Environment* env = node_bindings_->CreateEnvironment( - js_env_->context(), js_env_->platform()); + js_env_->isolate()->GetCurrentContext(), js_env_->platform()); node_env_ = std::make_unique(env); env->set_trace_sync_io(env->options()->trace_sync_io); @@ -626,7 +626,7 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() { // invoke Node/V8 APIs inside them. node_env_->env()->set_trace_sync_io(false); js_env_->DestroyMicrotasksRunner(); - node::Stop(node_env_->env()); + node::Stop(node_env_->env(), false); node_env_.reset(); auto default_context_key = ElectronBrowserContext::PartitionKey("""", false); diff --git a/shell/browser/javascript_environment.cc b/shell/browser/javascript_environment.cc index e9312131ba..5172a8e7d2 100644 --- a/shell/browser/javascript_environment.cc +++ b/shell/browser/javascript_environment.cc @@ -74,22 +74,45 @@ struct base::trace_event::TraceValue::Helper< namespace electron { +namespace { + +gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) { + std::unique_ptr create_params = + gin::IsolateHolder::getDefaultIsolateParams(); + // Align behavior with V8 Isolate default for Node.js. + // This is necessary for important aspects of Node.js + // including heap and cpu profilers to function properly. + // + // Additional note: + // We do not want to invoke a termination exception at exit when + // we're running with only_terminate_in_safe_scope set to false. Heap and + // coverage profilers run after environment exit and if there is a pending + // exception at this stage then they will fail to generate the appropriate + // profiles. Node.js does not call node::Stop(), which calls + // isolate->TerminateExecution(), and therefore does not have this issue + // when also running with only_terminate_in_safe_scope set to false. + create_params->only_terminate_in_safe_scope = false; + + return gin::IsolateHolder( + base::SingleThreadTaskRunner::GetCurrentDefault(), + gin::IsolateHolder::kSingleThread, + gin::IsolateHolder::IsolateType::kUtility, std::move(create_params), + gin::IsolateHolder::IsolateCreationMode::kNormal, isolate); +} + +} // namespace + JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop, bool setup_wasm_streaming) : isolate_(Initialize(event_loop, setup_wasm_streaming)), - isolate_holder_(base::SingleThreadTaskRunner::GetCurrentDefault(), - gin::IsolateHolder::kSingleThread, - gin::IsolateHolder::kAllowAtomicsWait, - gin::IsolateHolder::IsolateType::kUtility, - gin::IsolateHolder::IsolateCreationMode::kNormal, - nullptr, - nullptr, - isolate_), + isolate_holder_(CreateIsolateHolder(isolate_)), locker_(isolate_) { isolate_->Enter(); + v8::HandleScope scope(isolate_); auto context = node::NewContext(isolate_); - context_ = v8::Global(isolate_, context); + CHECK(!context.IsEmpty()); + context->Enter(); } @@ -99,7 +122,7 @@ JavascriptEnvironment::~JavascriptEnvironment() { { v8::HandleScope scope(isolate_); - context_.Get(isolate_)->Exit(); + isolate_->GetCurrentContext()->Exit(); } isolate_->Exit(); g_isolate = nullptr; diff --git a/shell/browser/javascript_environment.h b/shell/browser/javascript_environment.h index c40a939127..49cc2175f9 100644 --- a/shell/browser/javascript_environment.h +++ b/shell/browser/javascript_environment.h @@ -22,8 +22,8 @@ class MicrotasksRunner; // Manage the V8 isolate and context automatically. class JavascriptEnvironment { public: - explicit JavascriptEnvironment(uv_loop_t* event_loop, - bool setup_wasm_streaming = false); + JavascriptEnvironment(uv_loop_t* event_loop, + bool setup_wasm_streaming = false); ~JavascriptEnvironment(); // disable copy @@ -35,9 +35,6 @@ class JavascriptEnvironment { node::MultiIsolatePlatform* platform() const { return platform_.get(); } v8::Isolate* isolate() const { return isolate_; } - v8::Local context() const { - return v8::Local::New(isolate_, context_); - } static v8::Isolate* GetIsolate(); @@ -48,7 +45,6 @@ class JavascriptEnvironment { v8::Isolate* isolate_; gin::IsolateHolder isolate_holder_; v8::Locker locker_; - v8::Global context_; std::unique_ptr microtasks_runner_; }; diff --git a/shell/services/node/node_service.cc b/shell/services/node/node_service.cc index ffd2f6966f..7ce0fcb552 100644 --- a/shell/services/node/node_service.cc +++ b/shell/services/node/node_service.cc @@ -33,7 +33,7 @@ NodeService::~NodeService() { if (!node_env_stopped_) { node_env_->env()->set_trace_sync_io(false); js_env_->DestroyMicrotasksRunner(); - node::Stop(node_env_->env()); + node::Stop(node_env_->env(), false); } } @@ -59,7 +59,8 @@ void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) { // Create the global environment. node::Environment* env = node_bindings_->CreateEnvironment( - js_env_->context(), js_env_->platform(), params->args, params->exec_args); + js_env_->isolate()->GetCurrentContext(), js_env_->platform(), + params->args, params->exec_args); node_env_ = std::make_unique(env); node::SetProcessExitHandler(env, @@ -67,7 +68,7 @@ void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) { // Destroy node platform. env->set_trace_sync_io(false); js_env_->DestroyMicrotasksRunner(); - node::Stop(env); + node::Stop(env, false); node_env_stopped_ = true; receiver_.ResetWithReason(exit_code, """"); });",fix 3a94634ae559e5e9cc41e26b56af95a3f916a7f9,Samuel Attard,2022-11-18 23:45:22,build: force ninja binary to the right arch after src cache restore (#36401),"diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index bfd6567296..d28aa68327 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -495,6 +495,11 @@ step-fix-sync: &step-fix-sync # Remove extra output from calling gclient getdep which always calls update_depot_tools sed -i '' ""s/Updating depot_tools... //g"" esbuild_ensure_file cipd ensure --root src/third_party/devtools-frontend/src/third_party/esbuild -ensure-file esbuild_ensure_file + + # Fix ninja (wrong binary) + echo 'infra/3pp/tools/ninja/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/tools/ninja/${platform}'` > ninja_ensure_file + sed -i '' ""s/Updating depot_tools... //g"" ninja_ensure_file + cipd ensure --root src/third_party/ninja -ensure-file ninja_ensure_file fi cd src/third_party/angle",build 679a6589cd6660e0386d622373b48e2743497684,David Sanders,2024-01-29 06:51:43,chore: add extra links to issue template chooser (#41135),"diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..8ca65572ea --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,7 @@ +contact_links: + - name: Discord Chat + url: https://discord.gg/APGC3k5yaH + about: Have questions? Try asking on our Discord - this issue tracker is for reporting bugs or feature requests only + - name: Open Collective + url: https://opencollective.com/electron + about: Help support Electron by contributing to our Open Collective",chore 3d2a7545314f68c21f3fb92fb0a6eb9edcceabd3,David Sanders,2023-11-20 23:50:08,"chore: extend linting of code blocks in the docs (#40245) * chore: extend linting of code blocks in the docs * chore: combine lint:markdownlint and lint:markdown scripts","diff --git a/docs/api/accelerator.md b/docs/api/accelerator.md index e1fac744ad..7a019918a4 100644 --- a/docs/api/accelerator.md +++ b/docs/api/accelerator.md @@ -15,7 +15,7 @@ Shortcuts are registered with the [`globalShortcut`](global-shortcut.md) module using the [`register`](global-shortcut.md#globalshortcutregisteraccelerator-callback) method, i.e. -```javascript +```js const { app, globalShortcut } = require('electron') app.whenReady().then(() => { diff --git a/docs/api/browser-view.md b/docs/api/browser-view.md index 4db9ebc300..f117aec467 100644 --- a/docs/api/browser-view.md +++ b/docs/api/browser-view.md @@ -16,7 +16,7 @@ module is emitted. ### Example -```javascript +```js // In the main process. const { app, BrowserView, BrowserWindow } = require('electron') diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 283e958149..3af05f03ad 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process) This module cannot be used until the `ready` event of the `app` module is emitted. -```javascript +```js // In the main process. const { BrowserWindow } = require('electron') @@ -38,7 +38,7 @@ While loading the page, the `ready-to-show` event will be emitted when the rende process has rendered the page for the first time if the window has not been shown yet. Showing the window after this event will have no visual flash: -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow({ show: false }) win.once('ready-to-show', () => { @@ -59,7 +59,7 @@ For a complex app, the `ready-to-show` event could be emitted too late, making the app feel slow. In this case, it is recommended to show the window immediately, and use a `backgroundColor` close to your app's background: -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow({ backgroundColor: '#2e2c29' }) @@ -85,7 +85,7 @@ For more information about these color types see valid options in [win.setBackgr By using `parent` option, you can create child windows: -```javascript +```js const { BrowserWindow } = require('electron') const top = new BrowserWindow() @@ -101,7 +101,7 @@ The `child` window will always show on top of the `top` window. A modal window is a child window that disables parent window, to create a modal window, you have to set both `parent` and `modal` options: -```javascript +```js const { BrowserWindow } = require('electron') const top = new BrowserWindow() @@ -188,7 +188,7 @@ window should be closed, which will also be called when the window is reloaded. In Electron, returning any value other than `undefined` would cancel the close. For example: -```javascript +```js window.onbeforeunload = (e) => { console.log('I do not want to be closed') @@ -351,7 +351,7 @@ Commands are lowercased, underscores are replaced with hyphens, and the `APPCOMMAND_` prefix is stripped off. e.g. `APPCOMMAND_BROWSER_BACKWARD` is emitted as `browser-backward`. -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() win.on('app-command', (e, cmd) => { @@ -456,7 +456,7 @@ Returns `BrowserWindow | null` - The window with the given `id`. Objects created with `new BrowserWindow` have the following properties: -```javascript +```js const { BrowserWindow } = require('electron') // In this example `win` is our instance const win = new BrowserWindow({ width: 800, height: 600 }) @@ -780,7 +780,7 @@ Closes the currently open [Quick Look][quick-look] panel. Resizes and moves the window to the supplied bounds. Any properties that are not supplied will default to their current values. -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() @@ -1035,7 +1035,7 @@ Changes the attachment point for sheets on macOS. By default, sheets are attached just below the window frame, but you may want to display them beneath a HTML-rendered toolbar. For example: -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() @@ -1178,7 +1178,7 @@ To ensure that file URLs are properly formatted, it is recommended to use Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject) method: -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() @@ -1194,7 +1194,7 @@ win.loadURL(url) You can load a URL using a `POST` request with URL-encoded data by doing the following: -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() diff --git a/docs/api/client-request.md b/docs/api/client-request.md index 3bbbe6ced4..300fafa3ed 100644 --- a/docs/api/client-request.md +++ b/docs/api/client-request.md @@ -65,7 +65,7 @@ strictly follow the Node.js model as described in the For instance, we could have created the same request to 'github.com' as follows: -```javascript +```js const request = net.request({ method: 'GET', protocol: 'https:', @@ -104,7 +104,7 @@ The `callback` function is expected to be called back with user credentials: * `username` string * `password` string -```javascript @ts-type={request:Electron.ClientRequest} +```js @ts-type={request:Electron.ClientRequest} request.on('login', (authInfo, callback) => { callback('username', 'password') }) @@ -113,7 +113,7 @@ request.on('login', (authInfo, callback) => { Providing empty credentials will cancel the request and report an authentication error on the response object: -```javascript @ts-type={request:Electron.ClientRequest} +```js @ts-type={request:Electron.ClientRequest} request.on('response', (response) => { console.log(`STATUS: ${response.statusCode}`) response.on('error', (error) => { diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index ea5345f071..c4328e2871 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer On Linux, there is also a `selection` clipboard. To manipulate it you need to pass `selection` to each method: -```javascript +```js const { clipboard } = require('electron') clipboard.writeText('Example string', 'selection') diff --git a/docs/api/command-line-switches.md b/docs/api/command-line-switches.md index 8237cf53f2..d497028d22 100644 --- a/docs/api/command-line-switches.md +++ b/docs/api/command-line-switches.md @@ -6,7 +6,7 @@ You can use [app.commandLine.appendSwitch][append-switch] to append them in your app's main script before the [ready][ready] event of the [app][app] module is emitted: -```javascript +```js const { app } = require('electron') app.commandLine.appendSwitch('remote-debugging-port', '8315') app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1') @@ -185,7 +185,7 @@ list of hosts. This flag has an effect only if used in tandem with For example: -```javascript +```js const { app } = require('electron') app.commandLine.appendSwitch('proxy-bypass-list', ';*.google.com;*foo.com;1.2.3.4:5678') ``` diff --git a/docs/api/command-line.md b/docs/api/command-line.md index 9d36a03161..63046d7346 100644 --- a/docs/api/command-line.md +++ b/docs/api/command-line.md @@ -7,7 +7,7 @@ _This class is not exported from the `'electron'` module. It is only available a The following example shows how to check if the `--disable-gpu` flag is set. -```javascript +```js const { app } = require('electron') app.commandLine.hasSwitch('disable-gpu') ``` diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index ec8e3f7979..435cfe343c 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -10,7 +10,7 @@ This module does not include a web interface. To view recorded traces, use **Note:** You should not use this module until the `ready` event of the app module is emitted. -```javascript +```js const { app, contentTracing } = require('electron') app.whenReady().then(() => { diff --git a/docs/api/context-bridge.md b/docs/api/context-bridge.md index 1b5bc021e9..5002874994 100644 --- a/docs/api/context-bridge.md +++ b/docs/api/context-bridge.md @@ -6,7 +6,7 @@ Process: [Renderer](../glossary.md#renderer-process) An example of exposing an API to a renderer from an isolated preload script is given below: -```javascript +```js // Preload (Isolated World) const { contextBridge, ipcRenderer } = require('electron') @@ -18,7 +18,7 @@ contextBridge.exposeInMainWorld( ) ``` -```javascript @ts-nocheck +```js @ts-nocheck // Renderer (Main World) window.electron.doThing() @@ -64,7 +64,7 @@ the API become immutable and updates on either side of the bridge do not result An example of a complex API is shown below: -```javascript +```js const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInMainWorld( @@ -92,7 +92,7 @@ contextBridge.exposeInMainWorld( An example of `exposeInIsolatedWorld` is shown below: -```javascript +```js const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInIsolatedWorld( @@ -104,7 +104,7 @@ contextBridge.exposeInIsolatedWorld( ) ``` -```javascript @ts-nocheck +```js @ts-nocheck // Renderer (In isolated world id1004) window.electron.doThing() @@ -145,7 +145,7 @@ The table of supported types described above also applies to Node APIs that you Please note that many Node APIs grant access to local system resources. Be very cautious about which globals and APIs you expose to untrusted remote content. -```javascript +```js const { contextBridge } = require('electron') const crypto = require('node:crypto') contextBridge.exposeInMainWorld('nodeCrypto', { diff --git a/docs/api/cookies.md b/docs/api/cookies.md index 5665c8587c..8a3576d3fc 100644 --- a/docs/api/cookies.md +++ b/docs/api/cookies.md @@ -10,7 +10,7 @@ a `Session`. For example: -```javascript +```js const { session } = require('electron') // Query all cookies. diff --git a/docs/api/crash-reporter.md b/docs/api/crash-reporter.md index 8b8b2e2b2f..8883699db7 100644 --- a/docs/api/crash-reporter.md +++ b/docs/api/crash-reporter.md @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer The following is an example of setting up Electron to automatically submit crash reports to a remote server: -```javascript +```js const { crashReporter } = require('electron') crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' }) diff --git a/docs/api/debugger.md b/docs/api/debugger.md index fd0abe096d..26a4b7c6a9 100644 --- a/docs/api/debugger.md +++ b/docs/api/debugger.md @@ -8,7 +8,7 @@ _This class is not exported from the `'electron'` module. It is only available a Chrome Developer Tools has a [special binding][rdp] available at JavaScript runtime that allows interacting with pages and instrumenting them. -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md index 078d4f980b..5eba3efaa1 100644 --- a/docs/api/desktop-capturer.md +++ b/docs/api/desktop-capturer.md @@ -8,7 +8,7 @@ Process: [Main](../glossary.md#main-process) The following example shows how to capture video from a desktop window whose title is `Electron`: -```javascript +```js // In the main process. const { BrowserWindow, desktopCapturer } = require('electron') @@ -24,7 +24,7 @@ desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources = }) ``` -```javascript @ts-nocheck +```js @ts-nocheck // In the preload script. const { ipcRenderer } = require('electron') @@ -68,7 +68,7 @@ To capture both audio and video from the entire desktop the constraints passed to [`navigator.mediaDevices.getUserMedia`][] must include `chromeMediaSource: 'desktop'`, for both `audio` and `video`, but should not include a `chromeMediaSourceId` constraint. -```javascript +```js const constraints = { audio: { mandatory: { diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 7d1879c340..414ed39b64 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process) An example of showing a dialog to select multiple files: -```javascript +```js const { dialog } = require('electron') console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] })) ``` @@ -52,7 +52,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind The `filters` specifies an array of file types that can be displayed or selected when you want to limit the user to a specific type. For example: -```javascript +```js { filters: [ { name: 'Images', extensions: ['jpg', 'png', 'gif'] }, @@ -119,7 +119,7 @@ The `browserWindow` argument allows the dialog to attach itself to a parent wind The `filters` specifies an array of file types that can be displayed or selected when you want to limit the user to a specific type. For example: -```javascript +```js { filters: [ { name: 'Images', extensions: ['jpg', 'png', 'gif'] }, diff --git a/docs/api/dock.md b/docs/api/dock.md index d93f72afe4..efe77aa536 100644 --- a/docs/api/dock.md +++ b/docs/api/dock.md @@ -7,7 +7,7 @@ _This class is not exported from the `'electron'` module. It is only available a The following example shows how to bounce your icon on the dock. -```javascript +```js const { app } = require('electron') app.dock.bounce() ``` diff --git a/docs/api/download-item.md b/docs/api/download-item.md index 0a362d522f..d07293a888 100644 --- a/docs/api/download-item.md +++ b/docs/api/download-item.md @@ -9,7 +9,7 @@ _This class is not exported from the `'electron'` module. It is only available a It is used in `will-download` event of `Session` class, and allows users to control the download item. -```javascript +```js // In the main process. const { BrowserWindow } = require('electron') const win = new BrowserWindow() diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md index fa6d1e13fc..0150fa5e28 100644 --- a/docs/api/environment-variables.md +++ b/docs/api/environment-variables.md @@ -59,7 +59,7 @@ geolocation webservice. To enable this feature, acquire a and place the following code in your main process file, before opening any browser windows that will make geolocation requests: -```javascript +```js process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE' ``` diff --git a/docs/api/global-shortcut.md b/docs/api/global-shortcut.md index 66d9c6943a..9fe98c0415 100644 --- a/docs/api/global-shortcut.md +++ b/docs/api/global-shortcut.md @@ -12,7 +12,7 @@ shortcuts. not have the keyboard focus. This module cannot be used before the `ready` event of the app module is emitted. -```javascript +```js const { app, globalShortcut } = require('electron') app.whenReady().then(() => { diff --git a/docs/api/incoming-message.md b/docs/api/incoming-message.md index 904b4bfe12..02243fb7e9 100644 --- a/docs/api/incoming-message.md +++ b/docs/api/incoming-message.md @@ -89,7 +89,7 @@ tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values. Header names are not lowercased, and duplicates are not merged. -```javascript @ts-type={response:Electron.IncomingMessage} +```js @ts-type={response:Electron.IncomingMessage} // Prints something like: // // [ 'user-agent', diff --git a/docs/api/ipc-renderer.md b/docs/api/ipc-renderer.md index cf9b219c8d..6dc62b323d 100644 --- a/docs/api/ipc-renderer.md +++ b/docs/api/ipc-renderer.md @@ -120,7 +120,7 @@ The main process should listen for `channel` with For example: -```javascript @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise} +```js @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise} // Renderer process ipcRenderer.invoke('some-name', someArgument).then((result) => { // ... diff --git a/docs/api/menu.md b/docs/api/menu.md index ad253bf95d..860eb7e8d6 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -151,7 +151,7 @@ can have a submenu. An example of creating the application menu with the simple template API: -```javascript @ts-expect-error=[107] +```js @ts-expect-error=[107] const { app, Menu } = require('electron') const isMac = process.platform === 'darwin' @@ -353,7 +353,7 @@ By default, items will be inserted in the order they exist in the template unles Template: -```javascript +```js [ { id: '1', label: 'one' }, { id: '2', label: 'two' }, @@ -373,7 +373,7 @@ Menu: Template: -```javascript +```js [ { id: '1', label: 'one' }, { type: 'separator' }, @@ -397,7 +397,7 @@ Menu: Template: -```javascript +```js [ { id: '1', label: 'one', after: ['3'] }, { id: '2', label: 'two', before: ['1'] }, diff --git a/docs/api/native-image.md b/docs/api/native-image.md index d31b39f1c7..6563b67653 100644 --- a/docs/api/native-image.md +++ b/docs/api/native-image.md @@ -10,7 +10,7 @@ In Electron, for the APIs that take images, you can pass either file paths or For example, when creating a tray or setting a window's icon, you can pass an image file path as a `string`: -```javascript +```js const { BrowserWindow, Tray } = require('electron') const appIcon = new Tray('/Users/somebody/images/icon.png') @@ -20,7 +20,7 @@ console.log(appIcon, win) Or read the image from the clipboard, which returns a `NativeImage`: -```javascript +```js const { clipboard, Tray } = require('electron') const image = clipboard.readImage() const appIcon = new Tray(image) @@ -71,7 +71,7 @@ images/ └── icon@3x.png ``` -```javascript +```js const { Tray } = require('electron') const appIcon = new Tray('/Users/somebody/images/icon.png') console.log(appIcon) @@ -138,7 +138,7 @@ Creates a new `NativeImage` instance from a file located at `path`. This method returns an empty image if the `path` does not exist, cannot be read, or is not a valid image. -```javascript +```js const nativeImage = require('electron').nativeImage const image = nativeImage.createFromPath('/Users/somebody/images/icon.png') diff --git a/docs/api/net-log.md b/docs/api/net-log.md index db16c11193..f9b04212c0 100644 --- a/docs/api/net-log.md +++ b/docs/api/net-log.md @@ -4,7 +4,7 @@ Process: [Main](../glossary.md#main-process) -```javascript +```js const { app, netLog } = require('electron') app.whenReady().then(async () => { diff --git a/docs/api/net.md b/docs/api/net.md index 858ba19ea4..d670126146 100644 --- a/docs/api/net.md +++ b/docs/api/net.md @@ -26,7 +26,7 @@ Node.js. Example usage: -```javascript +```js const { app } = require('electron') app.whenReady().then(() => { const { net } = require('electron') diff --git a/docs/api/power-save-blocker.md b/docs/api/power-save-blocker.md index 1ba95f0aab..ee57287258 100644 --- a/docs/api/power-save-blocker.md +++ b/docs/api/power-save-blocker.md @@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process) For example: -```javascript +```js const { powerSaveBlocker } = require('electron') const id = powerSaveBlocker.start('prevent-display-sleep') diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 93dc050287..9b093fc890 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -7,7 +7,7 @@ Process: [Main](../glossary.md#main-process) An example of implementing a protocol that has the same effect as the `file://` protocol: -```javascript +```js const { app, protocol, net } = require('electron') app.whenReady().then(() => { @@ -31,7 +31,7 @@ a different session and your custom protocol will not work if you just use To have your custom protocol work in combination with a custom session, you need to register it to that session explicitly. -```javascript +```js const { app, BrowserWindow, net, protocol, session } = require('electron') const path = require('node:path') const url = require('url') @@ -67,7 +67,7 @@ video/audio. Specify a privilege with the value of `true` to enable the capabili An example of registering a privileged scheme, that bypasses Content Security Policy: -```javascript +```js const { protocol } = require('electron') protocol.registerSchemesAsPrivileged([ { scheme: 'foo', privileges: { bypassCSP: true } } @@ -222,7 +222,7 @@ property. Example: -```javascript +```js protocol.registerBufferProtocol('atom', (request, callback) => { callback({ mimeType: 'text/html', data: Buffer.from('
Response
') }) }) @@ -277,7 +277,7 @@ has the `data` property. Example: -```javascript +```js const { protocol } = require('electron') const { PassThrough } = require('stream') @@ -302,7 +302,7 @@ protocol.registerStreamProtocol('atom', (request, callback) => { It is possible to pass any object that implements the readable stream API (emits `data`/`end`/`error` events). For example, here's how a file could be returned: -```javascript +```js protocol.registerStreamProtocol('atom', (request, callback) => { callback(fs.createReadStream('index.html')) }) diff --git a/docs/api/push-notifications.md b/docs/api/push-notifications.md index 1cf8d88eb0..4a9d19f09e 100644 --- a/docs/api/push-notifications.md +++ b/docs/api/push-notifications.md @@ -6,7 +6,7 @@ Process: [Main](../glossary.md#main-process) For example, when registering for push notifications via Apple push notification services (APNS): -```javascript +```js const { pushNotifications, Notification } = require('electron') pushNotifications.registerForAPNSNotifications().then((token) => { diff --git a/docs/api/screen.md b/docs/api/screen.md index a576a5902c..4f68a2018b 100644 --- a/docs/api/screen.md +++ b/docs/api/screen.md @@ -14,20 +14,29 @@ property, so writing `let { screen } = require('electron')` will not work. An example of creating a window that fills the whole screen: -```javascript fiddle='docs/fiddles/screen/fit-screen' -const { app, BrowserWindow, screen } = require('electron') +```fiddle docs/fiddles/screen/fit-screen +// Retrieve information about screen size, displays, cursor position, etc. +// +// For more info, see: +// https://www.electronjs.org/docs/latest/api/screen + +const { app, BrowserWindow, screen } = require('electron/main') + +let mainWindow = null -let win app.whenReady().then(() => { - const { width, height } = screen.getPrimaryDisplay().workAreaSize - win = new BrowserWindow({ width, height }) - win.loadURL('https://github.com') + // Create a window that fills the screen's available work area. + const primaryDisplay = screen.getPrimaryDisplay() + const { width, height } = primaryDisplay.workAreaSize + + mainWindow = new BrowserWindow({ width, height }) + mainWindow.loadURL('https://electronjs.org') }) ``` Another example of creating a window in the external display: -```javascript +```js const { app, BrowserWindow, screen } = require('electron') let win diff --git a/docs/api/service-workers.md b/docs/api/service-workers.md index ec9f33d3e1..f1fa64f625 100644 --- a/docs/api/service-workers.md +++ b/docs/api/service-workers.md @@ -10,7 +10,7 @@ a `Session`. For example: -```javascript +```js const { session } = require('electron') // Get all service workers. diff --git a/docs/api/session.md b/docs/api/session.md index 01b330a875..f8f4367d6e 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -9,7 +9,7 @@ The `session` module can be used to create new `Session` objects. You can also access the `session` of existing pages by using the `session` property of [`WebContents`](web-contents.md), or from the `session` module. -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 600 }) @@ -75,7 +75,7 @@ _This class is not exported from the `'electron'` module. It is only available a You can create a `Session` object in the `session` module: -```javascript +```js const { session } = require('electron') const ses = session.fromPartition('persist:name') console.log(ses.getUserAgent()) @@ -98,7 +98,7 @@ Emitted when Electron is about to download `item` in `webContents`. Calling `event.preventDefault()` will cancel the download and `item` will not be available from next tick of the process. -```javascript @ts-expect-error=[4] +```js @ts-expect-error=[4] const { session } = require('electron') session.defaultSession.on('will-download', (event, item, webContents) => { event.preventDefault() @@ -214,7 +214,7 @@ cancel the request. Additionally, permissioning on `navigator.hid` can be further managed by using [`ses.setPermissionCheckHandler(handler)`](#sessetpermissioncheckhandlerhandler) and [`ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler). -```javascript @ts-type={fetchGrantedDevices:()=>(Array)} +```js @ts-type={fetchGrantedDevices:()=>(Array)} const { app, BrowserWindow } = require('electron') let win = null @@ -320,7 +320,7 @@ cancel the request. Additionally, permissioning on `navigator.serial` can be managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler) with the `serial` permission. -```javascript @ts-type={fetchGrantedDevices:()=>(Array)} +```js @ts-type={fetchGrantedDevices:()=>(Array)} const { app, BrowserWindow } = require('electron') let win = null @@ -463,7 +463,7 @@ cancel the request. Additionally, permissioning on `navigator.usb` can be further managed by using [`ses.setPermissionCheckHandler(handler)`](#sessetpermissioncheckhandlerhandler) and [`ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler). -```javascript @ts-type={fetchGrantedDevices:()=>(Array)} @ts-type={updateGrantedDevices:(devices:Array)=>void} +```js @ts-type={fetchGrantedDevices:()=>(Array)} @ts-type={updateGrantedDevices:(devices:Array)=>void} const { app, BrowserWindow } = require('electron') let win = null @@ -754,7 +754,7 @@ Sets download saving directory. By default, the download directory will be the Emulates network with the given configuration for the `session`. -```javascript +```js const win = new BrowserWindow() // To emulate a GPRS connection with 50kbps throughput and 500 ms latency. @@ -868,7 +868,7 @@ calling `callback(-2)` rejects it. Calling `setCertificateVerifyProc(null)` will revert back to default certificate verify proc. -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow() @@ -921,7 +921,7 @@ To clear the handler, call `setPermissionRequestHandler(null)`. Please note tha you must also implement `setPermissionCheckHandler` to get complete permission handling. Most web APIs do a permission check and then make a permission request if the check is denied. -```javascript +```js const { session } = require('electron') session.fromPartition('some-partition').setPermissionRequestHandler((webContents, permission, callback) => { if (webContents.getURL() === 'some-host' && permission === 'notifications') { @@ -967,7 +967,7 @@ you must also implement `setPermissionRequestHandler` to get complete permission Most web APIs do a permission check and then make a permission request if the check is denied. To clear the handler, call `setPermissionCheckHandler(null)`. -```javascript +```js const { session } = require('electron') const url = require('url') session.fromPartition('some-partition').setPermissionCheckHandler((webContents, permission, requestingOrigin) => { @@ -1012,7 +1012,7 @@ via the `navigator.mediaDevices.getDisplayMedia` API. Use the [desktopCapturer](desktop-capturer.md) API to choose which stream(s) to grant access to. -```javascript +```js const { session, desktopCapturer } = require('electron') session.defaultSession.setDisplayMediaRequestHandler((request, callback) => { @@ -1026,7 +1026,7 @@ session.defaultSession.setDisplayMediaRequestHandler((request, callback) => { Passing a [WebFrameMain](web-frame-main.md) object as a video or audio stream will capture the video or audio stream from that frame. -```javascript +```js const { session } = require('electron') session.defaultSession.setDisplayMediaRequestHandler((request, callback) => { @@ -1055,7 +1055,7 @@ Additionally, the default behavior of Electron is to store granted device permis If longer term storage is needed, a developer can store granted device permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`. -```javascript @ts-type={fetchGrantedDevices:()=>(Array)} +```js @ts-type={fetchGrantedDevices:()=>(Array)} const { app, BrowserWindow } = require('electron') let win = null @@ -1137,7 +1137,7 @@ The return value for the handler is a string array of USB classes which should b Returning an empty string array from the handler will allow all USB classes; returning the passed in array will maintain the default list of protected USB classes (this is also the default behavior if a handler is not defined). To clear the handler, call `setUSBProtectedClassesHandler(null)`. -```javascript +```js const { app, BrowserWindow } = require('electron') let win = null @@ -1192,7 +1192,7 @@ that requires additional validation will be automatically cancelled. macOS does not require a handler because macOS handles the pairing automatically. To clear the handler, call `setBluetoothPairingHandler(null)`. -```javascript +```js const { app, BrowserWindow, session } = require('electron') const path = require('node:path') @@ -1238,7 +1238,7 @@ Clears the host resolver cache. Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication. -```javascript +```js const { session } = require('electron') // consider any url ending with `example.com`, `foobar.com`, `baz` // for integrated authentication. @@ -1543,7 +1543,7 @@ A [`WebRequest`](web-request.md) object for this session. A [`Protocol`](protocol.md) object for this session. -```javascript +```js const { app, session } = require('electron') const path = require('node:path') @@ -1562,7 +1562,7 @@ app.whenReady().then(() => { A [`NetLog`](net-log.md) object for this session. -```javascript +```js const { app, session } = require('electron') app.whenReady().then(async () => { diff --git a/docs/api/shell.md b/docs/api/shell.md index f278c4bbdd..afbb966cc0 100644 --- a/docs/api/shell.md +++ b/docs/api/shell.md @@ -8,7 +8,7 @@ The `shell` module provides functions related to desktop integration. An example of opening a URL in the user's default browser: -```javascript +```js const { shell } = require('electron') shell.openExternal('https://github.com') diff --git a/docs/api/structures/printer-info.md b/docs/api/structures/printer-info.md index 61b637c7ce..5910dca8fc 100644 --- a/docs/api/structures/printer-info.md +++ b/docs/api/structures/printer-info.md @@ -14,7 +14,7 @@ The number represented by `status` means different things on different platforms Below is an example of some of the additional options that may be set which may be different on each platform. -```javascript +```js { name: 'Austin_4th_Floor_Printer___C02XK13BJHD4', displayName: 'Austin 4th Floor Printer @ C02XK13BJHD4', diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md index 1fea0e3fbc..7d61d79cb0 100644 --- a/docs/api/system-preferences.md +++ b/docs/api/system-preferences.md @@ -4,7 +4,7 @@ Process: [Main](../glossary.md#main-process) -```javascript +```js const { systemPreferences } = require('electron') console.log(systemPreferences.isAeroGlassEnabled()) ``` @@ -189,7 +189,7 @@ enabled, and `false` otherwise. An example of using it to determine if you should create a transparent window or not (transparent windows won't work correctly when DWM composition is disabled): -```javascript +```js const { BrowserWindow, systemPreferences } = require('electron') const browserOptions = { width: 1000, height: 800 } @@ -348,7 +348,7 @@ Returns `boolean` - whether or not this device has the ability to use Touch ID. Returns `Promise` - resolves if the user has successfully authenticated with Touch ID. -```javascript +```js const { systemPreferences } = require('electron') systemPreferences.promptTouchID('To get consent for a Security-Gated Thing').then(success => { diff --git a/docs/api/touch-bar.md b/docs/api/touch-bar.md index 7cbcc83ddd..c229430326 100644 --- a/docs/api/touch-bar.md +++ b/docs/api/touch-bar.md @@ -79,7 +79,7 @@ immediately updates the escape item in the touch bar. Below is an example of a simple slot machine touch bar game with a button and some labels. -```javascript +```js const { app, BrowserWindow, TouchBar } = require('electron') const { TouchBarLabel, TouchBarButton, TouchBarSpacer } = TouchBar diff --git a/docs/api/tray.md b/docs/api/tray.md index 84e1b6bd30..285065b2ae 100644 --- a/docs/api/tray.md +++ b/docs/api/tray.md @@ -8,7 +8,7 @@ Process: [Main](../glossary.md#main-process) `Tray` is an [EventEmitter][event-emitter]. -```javascript +```js const { app, Menu, Tray } = require('electron') let tray = null @@ -39,7 +39,7 @@ app.whenReady().then(() => { * In order for changes made to individual `MenuItem`s to take effect, you have to call `setContextMenu` again. For example: -```javascript +```js const { app, Menu, Tray } = require('electron') let appIcon = null diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 07965252b8..9896d7a1aa 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -9,7 +9,7 @@ It is responsible for rendering and controlling a web page and is a property of the [`BrowserWindow`](browser-window.md) object. An example of accessing the `webContents` object: -```javascript +```js const { BrowserWindow } = require('electron') const win = new BrowserWindow({ width: 800, height: 1500 }) @@ -53,7 +53,7 @@ If you want to also observe navigations in `