Compare commits

...

12 Commits

Author SHA1 Message Date
patchup[bot]
dde9f9d3ef chore: update patches 2025-06-11 19:03:17 +00:00
John Kleinschmidt
5db9939e9c Merge 0edcc985fa into 38fe14041d 2025-06-11 18:51:42 +00:00
Samuel Attard
0edcc985fa use pr head ref 2025-06-11 11:51:22 -07:00
Shelley Vohr
38fe14041d fix: crash calling Fetch.continueResponse with WebContentsView (#47434)
fix: crash calling Fetch.continueResponse with WebContentsView
2025-06-11 15:43:47 +02:00
dependabot[bot]
996945d3e3 build(deps): bump github/codeql-action from 3.28.18 to 3.28.19 (#47426)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ff0a06e83c...fca7ace96b)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-11 11:24:03 +02:00
Niklas Wenzel
d7ef8b79ae docs: mention kwallet6 command line option (#47427) 2025-06-10 16:12:31 -04:00
Erick Zhao
6aa3665b96 docs: no class inheritance (#47403) 2025-06-10 10:00:06 +02:00
Samuel Attard
37402a18a4 oops 2025-06-06 23:25:13 -07:00
Samuel Attard
a21afc3e45 again 2025-06-06 15:34:36 -07:00
John Kleinschmidt
cafcfe106d debug 2025-06-06 17:04:30 -04:00
John Kleinschmidt
1b1be6e1b3 Revert "chore: update patches (#47346)"
This reverts commit ba7c3bbdf7.
2025-06-06 16:43:32 -04:00
Samuel Attard
efafa08682 build: rewrite push-patch to use the github API instead of local git commits to ensure commits are signed 2025-06-06 13:00:15 -07:00
21 changed files with 209 additions and 53 deletions

View File

@@ -117,12 +117,7 @@ runs:
git update-index --refresh || true
if ! git diff-index --quiet HEAD --; then
# There are changes to the patches. Make a git commit with the updated patches
git add patches
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
# Export it
mkdir -p ../../patches
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
if node ./script/push-patch.js; then
if node ./script/patch-up.js; then
echo
echo "======================================================================"
echo "Changes to the patches when applying, we have auto-pushed the diff to the current branch"
@@ -130,6 +125,11 @@ runs:
echo "======================================================================"
exit 1
else
git add patches
GIT_COMMITTER_NAME="PatchUp" GIT_COMMITTER_EMAIL="73610968+patchup[bot]@users.noreply.github.com" git commit -m "chore: update patches" --author="PatchUp <73610968+patchup[bot]@users.noreply.github.com>"
# Export it
mkdir -p ../../patches
git format-patch -1 --stdout --keep-subject --no-stat --full-index > ../../patches/update-patches.patch
echo
echo "======================================================================"
echo "There were changes to the patches when applying."

View File

@@ -50,6 +50,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19
with:
sarif_file: results.sarif

View File

@@ -99,6 +99,10 @@ Process: [Main](../glossary.md#main-process)
It creates a new `BaseWindow` with native properties as set by the `options`.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new BaseWindow([options])`
* `options` [BaseWindowConstructorOptions](structures/base-window-options.md?inline) (optional)

View File

@@ -38,6 +38,10 @@ Process: [Main](../glossary.md#main-process)
This module cannot be used until the `ready` event of the `app`
module is emitted.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Example
```js

View File

@@ -151,6 +151,10 @@ Process: [Main](../glossary.md#main-process)
It creates a new `BrowserWindow` with native properties as set by the `options`.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new BrowserWindow([options])`
* `options` [BrowserWindowConstructorOptions](structures/browser-window-options.md?inline) (optional)

View File

@@ -43,6 +43,10 @@ Process: [Main](../glossary.md#main-process)
`ImageView` is an [EventEmitter][event-emitter].
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new ImageView()` _Experimental_
Creates an ImageView.

View File

@@ -11,6 +11,10 @@ Process: [Main](../glossary.md#main-process)
<!-- TODO(samuelmaddock): refactor doc gen to allow generics to reduce duplication -->
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Instance Methods
#### `ipcMainServiceWorker.on(channel, listener)`

View File

@@ -6,6 +6,10 @@ Process: [Main](../glossary.md#main-process)
See [`Menu`](menu.md) for examples.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new MenuItem(options)`
* `options` Object

View File

@@ -6,6 +6,10 @@
Process: [Main](../glossary.md#main-process)
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new Menu()`
Creates a new menu.

View File

@@ -37,6 +37,10 @@ ipcRenderer.on('port', (e) => {
})
```
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Instance Properties
#### `channel.port1`

View File

@@ -4,12 +4,9 @@
Process: [Main](../glossary.md#main-process)
:::info Renderer process notifications
If you want to show notifications from a renderer process you should use the
[web Notifications API](../tutorial/notifications.md)
:::
> [!NOTE]
> If you want to show notifications from a renderer process you should use the
> [web Notifications API](../tutorial/notifications.md)
## Class: Notification
@@ -21,6 +18,10 @@ Process: [Main](../glossary.md#main-process)
It creates a new `Notification` with native properties as set by the `options`.
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### Static Methods
The `Notification` class has the following static methods:

View File

@@ -73,5 +73,6 @@ command line flag is provided `--password-store="basic"`.
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`.
* `kwallet6` - When the desktop session is `kde6` or if the following command line flag
is provided `--password-store="kwallet6"`.
* `unknown` - When the function is called before app has emitted the `ready` event.

View File

@@ -13,6 +13,10 @@ For including the share menu as a submenu of other menus, please use the
Process: [Main](../glossary.md#main-process)
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new ShareMenu(sharingItem)`
* `sharingItem` SharingItem - The item to share.

View File

@@ -1,5 +1,9 @@
# TouchBar
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
## Class: TouchBar
> Create TouchBar layouts for native macOS applications

View File

@@ -25,6 +25,10 @@ app.whenReady().then(() => {
})
```
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
**Platform Considerations**
**Linux**

View File

@@ -26,6 +26,10 @@ Process: [Main](../glossary.md#main-process)
`View` is an [EventEmitter][event-emitter].
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new View()`
Creates a new `View`.

View File

@@ -33,6 +33,10 @@ Process: [Main](../glossary.md#main-process)
`WebContentsView` is an [EventEmitter][event-emitter].
> [!WARNING]
> Electron's built-in classes cannot be subclassed in user code.
> For more information, see [the FAQ](../faq.md#class-inheritance-does-not-work-with-electron-built-in-modules).
### `new WebContentsView([options])`
* `options` Object (optional)

View File

@@ -156,6 +156,14 @@ The effect is visible only on (some?) LCD screens. Even if you don't see a diffe
Notice that just setting the background in the CSS does not have the desired effect.
## Class inheritance does not work with Electron built-in modules
Electron classes cannot be subclassed with the [`extends`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends)
keyword (also known as class inheritance). This feature was never implemented in Electron due
to the added complexity it would add to C++/JavaScript interop in Electron's internals.
For more information, see [electron/electron#23](https://github.com/electron/electron/issues/23).
[memory-management]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
[closures]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage

128
script/patch-up.js Normal file
View File

@@ -0,0 +1,128 @@
const { appCredentialsFromString, getAuthOptionsForRepo } = require('@electron/github-app-auth');
const { Octokit } = require('@octokit/rest');
const fs = require('node:fs');
const path = require('node:path');
const { PATCH_UP_APP_CREDS } = process.env;
const REPO_OWNER = 'electron';
const REPO_NAME = 'electron';
async function getAllPatchFiles (dir) {
const files = [];
async function walkDir (currentDir) {
const entries = await fs.promises.readdir(currentDir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = path.join(currentDir, entry.name);
if (entry.isDirectory()) {
await walkDir(fullPath);
} else if (entry.isFile() && (entry.name.endsWith('.patch') || entry.name === 'README.md' || entry.name === 'config.json')) {
const relativePath = path.relative(process.cwd(), fullPath);
const content = await fs.promises.readFile(fullPath, 'utf8');
files.push({
path: relativePath,
content
});
}
}
}
await walkDir(dir);
return files;
}
function getCurrentCommitSha () {
return process.env.GITHUB_SHA;
}
function getCurrentBranch () {
return process.env.GITHUB_HEAD_REF;
}
async function main () {
if (!PATCH_UP_APP_CREDS) {
throw new Error('PATCH_UP_APP_CREDS environment variable not set');
}
const currentBranch = getCurrentBranch();
if (!currentBranch) {
throw new Error('GITHUB_HEAD_REF environment variable not set. Patch Up only works in PR workflows currently.');
}
const octokit = new Octokit({
...await getAuthOptionsForRepo({
name: REPO_OWNER,
owner: REPO_NAME
}, appCredentialsFromString(PATCH_UP_APP_CREDS))
});
const patchesDir = path.join(process.cwd(), 'patches');
// Get current git state
const currentCommitSha = getCurrentCommitSha();
// Get the tree SHA from the current commit
const currentCommit = await octokit.git.getCommit({
owner: REPO_OWNER,
repo: REPO_NAME,
commit_sha: currentCommitSha
});
const baseTreeSha = currentCommit.data.tree.sha;
// Find all patch files
const patchFiles = await getAllPatchFiles(patchesDir);
if (patchFiles.length === 0) {
throw new Error('No patch files found');
}
console.log(`Found ${patchFiles.length} patch files`);
// Create a new tree with the patch files
const tree = patchFiles.map(file => ({
path: file.path,
mode: '100644',
type: 'blob',
content: file.content
}));
const treeResponse = await octokit.git.createTree({
owner: REPO_OWNER,
repo: REPO_NAME,
base_tree: baseTreeSha,
tree
});
// Create a new commit
const commitMessage = 'chore: update patches';
const commitResponse = await octokit.git.createCommit({
owner: REPO_OWNER,
repo: REPO_NAME,
message: commitMessage,
tree: treeResponse.data.sha,
parents: [currentCommitSha]
});
// Update the branch reference
await octokit.git.updateRef({
owner: REPO_OWNER,
repo: REPO_NAME,
ref: `heads/${currentBranch}`,
sha: commitResponse.data.sha
});
console.log(`Successfully pushed commit ${commitResponse.data.sha} to ${currentBranch}`);
}
if (require.main === module) {
main().catch((err) => {
console.error(err);
process.exit(1);
});
}

View File

@@ -1,38 +0,0 @@
const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth');
const cp = require('node:child_process');
const { PATCH_UP_APP_CREDS } = process.env;
async function main () {
if (!PATCH_UP_APP_CREDS) {
throw new Error('PATCH_UP_APP_CREDS environment variable not set');
}
const token = await getTokenForRepo(
{
name: 'electron',
owner: 'electron'
},
appCredentialsFromString(PATCH_UP_APP_CREDS)
);
const remoteURL = `https://x-access-token:${token}@github.com/electron/electron.git`;
// NEVER LOG THE OUTPUT OF THIS COMMAND
// GIT LEAKS THE ACCESS CREDENTIALS IN CONSOLE LOGS
const { status } = cp.spawnSync('git', ['push', '--set-upstream', remoteURL], {
stdio: 'ignore'
});
if (status !== 0) {
throw new Error('Failed to push to target branch');
}
}
if (require.main === module) {
main().catch((err) => {
console.error(err);
process.exit(1);
});
}

View File

@@ -81,7 +81,11 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
void Debugger::RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
content::RenderFrameHost* new_rfh) {
if (agent_host_) {
// ConnectWebContents uses the primary main frame of the webContents,
// so if the new_rfh is not the primary main frame, we don't want to
// reconnect otherwise we'll end up trying to reconnect to a RenderFrameHost
// that already has a DevToolsAgentHost associated with it.
if (agent_host_ && new_rfh->IsInPrimaryMainFrame()) {
agent_host_->DisconnectWebContents();
auto* web_contents = content::WebContents::FromRenderFrameHost(new_rfh);
agent_host_->ConnectWebContents(web_contents);