mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
54 Commits
v34.0.0-al
...
v35.0.0-ni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15151c6853 | ||
|
|
8be4ae4bab | ||
|
|
31f8e7553b | ||
|
|
7cdf1a01b8 | ||
|
|
a720c8daf6 | ||
|
|
fb959f8d30 | ||
|
|
de04fc3b90 | ||
|
|
7ff7160135 | ||
|
|
9fc94a162b | ||
|
|
53458da01e | ||
|
|
dffe00b232 | ||
|
|
39b24aed92 | ||
|
|
f7ead785cd | ||
|
|
b3c2e83243 | ||
|
|
cc3359f126 | ||
|
|
46561fc5bc | ||
|
|
214c8228ed | ||
|
|
739688214b | ||
|
|
5d0d15a0b3 | ||
|
|
348801b20e | ||
|
|
57920e7747 | ||
|
|
a0f51d816e | ||
|
|
83d7040096 | ||
|
|
c42fb09fc9 | ||
|
|
fd500477ac | ||
|
|
d60d526df6 | ||
|
|
e3e94d45ee | ||
|
|
fff6ea438a | ||
|
|
3e77faf2f7 | ||
|
|
cc9d85d3ca | ||
|
|
d3d02ef111 | ||
|
|
e70f70f5b4 | ||
|
|
0d948da4b9 | ||
|
|
2cf59b3885 | ||
|
|
87bd665e41 | ||
|
|
35aeab6ecd | ||
|
|
738533dec7 | ||
|
|
456aac1f94 | ||
|
|
6c6e5c002a | ||
|
|
089f233054 | ||
|
|
2b0624f2f1 | ||
|
|
ac09d11ed1 | ||
|
|
9280add5b4 | ||
|
|
44c398fedb | ||
|
|
cbc12d6675 | ||
|
|
d801bad5d2 | ||
|
|
d386664900 | ||
|
|
67775d19ec | ||
|
|
cbe3cb770a | ||
|
|
bd4ea5ba72 | ||
|
|
af6e2fb257 | ||
|
|
df45474b58 | ||
|
|
b5acebf3ba | ||
|
|
ef84f13650 |
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -8,6 +8,7 @@
|
||||
DEPS @electron/wg-upgrades
|
||||
|
||||
# Releases WG
|
||||
/.github/workflows/update_appveyor_image.yml @electron/wg-releases
|
||||
/docs/breaking-changes.md @electron/wg-releases
|
||||
/npm/ @electron/wg-releases
|
||||
/script/release @electron/wg-releases
|
||||
|
||||
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
4
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: Bug Report
|
||||
description: Report an Electron bug
|
||||
title: "[Bug]: "
|
||||
description: Report a bug in Electron
|
||||
type: 'bug'
|
||||
labels: "bug :beetle:"
|
||||
body:
|
||||
- type: checkboxes
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: Feature Request
|
||||
description: Suggest an idea for Electron
|
||||
title: "[Feature Request]: "
|
||||
type: 'enhancement'
|
||||
labels: "enhancement :sparkles:"
|
||||
body:
|
||||
- type: checkboxes
|
||||
|
||||
15
.github/actions/checkout/action.yml
vendored
15
.github/actions/checkout/action.yml
vendored
@@ -57,13 +57,26 @@ runs:
|
||||
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
||||
echo "Using cache key: $DEPSHASH"
|
||||
echo "Checking for cache in: $cache_path"
|
||||
if [ ! -f "$cache_path" ]; then
|
||||
if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
|
||||
echo "cache_exists=false" >> $GITHUB_OUTPUT
|
||||
echo "Cache Does Not Exist for $DEPSHASH"
|
||||
else
|
||||
echo "cache_exists=true" >> $GITHUB_OUTPUT
|
||||
echo "Cache Already Exists for $DEPSHASH, Skipping.."
|
||||
fi
|
||||
- name: Check cross instance cache disk space
|
||||
if: steps.check-cache.outputs.cache_exists == 'false'
|
||||
shell: bash
|
||||
run: |
|
||||
# if there is less than 20 GB free space then creating the cache might fail so exit early
|
||||
freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
||||
freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
||||
if [ $freespace -le 20000 ]; then
|
||||
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
||||
exit 1
|
||||
else
|
||||
echo "The cross mount cache has $freespace_human free space - continuing"
|
||||
fi
|
||||
- name: Gclient Sync
|
||||
if: steps.check-cache.outputs.cache_exists == 'false'
|
||||
shell: bash
|
||||
|
||||
5
.github/actions/restore-cache-aks/action.yml
vendored
5
.github/actions/restore-cache-aks/action.yml
vendored
@@ -17,6 +17,11 @@ runs:
|
||||
fi
|
||||
|
||||
echo "Persisted cache is $(du -sh $cache_path | cut -f1)"
|
||||
if [ `du $cache_path | cut -f1` = "0" ]; then
|
||||
echo "Cache is empty - exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir temp-cache
|
||||
tar -xf $cache_path -C temp-cache
|
||||
echo "Unzipped cache is $(du -sh temp-cache/src | cut -f1)"
|
||||
|
||||
@@ -44,6 +44,11 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)"
|
||||
if [ `du $DEPSHASH.tar | cut -f1` = "0" ]; then
|
||||
echo "Cache is empty - exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir temp-cache
|
||||
tar -xf $DEPSHASH.tar -C temp-cache
|
||||
echo "Unzipped cache is $(du -sh temp-cache/src | cut -f1)"
|
||||
|
||||
6
.github/workflows/archaeologist-dig.yml
vendored
6
.github/workflows/archaeologist-dig.yml
vendored
@@ -9,11 +9,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.0.2
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Setup Node.js/npm
|
||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6
|
||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
- name: Setting Up Dig Site
|
||||
@@ -41,7 +41,7 @@ jobs:
|
||||
sha-file: .dig-old
|
||||
filename: electron.old.d.ts
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 #v4.4.0
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 #v4.4.3
|
||||
with:
|
||||
name: artifacts
|
||||
path: electron/artifacts
|
||||
|
||||
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
||||
build-image-sha: ${{ steps.set-output.outputs.build-image-sha }}
|
||||
docs-only: ${{ steps.set-output.outputs.docs-only }}
|
||||
steps:
|
||||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 #v4.0.2
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.0.2
|
||||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
||||
id: filter
|
||||
with:
|
||||
@@ -94,7 +94,7 @@ jobs:
|
||||
build-image-sha: ${{ needs.setup.outputs.build-image-sha }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
@@ -120,7 +120,7 @@ jobs:
|
||||
build-image-sha: ${{ needs.setup.outputs.build-image-sha}}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
21
.github/workflows/clean-src-cache.yml
vendored
Normal file
21
.github/workflows/clean-src-cache.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Clean Source Cache
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * SUN" # Run at midnight every Sunday
|
||||
|
||||
jobs:
|
||||
clean-src-cache:
|
||||
runs-on: electron-arc-linux-amd64-32core
|
||||
container:
|
||||
image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1
|
||||
options: --user root
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
steps:
|
||||
- name: Cleanup Source Cache
|
||||
shell: bash
|
||||
run: |
|
||||
df -h /mnt/cross-instance-cache
|
||||
find /mnt/cross-instance-cache -type f -mtime +30 -delete
|
||||
df -h /mnt/cross-instance-cache
|
||||
2
.github/workflows/linux-publish.yml
vendored
2
.github/workflows/linux-publish.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
2
.github/workflows/macos-publish.yml
vendored
2
.github/workflows/macos-publish.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
container: ${{ fromJSON(inputs.container) }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
2
.github/workflows/pipeline-electron-lint.yml
vendored
2
.github/workflows/pipeline-electron-lint.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
container: ${{ fromJSON(inputs.container) }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
- name: Create src dir
|
||||
run: mkdir src
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
@@ -95,7 +95,7 @@ jobs:
|
||||
run: df -h
|
||||
- name: Setup Node.js/npm
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6
|
||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
cache: yarn
|
||||
@@ -156,7 +156,7 @@ jobs:
|
||||
if: ${{ inputs.target-platform == 'linux' }}
|
||||
uses: ./src/electron/.github/actions/restore-cache-aks
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
TARGET_ARCH: ${{ inputs.target-arch }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
@@ -128,7 +128,7 @@ jobs:
|
||||
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
||||
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
fi
|
||||
done
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
@@ -203,7 +203,7 @@ jobs:
|
||||
if: always() && !cancelled()
|
||||
- name: Upload Test Artifacts
|
||||
if: always() && !cancelled()
|
||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
|
||||
with:
|
||||
name: test_artifacts_${{ env.ARTIFACT_KEY }}
|
||||
path: src/electron/spec/artifacts
|
||||
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
container: ${{ fromJSON(inputs.test-container) }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
@@ -108,7 +108,7 @@ jobs:
|
||||
container: ${{ fromJSON(inputs.test-container) }}
|
||||
steps:
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
|
||||
6
.github/workflows/scorecards.yml
vendored
6
.github/workflows/scorecards.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
@@ -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@f779452ac5af1c261dce0346a8f964149f49322b # v3.26.13
|
||||
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
6
.github/workflows/update_appveyor_image.yml
vendored
6
.github/workflows/update_appveyor_image.yml
vendored
@@ -19,10 +19,14 @@ jobs:
|
||||
with:
|
||||
creds: ${{ secrets.APPVEYOR_UPDATER_GH_APP_CREDS }}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
|
||||
with:
|
||||
node-version: 20.11.x
|
||||
- name: Yarn install
|
||||
run: |
|
||||
node script/yarn.js install --frozen-lockfile
|
||||
|
||||
5
BUILD.gn
5
BUILD.gn
@@ -865,6 +865,7 @@ if (is_mac) {
|
||||
":electron_framework_resources",
|
||||
":electron_swiftshader_library",
|
||||
":electron_xibs",
|
||||
"//third_party/electron_node:node_lib",
|
||||
]
|
||||
if (!is_mas_build) {
|
||||
deps += [ ":electron_crashpad_helper" ]
|
||||
@@ -920,7 +921,6 @@ if (is_mac) {
|
||||
"shell/app/electron_main_mac.cc",
|
||||
"shell/app/uv_stdio_fix.cc",
|
||||
"shell/app/uv_stdio_fix.h",
|
||||
"shell/common/electron_constants.cc",
|
||||
]
|
||||
include_dirs = [ "." ]
|
||||
info_plist = "shell/renderer/resources/mac/Info.plist"
|
||||
@@ -1189,6 +1189,7 @@ if (is_mac) {
|
||||
"//components/crash/core/app",
|
||||
"//content:sandbox_helper_win",
|
||||
"//electron/buildflags",
|
||||
"//third_party/electron_node:node_lib",
|
||||
"//ui/strings",
|
||||
]
|
||||
|
||||
@@ -1535,7 +1536,7 @@ copy("node_gypi_headers") {
|
||||
action("node_version_header") {
|
||||
inputs = [ "$node_dir/src/node_version.h" ]
|
||||
outputs = [ "$node_headers_dir/include/node/node_version.h" ]
|
||||
script = "script/generate_node_version_header.py"
|
||||
script = "script/node/generate_node_version_header.py"
|
||||
args = rebase_path(inputs) + rebase_path(outputs)
|
||||
if (node_module_version != "") {
|
||||
args += [ "$node_module_version" ]
|
||||
|
||||
2
DEPS
2
DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'132.0.6789.1',
|
||||
'132.0.6789.0',
|
||||
'node_version':
|
||||
'v20.18.0',
|
||||
'nan_version':
|
||||
|
||||
@@ -77,3 +77,6 @@ enterprise_cloud_content_analysis = false
|
||||
# TODO: remove dependency on legacy ipc
|
||||
# https://issues.chromium.org/issues/40943039
|
||||
content_enable_legacy_ipc = true
|
||||
|
||||
# Electron has its own unsafe-buffers enforcement directories.
|
||||
clang_unsafe_buffers_paths = "//electron/electron_unsafe_buffers_paths.txt"
|
||||
|
||||
@@ -512,7 +512,7 @@ Sets the content view of the window.
|
||||
|
||||
#### `win.getContentView()`
|
||||
|
||||
Returns [View](view.md) - The content view of the window.
|
||||
Returns [`View`](view.md) - The content view of the window.
|
||||
|
||||
#### `win.destroy()`
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ See https://developer.apple.com/library/archive/documentation/Performance/Concep
|
||||
|
||||
### Event: 'speed-limit-change' _macOS_ _Windows_
|
||||
|
||||
Returns:
|
||||
|
||||
* `limit` number - The operating system's advertised speed limit for CPUs, in percent.
|
||||
|
||||
Notification of a change in the operating system's advertised speed limit for
|
||||
|
||||
@@ -955,11 +955,17 @@ Emitted when a `<webview>` has been attached to this web contents.
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `level` Integer - The log level, from 0 to 3. In order it matches `verbose`, `info`, `warning` and `error`.
|
||||
* `message` string - The actual console message
|
||||
* `line` Integer - The line number of the source that triggered this console message
|
||||
* `sourceId` string
|
||||
* `details` Event\<\>
|
||||
* `message` string - Message text
|
||||
* `level` string - Message severity
|
||||
Possible values include `info`, `warning`, `error`, and `debug`.
|
||||
* `lineNumber` Integer - Line number in the log source
|
||||
* `sourceId` string - URL of the log source
|
||||
* `frame` WebFrameMain - Frame that logged the message
|
||||
* `level` Integer _Deprecated_ - The log level, from 0 to 3. In order it matches `verbose`, `info`, `warning` and `error`.
|
||||
* `message` string _Deprecated_ - The actual console message
|
||||
* `line` Integer _Deprecated_ - The line number of the source that triggered this console message
|
||||
* `sourceId` string _Deprecated_
|
||||
|
||||
Emitted when the associated window logs a console message.
|
||||
|
||||
|
||||
@@ -12,6 +12,23 @@ This document uses the following convention to categorize breaking changes:
|
||||
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
|
||||
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
|
||||
|
||||
## Planned Breaking API Changes (34.0)
|
||||
|
||||
### Deprecated: `level`, `message`, `line`, and `sourceId` arguments in `console-message` event on `WebContents`
|
||||
|
||||
The `console-message` event on `WebContents` has been updated to provide details on the `Event`
|
||||
argument.
|
||||
|
||||
```js
|
||||
// Deprecated
|
||||
webContents.on('console-message', (event, level, message, line, sourceId) => {})
|
||||
|
||||
// Replace with:
|
||||
webContents.on('console-message', ({ level, message, lineNumber, sourceId, frame }) => {})
|
||||
```
|
||||
|
||||
Additionally, `level` is now a string with possible values of `info`, `warning`, `error`, and `debug`.
|
||||
|
||||
## Planned Breaking API Changes (33.0)
|
||||
|
||||
### Behavior Changed: frame properties may retrieve detached WebFrameMain instances or none at all
|
||||
|
||||
@@ -78,7 +78,6 @@ The following Devtools extensions have been tested to work in Electron:
|
||||
* [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi)
|
||||
* [Backbone Debugger](https://chrome.google.com/webstore/detail/backbone-debugger/bhljhndlimiafopmmhjlgfpnnchjjbhd)
|
||||
* [jQuery Debugger](https://chrome.google.com/webstore/detail/jquery-debugger/dbhhnnnpaeobfddmlalhnehgclcmjimi)
|
||||
* [AngularJS Batarang](https://chrome.google.com/webstore/detail/angularjs-batarang/ighdmehidhipcmcojjgiloacoafjmpfk)
|
||||
* [Vue.js devtools](https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
|
||||
* [Cerebral Debugger](https://cerebraljs.com/docs/introduction/devtools.html)
|
||||
* [Redux DevTools Extension](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd)
|
||||
|
||||
34
electron_unsafe_buffers_paths.txt
Normal file
34
electron_unsafe_buffers_paths.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
# Copyright 2024 The Electron Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# The set of path prefixes that should be checked for unsafe buffer usage (see
|
||||
# -Wunsafe-buffer-usage in Clang).
|
||||
#
|
||||
# ***
|
||||
# Paths should be written as relative to the root of the source tree with
|
||||
# unix-style path separators. Directory prefixes should end with `/`, such
|
||||
# as `base/`.
|
||||
# ***
|
||||
#
|
||||
# Files in this set are known to not use pointer arithmetic/subscripting, and
|
||||
# make use of constructs like base::span or containers like std::vector instead.
|
||||
#
|
||||
# See `docs/unsafe_buffers.md`.
|
||||
|
||||
# These directories are excluded because they come from outside Electron and
|
||||
# we don't have control over their contents.
|
||||
-base/
|
||||
-chrome/
|
||||
-components/
|
||||
-device/
|
||||
-extensions/
|
||||
-google_apis/
|
||||
-net/
|
||||
-services/
|
||||
-skia/
|
||||
-third_party/
|
||||
-tools/
|
||||
-ui/
|
||||
-url/
|
||||
-v8/
|
||||
@@ -582,7 +582,6 @@ filenames = {
|
||||
"shell/common/crash_keys.h",
|
||||
"shell/common/electron_command_line.cc",
|
||||
"shell/common/electron_command_line.h",
|
||||
"shell/common/electron_constants.cc",
|
||||
"shell/common/electron_constants.h",
|
||||
"shell/common/electron_paths.h",
|
||||
"shell/common/gin_converters/accelerator_converter.cc",
|
||||
|
||||
@@ -549,6 +549,8 @@ WebContents.prototype.goToOffset = function (index: number) {
|
||||
return this._goToOffset(index);
|
||||
};
|
||||
|
||||
const consoleMessageDeprecated = deprecate.warnOnceMessage('\'console-message\' arguments are deprecated and will be removed. Please use Event<WebContentsConsoleMessageEventParams> object instead.');
|
||||
|
||||
// Add JavaScript wrappers for WebContents class.
|
||||
WebContents.prototype._init = function () {
|
||||
const prefs = this.getLastWebPreferences() || {};
|
||||
@@ -909,6 +911,15 @@ WebContents.prototype._init = function () {
|
||||
openDialogs.clear();
|
||||
});
|
||||
|
||||
// TODO(samuelmaddock): remove deprecated 'console-message' arguments
|
||||
this.on('-console-message' as any, (event: Electron.Event<Electron.WebContentsConsoleMessageEventParams>) => {
|
||||
const hasDeprecatedListener = this.listeners('console-message').some(listener => listener.length > 1);
|
||||
if (hasDeprecatedListener) {
|
||||
consoleMessageDeprecated();
|
||||
}
|
||||
this.emit('console-message', event, (event as any)._level, event.message, event.lineNumber, event.sourceId);
|
||||
});
|
||||
|
||||
app.emit('web-contents-created', { sender: this, preventDefault () {}, get defaultPrevented () { return false; } }, this);
|
||||
|
||||
// Properties
|
||||
|
||||
@@ -6,7 +6,7 @@ wrapFsWithAsar(require('fs'));
|
||||
|
||||
// See ElectronRendererClient::DidCreateScriptContext.
|
||||
if ((globalThis as any).blinkfetch) {
|
||||
const keys = ['fetch', 'Response', 'FormData', 'Request', 'Headers'];
|
||||
const keys = ['fetch', 'Response', 'FormData', 'Request', 'Headers', 'EventSource'];
|
||||
for (const key of keys) {
|
||||
(globalThis as any)[key] = (globalThis as any)[`blink${key}`];
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ global.require = makeRequireFunction(global.module);
|
||||
|
||||
// See WebWorkerObserver::WorkerScriptReadyForEvaluation.
|
||||
if ((globalThis as any).blinkfetch) {
|
||||
const keys = ['fetch', 'Response', 'FormData', 'Request', 'Headers'];
|
||||
const keys = ['fetch', 'Response', 'FormData', 'Request', 'Headers', 'EventSource'];
|
||||
for (const key of keys) {
|
||||
(globalThis as any)[key] = (globalThis as any)[`blink${key}`];
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
"null-loader": "^4.0.1",
|
||||
"pre-flight": "^2.0.0",
|
||||
"process": "^0.11.10",
|
||||
"remark-cli": "^10.0.0",
|
||||
"remark-cli": "^12.0.1",
|
||||
"remark-preset-lint-markdown-style-guide": "^4.0.0",
|
||||
"semver": "^7.6.3",
|
||||
"shx": "^0.3.4",
|
||||
@@ -58,7 +58,7 @@
|
||||
"ts-node": "6.2.0",
|
||||
"typescript": "^5.6.2",
|
||||
"url": "^0.11.4",
|
||||
"webpack": "^5.94.0",
|
||||
"webpack": "^5.95.0",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"wrapper-webpack-plugin": "^2.2.0"
|
||||
},
|
||||
|
||||
@@ -132,5 +132,5 @@ build_expose_webplugininfo_interface_to_electron.patch
|
||||
osr_shared_texture_remove_keyed_mutex_on_win_dxgi.patch
|
||||
feat_allow_usage_of_sccontentsharingpicker_on_supported_platforms.patch
|
||||
chore_partial_revert_of.patch
|
||||
ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch
|
||||
fix_software_compositing_infinite_loop.patch
|
||||
ui_add_missing_shortcut_text_for_vkey_command_on_linux.patch
|
||||
|
||||
@@ -11,7 +11,7 @@ really in 20/21. We have to wait until 22 is released to be able to
|
||||
build with upstream GN files.
|
||||
|
||||
diff --git a/BUILD.gn b/BUILD.gn
|
||||
index 1ed186b597eece7c34cb69c8e1e20870555a040d..2ce1e8a7dcca2ba153d387d11970c72b5f43c167 100644
|
||||
index 1ed186b597eece7c34cb69c8e1e20870555a040d..e36168f0a051ca2fa2fc024aadcf5375b860105e 100644
|
||||
--- a/BUILD.gn
|
||||
+++ b/BUILD.gn
|
||||
@@ -1,14 +1,406 @@
|
||||
@@ -113,7 +113,7 @@ index 1ed186b597eece7c34cb69c8e1e20870555a040d..2ce1e8a7dcca2ba153d387d11970c72b
|
||||
+}
|
||||
+
|
||||
+action("node_js2c_original_fs") {
|
||||
+ script = "tools/generate_original_fs.py"
|
||||
+ script = "//electron/script/node/generate_original_fs.py"
|
||||
+ inputs = fs_files
|
||||
+ outputs = []
|
||||
+ foreach(file, fs_files + original_fs_files) {
|
||||
@@ -2384,30 +2384,6 @@ index 0000000000000000000000000000000000000000..37c16859003e61636fe2f1a4040b1e90
|
||||
+ f.write(FILENAMES_JSON_HEADER)
|
||||
+ f.write(json.dumps(out, sort_keys=True, indent=2, separators=(',', ': ')))
|
||||
+ f.write('\n')
|
||||
diff --git a/tools/generate_original_fs.py b/tools/generate_original_fs.py
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5259e6a7a1fd6b21df69dc461dee67d95800c2c8
|
||||
--- /dev/null
|
||||
+++ b/tools/generate_original_fs.py
|
||||
@@ -0,0 +1,18 @@
|
||||
+import os
|
||||
+import sys
|
||||
+
|
||||
+node_root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
+out_dir = sys.argv[1]
|
||||
+fs_files = sys.argv[2:]
|
||||
+
|
||||
+for fs_file in fs_files:
|
||||
+ with open(os.path.join(node_root_dir, fs_file), 'r') as f:
|
||||
+ contents = f.read()
|
||||
+ original_fs_file = fs_file.replace('internal/fs/', 'internal/original-fs/').replace('lib/fs.js', 'lib/original-fs.js').replace('lib/fs/', 'lib/original-fs/')
|
||||
+
|
||||
+ with open(os.path.join(out_dir, fs_file), 'w') as original_f:
|
||||
+ original_f.write(contents)
|
||||
+
|
||||
+ with open(os.path.join(out_dir, original_fs_file), 'w') as transformed_f:
|
||||
+ transformed_contents = contents.replace('internal/fs/', 'internal/original-fs/').replace('require(\'fs', 'require(\'original-fs')
|
||||
+ transformed_f.write(transformed_contents)
|
||||
diff --git a/tools/install.py b/tools/install.py
|
||||
index b132c7bf26c02886a7ab341a1973bf449744ba0f..757e3e60a7be01fac55c5fbb010dbbae00b1bfca 100755
|
||||
--- a/tools/install.py
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import sys
|
||||
|
||||
node_version_file = sys.argv[1]
|
||||
out_file = sys.argv[2]
|
||||
NMV = None
|
||||
if len(sys.argv) > 3:
|
||||
NMV = sys.argv[3]
|
||||
|
||||
with open(node_version_file, 'r', encoding='utf-8') as in_file, \
|
||||
open(out_file, 'w', encoding='utf-8') as out_file:
|
||||
changed = False
|
||||
contents = in_file.read()
|
||||
new_contents = re.sub(
|
||||
r'^#define NODE_MODULE_VERSION [0-9]+$',
|
||||
'#define NODE_MODULE_VERSION ' + NMV,
|
||||
contents,
|
||||
flags=re.MULTILINE)
|
||||
|
||||
changed = contents != new_contents
|
||||
|
||||
if not changed and NMV is not None:
|
||||
raise Exception("Did not modify the NMV from nodes value, this value MUST "
|
||||
"differ from node")
|
||||
|
||||
out_file.writelines(new_contents)
|
||||
25
script/node/generate_node_version_header.py
Executable file
25
script/node/generate_node_version_header.py
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
node_version_file = sys.argv[1]
|
||||
out_file = sys.argv[2]
|
||||
NMV = None
|
||||
if len(sys.argv) > 3:
|
||||
NMV = sys.argv[3]
|
||||
|
||||
with open(node_version_file, 'r', encoding='utf-8') as in_file:
|
||||
with open(out_file, 'w', encoding='utf-8') as out_file:
|
||||
changed = False
|
||||
contents = in_file.read()
|
||||
new_contents = re.sub(r'^#define NODE_MODULE_VERSION [0-9]+$',
|
||||
'#define NODE_MODULE_VERSION ' + NMV,
|
||||
contents, flags=re.MULTILINE)
|
||||
|
||||
changed = contents != new_contents
|
||||
|
||||
if not changed and NMV is not None:
|
||||
raise Exception('NMV must differ from current value in Node.js')
|
||||
|
||||
out_file.writelines(new_contents)
|
||||
28
script/node/generate_original_fs.py
Normal file
28
script/node/generate_original_fs.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
NODE_ROOT_DIR = "../../third_party/electron_node"
|
||||
out_dir = sys.argv[1]
|
||||
fs_files = sys.argv[2:]
|
||||
|
||||
for fs_file in fs_files:
|
||||
with open(os.path.join(NODE_ROOT_DIR, fs_file), 'r',
|
||||
encoding='utf-8') as f:
|
||||
contents = f.read()
|
||||
original_fs_file = fs_file.replace('internal/fs/',
|
||||
'internal/original-fs/').replace('lib/fs.js',
|
||||
'lib/original-fs.js').replace('lib/fs/',
|
||||
'lib/original-fs/')
|
||||
|
||||
with open(os.path.join(out_dir, fs_file), 'w', encoding='utf-8'
|
||||
) as original_f:
|
||||
original_f.write(contents)
|
||||
|
||||
with open(os.path.join(out_dir, original_fs_file), 'w',
|
||||
encoding='utf-8') as transformed_f:
|
||||
transformed_contents = contents.replace('internal/fs/',
|
||||
'internal/original-fs/').replace('require(\'fs',
|
||||
'require(\'original-fs')
|
||||
transformed_f.write(transformed_contents)
|
||||
@@ -187,7 +187,8 @@ void ElectronContentClient::AddPlugins(
|
||||
pdf_info.name = kPDFInternalPluginName;
|
||||
pdf_info.description = kPDFPluginDescription;
|
||||
// This isn't a real file path; it's just used as a unique identifier.
|
||||
pdf_info.path = base::FilePath(kPdfPluginPath);
|
||||
static constexpr std::string_view kPdfPluginPath = "internal-pdf-viewer";
|
||||
pdf_info.path = base::FilePath::FromASCII(kPdfPluginPath);
|
||||
content::WebPluginMimeType pdf_mime_type(
|
||||
pdf::kInternalPluginMimeType, kPDFPluginExtension, kPDFPluginDescription);
|
||||
pdf_info.mime_types.push_back(pdf_mime_type);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "base/apple/bundle_locations.h"
|
||||
#include "base/apple/scoped_nsautorelease_pool.h"
|
||||
#include "base/at_exit.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
#include "electron/fuses.h"
|
||||
@@ -16,21 +17,22 @@
|
||||
#include "shell/app/node_main.h"
|
||||
#include "shell/common/electron_command_line.h"
|
||||
#include "shell/common/mac/main_application_bundle.h"
|
||||
#include "uv.h"
|
||||
|
||||
int ElectronMain(int argc, char* argv[]) {
|
||||
electron::ElectronMainDelegate delegate;
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.argc = argc;
|
||||
params.argv = const_cast<const char**>(argv);
|
||||
argv = uv_setup_args(argc, argv);
|
||||
base::CommandLine::Init(argc, argv);
|
||||
electron::ElectronCommandLine::Init(argc, argv);
|
||||
|
||||
electron::ElectronMainDelegate delegate;
|
||||
|
||||
// Ensure that Bundle Id is set before ContentMain.
|
||||
// Refs https://chromium-review.googlesource.com/c/chromium/src/+/5581006
|
||||
delegate.OverrideChildProcessPath();
|
||||
delegate.OverrideFrameworkBundlePath();
|
||||
delegate.SetUpBundleOverrides();
|
||||
|
||||
return content::ContentMain(std::move(params));
|
||||
return content::ContentMain(content::ContentMainParams{&delegate});
|
||||
}
|
||||
|
||||
int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
|
||||
@@ -39,6 +41,10 @@ int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
argv = uv_setup_args(argc, argv);
|
||||
base::CommandLine::Init(argc, argv);
|
||||
electron::ElectronCommandLine::Init(argc, argv);
|
||||
|
||||
base::AtExitManager atexit_manager;
|
||||
base::apple::ScopedNSAutoreleasePool pool;
|
||||
base::apple::SetOverrideFrameworkBundlePath(
|
||||
@@ -47,5 +53,5 @@ int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
|
||||
.Append("Frameworks")
|
||||
.Append(ELECTRON_PRODUCT_NAME " Framework.framework"));
|
||||
base::i18n::InitializeICU();
|
||||
return electron::NodeMain(argc, argv);
|
||||
return electron::NodeMain();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "base/at_exit.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "content/public/app/content_main.h"
|
||||
#include "electron/fuses.h"
|
||||
#include "shell/app/electron_main_delegate.h" // NOLINT
|
||||
@@ -15,12 +16,13 @@
|
||||
#include "shell/app/uv_stdio_fix.h"
|
||||
#include "shell/common/electron_command_line.h"
|
||||
#include "shell/common/electron_constants.h"
|
||||
#include "uv.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
char* indicator = getenv(name);
|
||||
return indicator && indicator[0] != '\0';
|
||||
[[nodiscard]] bool IsEnvSet(const base::cstring_view name) {
|
||||
const char* const indicator = getenv(name.c_str());
|
||||
return indicator && *indicator;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -28,17 +30,16 @@ bool IsEnvSet(const char* name) {
|
||||
int main(int argc, char* argv[]) {
|
||||
FixStdioStreams();
|
||||
|
||||
argv = uv_setup_args(argc, argv);
|
||||
base::CommandLine::Init(argc, argv);
|
||||
electron::ElectronCommandLine::Init(argc, argv);
|
||||
|
||||
if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
|
||||
base::i18n::InitializeICU();
|
||||
base::AtExitManager atexit_manager;
|
||||
return electron::NodeMain(argc, argv);
|
||||
return electron::NodeMain();
|
||||
}
|
||||
|
||||
electron::ElectronMainDelegate delegate;
|
||||
content::ContentMainParams params(&delegate);
|
||||
electron::ElectronCommandLine::Init(argc, argv);
|
||||
params.argc = argc;
|
||||
params.argv = const_cast<const char**>(argv);
|
||||
base::CommandLine::Init(params.argc, params.argv);
|
||||
return content::ContentMain(std::move(params));
|
||||
return content::ContentMain(content::ContentMainParams{&delegate});
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "electron/fuses.h"
|
||||
#include "electron/mas.h"
|
||||
#include "shell/app/electron_library_main.h"
|
||||
#include "shell/app/uv_stdio_fix.h"
|
||||
#include "shell/common/electron_constants.h"
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||
#include <mach-o/dyld.h>
|
||||
@@ -27,9 +29,9 @@ void abort_report_np(const char* fmt, ...);
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
char* indicator = getenv(name);
|
||||
return indicator && indicator[0] != '\0';
|
||||
[[nodiscard]] bool IsEnvSet(const base::cstring_view name) {
|
||||
const char* const indicator = getenv(name.c_str());
|
||||
return indicator && *indicator;
|
||||
}
|
||||
|
||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||
@@ -51,8 +53,7 @@ bool IsEnvSet(const char* name) {
|
||||
int main(int argc, char* argv[]) {
|
||||
FixStdioStreams();
|
||||
|
||||
if (electron::fuses::IsRunAsNodeEnabled() &&
|
||||
IsEnvSet("ELECTRON_RUN_AS_NODE")) {
|
||||
if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
|
||||
return ElectronInitializeICUandStartNode(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "base/i18n/icu_util.h"
|
||||
#include "base/memory/raw_ptr_exclusion.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/dark_mode_support.h"
|
||||
#include "chrome/app/exit_code_watcher_win.h"
|
||||
@@ -45,9 +46,9 @@ namespace {
|
||||
const char kUserDataDir[] = "user-data-dir";
|
||||
const char kProcessType[] = "type";
|
||||
|
||||
bool IsEnvSet(const char* name) {
|
||||
size_t required_size;
|
||||
getenv_s(&required_size, nullptr, 0, name);
|
||||
[[nodiscard]] bool IsEnvSet(const base::cstring_view name) {
|
||||
size_t required_size = 0;
|
||||
getenv_s(&required_size, nullptr, 0, name.c_str());
|
||||
return required_size != 0;
|
||||
}
|
||||
|
||||
@@ -126,20 +127,19 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
// If we are already a fiber then continue normal execution.
|
||||
#endif // defined(ARCH_CPU_32_BITS)
|
||||
|
||||
struct Arguments {
|
||||
{
|
||||
int argc = 0;
|
||||
RAW_PTR_EXCLUSION wchar_t** argv =
|
||||
::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
|
||||
~Arguments() { LocalFree(argv); }
|
||||
} arguments;
|
||||
|
||||
if (!arguments.argv)
|
||||
return -1;
|
||||
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
if (!argv)
|
||||
return -1;
|
||||
base::CommandLine::Init(0, nullptr); // args ignored on Windows
|
||||
electron::ElectronCommandLine::Init(argc, argv);
|
||||
LocalFree(argv);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Don't display assert dialog boxes in CI test runs
|
||||
static const char kCI[] = "CI";
|
||||
static constexpr base::cstring_view kCI = "CI";
|
||||
if (IsEnvSet(kCI)) {
|
||||
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
|
||||
@@ -158,18 +158,12 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
||||
base::RouteStdioToConsole(false);
|
||||
|
||||
std::vector<char*> argv(arguments.argc);
|
||||
std::transform(arguments.argv, arguments.argv + arguments.argc, argv.begin(),
|
||||
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
|
||||
if (run_as_node) {
|
||||
base::AtExitManager atexit_manager;
|
||||
base::i18n::InitializeICU();
|
||||
auto ret = electron::NodeMain(argv.size(), argv.data());
|
||||
std::ranges::for_each(argv, free);
|
||||
return ret;
|
||||
return electron::NodeMain();
|
||||
}
|
||||
|
||||
base::CommandLine::Init(argv.size(), argv.data());
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
|
||||
@@ -234,6 +228,5 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.instance = instance;
|
||||
params.sandbox_info = &sandbox_info;
|
||||
electron::ElectronCommandLine::Init(arguments.argc, arguments.argv);
|
||||
return content::ContentMain(std::move(params));
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "shell/app/uv_task_runner.h"
|
||||
#include "shell/browser/javascript_environment.h"
|
||||
#include "shell/common/api/electron_bindings.h"
|
||||
#include "shell/common/electron_command_line.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
@@ -115,12 +116,8 @@ v8::Local<v8::Value> GetParameters(v8::Isolate* isolate) {
|
||||
|
||||
namespace electron {
|
||||
|
||||
int NodeMain(int argc, char* argv[]) {
|
||||
bool initialized = base::CommandLine::Init(argc, argv);
|
||||
if (!initialized) {
|
||||
LOG(ERROR) << "Failed to initialize CommandLine";
|
||||
exit(1);
|
||||
}
|
||||
int NodeMain() {
|
||||
DCHECK(base::CommandLine::InitializedForCurrentProcess());
|
||||
|
||||
auto os_env = base::Environment::Create();
|
||||
bool node_options_enabled = electron::fuses::IsNodeOptionsEnabled();
|
||||
@@ -182,11 +179,8 @@ int NodeMain(int argc, char* argv[]) {
|
||||
// Explicitly register electron's builtin bindings.
|
||||
NodeBindings::RegisterBuiltinBindings();
|
||||
|
||||
// Hack around with the argv pointer. Used for process.title = "blah".
|
||||
argv = uv_setup_args(argc, argv);
|
||||
|
||||
// Parse Node.js cli flags and strip out disallowed options.
|
||||
std::vector<std::string> args(argv, argv + argc);
|
||||
const std::vector<std::string> args = ElectronCommandLine::AsUtf8();
|
||||
ExitIfContainsDisallowedFlags(args);
|
||||
|
||||
std::unique_ptr<node::InitializationResult> result =
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace electron {
|
||||
|
||||
int NodeMain(int argc, char* argv[]);
|
||||
int NodeMain();
|
||||
|
||||
} // namespace electron
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ void BaseWindow::OnWindowAlwaysOnTopChanged() {
|
||||
Emit("always-on-top-changed", IsAlwaysOnTop());
|
||||
}
|
||||
|
||||
void BaseWindow::OnExecuteAppCommand(const std::string& command_name) {
|
||||
void BaseWindow::OnExecuteAppCommand(const std::string_view command_name) {
|
||||
Emit("app-command", command_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
||||
void OnWindowEnterHtmlFullScreen() override;
|
||||
void OnWindowLeaveHtmlFullScreen() override;
|
||||
void OnWindowAlwaysOnTopChanged() override;
|
||||
void OnExecuteAppCommand(const std::string& command_name) override;
|
||||
void OnExecuteAppCommand(std::string_view command_name) override;
|
||||
void OnTouchBarItemResult(const std::string& item_id,
|
||||
const base::Value::Dict& details) override;
|
||||
void OnNewWindowForTab() override;
|
||||
|
||||
@@ -1068,14 +1068,31 @@ void WebContents::Close(std::optional<gin_helper::Dictionary> options) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebContents::DidAddMessageToConsole(
|
||||
content::WebContents* source,
|
||||
void WebContents::OnDidAddMessageToConsole(
|
||||
content::RenderFrameHost* source_frame,
|
||||
blink::mojom::ConsoleMessageLevel level,
|
||||
const std::u16string& message,
|
||||
int32_t line_no,
|
||||
const std::u16string& source_id) {
|
||||
return Emit("console-message", static_cast<int32_t>(level), message, line_no,
|
||||
source_id);
|
||||
const std::u16string& source_id,
|
||||
const std::optional<std::u16string>& untrusted_stack_trace) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
gin::Handle<gin_helper::internal::Event> event =
|
||||
gin_helper::internal::Event::New(isolate);
|
||||
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
|
||||
|
||||
gin_helper::Dictionary dict(isolate, event_object);
|
||||
dict.SetGetter("frame", source_frame);
|
||||
dict.Set("level", level);
|
||||
dict.Set("message", message);
|
||||
dict.Set("lineNumber", line_no);
|
||||
dict.Set("sourceId", source_id);
|
||||
|
||||
// TODO(samuelmaddock): Delete when deprecated arguments are fully removed.
|
||||
dict.Set("_level", static_cast<int32_t>(level));
|
||||
|
||||
EmitWithoutEvent("-console-message", event);
|
||||
}
|
||||
|
||||
void WebContents::OnCreateWindow(
|
||||
|
||||
@@ -530,11 +530,6 @@ class WebContents final : public ExclusiveAccessContext,
|
||||
#endif
|
||||
|
||||
// content::WebContentsDelegate:
|
||||
bool DidAddMessageToConsole(content::WebContents* source,
|
||||
blink::mojom::ConsoleMessageLevel level,
|
||||
const std::u16string& message,
|
||||
int32_t line_no,
|
||||
const std::u16string& source_id) override;
|
||||
bool IsWebContentsCreationOverridden(
|
||||
content::SiteInstance* source_site_instance,
|
||||
content::mojom::WindowContainerType window_container_type,
|
||||
@@ -680,6 +675,13 @@ class WebContents final : public ExclusiveAccessContext,
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
void OnWebContentsLostFocus(
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
void OnDidAddMessageToConsole(
|
||||
content::RenderFrameHost* source_frame,
|
||||
blink::mojom::ConsoleMessageLevel level,
|
||||
const std::u16string& message,
|
||||
int32_t line_no,
|
||||
const std::u16string& source_id,
|
||||
const std::optional<std::u16string>& untrusted_stack_trace) override;
|
||||
|
||||
// InspectableWebContentsDelegate:
|
||||
void DevToolsReloadPage() override;
|
||||
|
||||
@@ -17,7 +17,6 @@ void MicrotasksRunner::WillProcessTask(const base::PendingTask& pending_task,
|
||||
bool was_blocked_or_low_priority) {}
|
||||
|
||||
void MicrotasksRunner::DidProcessTask(const base::PendingTask& pending_task) {
|
||||
v8::Isolate::Scope scope(isolate_);
|
||||
// In the browser process we follow Node.js microtask policy of kExplicit
|
||||
// and let the MicrotaskRunner which is a task observer for chromium UI thread
|
||||
// scheduler run the microtask checkpoint. This worked fine because Node.js
|
||||
|
||||
@@ -665,9 +665,10 @@ void NativeWindow::NotifyWindowAlwaysOnTopChanged() {
|
||||
observer.OnWindowAlwaysOnTopChanged();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowExecuteAppCommand(const std::string& command) {
|
||||
void NativeWindow::NotifyWindowExecuteAppCommand(
|
||||
const std::string_view command_name) {
|
||||
for (NativeWindowObserver& observer : observers_)
|
||||
observer.OnExecuteAppCommand(command);
|
||||
observer.OnExecuteAppCommand(command_name);
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyTouchBarItemInteraction(const std::string& item_id,
|
||||
|
||||
@@ -326,7 +326,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||
void NotifyWindowEnterHtmlFullScreen();
|
||||
void NotifyWindowLeaveHtmlFullScreen();
|
||||
void NotifyWindowAlwaysOnTopChanged();
|
||||
void NotifyWindowExecuteAppCommand(const std::string& command);
|
||||
void NotifyWindowExecuteAppCommand(std::string_view command_name);
|
||||
void NotifyTouchBarItemInteraction(const std::string& item_id,
|
||||
base::Value::Dict details);
|
||||
void NotifyNewWindowForTab();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define ELECTRON_SHELL_BROWSER_NATIVE_WINDOW_OBSERVER_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/observer_list_types.h"
|
||||
#include "base/values.h"
|
||||
@@ -102,7 +103,7 @@ class NativeWindowObserver : public base::CheckedObserver {
|
||||
|
||||
// Called on Windows when App Commands arrive (WM_APPCOMMAND)
|
||||
// Some commands are implemented on on other platforms as well
|
||||
virtual void OnExecuteAppCommand(const std::string& command_name) {}
|
||||
virtual void OnExecuteAppCommand(std::string_view command_name) {}
|
||||
|
||||
virtual void UpdateWindowControlsOverlay(const gfx::Rect& bounding_rect) {}
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace electron {
|
||||
namespace {
|
||||
|
||||
// Convert Win32 WM_APPCOMMANDS to strings.
|
||||
const char* AppCommandToString(int command_id) {
|
||||
constexpr std::string_view AppCommandToString(int command_id) {
|
||||
switch (command_id) {
|
||||
case APPCOMMAND_BROWSER_BACKWARD:
|
||||
return kBrowserBackward;
|
||||
@@ -227,8 +227,8 @@ void NativeWindowViews::Maximize() {
|
||||
}
|
||||
|
||||
bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
||||
std::string command = AppCommandToString(command_id);
|
||||
NotifyWindowExecuteAppCommand(command);
|
||||
const auto command_name = AppCommandToString(command_id);
|
||||
NotifyWindowExecuteAppCommand(command_name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include "shell/common/electron_command_line.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "uv.h" // NOLINT(build/include_directory)
|
||||
#include "base/containers/to_vector.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
@@ -13,17 +14,25 @@ namespace electron {
|
||||
base::CommandLine::StringVector ElectronCommandLine::argv_;
|
||||
|
||||
// static
|
||||
void ElectronCommandLine::Init(int argc, base::CommandLine::CharType** argv) {
|
||||
void ElectronCommandLine::Init(int argc,
|
||||
base::CommandLine::CharType const* const* argv) {
|
||||
DCHECK(argv_.empty());
|
||||
|
||||
// NOTE: uv_setup_args does nothing on Windows, so we don't need to call it.
|
||||
// Otherwise we'd have to convert the arguments from UTF16.
|
||||
#if !BUILDFLAG(IS_WIN)
|
||||
// Hack around with the argv pointer. Used for process.title = "blah"
|
||||
argv = uv_setup_args(argc, argv);
|
||||
#endif
|
||||
// Safety: as is normal in command lines, argc and argv must correspond
|
||||
// to one another. Otherwise there will be out-of-bounds accesses.
|
||||
argv_.assign(argv, UNSAFE_BUFFERS(argv + argc));
|
||||
}
|
||||
|
||||
argv_.assign(argv, argv + argc);
|
||||
// static
|
||||
std::vector<std::string> ElectronCommandLine::AsUtf8() {
|
||||
DCHECK(!argv_.empty());
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
return base::ToVector(
|
||||
argv_, [](const auto& wstr) { return base::WideToUTF8(wstr); });
|
||||
#else
|
||||
return argv_;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
|
||||
@@ -20,7 +20,9 @@ class ElectronCommandLine {
|
||||
|
||||
static const base::CommandLine::StringVector& argv() { return argv_; }
|
||||
|
||||
static void Init(int argc, base::CommandLine::CharType** argv);
|
||||
static std::vector<std::string> AsUtf8();
|
||||
|
||||
static void Init(int argc, base::CommandLine::CharType const* const* argv);
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
// On Linux the command line has to be read from base::CommandLine since
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright (c) 2015 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/electron_constants.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
const char kBrowserForward[] = "browser-forward";
|
||||
const char kBrowserBackward[] = "browser-backward";
|
||||
|
||||
const char kDeviceVendorIdKey[] = "vendorId";
|
||||
const char kDeviceProductIdKey[] = "productId";
|
||||
const char kDeviceSerialNumberKey[] = "serialNumber";
|
||||
|
||||
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
const char kPDFExtensionPluginName[] = "Chromium PDF Viewer";
|
||||
const char kPDFInternalPluginName[] = "Chromium PDF Plugin";
|
||||
const base::FilePath::CharType kPdfPluginPath[] =
|
||||
FILE_PATH_LITERAL("internal-pdf-viewer");
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
} // namespace electron
|
||||
@@ -5,26 +5,29 @@
|
||||
#ifndef ELECTRON_SHELL_COMMON_ELECTRON_CONSTANTS_H_
|
||||
#define ELECTRON_SHELL_COMMON_ELECTRON_CONSTANTS_H_
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/cstring_view.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
// The app-command in NativeWindow.
|
||||
extern const char kBrowserForward[];
|
||||
extern const char kBrowserBackward[];
|
||||
inline constexpr std::string_view kBrowserForward = "browser-forward";
|
||||
inline constexpr std::string_view kBrowserBackward = "browser-backward";
|
||||
|
||||
// Keys for Device APIs
|
||||
extern const char kDeviceVendorIdKey[];
|
||||
extern const char kDeviceProductIdKey[];
|
||||
extern const char kDeviceSerialNumberKey[];
|
||||
inline constexpr std::string_view kDeviceVendorIdKey = "vendorId";
|
||||
inline constexpr std::string_view kDeviceProductIdKey = "productId";
|
||||
inline constexpr std::string_view kDeviceSerialNumberKey = "serialNumber";
|
||||
|
||||
extern const char kRunAsNode[];
|
||||
inline constexpr base::cstring_view kRunAsNode = "ELECTRON_RUN_AS_NODE";
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
extern const char kPDFExtensionPluginName[];
|
||||
extern const char kPDFInternalPluginName[];
|
||||
extern const base::FilePath::CharType kPdfPluginPath[];
|
||||
inline constexpr std::string_view kPDFExtensionPluginName =
|
||||
"Chromium PDF Viewer";
|
||||
inline constexpr std::string_view kPDFInternalPluginName =
|
||||
"Chromium PDF Plugin";
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "third_party/blink/public/common/input/web_mouse_event.h"
|
||||
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
|
||||
#include "third_party/blink/public/common/widget/device_emulation_params.h"
|
||||
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
|
||||
#include "third_party/blink/public/mojom/loader/referrer.mojom.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
#include "ui/events/blink/blink_event_util.h"
|
||||
@@ -699,4 +700,18 @@ bool Converter<blink::CloneableMessage>::FromV8(v8::Isolate* isolate,
|
||||
return electron::SerializeV8Value(isolate, val, out);
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value> Converter<blink::mojom::ConsoleMessageLevel>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::mojom::ConsoleMessageLevel& in) {
|
||||
using Val = blink::mojom::ConsoleMessageLevel;
|
||||
static constexpr auto Lookup = base::MakeFixedFlatMap<Val, std::string_view>({
|
||||
{Val::kVerbose, "debug"},
|
||||
{Val::kInfo, "info"},
|
||||
{Val::kWarning, "warning"},
|
||||
{Val::kError, "error"},
|
||||
});
|
||||
return StringToV8(isolate, Lookup.at(in));
|
||||
}
|
||||
|
||||
} // namespace gin
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
#include "third_party/blink/public/common/messaging/cloneable_message.h"
|
||||
#include "third_party/blink/public/common/web_cache/web_cache_resource_type_stats.h"
|
||||
#include "third_party/blink/public/mojom/devtools/console_message.mojom-forward.h"
|
||||
#include "third_party/blink/public/mojom/loader/referrer.mojom-forward.h"
|
||||
|
||||
namespace blink {
|
||||
@@ -126,6 +127,12 @@ struct Converter<blink::CloneableMessage> {
|
||||
blink::CloneableMessage* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<blink::mojom::ConsoleMessageLevel> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const blink::mojom::ConsoleMessageLevel& in);
|
||||
};
|
||||
|
||||
v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags);
|
||||
v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags);
|
||||
|
||||
|
||||
@@ -22,7 +22,10 @@ std::vector<std::string> GetPreferredLanguages() {
|
||||
DCHECK(languages); // A valid pointer is guaranteed.
|
||||
DCHECK(*languages); // At least one entry, "C", is guaranteed.
|
||||
|
||||
for (; *languages; ++languages) {
|
||||
// SAFETY: |g_get_language_names()| returns a glib-owned array
|
||||
// of const C strings, terminated by an empty string.
|
||||
// This loop is the correct way to walk through its return values.
|
||||
for (; *languages; UNSAFE_BUFFERS(++languages)) {
|
||||
if (strcmp(*languages, "C") != 0) {
|
||||
preferredLanguages.push_back(base::i18n::GetCanonicalLocale(*languages));
|
||||
}
|
||||
|
||||
@@ -799,15 +799,8 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment(
|
||||
v8::Local<v8::Context> context,
|
||||
node::MultiIsolatePlatform* platform,
|
||||
std::optional<base::RepeatingCallback<void()>> on_app_code_ready) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
auto& electron_args = ElectronCommandLine::argv();
|
||||
std::vector<std::string> args(electron_args.size());
|
||||
std::ranges::transform(electron_args, args.begin(),
|
||||
[](auto& a) { return base::WideToUTF8(a); });
|
||||
#else
|
||||
auto args = ElectronCommandLine::argv();
|
||||
#endif
|
||||
return CreateEnvironment(context, platform, args, {}, on_app_code_ready);
|
||||
return CreateEnvironment(context, platform, ElectronCommandLine::AsUtf8(), {},
|
||||
on_app_code_ready);
|
||||
}
|
||||
|
||||
void NodeBindings::LoadEnvironment(node::Environment* env) {
|
||||
|
||||
@@ -118,8 +118,8 @@ void ElectronRendererClient::DidCreateScriptContext(
|
||||
v8::Isolate* isolate = env->isolate();
|
||||
v8::Local<v8::Object> global = renderer_context->Global();
|
||||
|
||||
std::vector<std::string> keys = {"fetch", "Response", "FormData", "Request",
|
||||
"Headers"};
|
||||
std::vector<std::string> keys = {"fetch", "Response", "FormData",
|
||||
"Request", "Headers", "EventSource"};
|
||||
for (const auto& key : keys) {
|
||||
v8::MaybeLocal<v8::Value> value =
|
||||
global->Get(renderer_context, gin::StringToV8(isolate, key));
|
||||
|
||||
@@ -71,8 +71,8 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation(
|
||||
// is loaded. See corresponding change in node/init.ts.
|
||||
v8::Local<v8::Object> global = worker_context->Global();
|
||||
|
||||
std::vector<std::string> keys = {"fetch", "Response", "FormData", "Request",
|
||||
"Headers"};
|
||||
std::vector<std::string> keys = {"fetch", "Response", "FormData",
|
||||
"Request", "Headers", "EventSource"};
|
||||
for (const auto& key : keys) {
|
||||
v8::MaybeLocal<v8::Value> value =
|
||||
global->Get(worker_context, gin::StringToV8(isolate, key.c_str()));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BrowserView, BrowserWindow, screen, webContents } from 'electron/main';
|
||||
import { BrowserView, BrowserWindow, screen, session, webContents } from 'electron/main';
|
||||
|
||||
import { expect } from 'chai';
|
||||
|
||||
@@ -11,24 +11,29 @@ import { closeWindow } from './lib/window-helpers';
|
||||
|
||||
describe('BrowserView module', () => {
|
||||
const fixtures = path.resolve(__dirname, 'fixtures');
|
||||
const ses = session.fromPartition(crypto.randomUUID());
|
||||
|
||||
let w: BrowserWindow;
|
||||
let view: BrowserView;
|
||||
|
||||
const getSessionWebContents = () =>
|
||||
webContents.getAllWebContents().filter(wc => wc.session === ses);
|
||||
|
||||
beforeEach(() => {
|
||||
expect(webContents.getAllWebContents().length).to.equal(0, 'expected no webContents to exist');
|
||||
expect(getSessionWebContents().length).to.equal(0, 'expected no webContents to exist');
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false
|
||||
backgroundThrottling: false,
|
||||
session: ses
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (!w.isDestroyed()) {
|
||||
if (w && !w.isDestroyed()) {
|
||||
const p = once(w.webContents, 'destroyed');
|
||||
await closeWindow(w);
|
||||
w = null as any;
|
||||
@@ -42,7 +47,7 @@ describe('BrowserView module', () => {
|
||||
await p;
|
||||
}
|
||||
|
||||
expect(webContents.getAllWebContents().length).to.equal(0, 'expected no webContents to exist');
|
||||
expect(getSessionWebContents().length).to.equal(0, 'expected no webContents to exist');
|
||||
});
|
||||
|
||||
it('sets the correct class name on the prototype', () => {
|
||||
@@ -50,7 +55,7 @@ describe('BrowserView module', () => {
|
||||
});
|
||||
|
||||
it('can be created with an existing webContents', async () => {
|
||||
const wc = (webContents as typeof ElectronInternal.WebContents).create({ sandbox: true });
|
||||
const wc = (webContents as typeof ElectronInternal.WebContents).create({ session: ses, sandbox: true });
|
||||
await wc.loadURL('about:blank');
|
||||
|
||||
view = new BrowserView({ webContents: wc } as any);
|
||||
|
||||
@@ -977,7 +977,7 @@ describe('protocol module', () => {
|
||||
contextIsolation: false
|
||||
});
|
||||
const consoleMessages: string[] = [];
|
||||
newContents.on('console-message', (e, level, message) => consoleMessages.push(message));
|
||||
newContents.on('console-message', (e) => consoleMessages.push(e.message));
|
||||
try {
|
||||
newContents.loadURL(standardScheme + '://fake-host');
|
||||
const [, response] = await once(ipcMain, 'response');
|
||||
@@ -1631,7 +1631,7 @@ describe('protocol module', () => {
|
||||
defer(() => { protocol.unhandle('cors'); });
|
||||
|
||||
await contents.loadFile(path.resolve(fixturesPath, 'pages', 'base-page.html'));
|
||||
contents.on('console-message', (e, level, message) => console.log(message));
|
||||
contents.on('console-message', (e) => console.log(e.message));
|
||||
const ok = await contents.executeJavaScript(`(async () => {
|
||||
function wait(milliseconds) {
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||
|
||||
@@ -144,21 +144,36 @@ describe('utilityProcess module', () => {
|
||||
});
|
||||
|
||||
describe('app \'child-process-gone\' event', () => {
|
||||
const waitForCrash = (name: string) => {
|
||||
return new Promise<Electron.Details>((resolve) => {
|
||||
app.on('child-process-gone', function onCrash (_event, details) {
|
||||
if (details.name === name) {
|
||||
app.off('child-process-gone', onCrash);
|
||||
resolve(details);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ifit(!isWindows32Bit)('with default serviceName', async () => {
|
||||
const name = 'Node Utility Process';
|
||||
const crashPromise = waitForCrash(name);
|
||||
utilityProcess.fork(path.join(fixturesPath, 'crash.js'));
|
||||
const [, details] = await once(app, 'child-process-gone') as [any, Electron.Details];
|
||||
const details = await crashPromise;
|
||||
expect(details.type).to.equal('Utility');
|
||||
expect(details.serviceName).to.equal('node.mojom.NodeService');
|
||||
expect(details.name).to.equal('Node Utility Process');
|
||||
expect(details.name).to.equal(name);
|
||||
expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']);
|
||||
});
|
||||
|
||||
ifit(!isWindows32Bit)('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];
|
||||
const name = crypto.randomUUID();
|
||||
const crashPromise = waitForCrash(name);
|
||||
utilityProcess.fork(path.join(fixturesPath, 'crash.js'), [], { serviceName: name });
|
||||
const details = await crashPromise;
|
||||
expect(details.type).to.equal('Utility');
|
||||
expect(details.serviceName).to.equal('node.mojom.NodeService');
|
||||
expect(details.name).to.equal('Hello World!');
|
||||
expect(details.name).to.equal(name);
|
||||
expect(details.reason).to.be.oneOf(['crashed', 'abnormal-exit']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1965,9 +1965,9 @@ describe('webContents module', () => {
|
||||
afterEach(closeAllWindows);
|
||||
it('is triggered with correct log message', (done) => {
|
||||
const w = new BrowserWindow({ show: true });
|
||||
w.webContents.on('console-message', (e, level, message) => {
|
||||
w.webContents.on('console-message', (e) => {
|
||||
// Don't just assert as Chromium might emit other logs that we should ignore.
|
||||
if (message === 'a') {
|
||||
if (e.message === 'a') {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -379,7 +379,7 @@ describe('web security', () => {
|
||||
console.log(e.message)
|
||||
}
|
||||
</script>`);
|
||||
const [,, message] = await once(w.webContents, 'console-message');
|
||||
const [{ message }] = await once(w.webContents, 'console-message');
|
||||
expect(message).to.match(/Refused to evaluate a string/);
|
||||
});
|
||||
|
||||
@@ -399,7 +399,7 @@ describe('web security', () => {
|
||||
console.log(e.message)
|
||||
}
|
||||
</script>`);
|
||||
const [,, message] = await once(w.webContents, 'console-message');
|
||||
const [{ message }] = await once(w.webContents, 'console-message');
|
||||
expect(message).to.equal('true');
|
||||
});
|
||||
|
||||
@@ -1028,6 +1028,43 @@ describe('chromium features', () => {
|
||||
expect(code).to.equal(0);
|
||||
});
|
||||
|
||||
itremote('Worker with nodeIntegrationInWorker has access to EventSource', () => {
|
||||
const es = new EventSource('https://example.com');
|
||||
expect(es).to.have.property('url').that.is.a('string');
|
||||
expect(es).to.have.property('readyState').that.is.a('number');
|
||||
expect(es).to.have.property('withCredentials').that.is.a('boolean');
|
||||
});
|
||||
|
||||
itremote('Worker with nodeIntegrationInWorker has access to fetch-dependent interfaces', async (fixtures: string) => {
|
||||
const file = require('node:path').join(fixtures, 'hello.txt');
|
||||
expect(() => {
|
||||
fetch('file://' + file);
|
||||
}).to.not.throw();
|
||||
|
||||
expect(() => {
|
||||
const formData = new FormData();
|
||||
formData.append('username', 'Groucho');
|
||||
}).not.to.throw();
|
||||
|
||||
expect(() => {
|
||||
const request = new Request('https://example.com', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ foo: 'bar' })
|
||||
});
|
||||
expect(request.method).to.equal('POST');
|
||||
}).not.to.throw();
|
||||
|
||||
expect(() => {
|
||||
const response = new Response('Hello, world!');
|
||||
expect(response.status).to.equal(200);
|
||||
}).not.to.throw();
|
||||
|
||||
expect(() => {
|
||||
const headers = new Headers();
|
||||
headers.append('Content-Type', 'text/xml');
|
||||
}).not.to.throw();
|
||||
}, [path.join(__dirname, 'fixtures')]);
|
||||
|
||||
it('Worker can work', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
await w.loadURL(`file://${fixturesPath}/pages/blank.html`);
|
||||
@@ -1428,7 +1465,7 @@ describe('chromium features', () => {
|
||||
w.loadURL('about:blank');
|
||||
w.webContents.executeJavaScript('window.child = window.open(); child.opener = null');
|
||||
const [, { webContents }] = await once(app, 'browser-window-created');
|
||||
const [,, message] = await once(webContents, 'console-message');
|
||||
const [{ message }] = await once(webContents, 'console-message');
|
||||
expect(message).to.equal('{"require":"function","module":"object","exports":"object","process":"object","Buffer":"function"}');
|
||||
});
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'query' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.have.lengthOf(1);
|
||||
@@ -434,7 +434,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'executeScript', args: ['1 + 2'] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.equal(3);
|
||||
@@ -448,7 +448,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'connectTab', args: [portName] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = responseString.split(',');
|
||||
expect(response[0]).to.equal(portName);
|
||||
expect(response[1]).to.equal('howdy');
|
||||
@@ -461,7 +461,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'sendMessage', args: ['Hello World!'] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response.message).to.equal('Hello World!');
|
||||
@@ -480,7 +480,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [w2.webContents.id, { url }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
await w2Navigated;
|
||||
@@ -801,7 +801,7 @@ describe('chrome extensions', () => {
|
||||
|
||||
w.webContents.executeJavaScript('window.postMessage(\'fetch-confirmation\', \'*\')');
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const { message } = JSON.parse(responseString);
|
||||
|
||||
expect(message).to.equal('Hello from background.js');
|
||||
@@ -834,7 +834,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'getAcceptLanguages' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.be.an('array').that.is.not.empty('languages array is empty');
|
||||
@@ -846,7 +846,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'getUILanguage' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.be.a('string');
|
||||
@@ -858,7 +858,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'getMessage' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.equal('Hola mundo!!');
|
||||
@@ -877,7 +877,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'detectLanguage', args: [greetings] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.be.an('array');
|
||||
@@ -925,7 +925,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'isEnabled' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.equal(false);
|
||||
@@ -937,7 +937,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'setIcon' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.equal(null);
|
||||
@@ -949,7 +949,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'getBadgeText' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.equal('');
|
||||
@@ -982,7 +982,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'getZoom' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.equal(1);
|
||||
@@ -994,7 +994,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'setZoom', args: [2] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.deep.equal(2);
|
||||
@@ -1006,7 +1006,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'getZoomSettings' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.deep.equal({
|
||||
@@ -1022,7 +1022,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'setZoomSettings', args: [{ mode: 'disabled' }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.deep.equal({
|
||||
@@ -1039,7 +1039,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'get' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.have.property('url').that.is.a('string');
|
||||
@@ -1065,7 +1065,7 @@ describe('chrome extensions', () => {
|
||||
await w.loadURL(url);
|
||||
|
||||
w.webContents.executeJavaScript('window.postMessage(\'{}\', \'*\')');
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).not.to.have.property('url');
|
||||
expect(response).not.to.have.property('title');
|
||||
@@ -1092,7 +1092,7 @@ describe('chrome extensions', () => {
|
||||
const consoleMessage = once(w.webContents, 'console-message');
|
||||
const finish = once(w.webContents, 'did-finish-load');
|
||||
|
||||
await Promise.all([consoleMessage, finish]).then(([[,, responseString]]) => {
|
||||
await Promise.all([consoleMessage, finish]).then(([[{ message: responseString }]]) => {
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response.status).to.equal('reloaded');
|
||||
});
|
||||
@@ -1105,7 +1105,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [{ muted: true }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.have.property('mutedInfo').that.is.a('object');
|
||||
@@ -1122,7 +1122,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [{ url: 'chrome://crash' }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const { error } = JSON.parse(responseString);
|
||||
expect(error).to.eq('I\'m sorry. I\'m afraid I can\'t do that.');
|
||||
});
|
||||
@@ -1133,7 +1133,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [{ url: 'chrome://crash' }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const { error } = JSON.parse(responseString);
|
||||
expect(error).to.eq('I\'m sorry. I\'m afraid I can\'t do that.');
|
||||
});
|
||||
@@ -1144,7 +1144,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [{ url: 'devtools://blah' }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const { error } = JSON.parse(responseString);
|
||||
expect(error).to.eq('Cannot navigate to a devtools:// page without either the devtools or debugger permission.');
|
||||
});
|
||||
@@ -1155,7 +1155,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [{ url: 'chrome-untrusted://blah' }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const { error } = JSON.parse(responseString);
|
||||
expect(error).to.eq('Cannot navigate to a chrome-untrusted:// page.');
|
||||
});
|
||||
@@ -1166,7 +1166,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'update', args: [{ url: 'file://blah' }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const { error } = JSON.parse(responseString);
|
||||
expect(error).to.eq('Cannot navigate to a file URL without local file access.');
|
||||
});
|
||||
@@ -1183,7 +1183,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'query', args: [{ muted: true }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.have.lengthOf(1);
|
||||
|
||||
@@ -1220,7 +1220,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'query', args: [{ muted: true }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [, , responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.have.lengthOf(2);
|
||||
for (const tab of response) {
|
||||
@@ -1270,7 +1270,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'registerContentScripts' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.be.an('array').with.lengthOf(1);
|
||||
expect(response[0]).to.deep.equal({
|
||||
@@ -1290,7 +1290,7 @@ describe('chrome extensions', () => {
|
||||
|
||||
const message = { method: 'globalParams' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response).to.deep.equal({ changed: true });
|
||||
});
|
||||
@@ -1304,7 +1304,7 @@ describe('chrome extensions', () => {
|
||||
const message = { method: 'insertCSS' };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const [{ message: responseString }] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
expect(response.success).to.be.true();
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ app.whenReady().then(function () {
|
||||
|
||||
win.loadFile('index.html');
|
||||
|
||||
win.webContents.on('console-message', (event, level, message) => {
|
||||
console.log(message);
|
||||
win.webContents.on('console-message', (event) => {
|
||||
console.log(event.message);
|
||||
});
|
||||
|
||||
win.webContents.on('did-finish-load', () => app.quit());
|
||||
|
||||
@@ -162,6 +162,15 @@ describe('node feature', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('EventSource', () => {
|
||||
itremote('works correctly when nodeIntegration is enabled in the renderer', () => {
|
||||
const es = new EventSource('https://example.com');
|
||||
expect(es).to.have.property('url').that.is.a('string');
|
||||
expect(es).to.have.property('readyState').that.is.a('number');
|
||||
expect(es).to.have.property('withCredentials').that.is.a('boolean');
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetch', () => {
|
||||
itremote('works correctly when nodeIntegration is enabled in the renderer', async (fixtures: string) => {
|
||||
const file = require('node:path').join(fixtures, 'hello.txt');
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/base-page-security.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('Node.js Integration with Remote Content');
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/base-page-security-onload-message.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', isLoaded);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', isLoaded);
|
||||
expect(message).to.not.include('Node.js Integration with Remote Content');
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/base-page-security.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('Disabled webSecurity');
|
||||
});
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('security warnings', () => {
|
||||
|
||||
useCsp = false;
|
||||
w.loadURL(`${serverUrl}/base-page-security.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('Insecure Content-Security-Policy');
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/base-page-security.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('allowRunningInsecureContent');
|
||||
});
|
||||
|
||||
@@ -160,7 +160,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/base-page-security.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('experimentalFeatures');
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/base-page-security.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('enableBlinkFeatures');
|
||||
});
|
||||
|
||||
@@ -185,7 +185,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/webview-allowpopups.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('allowpopups');
|
||||
});
|
||||
|
||||
@@ -196,7 +196,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/insecure-resources.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.include('Insecure Resources');
|
||||
});
|
||||
|
||||
@@ -207,7 +207,7 @@ describe('security warnings', () => {
|
||||
});
|
||||
|
||||
w.loadURL(`${serverUrl}/insecure-resources.html`);
|
||||
const [,, message] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
const [{ message }] = await emittedUntil(w.webContents, 'console-message', messageContainsSecurityWarning);
|
||||
expect(message).to.not.include('insecure-resources.html');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user