From 38fa55d54ef2985504552bf775adce5cc90546a6 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 22:05:48 -0800 Subject: [PATCH 001/172] docs: update E23 release dates (#36488) docs: update E23 release dates (#36475) Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Michaela Laurencin <35157522+mlaurencin@users.noreply.github.com> --- docs/tutorial/electron-timelines.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/electron-timelines.md b/docs/tutorial/electron-timelines.md index 54f3022898d67..e35fd4587540e 100644 --- a/docs/tutorial/electron-timelines.md +++ b/docs/tutorial/electron-timelines.md @@ -9,10 +9,11 @@ check out our [Electron Versioning](./electron-versioning.md) doc. | Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported | | ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- | -| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | TBD | M108 | TBD | ✅ | -| 21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | TBD | M106 | v16.17 | ✅ | +| 23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | TBD | M110 | TBD | ✅ | +| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | TBD | M108 | v16.17 | ✅ | +| 21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | TBD | M106 | v16.16 | ✅ | | 20.0.0 | 2022-May-26 | 2022-Jun-21 | 2022-Aug-02 | TBD | M104 | v16.15 | ✅ | -| 19.0.0 | 2022-Mar-31 | 2022-Apr-26 | 2022-May-24 | TBD | M102 | v16.14 | ✅ | +| 19.0.0 | 2022-Mar-31 | 2022-Apr-26 | 2022-May-24 | 2022-Nov-29 | M102 | v16.14 | 🚫 | | 18.0.0 | 2022-Feb-03 | 2022-Mar-03 | 2022-Mar-29 | 2022-Sep-27 | M100 | v16.13 | 🚫 | | 17.0.0 | 2021-Nov-18 | 2022-Jan-06 | 2022-Feb-01 | 2022-Aug-02 | M98 | v16.13 | 🚫 | | 16.0.0 | 2021-Sep-23 | 2021-Oct-20 | 2021-Nov-16 | 2022-May-24 | M96 | v16.9 | 🚫 | From 5f030bdd2c81286b455aeb506e083be5af3087c2 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 30 Nov 2022 16:20:29 -0500 Subject: [PATCH 002/172] docs: fix loadExtension example (#36499) Co-authored-by: Jeremy Rose Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose --- docs/api/extensions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/extensions.md b/docs/api/extensions.md index c8fbb015a1f74..2c1539d57d73e 100644 --- a/docs/api/extensions.md +++ b/docs/api/extensions.md @@ -20,7 +20,7 @@ work). Extensions are installed per-`session`. To load an extension, call ```js const { session } = require('electron') -session.loadExtension('path/to/unpacked/extension').then(({ id }) => { +session.defaultSession.loadExtension('path/to/unpacked/extension').then(({ id }) => { // ... }) ``` From 99c0e1cde2ae2841b4cf393091bbe0bfeb5d4963 Mon Sep 17 00:00:00 2001 From: Keeley Hammond Date: Wed, 30 Nov 2022 13:27:45 -0800 Subject: [PATCH 003/172] ci: bake appveyor images automatically, run sync on depshash change (#36462) * ci: bake appveyor images automatically, run sync on depshash change * build: fixup appveyor image for release * build: make sure symstore is in the PATH when baking an image * build: update to use fixed baked image * cleanup sdk install * chore: fix test process.arch (doesn't work on arm) Co-authored-by: John Kleinschmidt --- .github/workflows/update_appveyor_image.yml | 62 ++++ appveyor-bake.yml | 52 +++ appveyor.yml | 374 +++++++++----------- build/profile_toolchain.py | 56 +-- script/lib/utils.js | 1 + script/prepare-appveyor.js | 219 ++++++++++++ script/release/ci-release-build.js | 2 +- script/setup-win-for-dev.bat | 42 +-- spec/api-browser-view-spec.ts | 4 +- spec/api-browser-window-spec.ts | 4 +- 10 files changed, 528 insertions(+), 288 deletions(-) create mode 100644 .github/workflows/update_appveyor_image.yml create mode 100644 appveyor-bake.yml create mode 100644 script/prepare-appveyor.js diff --git a/.github/workflows/update_appveyor_image.yml b/.github/workflows/update_appveyor_image.yml new file mode 100644 index 0000000000000..9d84c7d9598d8 --- /dev/null +++ b/.github/workflows/update_appveyor_image.yml @@ -0,0 +1,62 @@ +name: Update AppVeyor Image + +# Run chron daily Mon-Fri +on: + schedule: + - cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru) + +permissions: + contents: write + pull-requests: write + +jobs: + bake-appveyor-image: + name: Bake AppVeyor Image + permissions: + contents: write + pull-requests: write # to create a new PR with updated Appveyor images + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Yarn install + run: | + node script/yarn.js install --frozen-lockfile + - name: Set Repo for Commit + run: git config --global --add safe.directory $GITHUB_WORKSPACE + - name: Check AppVeyor Image + env: + APPVEYOR_TOKEN: ${{ secrets.APPVEYOR_TOKEN }} + run: | + node ./script/prepare-appveyor + if [ -f ./image_version.txt ]; then + echo "APPVEYOR_IMAGE_VERSION="$(cat image_version.txt)"" >> $GITHUB_ENV + rm image_version.txt + fi + - name: (Optionally) Update Appveyor Image + if: ${{ env.APPVEYOR_IMAGE_VERSION }} + uses: mikefarah/yq@v4.27.2 + with: + cmd: yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml" + - name: (Optionally) Generate Commit Diff + if: ${{ env.APPVEYOR_IMAGE_VERSION }} + run: | + diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true + patch -f appveyor.yml < appveyor.diff + rm appveyor2.yml appveyor.diff + - name: (Optionally) Commit and Pull Request + if: ${{ env.APPVEYOR_IMAGE_VERSION }} + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} + commit-message: 'build: update appveyor image to latest version' + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: bump-appveyor-image + delete-branch: true + title: 'build: update appveyor image to latest version' + body: | + This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}. \ No newline at end of file diff --git a/appveyor-bake.yml b/appveyor-bake.yml new file mode 100644 index 0000000000000..26bfc782a62ac --- /dev/null +++ b/appveyor-bake.yml @@ -0,0 +1,52 @@ +# The config is used to bake appveyor images, not for running CI jobs. +# The config expects the following environment variables to be set: +# - "APPVEYOR_BAKE_IMAGE" e.g. 'electron-99.0.4767.0'. Name of the image to be baked. +# Typically named after the Chromium version on which the image is built. +# This can be set dynamically in the prepare-appveyor script. + +version: 1.0.{build} +build_cloud: electronhq-16-core +image: Windows_Default_Appveyor +environment: + GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache + ELECTRON_OUT_DIR: Default + ELECTRON_ENABLE_STACK_DUMPING: 1 + MOCHA_REPORTER: mocha-multi-reporters + MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap + GOMA_FALLBACK_ON_AUTH_FAILURE: true + DEPOT_TOOLS_WIN_TOOLCHAIN: 0 + PYTHONIOENCODING: UTF-8 +build_script: + - ps: Resize-Partition -DriveLetter C -Size (256GB) # ensure initial partition size + - ps: Get-Partition -DriveLetter C + - git config --global core.longpaths true + - cd .. + - mkdir src + - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: $env:PATH="$pwd\depot_tools;$env:PATH" + - update_depot_tools.bat + - ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron + - src\electron\script\setup-win-for-dev.bat + - >- + gclient config + --name "src\electron" + --unmanaged + %GCLIENT_EXTRA_ARGS% + "https://github.com/electron/electron" + - ps: cd src\electron + - ps: node script\generate-deps-hash.js + - ps: $depshash = Get-Content .\.depshash -Raw + - ps: Copy-Item -path .\.depshash -destination ..\.depshash + - ps: cd ..\.. + - gclient sync --with_branch_heads --with_tags --nohooks + - ps: regsvr32 /s "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll" +on_image_bake: + - ps: >- + echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD" + - ps: Remove-Item -Recurse -Force $pwd\depot_tools + - ps: Remove-Item -Recurse -Force $pwd\src\electron +# Uncomment these lines to enable RDP +#on_finish: +# - ps: >- +# $env:APPVEYOR_RDP_PASSWORD = "electron" +# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 24032b3141630..341f6da0d7cb3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,23 +24,24 @@ # https://www.appveyor.com/docs/build-configuration/#custom-environment-variables version: 1.0.{build} -build_cloud: electron-16-core -image: vs2019bt-16.16.11 +build_cloud: electronhq-16-core +image: e-108.0.5359.48 environment: - GIT_CACHE_PATH: C:\Users\electron\libcc_cache + GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default ELECTRON_ENABLE_STACK_DUMPING: 1 ELECTRON_ALSO_LOG_TO_STDERR: 1 MOCHA_REPORTER: mocha-multi-reporters MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap GOMA_FALLBACK_ON_AUTH_FAILURE: true + DEPOT_TOOLS_WIN_TOOLCHAIN: 0 + PYTHONIOENCODING: UTF-8 matrix: - - job_name: Build - - - job_name: Test - job_depends_on: Build + - job_name: Build + - job_name: Test + job_depends_on: Build clone_folder: C:\projects\src\electron @@ -50,167 +51,129 @@ matrix: for: - - - matrix: + - matrix: only: - job_name: Build init: - - ps: >- - if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { - Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild - } + - ps: >- + if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { + Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild + } build_script: - - ps: | - node script/yarn.js install --frozen-lockfile - node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH - if ($LASTEXITCODE -eq 0) { - Write-warning "Skipping tests for doc only change"; Exit-AppveyorBuild - } - $global:LASTEXITCODE = 0 - - cd .. - - ps: Write-Host "Building $env:GN_CONFIG build" - - git config --global core.longpaths true - - update_depot_tools.bat - - ps: >- - if (Test-Path 'env:RAW_GOMA_AUTH') { - $env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config" - $env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE - } - - git clone https://github.com/electron/build-tools.git - - cd build-tools - - npm install - - mkdir third_party - - ps: >- - node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })" - - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)" - - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)" - - cd ..\.. - - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR - - ps: >- - if (Test-Path 'env:RAW_GOMA_AUTH') { - $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info - if ($goma_login -eq 'Login as Fermi Planck') { - Write-warning "Goma authentication is correct"; - } else { - Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token."; - $host.SetShouldExit(1) + - ps: | + node script/yarn.js install --frozen-lockfile + node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH + if ($LASTEXITCODE -eq 0) { + Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild } - } - - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" - - ps: >- - if ($env:GN_CONFIG -ne 'release') { - $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] " - } - - >- - gclient config - --name "src\electron" - --unmanaged - %GCLIENT_EXTRA_ARGS% - "https://github.com/electron/electron" - - ps: >- - if ($env:GN_CONFIG -eq 'release') { - $env:RUN_GCLIENT_SYNC="true" - } else { - cd src\electron - node script\generate-deps-hash.js - $depshash = Get-Content .\.depshash -Raw - $zipfile = "Z:\$depshash.7z" - cd ..\.. - if (Test-Path -Path $zipfile) { - # file exists, unzip and then gclient sync - 7z x -y $zipfile -mmt=14 -aoa - if (-not (Test-Path -Path "src\buildtools")) { - # the zip file must be corrupt - resync - $env:RUN_GCLIENT_SYNC="true" - if ($env:TARGET_ARCH -ne 'ia32') { - # only save on x64/woa to avoid contention saving - $env:SAVE_GCLIENT_SRC="true" - } + $global:LASTEXITCODE = 0 + - cd .. + - ps: Write-Host "Building $env:GN_CONFIG build" + - git config --global core.longpaths true + - ps: >- + if (Test-Path -Path "$pwd\depot_tools") { + Remove-Item -Recurse -Force $pwd\depot_tools + } + - ps: >- + if (Test-Path -Path "$pwd\build-tools") { + Remove-Item -Recurse -Force $pwd\build-tools + } + - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: $env:PATH="$pwd\depot_tools;$env:PATH" + - ps: >- + if (Test-Path -Path "$pwd\src\electron") { + Remove-Item -Recurse -Force $pwd\src\electron + } + - ps: >- + if (Test-Path 'env:RAW_GOMA_AUTH') { + $env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config" + $env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE + } + - git clone https://github.com/electron/build-tools.git + - cd build-tools + - npm install + - mkdir third_party + - ps: >- + node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })" + - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)" + - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)" + - cd ..\.. + - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR + - ps: >- + if (Test-Path 'env:RAW_GOMA_AUTH') { + $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info + if ($goma_login -eq 'Login as Fermi Planck') { + Write-warning "Goma authentication is correct"; } else { - # update angle - cd src\third_party\angle - git remote set-url origin https://chromium.googlesource.com/angle/angle.git - git fetch - cd ..\..\.. - } - } else { - # file does not exist, gclient sync, then zip - $env:RUN_GCLIENT_SYNC="true" - if ($env:TARGET_ARCH -ne 'ia32') { - # only save on x64/woa to avoid contention saving - $env:SAVE_GCLIENT_SRC="true" + Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token."; + $host.SetShouldExit(1) } } - } - - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync ) - - ps: >- - if ($env:SAVE_GCLIENT_SRC -eq 'true') { - # archive current source for future use - # only run on x64/woa to avoid contention saving - $(7z a $zipfile src -xr!android_webview -xr!electron -xr'!*\.git' -xr!third_party\WebKit\LayoutTests! -xr!third_party\blink\web_tests -xr!third_party\blink\perf_tests -slp -t7z -mmt=30) - if ($LASTEXITCODE -ne 0) { - Write-warning "Could not save source to shared drive; continuing anyway" + - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" + - ps: >- + if ($env:GN_CONFIG -ne 'release') { + $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] " + } + - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron" + # Patches are applied in the image bake. Check depshash to see if patches have changed. + - ps: $env:RUN_GCLIENT_SYNC="false" + - ps: $depshash_baked = Get-Content .\src\.depshash -Raw + - ps: cd src\electron + - ps: node script\generate-deps-hash.js + - ps: $depshash = Get-Content .\.depshash -Raw + - ps: cd ..\.. + - ps: >- + if ($depshash_baked -ne $depshash) { + $env:RUN_GCLIENT_SYNC="true" } - # build time generation of file gen/angle/angle_commit.h depends on - # third_party/angle/.git - # https://chromium-review.googlesource.com/c/angle/angle/+/2074924 - $(7z a $zipfile src\third_party\angle\.git) - if ($LASTEXITCODE -ne 0) { - Write-warning "Failed to add third_party\angle\.git; continuing anyway" + - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks ) + - cd src + - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn + - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% " + - gn check out/Default //electron:electron_lib + - gn check out/Default //electron:electron_app + - gn check out/Default //electron/shell/common/api:mojo + - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app) + - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default ) + - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%" + - ninja -C out/ffmpeg electron:electron_ffmpeg_zip + - ninja -C out/Default electron:electron_dist_zip + - ninja -C out/Default shell_browser_ui_unittests + - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args + # Remove unused args from mksnapshot_args + - ps: >- + Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args + - ninja -C out/Default electron:electron_mksnapshot_zip + - cd out\Default + - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S + - cd ..\.. + - ninja -C out/Default electron:hunspell_dictionaries_zip + - ninja -C out/Default electron:electron_chromedriver_zip + - ninja -C out/Default third_party/electron_node:headers + - python %LOCAL_GOMA_DIR%\goma_ctl.py stat + - ps: >- + Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json + - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json + - 7z a node_headers.zip out\Default\gen\node_headers + - ps: >- + if ($env:GN_CONFIG -eq 'release') { + # Needed for msdia140.dll on 64-bit windows + $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" + ninja -C out/Default electron:electron_symbols } - # build time generation of file dawn/common/Version_autogen.h depends on third_party/dawn/.git/HEAD - # https://dawn-review.googlesource.com/c/dawn/+/83901 - $(7z a $zipfile src\third_party\dawn\.git) - if ($LASTEXITCODE -ne 0) { - Write-warning "Failed to add third_party\dawn\.git; continuing anyway" + - ps: >- + if ($env:GN_CONFIG -eq 'release') { + python3 electron\script\zip-symbols.py + appveyor-retry appveyor PushArtifact out/Default/symbols.zip + } else { + # It's useful to have pdb files when debugging testing builds that are + # built on CI. + 7z a pdb.zip out\Default\*.pdb } - } - - cd src - - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn - - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% " - - gn check out/Default //electron:electron_lib - - gn check out/Default //electron:electron_app - - gn check out/Default //electron/shell/common/api:mojo - - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app) - - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default ) - - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%" - - ninja -C out/ffmpeg electron:electron_ffmpeg_zip - - ninja -C out/Default electron:electron_dist_zip - - ninja -C out/Default shell_browser_ui_unittests - - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args - - ps: >- - # Remove unused args from mksnapshot_args + - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest - Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args - - ninja -C out/Default electron:electron_mksnapshot_zip - - cd out\Default - - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S - - cd ..\.. - - ninja -C out/Default electron:hunspell_dictionaries_zip - - ninja -C out/Default electron:electron_chromedriver_zip - - ninja -C out/Default third_party/electron_node:headers - - python %LOCAL_GOMA_DIR%\goma_ctl.py stat - - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json - - 7z a node_headers.zip out\Default\gen\node_headers - - ps: >- - if ($env:GN_CONFIG -eq 'release') { - # Needed for msdia140.dll on 64-bit windows - $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" - ninja -C out/Default electron:electron_symbols - } - - ps: >- - if ($env:GN_CONFIG -eq 'release') { - python3 electron\script\zip-symbols.py - appveyor-retry appveyor PushArtifact out/Default/symbols.zip - } else { - # It's useful to have pdb files when debugging testing builds that are - # built on CI. - 7z a pdb.zip out\Default\*.pdb - } - - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest - deploy_script: - cd electron - ps: >- @@ -227,7 +190,7 @@ for: } on_finish: # Uncomment this lines to enable RDP - #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - cd C:\projects\src - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) @@ -241,57 +204,55 @@ for: - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip - } - - - - matrix: + } + - matrix: only: - job_name: Test init: - - ps: | - if ($env:RUN_TESTS -ne 'true') { - Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild - } - if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { - Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild - } + - ps: | + if ($env:RUN_TESTS -ne 'true') { + Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild + } + if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { + Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild + } build_script: - - ps: | - node script/yarn.js install --frozen-lockfile - node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH - if ($LASTEXITCODE -eq 0) { - Write-warning "Skipping tests for doc only change"; Exit-AppveyorBuild - } - $global:LASTEXITCODE = 0 - - ps: | - cd .. - mkdir out\Default - cd .. - # Download build artifacts - $apiUrl = 'https://ci.appveyor.com/api' - $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID" - $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib') - foreach ($job in $build_info.build.jobs) { - if ($job.name -eq "Build") { - $jobId = $job.jobId - foreach($artifact_name in $artifacts_to_download) { - if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') { - $outfile = "src\out\Default\$artifact_name" - } else { - $outfile = $artifact_name + - ps: | + node script/yarn.js install --frozen-lockfile + node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH + if ($LASTEXITCODE -eq 0) { + Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild + } + $global:LASTEXITCODE = 0 + - cd .. + - mkdir out\Default + - cd .. + - ps: | + # Download build artifacts + $apiUrl = 'https://ci.appveyor.com/api' + $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID" + $artifacts_to_download = @('dist.zip','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib') + foreach ($job in $build_info.build.jobs) { + if ($job.name -eq "Build") { + $jobId = $job.jobId + foreach($artifact_name in $artifacts_to_download) { + if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') { + $outfile = "src\out\Default\$artifact_name" + } else { + $outfile = $artifact_name + } + Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile } - Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile } } - } - - ps: | - $out_default_zips = @('dist.zip','chromedriver.zip','mksnapshot.zip') - foreach($zip_name in $out_default_zips) { - 7z x -y -osrc\out\Default $zip_name - } - - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip - - ps: 7z x -y -osrc node_headers.zip + - ps: | + $out_default_zips = @('dist.zip','chromedriver.zip','mksnapshot.zip') + foreach($zip_name in $out_default_zips) { + 7z x -y -osrc\out\Default $zip_name + } + - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip + - ps: 7z x -y -osrc node_headers.zip test_script: # Workaround for https://github.com/appveyor/ci/issues/2420 @@ -301,15 +262,22 @@ for: New-Item .\out\Default\gen\node_headers\Release -Type directory Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib - cd electron + # Explicitly set npm_config_arch because the .env doesn't persist + - ps: >- + if ($env:TARGET_ARCH -eq 'ia32') { + $env:npm_config_arch = "ia32" + } - echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging=file --log-file=%cd%\electron.log - echo Running native test suite & node script/yarn test -- --trace-uncaught --runners=native --enable-logging=file --log-file=%cd%\electron.log - cd .. - - echo Verifying non proprietary ffmpeg & python3 electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg + - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg - echo "About to verify mksnapshot" - - echo Verifying mksnapshot & python3 electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% + - echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd% - echo "Done verifying mksnapshot" - - echo Verifying chromedriver & python3 electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd% + - echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd% - echo "Done verifying chromedriver" - - on_finish: + + # Uncomment these lines to enable RDP + # on_finish: + # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log ) \ No newline at end of file diff --git a/build/profile_toolchain.py b/build/profile_toolchain.py index 4251315e0a16a..6e51a7eaa1423 100755 --- a/build/profile_toolchain.py +++ b/build/profile_toolchain.py @@ -5,8 +5,6 @@ import os import optparse import json -import re -import subprocess sys.path.append("%s/../../build" % os.path.dirname(os.path.realpath(__file__))) @@ -36,56 +34,10 @@ def calculate_hash(root): return CalculateHash('.', None) def windows_installed_software(): - powershell_command = [ - "Get-CimInstance", - "-Namespace", - "root\cimv2", - "-Class", - "Win32_product", - "|", - "Select", - "vendor,", - "description,", - "@{l='install_location';e='InstallLocation'},", - "@{l='install_date';e='InstallDate'},", - "@{l='install_date_2';e='InstallDate2'},", - "caption,", - "version,", - "name,", - "@{l='sku_number';e='SKUNumber'}", - "|", - "ConvertTo-Json", - ] - - proc = subprocess.Popen( - ["powershell.exe", "-Command", "-"], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - ) - - stdout, _ = proc.communicate(" ".join(powershell_command).encode("utf-8")) - - if proc.returncode != 0: - raise RuntimeError("Failed to get list of installed software") - - # On AppVeyor there's other output related to PSReadline, - # so grab only the JSON output and ignore everything else - json_match = re.match( - r".*(\[.*{.*}.*\]).*", stdout.decode("utf-8"), re.DOTALL - ) - - if not json_match: - raise RuntimeError( - "Couldn't find JSON output for list of installed software" - ) - - # Filter out missing keys - return list( - map( - lambda info: {k: info[k] for k in info if info[k]}, - json.loads(json_match.group(1)), - ) - ) + # file_path = os.path.join(os.getcwd(), 'installed_software.json') + # return json.loads(open('installed_software.json').read().decode('utf-8')) + f = open('installed_software.json', encoding='utf-8-sig') + return json.load(f) def windows_profile(): diff --git a/script/lib/utils.js b/script/lib/utils.js index 44c81dc86aca0..b562b03faaebd 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -129,6 +129,7 @@ module.exports = { getElectronExec, getOutDir, getAbsoluteElectronExec, + handleGitCall, ELECTRON_DIR, SRC_DIR }; diff --git a/script/prepare-appveyor.js b/script/prepare-appveyor.js new file mode 100644 index 0000000000000..9960b877f5df6 --- /dev/null +++ b/script/prepare-appveyor.js @@ -0,0 +1,219 @@ +if (!process.env.CI) require('dotenv-safe').load(); + +const assert = require('assert'); +const fs = require('fs'); +const got = require('got'); +const path = require('path'); +const { handleGitCall, ELECTRON_DIR } = require('./lib/utils.js'); +const { Octokit } = require('@octokit/rest'); +const octokit = new Octokit(); + +const APPVEYOR_IMAGES_URL = 'https://ci.appveyor.com/api/build-clouds'; +const APPVEYOR_JOB_URL = 'https://ci.appveyor.com/api/builds'; +const ROLLER_BRANCH_PATTERN = /^roller\/chromium$/; + +const DEFAULT_BUILD_CLOUD_ID = '1598'; +const DEFAULT_BUILD_CLOUD = 'electronhq-16-core'; +const DEFAULT_BAKE_BASE_IMAGE = 'Windows_Default_Appveyor'; +const DEFAULT_BUILD_IMAGE = 'Windows_Default_Appveyor'; + +const appveyorBakeJob = 'electron-bake-image'; +const appVeyorJobs = { + 'electron-x64': 'electron-x64-testing', + 'electron-woa': 'electron-woa-testing', + 'electron-ia32': 'electron-ia32-testing' +}; + +async function makeRequest ({ auth, username, password, url, headers, body, method }) { + const clonedHeaders = { + ...(headers || {}) + }; + if (auth?.bearer) { + clonedHeaders.Authorization = `Bearer ${auth.bearer}`; + } + + const options = { + headers: clonedHeaders, + body, + method + }; + + if (username || password) { + options.username = username; + options.password = password; + } + + const response = await got(url, options); + + if (response.statusCode < 200 || response.statusCode >= 300) { + console.error('Error: ', `(status ${response.statusCode})`, response.body); + throw new Error(`Unexpected status code ${response.statusCode} from ${url}`); + } + return JSON.parse(response.body); +} + +async function checkAppVeyorImage (options) { + const IMAGE_URL = `${APPVEYOR_IMAGES_URL}/${options.cloudId}`; + const requestOpts = { + url: IMAGE_URL, + auth: { + bearer: process.env.APPVEYOR_TOKEN + }, + headers: { + 'Content-Type': 'application/json' + }, + method: 'GET' + }; + + try { + const { settings } = await makeRequest(requestOpts); + const { cloudSettings } = settings; + return cloudSettings.images.find(image => image.name === `${options.imageVersion}`) || null; + } catch (err) { + console.log('Could not call AppVeyor: ', err); + } +} + +async function getPullRequestId (targetBranch) { + const prsForBranch = await octokit.pulls.list({ + owner: 'electron', + repo: 'electron', + state: 'open', + head: `electron:${targetBranch}` + }); + if (prsForBranch.data.length === 1) { + return prsForBranch.data[0].number; + } else { + return null; + } +} + +function useAppVeyorImage (targetBranch, options) { + const validJobs = Object.keys(appVeyorJobs); + if (options.job) { + assert(validJobs.includes(options.job), `Unknown AppVeyor CI job name: ${options.job}. Valid values are: ${validJobs}.`); + callAppVeyorBuildJobs(targetBranch, options.job, options); + } else { + validJobs.forEach((job) => callAppVeyorBuildJobs(targetBranch, job, options)); + } +} + +async function callAppVeyorBuildJobs (targetBranch, job, options) { + console.log(`Using AppVeyor image ${options.version} for ${job}`); + + const pullRequestId = await getPullRequestId(targetBranch); + const environmentVariables = { + APPVEYOR_BUILD_WORKER_CLOUD: DEFAULT_BUILD_CLOUD, + APPVEYOR_BUILD_WORKER_IMAGE: options.version, + ELECTRON_OUT_DIR: 'Default', + ELECTRON_ENABLE_STACK_DUMPING: 1, + ELECTRON_ALSO_LOG_TO_STDERR: 1, + GOMA_FALLBACK_ON_AUTH_FAILURE: true, + DEPOT_TOOLS_WIN_TOOLCHAIN: 0, + PYTHONIOENCODING: 'UTF-8' + }; + + const requestOpts = { + url: APPVEYOR_JOB_URL, + auth: { + bearer: process.env.APPVEYOR_TOKEN + }, + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + accountName: 'electron-bot', + projectSlug: appVeyorJobs[job], + branch: targetBranch, + pullRequestId: pullRequestId || undefined, + commitId: options.commit || undefined, + environmentVariables + }), + method: 'POST' + }; + + try { + const { version } = await makeRequest(requestOpts); + const buildUrl = `https://ci.appveyor.com/project/electron-bot/${appVeyorJobs[job]}/build/${version}`; + console.log(`AppVeyor CI request for ${job} successful. Check status at ${buildUrl}`); + } catch (err) { + console.log('Could not call AppVeyor: ', err); + } +} + +async function bakeAppVeyorImage (targetBranch, options) { + console.log(`Baking a new AppVeyor image for ${options.version}, on build cloud ${options.cloudId}`); + + const environmentVariables = { + APPVEYOR_BUILD_WORKER_CLOUD: DEFAULT_BUILD_CLOUD, + APPVEYOR_BUILD_WORKER_IMAGE: DEFAULT_BAKE_BASE_IMAGE, + APPVEYOR_BAKE_IMAGE: options.version + }; + + const requestOpts = { + url: APPVEYOR_JOB_URL, + auth: { + bearer: process.env.APPVEYOR_TOKEN + }, + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + accountName: 'electron-bot', + projectSlug: appveyorBakeJob, + branch: targetBranch, + commitId: options.commit || undefined, + environmentVariables + }), + method: 'POST' + }; + + try { + const { version } = await makeRequest(requestOpts); + const bakeUrl = `https://ci.appveyor.com/project/electron-bot/${appveyorBakeJob}/build/${version}`; + console.log(`AppVeyor image bake request for ${options.version} successful. Check bake status at ${bakeUrl}`); + } catch (err) { + console.log('Could not call AppVeyor: ', err); + } +} + +async function prepareAppVeyorImage (opts) { + const branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], ELECTRON_DIR); + if (ROLLER_BRANCH_PATTERN.test(branch)) { + useAppVeyorImage(branch, { ...opts, version: DEFAULT_BUILD_IMAGE, cloudId: DEFAULT_BUILD_CLOUD_ID }); + } else { + // eslint-disable-next-line no-control-regex + const versionRegex = new RegExp('chromium_version\':\n +\'(.+?)\',', 'm'); + const deps = fs.readFileSync(path.resolve(__dirname, '..', 'DEPS'), 'utf8'); + const [, CHROMIUM_VERSION] = versionRegex.exec(deps); + + const cloudId = opts.cloudId || DEFAULT_BUILD_CLOUD_ID; + const imageVersion = opts.imageVersion || `e-${CHROMIUM_VERSION}`; + const image = await checkAppVeyorImage({ cloudId, imageVersion }); + + if (image && image.name) { + console.log(`Image exists for ${image.name}. Continuing AppVeyor jobs using ${cloudId}.\n`); + } else { + console.log(`No AppVeyor image found for ${imageVersion} in ${cloudId}. + Creating new image for ${imageVersion}, using Chromium ${CHROMIUM_VERSION} - job will run after image is baked.`); + await bakeAppVeyorImage(branch, { ...opts, version: imageVersion, cloudId }); + + // write image to temp file if running on CI + if (process.env.CI) fs.writeFileSync('./image_version.txt', imageVersion); + } + } +} + +module.exports = prepareAppVeyorImage; + +// Load or bake AppVeyor images for Windows CI. +// Usage: prepare-appveyor.js [--cloudId=CLOUD_ID] [--appveyorJobId=xxx] [--imageVersion=xxx] +// [--commit=sha] [--branch=branch_name] +if (require.main === module) { + const args = require('minimist')(process.argv.slice(2)); + prepareAppVeyorImage(args) + .catch((err) => { + console.error(err); + process.exit(1); + }); +} diff --git a/script/release/ci-release-build.js b/script/release/ci-release-build.js index ef3616374b4c8..1121f7b56125d 100644 --- a/script/release/ci-release-build.js +++ b/script/release/ci-release-build.js @@ -204,7 +204,7 @@ async function callAppVeyor (targetBranch, job, options) { console.log(`Triggering AppVeyor to run build job: ${job} on branch: ${targetBranch} with release flag.`); const environmentVariables = { ELECTRON_RELEASE: 1, - APPVEYOR_BUILD_WORKER_CLOUD: 'libcc-20' + APPVEYOR_BUILD_WORKER_CLOUD: 'electronhq-16-core' }; if (!options.ghRelease) { diff --git a/script/setup-win-for-dev.bat b/script/setup-win-for-dev.bat index e2ee59f5abbb7..2b5fb9a2eabfa 100644 --- a/script/setup-win-for-dev.bat +++ b/script/setup-win-for-dev.bat @@ -1,9 +1,7 @@ REM Parameters vs_buildtools.exe download link and wsdk version @ECHO OFF -SET buildtools_link=https://download.visualstudio.microsoft.com/download/pr/d7691cc1-82e6-434f-8e9f-a612f85b4b76/c62179f8cbbb58d4af22c21e8d4e122165f21615f529c94fad5cc7e012f1ef08/vs_BuildTools.exe -SET wsdk10_link=https://go.microsoft.com/fwlink/p/?LinkId=845298 -SET wsdk=10SDK.18362 +SET wsdk=10SDK.20348 REM Check for disk space Rem 543210987654321 @@ -44,24 +42,6 @@ IF NOT "%1"=="" ( if not exist "C:\TEMP\" mkdir C:\TEMP -REM Download vs_buildtools.exe to C:\TEMP\vs_buildtools.exe -powershell -command "& { iwr %buildtools_link% -OutFile C:\TEMP\vs_buildtools.exe }" - -REM Install Visual Studio Toolchain -C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache ^ - --installPath "%ProgramFiles(x86)%/Microsoft Visual Studio/2019/Community" ^ - --add Microsoft.VisualStudio.Workload.VCTools ^ - --add Microsoft.VisualStudio.Component.VC.140 ^ - --add Microsoft.VisualStudio.Component.VC.ATLMFC ^ - --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^ - --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ^ - --add Microsoft.VisualStudio.Component.Windows%wsdk% ^ - --includeRecommended - -REM Install Windows SDK -powershell -command "& { iwr %wsdk10_link% -OutFile C:\TEMP\wsdk10.exe }" -C:\TEMP\wsdk10.exe /features /quiet - REM Install chocolatey to further install dependencies set chocolateyUseWindowsCompression='true' @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" ^ @@ -69,15 +49,21 @@ set chocolateyUseWindowsCompression='true' -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" -REM Install nodejs python git and yarn needed dependencies -choco install -y nodejs python2 git yarn windows-sdk-10-version-1903-windbg -call C:\ProgramData\chocolatey\bin\RefreshEnv.cmd -SET PATH=C:\Python27\;C:\Python27\Scripts;%PATH% +REM Install Visual Studio Toolchain +choco install visualstudio2019buildtools --package-parameters "--quiet --wait --norestart --nocache --installPath ""%ProgramFiles(x86)%/Microsoft Visual Studio/2019/Community"" --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.140 --add Microsoft.VisualStudio.Component.VC.ATLMFC --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 --add Microsoft.VisualStudio.Component.Windows%wsdk% --includeRecommended" + +REM Install Windows SDK +choco install windows-sdk-10-version-2104-all -pip install pywin32 +REM Install nodejs python git and yarn needed dependencies +choco install -y nodejs-lts python2 git yarn +choco install python --version 3.7.9 call C:\ProgramData\chocolatey\bin\RefreshEnv.cmd -pip2 install pywin32 +SET PATH=C:\Python27\;C:\Python27\Scripts;C:\Python39\;C:\Python39\Scripts;%PATH% REM Setup Depot Tools git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git C:\depot_tools -SET PATH=%PATH%;C:\depot_tools\ \ No newline at end of file +SET PATH=%PATH%;C:\depot_tools\ + +REM Add symstore to PATH permanently +setx path "%%path%%;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64" \ No newline at end of file diff --git a/spec/api-browser-view-spec.ts b/spec/api-browser-view-spec.ts index e8b2c05b1beb3..89ee7af47d0b2 100644 --- a/spec/api-browser-view-spec.ts +++ b/spec/api-browser-view-spec.ts @@ -63,7 +63,7 @@ describe('BrowserView module', () => { }); // Linux and arm64 platforms (WOA and macOS) do not return any capture sources - ifit(process.platform !== 'linux' && process.arch !== 'arm64')('sets the background color to transparent if none is set', async () => { + ifit(process.platform === 'darwin' && process.arch === 'x64')('sets the background color to transparent if none is set', async () => { const display = screen.getPrimaryDisplay(); const WINDOW_BACKGROUND_COLOR = '#55ccbb'; @@ -87,7 +87,7 @@ describe('BrowserView module', () => { }); // Linux and arm64 platforms (WOA and macOS) do not return any capture sources - ifit(process.platform !== 'linux' && process.arch !== 'arm64')('successfully applies the background color', async () => { + ifit(process.platform === 'darwin' && process.arch === 'x64')('successfully applies the background color', async () => { const WINDOW_BACKGROUND_COLOR = '#55ccbb'; const VIEW_BACKGROUND_COLOR = '#ff00ff'; const display = screen.getPrimaryDisplay(); diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 3e0bdedc91672..bc9f23940247b 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -5491,7 +5491,7 @@ describe('BrowserWindow module', () => { }); // Linux and arm64 platforms (WOA and macOS) do not return any capture sources - ifit(process.platform !== 'linux' && process.arch !== 'arm64')('should not display a visible background', async () => { + ifit(process.platform === 'darwin' && process.arch === 'x64')('should not display a visible background', async () => { const display = screen.getPrimaryDisplay(); const backgroundWindow = new BrowserWindow({ @@ -5533,7 +5533,7 @@ describe('BrowserWindow module', () => { afterEach(closeAllWindows); // Linux/WOA doesn't return any capture sources. - ifit(process.platform !== 'linux' && (process.platform !== 'win32' || process.arch !== 'arm64'))('should display the set color', async () => { + ifit(process.platform === 'darwin')('should display the set color', async () => { const display = screen.getPrimaryDisplay(); const w = new BrowserWindow({ From 27ce311a20276a53a2d0e6f5980120050aa21b93 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 1 Dec 2022 10:29:34 -0800 Subject: [PATCH 004/172] docs: document outlivesOpener option in window open handler (#36508) Co-authored-by: Jeremy Rose --- docs/api/web-contents.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 17084a7c7c30f..0e49cb76a9977 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1155,7 +1155,7 @@ Ignore application menu shortcuts while this web contents is focused. #### `contents.setWindowOpenHandler(handler)` -* `handler` Function<{action: 'deny'} | {action: 'allow', overrideBrowserWindowOptions?: BrowserWindowConstructorOptions}> +* `handler` Function<{action: 'deny'} | {action: 'allow', outlivesOpener?: boolean, overrideBrowserWindowOptions?: BrowserWindowConstructorOptions}> * `details` Object * `url` string - The _resolved_ version of the URL passed to `window.open()`. e.g. opening a window with `window.open('foo')` will yield something like `https://the-origin/the/current/path/foo`. * `frameName` string - Name of the window provided in `window.open()` @@ -1170,8 +1170,11 @@ Ignore application menu shortcuts while this web contents is focused. be set. If no post data is to be sent, the value will be `null`. Only defined when the window is being created by a form that set `target=_blank`. - Returns `{action: 'deny'} | {action: 'allow', overrideBrowserWindowOptions?: BrowserWindowConstructorOptions}` - `deny` cancels the creation of the new + Returns `{action: 'deny'} | {action: 'allow', outlivesOpener?: boolean, overrideBrowserWindowOptions?: BrowserWindowConstructorOptions}` - `deny` cancels the creation of the new window. `allow` will allow the new window to be created. Specifying `overrideBrowserWindowOptions` allows customization of the created window. + By default, child windows are closed when their opener is closed. This can be + changed by specifying `outlivesOpener: true`, in which case the opened window + will not be closed when its opener is closed. Returning an unrecognized value such as a null, undefined, or an object without a recognized 'action' value will result in a console error and have the same effect as returning `{action: 'deny'}`. From 38eb4142986cb1c1100567918a7129e2dd86a4d1 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Thu, 1 Dec 2022 12:37:16 -0800 Subject: [PATCH 005/172] chore: cherry-pick 3235c1d1955b from chromium (#36518) * chore: cherry-pick 3235c1d1955b from chromium * chore: update patches Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-3235c1d1955b.patch | 376 ++++++++++++++++++ 2 files changed, 377 insertions(+) create mode 100644 patches/chromium/cherry-pick-3235c1d1955b.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 50a0f9bc50e0c..abab2e5a0125d 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -122,3 +122,4 @@ fix_remove_caption-removing_style_call.patch build_allow_electron_to_use_exec_script.patch cherry-pick-7196a42b42ce.patch fix_tray_icon_gone_on_lock_screen.patch +cherry-pick-3235c1d1955b.patch diff --git a/patches/chromium/cherry-pick-3235c1d1955b.patch b/patches/chromium/cherry-pick-3235c1d1955b.patch new file mode 100644 index 0000000000000..dac245c2fdc2c --- /dev/null +++ b/patches/chromium/cherry-pick-3235c1d1955b.patch @@ -0,0 +1,376 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Johannes Kron +Date: Thu, 1 Dec 2022 01:52:27 +0000 +Subject: Set visible_rect for streams captured with ScreenCaptureKit + +This is needed to make the window capturing code on macOS +using the new ScreenCaptureKit API work, because the IOSurface +may be larger than the actual content resulting in garbage +unless the frame is cropped to |visible_rect|. + +Bug: chromium:1352405 +Change-Id: I1ce3c13947b9b4f9b75a071800a84a27a7c2ee4a +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4046582 +Reviewed-by: Mark Foltz +Commit-Queue: Johannes Kron +Reviewed-by: ccameron chromium +Reviewed-by: Ilya Nikolaevskiy +Reviewed-by: Will Cassella +Cr-Commit-Position: refs/heads/main@{#1077752} + +diff --git a/content/browser/media/capture/desktop_capture_device_mac.cc b/content/browser/media/capture/desktop_capture_device_mac.cc +index 77eec733bed5cc6ba42ea77994b3a276279b0603..1807356bfad1d37ff09486db2e7cbe31b79ad6a8 100644 +--- a/content/browser/media/capture/desktop_capture_device_mac.cc ++++ b/content/browser/media/capture/desktop_capture_device_mac.cc +@@ -127,7 +127,8 @@ class DesktopCaptureDeviceMac : public IOSurfaceCaptureDeviceBase { + + private: + void OnFrame(gfx::ScopedInUseIOSurface io_surface) { +- OnReceivedIOSurfaceFromStream(io_surface, requested_format_); ++ OnReceivedIOSurfaceFromStream(io_surface, requested_format_, ++ gfx::Rect(requested_format_.frame_size)); + } + + const CGDirectDisplayID display_id_; +diff --git a/content/browser/media/capture/io_surface_capture_device_base_mac.cc b/content/browser/media/capture/io_surface_capture_device_base_mac.cc +index ae076bdd6fb9c1ebc72baa2f78a8568d859564ce..0bf2c58b6840c15d827a7b4a5888d1f56ff50943 100644 +--- a/content/browser/media/capture/io_surface_capture_device_base_mac.cc ++++ b/content/browser/media/capture/io_surface_capture_device_base_mac.cc +@@ -39,10 +39,12 @@ void IOSurfaceCaptureDeviceBase::RequestRefreshFrame() { + + void IOSurfaceCaptureDeviceBase::OnReceivedIOSurfaceFromStream( + gfx::ScopedInUseIOSurface io_surface, +- const media::VideoCaptureFormat& capture_format) { ++ const media::VideoCaptureFormat& capture_format, ++ const gfx::Rect& visible_rect) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + last_received_io_surface_ = std::move(io_surface); + last_received_capture_format_ = capture_format; ++ last_visible_rect_ = visible_rect; + + // Immediately send the new frame to the client. + SendLastReceivedIOSurfaceToClient(); +@@ -66,7 +68,7 @@ void IOSurfaceCaptureDeviceBase::SendLastReceivedIOSurfaceToClient() { + media::CapturedExternalVideoBuffer(std::move(handle), + last_received_capture_format_, + gfx::ColorSpace::CreateREC709()), +- {}, now, now - first_frame_time_); ++ {}, now, now - first_frame_time_, last_visible_rect_); + } + + void IOSurfaceCaptureDeviceBase::ComputeFrameSizeAndDestRect( +diff --git a/content/browser/media/capture/io_surface_capture_device_base_mac.h b/content/browser/media/capture/io_surface_capture_device_base_mac.h +index 2781f212d77c9361ff2e28d5e13bbaab14ab0750..8ac12480f663a74dfbdcf7128a582a81b4474d25 100644 +--- a/content/browser/media/capture/io_surface_capture_device_base_mac.h ++++ b/content/browser/media/capture/io_surface_capture_device_base_mac.h +@@ -10,6 +10,7 @@ + #include "base/timer/timer.h" + #include "content/common/content_export.h" + #include "media/capture/video/video_capture_device.h" ++#include "ui/gfx/geometry/rect.h" + #include "ui/gfx/mac/io_surface.h" + + namespace content { +@@ -35,7 +36,8 @@ class CONTENT_EXPORT IOSurfaceCaptureDeviceBase + protected: + void OnReceivedIOSurfaceFromStream( + gfx::ScopedInUseIOSurface io_surface, +- const media::VideoCaptureFormat& capture_format); ++ const media::VideoCaptureFormat& capture_format, ++ const gfx::Rect& visible_rect); + void SendLastReceivedIOSurfaceToClient(); + + // Given a source frame size `source_size`, and `capture_params_`, compute the +@@ -71,6 +73,7 @@ class CONTENT_EXPORT IOSurfaceCaptureDeviceBase + // frames come in, then this will be repeatedly sent at `min_frame_rate_`. + gfx::ScopedInUseIOSurface last_received_io_surface_; + media::VideoCaptureFormat last_received_capture_format_; ++ gfx::Rect last_visible_rect_; + + base::WeakPtrFactory weak_factory_base_{this}; + }; +diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm +index 5d640a372f1649e0e2cb7e1828dbb3c66eb1e4d7..cda6a78ca4c87b459252066189394817ea0c0890 100644 +--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm ++++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm +@@ -17,7 +17,8 @@ + #include "ui/gfx/native_widget_types.h" + + using SampleCallback = base::RepeatingCallback)>; ++ absl::optional, ++ absl::optional)>; + using ErrorCallback = base::RepeatingClosure; + + API_AVAILABLE(macos(12.3)) +@@ -49,9 +50,14 @@ - (void)stream:(SCStream*)stream + if (!pixelBuffer) + return; + +- // Read out width, height and scaling from metadata to determine the captured +- // content size. ++ // Read out width, height and scaling from metadata to determine ++ // |contentSize|, which is the size of the content on screen, and ++ // |visibleRect|, which is the region of the IOSurface that contains the ++ // captured content. |contentSize| is used to detect when a captured window is ++ // resized so that the stream configuration can be updated and |visibleRect| ++ // is needed because the IOSurface may be larger than the captured content. + absl::optional contentSize; ++ absl::optional visibleRect; + CFArrayRef attachmentsArray = + CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, false); + if (attachmentsArray && CFArrayGetCount(attachmentsArray) > 0) { +@@ -70,6 +76,7 @@ - (void)stream:(SCStream*)stream + succeed &= CFNumberGetValue(contentScaleValue, kCFNumberFloatType, + &contentScale); + if (succeed) { ++ visibleRect.emplace(contentRect); + contentSize.emplace(round(contentRect.size.width / contentScale), + round(contentRect.size.height / contentScale)); + } +@@ -81,7 +88,7 @@ - (void)stream:(SCStream*)stream + return; + _sampleCallback.Run( + gfx::ScopedInUseIOSurface(ioSurface, base::scoped_policy::RETAIN), +- contentSize); ++ contentSize, visibleRect); + } + + - (void)stream:(SCStream*)stream didStopWithError:(NSError*)error { +@@ -248,7 +255,8 @@ void OnStreamStopped(bool error) { + } + } + void OnStreamSample(gfx::ScopedInUseIOSurface io_surface, +- absl::optional content_size) { ++ absl::optional content_size, ++ absl::optional visible_rect) { + if (requested_capture_format_) { + // Does the size of io_surface match the requested format? + size_t io_surface_width = IOSurfaceGetWidth(io_surface); +@@ -310,9 +318,11 @@ void OnStreamSample(gfx::ScopedInUseIOSurface io_surface, + } + } + } +- // TODO(https://crbug.com/1352405): Set visible rect to make it possible to +- // crop the frame when it's rendered/encoded. +- OnReceivedIOSurfaceFromStream(io_surface, actual_capture_format_); ++ // The IO surface may be larger than the actual content size. Pass on ++ // visible rect to be able to render/encode the frame correctly. ++ OnReceivedIOSurfaceFromStream( ++ io_surface, actual_capture_format_, ++ visible_rect.value_or(gfx::Rect(actual_capture_format_.frame_size))); + } + void OnStreamError() { + client()->OnError(media::VideoCaptureError::kScreenCaptureKitStreamError, +diff --git a/content/browser/renderer_host/media/video_capture_controller_unittest.cc b/content/browser/renderer_host/media/video_capture_controller_unittest.cc +index 048eea2a9edc5e9ea0817d4ae43187e49188f087..44505aabec3d17c87702a946b4e59d371308b83c 100644 +--- a/content/browser/renderer_host/media/video_capture_controller_unittest.cc ++++ b/content/browser/renderer_host/media/video_capture_controller_unittest.cc +@@ -701,7 +701,8 @@ TEST_P(VideoCaptureControllerTest, CaptureWithScaledFrames) { + + device_client_->OnIncomingCapturedExternalBuffer( + std::move(external_buffer), std::move(scaled_external_buffers), +- arbitrary_reference_time_, arbitrary_timestamp_); ++ arbitrary_reference_time_, arbitrary_timestamp_, ++ gfx::Rect(capture_format.frame_size)); + } + + #endif +diff --git a/media/capture/video/chromeos/mock_video_capture_client.cc b/media/capture/video/chromeos/mock_video_capture_client.cc +index 7c295fa4daaeb837a82685aee7d1f8d0512a2b4d..fd38373927c3864806b60e564389d83ada585cb6 100644 +--- a/media/capture/video/chromeos/mock_video_capture_client.cc ++++ b/media/capture/video/chromeos/mock_video_capture_client.cc +@@ -71,7 +71,8 @@ void MockVideoCaptureClient::OnIncomingCapturedExternalBuffer( + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) { ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) { + if (frame_cb_) + std::move(frame_cb_).Run(); + } +diff --git a/media/capture/video/chromeos/mock_video_capture_client.h b/media/capture/video/chromeos/mock_video_capture_client.h +index c4a3fba38054374927b342455d467f9fd555b79d..d4f6fa931b05bd50a4129301e18abf76617e2e93 100644 +--- a/media/capture/video/chromeos/mock_video_capture_client.h ++++ b/media/capture/video/chromeos/mock_video_capture_client.h +@@ -58,7 +58,8 @@ class MockVideoCaptureClient : public VideoCaptureDevice::Client { + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) override; ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) override; + // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. + ReserveResult ReserveOutputBuffer(const gfx::Size& dimensions, + VideoPixelFormat format, +diff --git a/media/capture/video/fuchsia/video_capture_device_fuchsia_test.cc b/media/capture/video/fuchsia/video_capture_device_fuchsia_test.cc +index 3039594560a2de51557b32b336ca2673b0decd4c..0518b3c4cf6bcdc90031c0857d653cd5a0accfdb 100644 +--- a/media/capture/video/fuchsia/video_capture_device_fuchsia_test.cc ++++ b/media/capture/video/fuchsia/video_capture_device_fuchsia_test.cc +@@ -162,7 +162,8 @@ class TestVideoCaptureClient final : public VideoCaptureDevice::Client { + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) override { ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) override { + NOTREACHED(); + } + void OnIncomingCapturedBuffer(Buffer buffer, +diff --git a/media/capture/video/mac/video_capture_device_mac.mm b/media/capture/video/mac/video_capture_device_mac.mm +index 3fd0e0794c7fa1708b15fa5bd76502a000bcac91..1b6fa23748024058c0b2ccce6d211bd3978d5f3b 100644 +--- a/media/capture/video/mac/video_capture_device_mac.mm ++++ b/media/capture/video/mac/video_capture_device_mac.mm +@@ -827,9 +827,9 @@ ScopedIOUSBInterfaceInterface control_interface( + ", and expected " + capture_format_.frame_size.ToString()); + return; + } +- client_->OnIncomingCapturedExternalBuffer(std::move(frame), +- std::move(scaled_frames), +- base::TimeTicks::Now(), timestamp); ++ client_->OnIncomingCapturedExternalBuffer( ++ std::move(frame), std::move(scaled_frames), base::TimeTicks::Now(), ++ timestamp, gfx::Rect(capture_format_.frame_size)); + } + + void VideoCaptureDeviceMac::OnPhotoTaken(const uint8_t* image_data, +diff --git a/media/capture/video/mock_video_capture_device_client.h b/media/capture/video/mock_video_capture_device_client.h +index 49c2399f6d429e78032792134781f576c61ae15f..c65dcc3fa475090d9ca8e6890d523247c398780f 100644 +--- a/media/capture/video/mock_video_capture_device_client.h ++++ b/media/capture/video/mock_video_capture_device_client.h +@@ -35,11 +35,12 @@ class MockVideoCaptureDeviceClient : public VideoCaptureDevice::Client { + base::TimeTicks reference_time, + base::TimeDelta timestamp, + int frame_feedback_id)); +- MOCK_METHOD4(OnIncomingCapturedExternalBuffer, ++ MOCK_METHOD5(OnIncomingCapturedExternalBuffer, + void(CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp)); ++ base::TimeDelta timestamp, ++ gfx::Rect visible_size)); + MOCK_METHOD4(ReserveOutputBuffer, + ReserveResult(const gfx::Size&, VideoPixelFormat, int, Buffer*)); + MOCK_METHOD3(OnError, +diff --git a/media/capture/video/video_capture_device.h b/media/capture/video/video_capture_device.h +index 76c0a61b372dafbba62c2ec7c84bbd6854f2fa02..5ef13cc639d148023147f0be812c1b09b2cbc815 100644 +--- a/media/capture/video/video_capture_device.h ++++ b/media/capture/video/video_capture_device.h +@@ -191,18 +191,21 @@ class CAPTURE_EXPORT VideoCaptureDevice + base::TimeDelta timestamp, + int frame_feedback_id = 0) = 0; + +- // Captured a new video frame. The data for this frame is in |handle|, +- // which is owned by the platform-specific capture device. It is the +- // responsibilty of the implementation to prevent the buffer in |handle| +- // from being reused by the external capturer. In practice, this is used +- // only on macOS, the external capturer maintains a CVPixelBufferPool, and +- // gfx::ScopedInUseIOSurface is used to prevent reuse of buffers until all +- // consumers have consumed them. ++ // Captured a new video frame. The data for this frame is in ++ // |buffer.handle|, which is owned by the platform-specific capture device. ++ // It is the responsibility of the implementation to prevent the buffer in ++ // |buffer.handle| from being reused by the external capturer. In practice, ++ // this is used only on macOS, the external capturer maintains a ++ // CVPixelBufferPool, and gfx::ScopedInUseIOSurface is used to prevent reuse ++ // of buffers until all consumers have consumed them. |visible_rect| ++ // specifies the region in the memory pointed to by |buffer.handle| that ++ // contains the captured content. + virtual void OnIncomingCapturedExternalBuffer( + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) = 0; ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) = 0; + + // Reserve an output buffer into which contents can be captured directly. + // The returned |buffer| will always be allocated with a memory size +diff --git a/media/capture/video/video_capture_device_client.cc b/media/capture/video/video_capture_device_client.cc +index efa175865f53d5c187cbb65cb4c1b9b40be63614..6229529c8a5878aaec253d5acf1797ae3dcc139f 100644 +--- a/media/capture/video/video_capture_device_client.cc ++++ b/media/capture/video/video_capture_device_client.cc +@@ -468,14 +468,21 @@ void VideoCaptureDeviceClient::OnIncomingCapturedExternalBuffer( + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) { ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) { + auto ready_frame = CreateReadyFrameFromExternalBuffer( +- std::move(buffer), reference_time, timestamp); ++ std::move(buffer), reference_time, timestamp, visible_rect); + std::vector scaled_ready_frames; + scaled_ready_frames.reserve(scaled_buffers.size()); + for (auto& scaled_buffer : scaled_buffers) { ++ // TODO(https://crbug.com/1191986): |visible_rect| is not set correctly for ++ // |scaled_buffers|, but scaled buffers is deprecated and not used. It will ++ // be removed in another CL. ++ gfx::Rect scaled_buffer_visible_rect = ++ gfx::Rect{scaled_buffer.format.frame_size}; + scaled_ready_frames.push_back(CreateReadyFrameFromExternalBuffer( +- std::move(scaled_buffer), reference_time, timestamp)); ++ std::move(scaled_buffer), reference_time, timestamp, ++ scaled_buffer_visible_rect)); + } + receiver_->OnFrameReadyInBuffer(std::move(ready_frame), + std::move(scaled_ready_frames)); +@@ -484,7 +491,8 @@ void VideoCaptureDeviceClient::OnIncomingCapturedExternalBuffer( + ReadyFrameInBuffer VideoCaptureDeviceClient::CreateReadyFrameFromExternalBuffer( + CapturedExternalVideoBuffer buffer, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) { ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) { + // Reserve an ID for this buffer that will not conflict with any of the IDs + // used by |buffer_pool_|. + int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; +@@ -517,7 +525,7 @@ ReadyFrameInBuffer VideoCaptureDeviceClient::CreateReadyFrameFromExternalBuffer( + info->pixel_format = buffer.format.pixel_format; + info->color_space = buffer.color_space; + info->coded_size = buffer.format.frame_size; +- info->visible_rect = gfx::Rect(buffer.format.frame_size); ++ info->visible_rect = visible_rect; + info->metadata.frame_rate = buffer.format.frame_rate; + info->metadata.reference_time = reference_time; + +diff --git a/media/capture/video/video_capture_device_client.h b/media/capture/video/video_capture_device_client.h +index d1c5b3db855d98f10cabcc71a09d40bbb2601296..56d432c99bcd16b221f574d312731f4c87706caf 100644 +--- a/media/capture/video/video_capture_device_client.h ++++ b/media/capture/video/video_capture_device_client.h +@@ -87,7 +87,8 @@ class CAPTURE_EXPORT VideoCaptureDeviceClient + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) override; ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) override; + ReserveResult ReserveOutputBuffer(const gfx::Size& dimensions, + VideoPixelFormat format, + int frame_feedback_id, +@@ -116,7 +117,8 @@ class CAPTURE_EXPORT VideoCaptureDeviceClient + ReadyFrameInBuffer CreateReadyFrameFromExternalBuffer( + CapturedExternalVideoBuffer buffer, + base::TimeTicks reference_time, +- base::TimeDelta timestamp); ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect); + + // A branch of OnIncomingCapturedData for Y16 frame_format.pixel_format. + void OnIncomingCapturedY16Data(const uint8_t* data, +diff --git a/media/capture/video/win/video_capture_device_mf_win_unittest.cc b/media/capture/video/win/video_capture_device_mf_win_unittest.cc +index 1cffb468c33f6185bc656d19760854908e89aa65..293672feabe4172c2946a06ec54b2e67e5533afb 100644 +--- a/media/capture/video/win/video_capture_device_mf_win_unittest.cc ++++ b/media/capture/video/win/video_capture_device_mf_win_unittest.cc +@@ -83,7 +83,8 @@ class MockClient : public VideoCaptureDevice::Client { + CapturedExternalVideoBuffer buffer, + std::vector scaled_buffers, + base::TimeTicks reference_time, +- base::TimeDelta timestamp) override {} ++ base::TimeDelta timestamp, ++ gfx::Rect visible_rect) override {} + + MOCK_METHOD4(ReserveOutputBuffer, + ReserveResult(const gfx::Size&, VideoPixelFormat, int, Buffer*)); From 7949645606eb828ec1c61a7d99c760091c33c5ac Mon Sep 17 00:00:00 2001 From: "electron-roller[bot]" <84116207+electron-roller[bot]@users.noreply.github.com> Date: Thu, 1 Dec 2022 21:47:05 -0500 Subject: [PATCH 006/172] chore: bump chromium to 108.0.5359.72 (22-x-y) (#36493) chore: bump chromium in DEPS to 108.0.5359.72 Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 5b4907849e649..f24b26ed51f22 100644 --- a/DEPS +++ b/DEPS @@ -2,7 +2,7 @@ gclient_gn_args_from = 'src' vars = { 'chromium_version': - '108.0.5359.62', + '108.0.5359.72', 'node_version': 'v16.17.1', 'nan_version': From dcce07dcd81dd5ecfd3e2e9c81f2205e0e13d042 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 5 Dec 2022 09:06:29 -0800 Subject: [PATCH 007/172] chore: cherry-pick 2611772cf0a0 from chromium (#36517) * chore: cherry-pick 2611772cf0a0 from chromium * chore: update patches Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-2611772cf0a0.patch | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 patches/chromium/cherry-pick-2611772cf0a0.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index abab2e5a0125d..f38a2a8301e0f 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -122,4 +122,5 @@ fix_remove_caption-removing_style_call.patch build_allow_electron_to_use_exec_script.patch cherry-pick-7196a42b42ce.patch fix_tray_icon_gone_on_lock_screen.patch +cherry-pick-2611772cf0a0.patch cherry-pick-3235c1d1955b.patch diff --git a/patches/chromium/cherry-pick-2611772cf0a0.patch b/patches/chromium/cherry-pick-2611772cf0a0.patch new file mode 100644 index 0000000000000..98b8b5595bb1d --- /dev/null +++ b/patches/chromium/cherry-pick-2611772cf0a0.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Johannes Kron +Date: Mon, 28 Nov 2022 10:17:22 +0000 +Subject: Add feature for window capturing with ScreenCaptureKit + +Makes it possible to launch window capturing with +ScreenCaptureKit individually. + +Bug: chromium:1352405 +Change-Id: Ie58d15007667db887ebf5f6f3092ef323f925461 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4047186 +Reviewed-by: Elad Alon +Commit-Queue: Johannes Kron +Cr-Commit-Position: refs/heads/main@{#1076120} + +diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc +index 4e510e5199a62e536542088e79c9b825225664fa..21d8f08c5d7abf414f0ecc7a909a87d9d5ce0513 100644 +--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc ++++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc +@@ -98,6 +98,13 @@ BASE_FEATURE(kDesktopCaptureMacV2, + BASE_FEATURE(kScreenCaptureKitMac, + "ScreenCaptureKitMac", + base::FEATURE_DISABLED_BY_DEFAULT); ++ ++// If this feature is enabled, ScreenCaptureKit will be used for window ++// capturing even if kScreenCaptureKitMac is disabled. Please note that this ++// feature has no effect if kScreenCaptureKitMac is enabled. ++BASE_FEATURE(kScreenCaptureKitMacWindow, ++ "ScreenCaptureKitMacWindow", ++ base::FEATURE_DISABLED_BY_DEFAULT); + #endif + + void IncrementDesktopCaptureCounters(const DesktopMediaID& device_id) { +@@ -491,7 +498,9 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread( + // Prefer using ScreenCaptureKit. After that try DesktopCaptureDeviceMac, and + // if both fail, use the generic DesktopCaptureDevice. + if (!video_capture_device && +- base::FeatureList::IsEnabled(kScreenCaptureKitMac)) { ++ (base::FeatureList::IsEnabled(kScreenCaptureKitMac) || ++ (desktop_id.type == DesktopMediaID::TYPE_WINDOW && ++ base::FeatureList::IsEnabled(kScreenCaptureKitMacWindow)))) { + if ((video_capture_device = CreateScreenCaptureKitDeviceMac(desktop_id))) + implementation = kScreenCaptureKitDeviceMac; + } From 32f71c118f987c7e18266f7f97266319497326b6 Mon Sep 17 00:00:00 2001 From: "electron-roller[bot]" <84116207+electron-roller[bot]@users.noreply.github.com> Date: Mon, 5 Dec 2022 13:19:26 -0500 Subject: [PATCH 008/172] chore: bump chromium to 108.0.5359.94 (22-x-y) (#36546) chore: bump chromium in DEPS to 108.0.5359.94 Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index f24b26ed51f22..9bc1423bbcbe2 100644 --- a/DEPS +++ b/DEPS @@ -2,7 +2,7 @@ gclient_gn_args_from = 'src' vars = { 'chromium_version': - '108.0.5359.72', + '108.0.5359.94', 'node_version': 'v16.17.1', 'nan_version': From 896aa1adb9ed04bd6da8af3f60761fd3b7448490 Mon Sep 17 00:00:00 2001 From: "electron-roller[bot]" <84116207+electron-roller[bot]@users.noreply.github.com> Date: Thu, 8 Dec 2022 13:38:09 -0500 Subject: [PATCH 009/172] chore: bump chromium to 108.0.5359.99 (22-x-y) (#36613) chore: bump chromium in DEPS to 108.0.5359.99 Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index 9bc1423bbcbe2..e24bf5ca6ad8b 100644 --- a/DEPS +++ b/DEPS @@ -2,7 +2,7 @@ gclient_gn_args_from = 'src' vars = { 'chromium_version': - '108.0.5359.94', + '108.0.5359.99', 'node_version': 'v16.17.1', 'nan_version': From 09430e27a9190311471ce078b9a252dd7b2c3b65 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 8 Dec 2022 14:55:45 -0800 Subject: [PATCH 010/172] docs: add mdn link to web-request-filter.md (#36617) * Add MDN link to web-request-filter.md When I was using the Electron docs I wanted to know how to use [webRequest.onBeforeSendHeaders](https://www.electronjs.org/docs/latest/api/web-request#webrequestonbeforesendheadersfilter-listener) but I was unable to correctly guess the correct format for the `WebRequestFilter` URL strings, and there was no explanation in the Electron docs. Eventually I googled it and found the MDN article which helped me. Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com> * Update docs/api/structures/web-request-filter.md Co-authored-by: Black-Hole <158blackhole@gmail.com> Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com> * Update docs/api/structures/web-request-filter.md Co-authored-by: Black-Hole <158blackhole@gmail.com> Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Hugh Davey <9026053+hughjdavey@users.noreply.github.com> --- docs/api/structures/web-request-filter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/structures/web-request-filter.md b/docs/api/structures/web-request-filter.md index ae54cea7bfc08..03ee6f4b26582 100644 --- a/docs/api/structures/web-request-filter.md +++ b/docs/api/structures/web-request-filter.md @@ -1,3 +1,3 @@ # WebRequestFilter Object -* `urls` string[] - Array of URL patterns that will be used to filter out the requests that do not match the URL patterns. +* `urls` string[] - Array of [URL patterns](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) that will be used to filter out the requests that do not match the URL patterns. From 64b514472ded5bbb9bd36af91cbc915f1cffcb65 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 13 Dec 2022 10:40:13 -0800 Subject: [PATCH 011/172] chore: cherry-pick 09ae62b from node (#36624) Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/node/.patches | 1 + patches/node/cherry-pick-09ae62b.patch | 191 +++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 patches/node/cherry-pick-09ae62b.patch diff --git a/patches/node/.patches b/patches/node/.patches index c9c793b51f35b..db61769dc2e28 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -53,3 +53,4 @@ fix_parallel_test-v8-stats.patch fix_expose_the_built-in_electron_module_via_the_esm_loader.patch chore_enable_c_17_for_native_modules.patch enable_crashpad_linux_node_processes.patch +cherry-pick-09ae62b.patch diff --git a/patches/node/cherry-pick-09ae62b.patch b/patches/node/cherry-pick-09ae62b.patch new file mode 100644 index 0000000000000..3d74fc6a10d03 --- /dev/null +++ b/patches/node/cherry-pick-09ae62b.patch @@ -0,0 +1,191 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Michael Dawson +Date: Tue, 25 Oct 2022 17:39:41 -0400 +Subject: node-api: handle no support for external buffers + +Refs: https://github.com/electron/electron/issues/35801 +Refs: https://github.com/nodejs/abi-stable-node/issues/441 + +Electron recently dropped support for external +buffers. Provide a way for addon authors to: +- hide the methods to create external buffers so they can + avoid using them if they want the broadest compatibility. +- call the methods that create external buffers at runtime + to check if external buffers are supported and either + use them or not based on the return code. + +Signed-off-by: Michael Dawson + +PR-URL: https://github.com/nodejs/node/pull/45181 +Reviewed-By: Chengzhong Wu +Reviewed-By: Minwoo Jung + +diff --git a/doc/api/n-api.md b/doc/api/n-api.md +index 71a0081352d3497b9d0c12666b2c6e3ef6da650a..6ba74e5dc7a358ea3dc1e1ce6cd9636a6143c371 100644 +--- a/doc/api/n-api.md ++++ b/doc/api/n-api.md +@@ -579,6 +579,7 @@ typedef enum { + napi_arraybuffer_expected, + napi_detachable_arraybuffer_expected, + napi_would_deadlock, /* unused */ ++ napi_no_external_buffers_allowed + } napi_status; + ``` + +@@ -2399,6 +2400,19 @@ napi_create_external_arraybuffer(napi_env env, + + Returns `napi_ok` if the API succeeded. + ++**Some runtimes other than Node.js have dropped support for external buffers**. ++On runtimes other than Node.js this method may return ++`napi_no_external_buffers_allowed` to indicate that external ++buffers are not supported. One such runtime is Electron as ++described in this issue ++[electron/issues/35801](https://github.com/electron/electron/issues/35801). ++ ++In order to maintain broadest compatibility with all runtimes ++you may define `NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED` in your addon before ++includes for the node-api headers. Doing so will hide the 2 functions ++that create external buffers. This will ensure a compilation error ++occurs if you accidentally use one of these methods. ++ + This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`. + The underlying byte buffer of the `ArrayBuffer` is externally allocated and + managed. The caller must ensure that the byte buffer remains valid until the +@@ -2443,6 +2457,19 @@ napi_status napi_create_external_buffer(napi_env env, + + Returns `napi_ok` if the API succeeded. + ++**Some runtimes other than Node.js have dropped support for external buffers**. ++On runtimes other than Node.js this method may return ++`napi_no_external_buffers_allowed` to indicate that external ++buffers are not supported. One such runtime is Electron as ++described in this issue ++[electron/issues/35801](https://github.com/electron/electron/issues/35801). ++ ++In order to maintain broadest compatibility with all runtimes ++you may define `NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED` in your addon before ++includes for the node-api headers. Doing so will hide the 2 functions ++that create external buffers. This will ensure a compilation error ++occurs if you accidentally use one of these methods. ++ + This API allocates a `node::Buffer` object and initializes it with data + backed by the passed in buffer. While this is still a fully-supported data + structure, in most cases using a `TypedArray` will suffice. +diff --git a/src/js_native_api.h b/src/js_native_api.h +index 220d140d4bfe9a076c739cdc2b03ea22963aa704..d11a2c5a18cf16ece1c74b735886b5ee0c7ec009 100644 +--- a/src/js_native_api.h ++++ b/src/js_native_api.h +@@ -401,6 +401,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_create_arraybuffer(napi_env env, + size_t byte_length, + void** data, + napi_value* result); ++#ifndef NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + NAPI_EXTERN napi_status NAPI_CDECL + napi_create_external_arraybuffer(napi_env env, + void* external_data, +@@ -408,6 +409,7 @@ napi_create_external_arraybuffer(napi_env env, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result); ++#endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + NAPI_EXTERN napi_status NAPI_CDECL napi_get_arraybuffer_info( + napi_env env, napi_value arraybuffer, void** data, size_t* byte_length); + NAPI_EXTERN napi_status NAPI_CDECL napi_is_typedarray(napi_env env, +diff --git a/src/js_native_api_types.h b/src/js_native_api_types.h +index 376930ba4a32206097bc2f20f4c04c9910c231e0..517614950a90f75330e7afeafcc4ed180308c871 100644 +--- a/src/js_native_api_types.h ++++ b/src/js_native_api_types.h +@@ -98,7 +98,8 @@ typedef enum { + napi_date_expected, + napi_arraybuffer_expected, + napi_detachable_arraybuffer_expected, +- napi_would_deadlock // unused ++ napi_would_deadlock, // unused ++ napi_no_external_buffers_allowed + } napi_status; + // Note: when adding a new enum value to `napi_status`, please also update + // * `const int last_status` in the definition of `napi_get_last_error_info()' +diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc +index 5f8e21e0b58c8a8fea1e3ee2e0eecf5b892e4683..bafcb9bec5bafdb775b467476c94f44ca8c4b64e 100644 +--- a/src/js_native_api_v8.cc ++++ b/src/js_native_api_v8.cc +@@ -748,6 +748,7 @@ static const char* error_messages[] = { + "An arraybuffer was expected", + "A detachable arraybuffer was expected", + "Main thread would deadlock", ++ "External buffers are not allowed", + }; + + napi_status NAPI_CDECL napi_get_last_error_info( +@@ -759,7 +760,7 @@ napi_status NAPI_CDECL napi_get_last_error_info( + // message in the `napi_status` enum each time a new error message is added. + // We don't have a napi_status_last as this would result in an ABI + // change each time a message was added. +- const int last_status = napi_would_deadlock; ++ const int last_status = napi_no_external_buffers_allowed; + + static_assert(NAPI_ARRAYSIZE(error_messages) == last_status + 1, + "Count of error messages must match count of error values"); +diff --git a/src/node_api.cc b/src/node_api.cc +index 08352b0a584b543cf1ad2947f820d8a5dc7fe0db..26e0292083cd760b7f6aeddca3527631652c5d03 100644 +--- a/src/node_api.cc ++++ b/src/node_api.cc +@@ -949,6 +949,10 @@ napi_status NAPI_CDECL napi_create_external_buffer(napi_env env, + NAPI_PREAMBLE(env); + CHECK_ARG(env, result); + ++#if defined(V8_ENABLE_SANDBOX) ++ return napi_set_last_error(env, napi_no_external_buffers_allowed); ++#endif ++ + v8::Isolate* isolate = env->isolate; + + // The finalizer object will delete itself after invoking the callback. +diff --git a/src/node_api.h b/src/node_api.h +index 982b41cadf20aed89c3c61feeec8e74ed875e25c..07af926cafb536a25c99ada43cdf0fc1c2f72896 100644 +--- a/src/node_api.h ++++ b/src/node_api.h +@@ -153,6 +153,7 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer(napi_env env, + size_t length, + void** data, + napi_value* result); ++#ifndef NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + NAPI_EXTERN napi_status NAPI_CDECL + napi_create_external_buffer(napi_env env, + size_t length, +@@ -160,6 +161,7 @@ napi_create_external_buffer(napi_env env, + napi_finalize finalize_cb, + void* finalize_hint, + napi_value* result); ++#endif // NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + NAPI_EXTERN napi_status NAPI_CDECL napi_create_buffer_copy(napi_env env, + size_t length, + const void* data, +diff --git a/test/js-native-api/test_general/test_general.c b/test/js-native-api/test_general/test_general.c +index 7b755ce9a9f202eaf91e5103d6c0204925f99cac..b474ab442cb763cb84ec77901da91a6f1471c946 100644 +--- a/test/js-native-api/test_general/test_general.c ++++ b/test/js-native-api/test_general/test_general.c +@@ -1,3 +1,8 @@ ++// we define NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED here to ++// validate that it can be used as a form of test itself. It is ++// not related to any of the other tests ++// defined in the file ++#define NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + #include + #include + #include +diff --git a/test/node-api/test_general/test_general.c b/test/node-api/test_general/test_general.c +index d430e2df4f3520fddbc5ce8d260adba565e6c3c9..b8d837d5e45650fcb9ba04030721b0f51377f078 100644 +--- a/test/node-api/test_general/test_general.c ++++ b/test/node-api/test_general/test_general.c +@@ -1,4 +1,9 @@ + #define NAPI_EXPERIMENTAL ++// we define NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED here to validate that it can ++// be used as a form of test itself. It is ++// not related to any of the other tests ++// defined in the file ++#define NODE_API_NO_EXTERNAL_BUFFERS_ALLOWED + #include + #include + #include "../../js-native-api/common.h" From a7f80017cf3eaf35721adc692dd8011fb0ecb297 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 13 Dec 2022 10:54:10 -0800 Subject: [PATCH 012/172] docs: link net.request options to ClientRequestConstructorOptions (#36569) Co-authored-by: Samuel Attard Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard --- docs/api/net.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/net.md b/docs/api/net.md index ffbff49d054b4..2fcf307d752c3 100644 --- a/docs/api/net.md +++ b/docs/api/net.md @@ -54,7 +54,7 @@ The `net` module has the following methods: ### `net.request(options)` -* `options` (ClientRequestConstructorOptions | string) - The `ClientRequest` constructor options. +* `options` ([ClientRequestConstructorOptions](client-request.md#new-clientrequestoptions) | string) - The `ClientRequest` constructor options. Returns [`ClientRequest`](./client-request.md) From 14fade291571aa24952111658dd2f49a906dbba4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:46:19 -0500 Subject: [PATCH 013/172] fix: strip branded binaries (#36654) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating branded release builds and using scripts/strip-binaries.py on Linux, the final artifacts end up unstripped due to the static set of binaries considered for stripping. With this patch the name of the electron binary is taken from the BRANDING.json `project_name` key. Signed-off-by: Robert Günzler Co-authored-by: Robert Günzler Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Robert Günzler --- script/add-debug-link.py | 6 +++--- script/copy-debug-symbols.py | 6 +++--- script/lib/config.py | 10 ---------- script/lib/util.py | 11 +++++++++++ script/strip-binaries.py | 6 +++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/script/add-debug-link.py b/script/add-debug-link.py index 167c9e2d93545..68ef0d3fd415f 100755 --- a/script/add-debug-link.py +++ b/script/add-debug-link.py @@ -4,11 +4,11 @@ import os import sys -from lib.config import LINUX_BINARIES, PLATFORM -from lib.util import execute, get_out_dir +from lib.config import PLATFORM +from lib.util import execute, get_linux_binaries, get_out_dir def add_debug_link_into_binaries(directory, target_cpu, debug_dir): - for binary in LINUX_BINARIES: + for binary in get_linux_binaries(): binary_path = os.path.join(directory, binary) if os.path.isfile(binary_path): add_debug_link_into_binary(binary_path, target_cpu, debug_dir) diff --git a/script/copy-debug-symbols.py b/script/copy-debug-symbols.py index 0ceff1a0e2e3f..d1cd4c8b4868f 100755 --- a/script/copy-debug-symbols.py +++ b/script/copy-debug-symbols.py @@ -4,12 +4,12 @@ import os import sys -from lib.config import LINUX_BINARIES, PLATFORM -from lib.util import execute, get_out_dir, safe_mkdir +from lib.config import PLATFORM +from lib.util import execute, get_linux_binaries, get_out_dir, safe_mkdir # It has to be done before stripping the binaries. def copy_debug_from_binaries(directory, out_dir, target_cpu, compress): - for binary in LINUX_BINARIES: + for binary in get_linux_binaries(): binary_path = os.path.join(directory, binary) if os.path.isfile(binary_path): copy_debug_from_binary(binary_path, out_dir, target_cpu, compress) diff --git a/script/lib/config.py b/script/lib/config.py index 883a0374bc251..eaa5f5ac697cf 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -13,16 +13,6 @@ 'win32': 'win32', }[sys.platform] -LINUX_BINARIES = [ - 'chrome-sandbox', - 'chrome_crashpad_handler', - 'electron', - 'libEGL.so', - 'libGLESv2.so', - 'libffmpeg.so', - 'libvk_swiftshader.so', -] - verbose_mode = False diff --git a/script/lib/util.py b/script/lib/util.py index 7911d2da79fcf..abf1310673d80 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -215,3 +215,14 @@ def get_buildtools_executable(name): if sys.platform == 'win32': path += '.exe' return path + +def get_linux_binaries(): + return [ + 'chrome-sandbox', + 'chrome_crashpad_handler', + get_electron_branding()['project_name'], + 'libEGL.so', + 'libGLESv2.so', + 'libffmpeg.so', + 'libvk_swiftshader.so', + ] diff --git a/script/strip-binaries.py b/script/strip-binaries.py index 625218c5b6810..059a8b8e8e8c9 100755 --- a/script/strip-binaries.py +++ b/script/strip-binaries.py @@ -4,11 +4,11 @@ import os import sys -from lib.config import LINUX_BINARIES, enable_verbose_mode -from lib.util import execute, get_out_dir +from lib.config import enable_verbose_mode +from lib.util import execute, get_linux_binaries, get_out_dir def strip_binaries(directory, target_cpu): - for binary in LINUX_BINARIES: + for binary in get_linux_binaries(): binary_path = os.path.join(directory, binary) if os.path.isfile(binary_path): strip_binary(binary_path, target_cpu) From 0b9206213cfacd03fdd0010ec3e99a42271fcb28 Mon Sep 17 00:00:00 2001 From: "electron-roller[bot]" <84116207+electron-roller[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:47:08 -0500 Subject: [PATCH 014/172] chore: bump chromium to 108.0.5359.125 (22-x-y) (#36661) * chore: bump chromium in DEPS to 108.0.5359.125 * chore: update patches Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- DEPS | 2 +- .../revert_track_ssl_error_zero_return_explicitly.patch | 6 +++--- patches/chromium/can_create_window.patch | 2 +- patches/chromium/webview_cross_drag.patch | 4 ++-- patches/chromium/webview_fullscreen.patch | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index e24bf5ca6ad8b..7573a903314d9 100644 --- a/DEPS +++ b/DEPS @@ -2,7 +2,7 @@ gclient_gn_args_from = 'src' vars = { 'chromium_version': - '108.0.5359.99', + '108.0.5359.125', 'node_version': 'v16.17.1', 'nan_version': diff --git a/patches/boringssl/revert_track_ssl_error_zero_return_explicitly.patch b/patches/boringssl/revert_track_ssl_error_zero_return_explicitly.patch index 858b0a7ff484c..aae119e346e29 100644 --- a/patches/boringssl/revert_track_ssl_error_zero_return_explicitly.patch +++ b/patches/boringssl/revert_track_ssl_error_zero_return_explicitly.patch @@ -48,10 +48,10 @@ index a6ca0ab96266475384429e73970de18d4ba09912..c7e7bd02f2484f91bf55df1400e94804 void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, RSA *(*cb)(SSL *ssl, int is_export, diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc -index 3709a4694f3c9be67fd918f125f023b5aa660971..3507f4ef5bd4444c2499b06a5e312ab54f08bc3b 100644 +index 3515f602f192369bfc25b1df0bb8a71d3320afb7..5179b12f63740771312563391a1c348d611a8ba9 100644 --- a/ssl/ssl_test.cc +++ b/ssl/ssl_test.cc -@@ -8358,11 +8358,6 @@ TEST(SSLTest, ErrorSyscallAfterCloseNotify) { +@@ -8360,11 +8360,6 @@ TEST(SSLTest, ErrorSyscallAfterCloseNotify) { EXPECT_EQ(ret, 0); EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_ZERO_RETURN); @@ -63,7 +63,7 @@ index 3709a4694f3c9be67fd918f125f023b5aa660971..3507f4ef5bd4444c2499b06a5e312ab5 // Although the client has seen close_notify, it should continue to report // |SSL_ERROR_SYSCALL| when its writes fail. ret = SSL_write(client.get(), data, sizeof(data)); -@@ -8370,22 +8365,6 @@ TEST(SSLTest, ErrorSyscallAfterCloseNotify) { +@@ -8372,22 +8367,6 @@ TEST(SSLTest, ErrorSyscallAfterCloseNotify) { EXPECT_EQ(SSL_get_error(client.get(), ret), SSL_ERROR_SYSCALL); EXPECT_TRUE(write_failed); write_failed = false; diff --git a/patches/chromium/can_create_window.patch b/patches/chromium/can_create_window.patch index 43347ec31c0d2..0f068ea1d3e88 100644 --- a/patches/chromium/can_create_window.patch +++ b/patches/chromium/can_create_window.patch @@ -9,7 +9,7 @@ potentially prevent a window from being created. TODO(loc): this patch is currently broken. diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc -index e4e16ccdcd2070e56d9572b7d4bc22d685cb34bc..7484975281bf5c19b1640c56ea6ad5f8a1add54a 100644 +index 81ee9846e14c148be31170f0439b59b046c77244..a93ba154cd435c4a00f625c7cb887116df5b7c64 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc @@ -7443,6 +7443,7 @@ void RenderFrameHostImpl::CreateNewWindow( diff --git a/patches/chromium/webview_cross_drag.patch b/patches/chromium/webview_cross_drag.patch index 8e861d1c5cba5..b8104ee8a77e8 100644 --- a/patches/chromium/webview_cross_drag.patch +++ b/patches/chromium/webview_cross_drag.patch @@ -8,10 +8,10 @@ This allows dragging and dropping between s. Originally landed in https://github.com/electron/libchromiumcontent/pull/267 diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc -index 7a7f170f3cd9fc6d617f2a00d5048163f9ed0017..d3ea49e3228262f30a04e45c1d1bf1939e64da6c 100644 +index 01e059f56861f5f4aa806a8113d2b3f016a2c504..000efc6882c2cb5ccb7b99e9d3a70f7f1efe5908 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc -@@ -916,10 +916,7 @@ bool WebContentsViewAura::IsValidDragTarget( +@@ -917,10 +917,7 @@ bool WebContentsViewAura::IsValidDragTarget( // for the outermost view. Inner `WebContents` will have a // `WebContentsViewChildFrame` so when dragging between an inner // `WebContents` and its embedder the view IDs will be the same. diff --git a/patches/chromium/webview_fullscreen.patch b/patches/chromium/webview_fullscreen.patch index 5b9a241d09571..46455a3a26795 100644 --- a/patches/chromium/webview_fullscreen.patch +++ b/patches/chromium/webview_fullscreen.patch @@ -14,7 +14,7 @@ Note that we also need to manually update embedder's `api::WebContents::IsFullscreenForTabOrPending` value. diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc -index 7484975281bf5c19b1640c56ea6ad5f8a1add54a..674168c49840bf73512ec9fba7a91e4d8c49c7a0 100644 +index a93ba154cd435c4a00f625c7cb887116df5b7c64..17c0b7976b4c547a55ce32f79136bf11cdc38b5d 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc @@ -6718,6 +6718,17 @@ void RenderFrameHostImpl::EnterFullscreen( From a63ea46ab2e837ec0fbb00c9c427bfc0d196a734 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 14 Dec 2022 17:37:53 -0500 Subject: [PATCH 015/172] ci: update Windows image to e-108.0.5359.125 (#36670) --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 341f6da0d7cb3..c4a41b875f0ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,7 +25,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-108.0.5359.48 +image: e-108.0.5359.125 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default From f49f0d4cd725ad157e4c5147d848e1e9ee932496 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:40:16 -0500 Subject: [PATCH 016/172] docs: fix broken links (#36560) * docs: fix broken links Co-authored-by: David Sanders * docs: change link to navigator.getUserMedia Co-authored-by: Jeremy Rose Co-authored-by: David Sanders * docs: fix link in examples.md Co-authored-by: David Sanders Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders --- docs/api/app.md | 1 - docs/api/dock.md | 2 ++ docs/api/message-port-main.md | 1 + docs/api/parent-port.md | 2 ++ docs/api/structures/desktop-capturer-source.md | 2 +- docs/api/system-preferences.md | 2 +- docs/api/utility-process.md | 1 + docs/api/web-contents.md | 1 + docs/api/web-frame-main.md | 1 + docs/glossary.md | 4 ++-- docs/tutorial/dark-mode.md | 2 +- docs/tutorial/devtools-extension.md | 2 +- docs/tutorial/examples.md | 1 + docs/tutorial/tutorial-6-publishing-updating.md | 2 +- docs/tutorial/updates.md | 2 +- 15 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index 418c3504c3da9..4ccd7fde8675d 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1509,7 +1509,6 @@ dock on macOS. A `boolean` property that returns `true` if the app is packaged, `false` otherwise. For many apps, this property can be used to distinguish development and production environments. -[dock-menu]:https://developer.apple.com/macos/human-interface-guidelines/menus/dock-menus/ [tasks]:https://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx [electron-forge]: https://www.electronforge.io/ diff --git a/docs/api/dock.md b/docs/api/dock.md index 3e798e793192e..d93f72afe4381 100644 --- a/docs/api/dock.md +++ b/docs/api/dock.md @@ -79,3 +79,5 @@ Returns `Menu | null` - The application's [dock menu][dock-menu]. * `image` ([NativeImage](native-image.md) | string) Sets the `image` associated with this dock icon. + +[dock-menu]: https://developer.apple.com/macos/human-interface-guidelines/menus/dock-menus/ diff --git a/docs/api/message-port-main.md b/docs/api/message-port-main.md index 5309843916653..371d358f94cb0 100644 --- a/docs/api/message-port-main.md +++ b/docs/api/message-port-main.md @@ -56,3 +56,4 @@ Emitted when the remote end of a MessagePortMain object becomes disconnected. [`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort [Channel Messaging API]: https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API +[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter diff --git a/docs/api/parent-port.md b/docs/api/parent-port.md index 9c6ad3a08d655..4b181b474b933 100644 --- a/docs/api/parent-port.md +++ b/docs/api/parent-port.md @@ -44,3 +44,5 @@ event. * `message` any Sends a message from the process to its parent. + +[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter diff --git a/docs/api/structures/desktop-capturer-source.md b/docs/api/structures/desktop-capturer-source.md index 1740ee7924f52..e898ebd523628 100644 --- a/docs/api/structures/desktop-capturer-source.md +++ b/docs/api/structures/desktop-capturer-source.md @@ -2,7 +2,7 @@ * `id` string - The identifier of a window or screen that can be used as a `chromeMediaSourceId` constraint when calling - [`navigator.webkitGetUserMedia`]. The format of the identifier will be + [`navigator.getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia). The format of the identifier will be `window:XX:YY` or `screen:ZZ:0`. XX is the windowID/handle. YY is 1 for the current process, and 0 for all others. ZZ is a sequential number that represents the screen, and it does not equal to the index in the diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md index 6c0a6a388fb46..2c57be7701660 100644 --- a/docs/api/system-preferences.md +++ b/docs/api/system-preferences.md @@ -441,7 +441,7 @@ It will always return `granted` for `screen` and for all media types on older ve Returns `Promise` - A promise that resolves with `true` if consent was granted and `false` if it was denied. If an invalid `mediaType` is passed, the promise will be rejected. If an access request was denied and later is changed through the System Preferences pane, a restart of the app will be required for the new permissions to take effect. If access has already been requested and denied, it _must_ be changed through the preference pane; an alert will not pop up and the promise will resolve with the existing access status. -**Important:** In order to properly leverage this API, you [must set](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos?language=objc) the `NSMicrophoneUsageDescription` and `NSCameraUsageDescription` strings in your app's `Info.plist` file. The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. See [Electron Application Distribution](../tutorial/application-distribution.md#macos) for more information about how to set these in the context of Electron. +**Important:** In order to properly leverage this API, you [must set](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos?language=objc) the `NSMicrophoneUsageDescription` and `NSCameraUsageDescription` strings in your app's `Info.plist` file. The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. See [Electron Application Distribution](../tutorial/application-distribution.md#rebranding-with-downloaded-binaries) for more information about how to set these in the context of Electron. This user consent was not required until macOS 10.14 Mojave, so this method will always return `true` if your system is running 10.13 High Sierra or lower. diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index 9495b527e730d..ed9b44af1ab15 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -135,3 +135,4 @@ Emitted when the child process sends a message using [`process.parentPort.postMe [Services API]: https://chromium.googlesource.com/chromium/src/+/master/docs/mojo_and_services.md [stdio]: https://nodejs.org/dist/latest/docs/api/child_process.html#optionsstdio [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter +[`MessagePortMain`]: message-port-main.md diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 0e49cb76a9977..b26b0dc0432fb 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -2073,3 +2073,4 @@ with open(), or by navigating a link with a target attribute. [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm [`postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage +[`MessagePortMain`]: message-port-main.md diff --git a/docs/api/web-frame-main.md b/docs/api/web-frame-main.md index 3d3b87b354028..34033a85645fc 100644 --- a/docs/api/web-frame-main.md +++ b/docs/api/web-frame-main.md @@ -233,3 +233,4 @@ See also how the [Page Visibility API](browser-window.md#page-visibility) is aff [SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm [`postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage +[`MessagePortMain`]: message-port-main.md diff --git a/docs/glossary.md b/docs/glossary.md index 01ba457ff8839..020dfbe4552f4 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -132,7 +132,7 @@ OSR (offscreen rendering) can be used for loading heavy page in background and then displaying it after (it will be much faster). It allows you to render page without showing it on screen. -For more information, read the [Offscreen Rendering][osr] tutorial. +For more information, read the [Offscreen Rendering] tutorial. ### preload script @@ -235,10 +235,10 @@ embedded content. [mac app store submission guide]: tutorial/mac-app-store-submission-guide.md [main]: #main-process [msi]: https://docs.microsoft.com/en-us/windows/win32/msi/windows-installer-portal +[Native Node Modules]: tutorial/using-native-node-modules.md [offscreen rendering]: tutorial/offscreen-rendering.md [process sandboxing]: tutorial/sandbox.md [renderer]: #renderer-process [userland]: #userland -[using native node modules]: tutorial/using-native-node-modules.md [UtilityProcess]: api/utility-process.md [v8]: #v8 diff --git a/docs/tutorial/dark-mode.md b/docs/tutorial/dark-mode.md index bf16303e4ecb1..27fbff07d1585 100644 --- a/docs/tutorial/dark-mode.md +++ b/docs/tutorial/dark-mode.md @@ -13,7 +13,7 @@ from the OS. If your app has its own dark mode, you should toggle it on and off in sync with the system's dark mode setting. You can do this by using the -[prefer-color-scheme] CSS media query. +[prefers-color-scheme] CSS media query. ### Manually update your own interfaces diff --git a/docs/tutorial/devtools-extension.md b/docs/tutorial/devtools-extension.md index 8fb5eb059868f..0b8d8045f2f2f 100644 --- a/docs/tutorial/devtools-extension.md +++ b/docs/tutorial/devtools-extension.md @@ -15,7 +15,7 @@ NPM package that does just that. If you don't want to use the tooling approach, you can also do all of the necessary operations by hand. To load an extension in Electron, you need to download it via Chrome, locate its filesystem path, and then load it into your [Session][session] by calling the -[`ses.loadExtension`] API. +[`ses.loadExtension`][load-extension] API. Using the [React Developer Tools][react-devtools] as an example: diff --git a/docs/tutorial/examples.md b/docs/tutorial/examples.md index b88bbc028b221..c30e0fc7e8744 100644 --- a/docs/tutorial/examples.md +++ b/docs/tutorial/examples.md @@ -52,5 +52,6 @@ You can find the full list of "How to?" in the sidebar. If there is something that you would like to do that is not documented, please join our [Discord server][discord] and let us know! +[app]: ../api/app.md [discord]: https://discord.gg/electronjs [fiddle]: https://www.electronjs.org/fiddle diff --git a/docs/tutorial/tutorial-6-publishing-updating.md b/docs/tutorial/tutorial-6-publishing-updating.md index 4adfb434bdb9f..a5a67e76834ee 100644 --- a/docs/tutorial/tutorial-6-publishing-updating.md +++ b/docs/tutorial/tutorial-6-publishing-updating.md @@ -227,7 +227,7 @@ rest of our docs and happy developing! If you have questions, please stop by our [github actions]: https://github.com/features/actions [github publisher]: https://www.electronforge.io/config/publishers/github [github releases]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository -[git tag]: https://git-scm.com/book/en/v2/Git-Basics-Tagging +[git-tag]: https://git-scm.com/book/en/v2/Git-Basics-Tagging [new-pat]: https://github.com/settings/tokens/new [publish command]: https://www.electronforge.io/cli#publish [publisher]: https://www.electronforge.io/config/publishers diff --git a/docs/tutorial/updates.md b/docs/tutorial/updates.md index 530d9658d496d..ed7c1d8faf999 100644 --- a/docs/tutorial/updates.md +++ b/docs/tutorial/updates.md @@ -67,7 +67,7 @@ Depending on your needs, you can choose from one of these: to minify server cost. Once you've deployed your update server, you can instrument your app code to receive and -apply the updates with Electron's [autoUpdater] module. +apply the updates with Electron's [autoUpdater](../api/auto-updater.md) module. ### Step 2: Receiving updates in your app From f05b54bdd30771f15d21b35bac673bd65bf4042c Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 15 Dec 2022 12:13:32 -0500 Subject: [PATCH 017/172] ci: pin action shas (#36564) Signed-off-by: StepSecurity Bot Co-authored-by: StepSecurity Bot Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: StepSecurity Bot --- .github/workflows/update_appveyor_image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update_appveyor_image.yml b/.github/workflows/update_appveyor_image.yml index 9d84c7d9598d8..49c265c598744 100644 --- a/.github/workflows/update_appveyor_image.yml +++ b/.github/workflows/update_appveyor_image.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0 with: fetch-depth: 0 - name: Yarn install @@ -37,7 +37,7 @@ jobs: fi - name: (Optionally) Update Appveyor Image if: ${{ env.APPVEYOR_IMAGE_VERSION }} - uses: mikefarah/yq@v4.27.2 + uses: mikefarah/yq@1c7dc0e88aad311c89889bc5ce5d8f96931a1bd0 # v4.27.2 with: cmd: yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml" - name: (Optionally) Generate Commit Diff @@ -48,7 +48,7 @@ jobs: rm appveyor2.yml appveyor.diff - name: (Optionally) Commit and Pull Request if: ${{ env.APPVEYOR_IMAGE_VERSION }} - uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3 with: token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} commit-message: 'build: update appveyor image to latest version' From 02949a7e6fb480057362fbf85454480e7798da0e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 30 Dec 2022 22:16:22 -0800 Subject: [PATCH 018/172] docs: update visual studio min version (#36731) Co-authored-by: George Xu Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: George Xu --- docs/development/build-instructions-windows.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/development/build-instructions-windows.md b/docs/development/build-instructions-windows.md index 171679ddab5ba..4dd86e83aa1a9 100644 --- a/docs/development/build-instructions-windows.md +++ b/docs/development/build-instructions-windows.md @@ -7,13 +7,12 @@ Follow the guidelines below for building **Electron itself** on Windows, for the ## Prerequisites * Windows 10 / Server 2012 R2 or higher -* Visual Studio 2017 15.7.2 or higher - [download VS 2019 Community Edition for - free](https://www.visualstudio.com/vs/) +* Visual Studio 2019 (>=16.0.0) to build, but Visual Studio 2022 (>=17.0.0) is preferred - [download VS 2022 Community Edition for free](https://www.visualstudio.com/vs/) * See [the Chromium build documentation](https://chromium.googlesource.com/chromium/src/+/main/docs/windows_build_instructions.md#visual-studio) for more details on which Visual Studio components are required. * If your Visual Studio is installed in a directory other than the default, you'll need to set a few environment variables to point the toolchains to your installation path. - * `vs2019_install = DRIVE:\path\to\Microsoft Visual Studio\2019\Community`, replacing `2019` and `Community` with your installed versions and replacing `DRIVE:` with the drive that Visual Studio is on. Often, this will be `C:`. + * `vs2022_install = DRIVE:\path\to\Microsoft Visual Studio\2022\Community`, replacing `2022` and `Community` with your installed versions and replacing `DRIVE:` with the drive that Visual Studio is on. Often, this will be `C:`. * `WINDOWSSDKDIR = DRIVE:\path\to\Windows Kits\10`, replacing `DRIVE:` with the drive that Windows Kits is on. Often, this will be `C:`. * [Node.js](https://nodejs.org/download/) * [Git](https://git-scm.com) From 0bd4cea3a02396065a7916fefe6b845efe2f2206 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 2 Jan 2023 11:52:36 +0100 Subject: [PATCH 019/172] fix: blend node and blink code generation policy when both are loaded (#36668) * fix: blend node and blink code generation policy when both are loaded (#36567) Co-authored-by: Jeremy Rose * Update .patches * fix patches Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose Co-authored-by: John Kleinschmidt --- patches/chromium/.patches | 1 + ...egenerationcheckcallbackinmainthread.patch | 38 ++++++++++++++++ patches/node/.patches | 1 + ...ol_codegenerationfromstringscallback.patch | 44 +++++++++++++++++++ shell/common/node_bindings.cc | 30 ++++++++++--- spec/chromium-spec.ts | 24 ++++++++++ 6 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 patches/chromium/expose_v8initializer_codegenerationcheckcallbackinmainthread.patch create mode 100644 patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index f38a2a8301e0f..fcb5a7a641d8c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -124,3 +124,4 @@ cherry-pick-7196a42b42ce.patch fix_tray_icon_gone_on_lock_screen.patch cherry-pick-2611772cf0a0.patch cherry-pick-3235c1d1955b.patch +expose_v8initializer_codegenerationcheckcallbackinmainthread.patch diff --git a/patches/chromium/expose_v8initializer_codegenerationcheckcallbackinmainthread.patch b/patches/chromium/expose_v8initializer_codegenerationcheckcallbackinmainthread.patch new file mode 100644 index 0000000000000..43bfdadef0acf --- /dev/null +++ b/patches/chromium/expose_v8initializer_codegenerationcheckcallbackinmainthread.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jeremy Rose +Date: Mon, 5 Dec 2022 14:27:20 -0800 +Subject: expose V8Initializer::CodeGenerationCheckCallbackInMainThread + +This is needed to blend Blink and Node's policy for code generation policy. + +diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +index 04aa629a635a93decc7261e143587d92f78c1b09..b1a665cc887d735bd3db299439f11369d8265837 100644 +--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc ++++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +@@ -441,8 +441,9 @@ TrustedTypesCodeGenerationCheck(v8::Local context, + return {true, V8String(context->GetIsolate(), stringified_source)}; + } + +-static v8::ModifyCodeGenerationFromStringsResult +-CodeGenerationCheckCallbackInMainThread(v8::Local context, ++// static ++v8::ModifyCodeGenerationFromStringsResult ++V8Initializer::CodeGenerationCheckCallbackInMainThread(v8::Local context, + v8::Local source, + bool is_code_like) { + // The TC39 "Dynamic Code Brand Check" feature is currently behind a flag. +diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h +index 39d1351a4a8bbc95097640be54affec426abe73e..30a36cf16d4a8f4692ec6a13be1217212390172a 100644 +--- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.h ++++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.h +@@ -69,6 +69,10 @@ class CORE_EXPORT V8Initializer { + v8::Local); + static void MessageHandlerInWorker(v8::Local, + v8::Local); ++ static v8::ModifyCodeGenerationFromStringsResult ++ CodeGenerationCheckCallbackInMainThread(v8::Local context, ++ v8::Local source, ++ bool is_code_like); + static bool WasmCodeGenerationCheckCallbackInMainThread( + v8::Local context, + v8::Local source); diff --git a/patches/node/.patches b/patches/node/.patches index db61769dc2e28..0495363a662e2 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -54,3 +54,4 @@ fix_expose_the_built-in_electron_module_via_the_esm_loader.patch chore_enable_c_17_for_native_modules.patch enable_crashpad_linux_node_processes.patch cherry-pick-09ae62b.patch +allow_embedder_to_control_codegenerationfromstringscallback.patch diff --git a/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch b/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch new file mode 100644 index 0000000000000..edc2eebde5ad6 --- /dev/null +++ b/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jeremy Rose +Date: Mon, 5 Dec 2022 14:28:40 -0800 +Subject: allow embedder to control CodeGenerationFromStringsCallback + +This is needed to blend Blink and Node's code generation policy. + +This should be upstreamed. + +diff --git a/src/api/environment.cc b/src/api/environment.cc +index 93d85d46dc6b3b30795b88ffa8070253f62e51bd..05f8232c4b38f51e8059e8d01b0eb2475768c43f 100644 +--- a/src/api/environment.cc ++++ b/src/api/environment.cc +@@ -256,11 +256,15 @@ void SetIsolateErrorHandlers(v8::Isolate* isolate, const IsolateSettings& s) { + void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) { + isolate->SetMicrotasksPolicy(s.policy); + ++ // Allow the embedder first chance at policy decisions. ++ // This is particularly important for embedders that combine Node and Blink, ++ // as Blink must be able to make Content Security Policy-based decisions. + auto* allow_wasm_codegen_cb = s.allow_wasm_code_generation_callback ? + s.allow_wasm_code_generation_callback : AllowWasmCodeGenerationCallback; + isolate->SetAllowWasmCodeGenerationCallback(allow_wasm_codegen_cb); +- isolate->SetModifyCodeGenerationFromStringsCallback( +- ModifyCodeGenerationFromStrings); ++ auto* modify_code_generation_from_strings_callback = s.modify_code_generation_from_strings_callback ? ++ s.modify_code_generation_from_strings_callback : ModifyCodeGenerationFromStrings; ++ isolate->SetModifyCodeGenerationFromStringsCallback(modify_code_generation_from_strings_callback); + + if ((s.flags & SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK) == 0) { + auto* promise_reject_cb = s.promise_reject_callback ? +diff --git a/src/node.h b/src/node.h +index 38bbb20968772a4ba6bceddb04a83589f8582fc8..a5ee97ae83149a1924e9d6198ad4b2a7fd8b876d 100644 +--- a/src/node.h ++++ b/src/node.h +@@ -374,6 +374,8 @@ struct IsolateSettings { + v8::PromiseRejectCallback promise_reject_callback = nullptr; + v8::AllowWasmCodeGenerationCallback + allow_wasm_code_generation_callback = nullptr; ++ v8::ModifyCodeGenerationFromStringsCallback2 ++ modify_code_generation_from_strings_callback = nullptr; + }; + + // Overriding IsolateSettings may produce unexpected behavior diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 4a45620372b8c..f8ef51aac8008 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -158,19 +158,35 @@ void V8FatalErrorCallback(const char* location, const char* message) { } bool AllowWasmCodeGenerationCallback(v8::Local context, - v8::Local) { + v8::Local source) { // If we're running with contextIsolation enabled in the renderer process, // fall back to Blink's logic. - v8::Isolate* isolate = context->GetIsolate(); - if (node::Environment::GetCurrent(isolate) == nullptr) { + if (node::Environment::GetCurrent(context) == nullptr) { if (gin_helper::Locker::IsBrowserProcess()) return false; return blink::V8Initializer::WasmCodeGenerationCheckCallbackInMainThread( - context, v8::String::Empty(isolate)); + context, source); + } + + return node::AllowWasmCodeGenerationCallback(context, source); +} + +v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( + v8::Local context, + v8::Local source, + bool is_code_like) { + // If we're running with contextIsolation enabled in the renderer process, + // fall back to Blink's logic. + if (node::Environment::GetCurrent(context) == nullptr) { + if (gin_helper::Locker::IsBrowserProcess()) { + NOTREACHED(); + return {false, {}}; + } + return blink::V8Initializer::CodeGenerationCheckCallbackInMainThread( + context, source, is_code_like); } - return node::AllowWasmCodeGenerationCallback(context, - v8::String::Empty(isolate)); + return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); } void ErrorMessageListener(v8::Local message, @@ -547,6 +563,8 @@ node::Environment* NodeBindings::CreateEnvironment( // Use a custom callback here to allow us to leverage Blink's logic in the // renderer process. is.allow_wasm_code_generation_callback = AllowWasmCodeGenerationCallback; + is.modify_code_generation_from_strings_callback = + ModifyCodeGenerationFromStrings; if (browser_env_ == BrowserEnvironment::kBrowser || browser_env_ == BrowserEnvironment::kUtility) { diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 5200e92e7966d..0fda4cf4b93be 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -355,6 +355,30 @@ describe('web security', () => { }); }); + describe('csp in sandbox: false', () => { + it('is correctly applied', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox: false } + }); + w.loadURL(`data:text/html, + + + `); + const [,, message] = await emittedOnce(w.webContents, 'console-message'); + expect(message).to.equal('success'); + }); + }); + it('does not crash when multiple WebContent are created with web security disabled', () => { const options = { show: false, webPreferences: { webSecurity: false } }; const w1 = new BrowserWindow(options); From 763daa870706bdc67ba250f6b4351009b110c9c4 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 4 Jan 2023 20:45:54 -0500 Subject: [PATCH 020/172] build: fixup mksnapshot args on linux (#36782) * build: fixup mksnapshot args on linux (cherry picked from commit 8f134d7429269740ce4f7ed17f5203c83efab322) * build: completely remove turbo profiling input --- .circleci/config/base.yml | 6 +++--- build/args/all.gn | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index b258a0deef78e..036b225447227 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -575,7 +575,7 @@ step-electron-build: &step-electron-build ninja -C out/Default tools/v8_context_snapshot -j $NUMBER_OF_NINJA_PROCESSES gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args # Remove unused args from mksnapshot_args - SEDOPTION= + SEDOPTION="-i" if [ "`uname`" == "Darwin" ]; then SEDOPTION="-i ''" fi @@ -772,7 +772,7 @@ step-mksnapshot-build: &step-mksnapshot-build ninja -C out/Default electron:electron_mksnapshot -j $NUMBER_OF_NINJA_PROCESSES gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args # Remove unused args from mksnapshot_args - SEDOPTION= + SEDOPTION="-i" if [ "`uname`" == "Darwin" ]; then SEDOPTION="-i ''" fi @@ -2209,4 +2209,4 @@ workflows: jobs: - lint -# VS Code Extension Version: 1.1.1 \ No newline at end of file +# VS Code Extension Version: 1.4.0 \ No newline at end of file diff --git a/build/args/all.gn b/build/args/all.gn index e52c9678523d4..9bfb8e3c23a4e 100644 --- a/build/args/all.gn +++ b/build/args/all.gn @@ -48,3 +48,5 @@ is_cfi = false # TODO: fix this once sysroots have been updated. use_qt = false + +v8_builtins_profiling_log_file = "" From d225809cc48680dd69ebdcf141e0e1653729c11e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 5 Jan 2023 12:03:46 -0500 Subject: [PATCH 021/172] fix: rename WebSwapCGLLayer to WebSwapCGLLayerChromium (#36800) * fix: rename WebSwapCGLLayer to WebSwapCGLLayerChromium Co-authored-by: Milan Burda * undo changes to patches/config.json Co-authored-by: Jeremy Rose Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda Co-authored-by: Jeremy Rose --- patches/angle/.patches | 1 + ...pcgllayer_to_webswapcgllayerchromium.patch | 66 +++++++++++++++++++ patches/config.json | 2 + 3 files changed, 69 insertions(+) create mode 100644 patches/angle/.patches create mode 100644 patches/angle/fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch diff --git a/patches/angle/.patches b/patches/angle/.patches new file mode 100644 index 0000000000000..ca864b58a91d0 --- /dev/null +++ b/patches/angle/.patches @@ -0,0 +1 @@ +fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch diff --git a/patches/angle/fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch b/patches/angle/fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch new file mode 100644 index 0000000000000..a13e32902ade5 --- /dev/null +++ b/patches/angle/fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Milan Burda +Date: Mon, 10 Oct 2022 15:11:08 +0400 +Subject: fix: rename WebSwapCGLLayer to WebSwapCGLLayerChromium + +Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x23c589b50) +and src/out/testing/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x1123f8488). +One of the two will be used. Which one is undefined. + +diff --git a/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h b/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h +index 7101cd271c07e604c6f5241d1a22f59f446c0033..98a89976f87e32a66bd504951698204fad938d57 100644 +--- a/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h ++++ b/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.h +@@ -18,7 +18,7 @@ struct __IOSurface; + typedef __IOSurface *IOSurfaceRef; + + // WebKit's build process requires that every Objective-C class name has the prefix "Web". +-@class WebSwapCGLLayer; ++@class WebSwapCGLLayerChromium; + + namespace rx + { +@@ -89,7 +89,7 @@ class WindowSurfaceCGL : public SurfaceGL + gl::Framebuffer *framebuffer) override; + + private: +- WebSwapCGLLayer *mSwapLayer; ++ WebSwapCGLLayerChromium *mSwapLayer; + SharedSwapState mSwapState; + uint64_t mCurrentSwapId; + +diff --git a/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm b/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm +index 27990e9c2facbbe0e30f4b275e0778a6474fb9ce..84f9fa9b6d31fb0e85a4c4270dff4d935f855c26 100644 +--- a/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm ++++ b/src/libANGLE/renderer/gl/cgl/WindowSurfaceCGL.mm +@@ -24,7 +24,7 @@ + # include "libANGLE/renderer/gl/StateManagerGL.h" + # include "libANGLE/renderer/gl/cgl/DisplayCGL.h" + +-@interface WebSwapCGLLayer : CAOpenGLLayer { ++@interface WebSwapCGLLayerChromium : CAOpenGLLayer { + CGLContextObj mDisplayContext; + + bool initialized; +@@ -38,7 +38,7 @@ - (id)initWithSharedState:(rx::SharedSwapState *)swapState + withFunctions:(const rx::FunctionsGL *)functions; + @end + +-@implementation WebSwapCGLLayer ++@implementation WebSwapCGLLayerChromium + - (id)initWithSharedState:(rx::SharedSwapState *)swapState + withContext:(CGLContextObj)displayContext + withFunctions:(const rx::FunctionsGL *)functions +@@ -220,9 +220,9 @@ - (void)drawInCGLContext:(CGLContextObj)glContext + mSwapState.lastRendered = &mSwapState.textures[1]; + mSwapState.beingPresented = &mSwapState.textures[2]; + +- mSwapLayer = [[WebSwapCGLLayer alloc] initWithSharedState:&mSwapState +- withContext:mContext +- withFunctions:mFunctions]; ++ mSwapLayer = [[WebSwapCGLLayerChromium alloc] initWithSharedState:&mSwapState ++ withContext:mContext ++ withFunctions:mFunctions]; + [mLayer addSublayer:mSwapLayer]; + [mSwapLayer setContentsScale:[mLayer contentsScale]]; + diff --git a/patches/config.json b/patches/config.json index bbf0d46409474..bac8c8b9a4586 100644 --- a/patches/config.json +++ b/patches/config.json @@ -1,6 +1,8 @@ { "src/electron/patches/chromium": "src", + "src/electron/patches/angle": "src/third_party/angle", + "src/electron/patches/boringssl": "src/third_party/boringssl/src", "src/electron/patches/devtools_frontend": "src/third_party/devtools-frontend/src", From a35de7e89f8e8f9cd85a864dc03acf6be3286b0e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 16:41:16 +0900 Subject: [PATCH 022/172] fix: focus rings with multiple buttons in `showMessageBox` (#36802) fix: focus rings with multiple buttons in messageBox Co-authored-by: Shelley Vohr Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- shell/browser/ui/message_box_mac.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shell/browser/ui/message_box_mac.mm b/shell/browser/ui/message_box_mac.mm index 9ab03a0472eae..fe376daac8b55 100644 --- a/shell/browser/ui/message_box_mac.mm +++ b/shell/browser/ui/message_box_mac.mm @@ -71,9 +71,6 @@ int button_count = static_cast([ns_buttons count]); if (settings.default_id >= 0 && settings.default_id < button_count) { - // Highlight the button at default_id - [[ns_buttons objectAtIndex:settings.default_id] highlight:YES]; - // The first button added gets set as the default selected, so remove // that and set the button @ default_id to be default. [[ns_buttons objectAtIndex:0] setKeyEquivalent:@""]; @@ -86,6 +83,11 @@ [[ns_buttons objectAtIndex:settings.cancel_id] setKeyEquivalent:@"\e"]; } + // TODO(@codebytere): This behavior violates HIG & should be deprecated. + if (settings.cancel_id >= 0 && settings.cancel_id == settings.default_id) { + [[ns_buttons objectAtIndex:settings.default_id] highlight:YES]; + } + if (!settings.checkbox_label.empty()) { alert.showsSuppressionButton = YES; alert.suppressionButton.title = From e65fc9116a2f68a1fd40887fced60bdcff63ffa1 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 09:34:29 +0900 Subject: [PATCH 023/172] docs: update links (#36770) Co-authored-by: David Sanders Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders --- docs/README.md | 2 +- docs/api/auto-updater.md | 6 +++--- docs/api/utility-process.md | 2 +- docs/tutorial/boilerplates-and-clis.md | 2 +- docs/tutorial/forge-overview.md | 2 +- docs/tutorial/notifications.md | 2 +- docs/tutorial/performance.md | 2 +- docs/tutorial/snapcraft.md | 6 +++--- docs/tutorial/tutorial-4-adding-features.md | 2 +- docs/tutorial/tutorial-6-publishing-updating.md | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/README.md b/docs/README.md index 57172020a87d6..83c3df1fde454 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,7 +42,7 @@ an issue: * [Web embeds in Electron](tutorial/web-embeds.md) * [Boilerplates and CLIs](tutorial/boilerplates-and-clis.md) * [Boilerplate vs CLI](tutorial/boilerplates-and-clis.md#boilerplate-vs-cli) - * [electron-forge](tutorial/boilerplates-and-clis.md#electron-forge) + * [Electron Forge](tutorial/boilerplates-and-clis.md#electron-forge) * [electron-builder](tutorial/boilerplates-and-clis.md#electron-builder) * [electron-react-boilerplate](tutorial/boilerplates-and-clis.md#electron-react-boilerplate) * [Other Tools and Boilerplates](tutorial/boilerplates-and-clis.md#other-tools-and-boilerplates) diff --git a/docs/api/auto-updater.md b/docs/api/auto-updater.md index d181dfaccb0ec..dc82b783baacc 100644 --- a/docs/api/auto-updater.md +++ b/docs/api/auto-updater.md @@ -32,9 +32,9 @@ This is a requirement of `Squirrel.Mac`. On Windows, you have to install your app into a user's machine before you can use the `autoUpdater`, so it is recommended that you use the -[electron-winstaller][installer-lib], [electron-forge][electron-forge-lib] or the [grunt-electron-installer][installer] package to generate a Windows installer. +[electron-winstaller][installer-lib], [Electron Forge][electron-forge-lib] or the [grunt-electron-installer][installer] package to generate a Windows installer. -When using [electron-winstaller][installer-lib] or [electron-forge][electron-forge-lib] make sure you do not try to update your app [the first time it runs](https://github.com/electron/windows-installer#handling-squirrel-events) (Also see [this issue for more info](https://github.com/electron/electron/issues/7155)). It's also recommended to use [electron-squirrel-startup](https://github.com/mongodb-js/electron-squirrel-startup) to get desktop shortcuts for your app. +When using [electron-winstaller][installer-lib] or [Electron Forge][electron-forge-lib] make sure you do not try to update your app [the first time it runs](https://github.com/electron/windows-installer#handling-squirrel-events) (Also see [this issue for more info](https://github.com/electron/electron/issues/7155)). It's also recommended to use [electron-squirrel-startup](https://github.com/mongodb-js/electron-squirrel-startup) to get desktop shortcuts for your app. The installer generated with Squirrel will create a shortcut icon with an [Application User Model ID][app-user-model-id] in the format of @@ -139,6 +139,6 @@ application starts. [squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows [installer]: https://github.com/electron/grunt-electron-installer [installer-lib]: https://github.com/electron/windows-installer -[electron-forge-lib]: https://github.com/electron-userland/electron-forge +[electron-forge-lib]: https://github.com/electron/forge [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index ed9b44af1ab15..2c228598deb80 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -132,7 +132,7 @@ Returns: Emitted when the child process sends a message using [`process.parentPort.postMessage()`](process.md#processparentport). [`child_process.fork`]: https://nodejs.org/dist/latest-v16.x/docs/api/child_process.html#child_processforkmodulepath-args-options -[Services API]: https://chromium.googlesource.com/chromium/src/+/master/docs/mojo_and_services.md +[Services API]: https://chromium.googlesource.com/chromium/src/+/main/docs/mojo_and_services.md [stdio]: https://nodejs.org/dist/latest/docs/api/child_process.html#optionsstdio [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [`MessagePortMain`]: message-port-main.md diff --git a/docs/tutorial/boilerplates-and-clis.md b/docs/tutorial/boilerplates-and-clis.md index f344ae1b25979..68a7a5728f6fb 100644 --- a/docs/tutorial/boilerplates-and-clis.md +++ b/docs/tutorial/boilerplates-and-clis.md @@ -24,7 +24,7 @@ development and release. They are more helpful and supportive but enforce guidelines on how your code should be structured and built. *Especially for beginners, using a command line tool is likely to be helpful*. -## electron-forge +## Electron Forge Electron Forge is a tool for packaging and publishing Electron applications. It unifies Electron's tooling ecosystem into a single extensible interface so that anyone can jump right into making Electron apps. diff --git a/docs/tutorial/forge-overview.md b/docs/tutorial/forge-overview.md index e297e700c4fdc..0ec6872ce7fc2 100644 --- a/docs/tutorial/forge-overview.md +++ b/docs/tutorial/forge-overview.md @@ -31,6 +31,6 @@ template and submit a new issue. [(package)]: https://www.electronforge.io/cli#package [(make)]: https://www.electronforge.io/cli#make [(publish)]: https://www.electronforge.io/cli#publish -[GitHub issue tracker]: https://github.com/electron-userland/electron-forge/issues +[GitHub issue tracker]: https://github.com/electron/forge/issues [discord]: https://discord.gg/APGC3k5yaH [tutorial]: https://www.electronjs.org/docs/latest/tutorial/tutorial-prerequisites diff --git a/docs/tutorial/notifications.md b/docs/tutorial/notifications.md index 59b4a8499276b..d04243f0ae16b 100644 --- a/docs/tutorial/notifications.md +++ b/docs/tutorial/notifications.md @@ -149,4 +149,4 @@ GNOME, KDE. [notification-spec]: https://developer-old.gnome.org/notification-spec/ [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx [set-app-user-model-id]: ../api/app.md#appsetappusermodelidid-windows -[squirrel-events]: https://github.com/electron/windows-installer/blob/master/README.md#handling-squirrel-events +[squirrel-events]: https://github.com/electron/windows-installer/blob/main/README.md#handling-squirrel-events diff --git a/docs/tutorial/performance.md b/docs/tutorial/performance.md index d06a8220cff02..e45e68a0e53e5 100644 --- a/docs/tutorial/performance.md +++ b/docs/tutorial/performance.md @@ -438,7 +438,7 @@ Call `Menu.setApplicationMenu(null)` before `app.on("ready")`. This will prevent [request-idle-callback]: https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback [multithreading]: ./multithreading.md [caniuse]: https://caniuse.com/ -[jquery-need]: http://youmightnotneedjquery.com/ +[jquery-need]: https://youmightnotneedjquery.com/ [service-workers]: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API [webpack]: https://webpack.js.org/ [parcel]: https://parceljs.org/ diff --git a/docs/tutorial/snapcraft.md b/docs/tutorial/snapcraft.md index f87e4cf9af5bd..c315e831cfcec 100644 --- a/docs/tutorial/snapcraft.md +++ b/docs/tutorial/snapcraft.md @@ -13,7 +13,7 @@ system modification. There are three ways to create a `.snap` file: -1) Using [`electron-forge`][electron-forge] or +1) Using [Electron Forge][electron-forge] or [`electron-builder`][electron-builder], both tools that come with `snap` support out of the box. This is the easiest option. 2) Using `electron-installer-snap`, which takes `electron-packager`'s output. @@ -162,7 +162,7 @@ building blocks. If you do not already have a `.deb` package, using `electron-installer-snap` might be an easier path to create snap packages. However, multiple solutions -for creating Debian packages exist, including [`electron-forge`][electron-forge], +for creating Debian packages exist, including [Electron Forge][electron-forge], [`electron-builder`][electron-builder] or [`electron-installer-debian`][electron-installer-debian]. @@ -239,7 +239,7 @@ apps: [snapcraft-syntax]: https://docs.snapcraft.io/build-snaps/syntax [electron-packager]: https://github.com/electron/electron-packager -[electron-forge]: https://github.com/electron-userland/electron-forge +[electron-forge]: https://github.com/electron/forge [electron-builder]: https://github.com/electron-userland/electron-builder [electron-installer-debian]: https://github.com/unindented/electron-installer-debian [electron-winstaller]: https://github.com/electron/windows-installer diff --git a/docs/tutorial/tutorial-4-adding-features.md b/docs/tutorial/tutorial-4-adding-features.md index b5fd630ed6e3c..fc74559cee1b6 100644 --- a/docs/tutorial/tutorial-4-adding-features.md +++ b/docs/tutorial/tutorial-4-adding-features.md @@ -63,7 +63,7 @@ into end users' hands. [discord]: https://discord.gg/electronjs -[github]: https://github.com/electron/electronjs.org-new/issues/new +[github]: https://github.com/electron/website/issues/new [how-to]: ./examples.md [node-platform]: https://nodejs.org/api/process.html#process_process_platform diff --git a/docs/tutorial/tutorial-6-publishing-updating.md b/docs/tutorial/tutorial-6-publishing-updating.md index a5a67e76834ee..f10c536968734 100644 --- a/docs/tutorial/tutorial-6-publishing-updating.md +++ b/docs/tutorial/tutorial-6-publishing-updating.md @@ -222,8 +222,8 @@ rest of our docs and happy developing! If you have questions, please stop by our [code-signed]: ./code-signing.md [discord server]: https://discord.gg/electronjs [electron fiddle]: https://electronjs.org/fiddle -[fiddle-build]: https://github.com/electron/fiddle/blob/master/.github/workflows/build.yaml -[fiddle-forge-config]: https://github.com/electron/fiddle/blob/master/forge.config.js +[fiddle-build]: https://github.com/electron/fiddle/blob/main/.github/workflows/build.yaml +[fiddle-forge-config]: https://github.com/electron/fiddle/blob/main/forge.config.js [github actions]: https://github.com/features/actions [github publisher]: https://www.electronforge.io/config/publishers/github [github releases]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository From effff344164c45252d3e346dcea5922e0b670c18 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 09:37:57 +0900 Subject: [PATCH 024/172] docs: fix link in breaking-changes.md (#36836) Co-authored-by: David Sanders Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders --- docs/breaking-changes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index b923254f6a12d..31d950f354019 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -170,7 +170,7 @@ requires unsafe mode), so Electron is unable to support this feature on Linux. The handler invoked when `session.setDevicePermissionHandler(handler)` is used has a change to its arguments. This handler no longer is passed a frame -`[WebFrameMain](api/web-frame-main.md)`, but instead is passed the `origin`, which +[`WebFrameMain`](api/web-frame-main.md), but instead is passed the `origin`, which is the origin that is checking for device permission. ## Planned Breaking API Changes (19.0) From a07c34e420b69e3cdd3a5305c49eb1128b25fabb Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 10 Jan 2023 12:17:28 +0100 Subject: [PATCH 025/172] fix: handle Notification requireInteraction option (#36501) Co-authored-by: Jeremy Spiegel Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Spiegel --- shell/browser/notifications/platform_notification_service.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shell/browser/notifications/platform_notification_service.cc b/shell/browser/notifications/platform_notification_service.cc index f91c13f2b8d4a..aa2eb839c59b3 100644 --- a/shell/browser/notifications/platform_notification_service.cc +++ b/shell/browser/notifications/platform_notification_service.cc @@ -35,6 +35,9 @@ void OnWebNotificationAllowed(base::WeakPtr notification, options.icon = icon; options.silent = audio_muted ? true : data.silent; options.has_reply = false; + if (data.require_interaction) + options.timeout_type = u"never"; + notification->Show(options); } else { notification->Destroy(); From 470a365743cf38280795e85c7cda8b97b0f2a80b Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 11:56:05 +0100 Subject: [PATCH 026/172] fix: RTL `WindowButtonsProxy` buttons (#36851) * fix: RTL WindowButtonsProxy buttons Co-authored-by: Shelley Vohr * chore: address review feedback Co-authored-by: Shelley Vohr Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- shell/browser/browser.h | 2 ++ shell/browser/browser_mac.mm | 35 ++++++++++++++++++++ shell/browser/electron_browser_main_parts.cc | 1 + 3 files changed, 38 insertions(+) diff --git a/shell/browser/browser.h b/shell/browser/browser.h index 7fc47ef826dad..d9b03bfd95f85 100644 --- a/shell/browser/browser.h +++ b/shell/browser/browser.h @@ -202,6 +202,8 @@ class Browser : public WindowListObserver { bool UpdateUserActivityState(const std::string& type, base::Value::Dict user_info); + void ApplyForcedRTL(); + // Bounce the dock icon. enum class BounceType{ kCritical = 0, // NSCriticalRequest diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index ab7942e369b8d..e5bb696cae1e5 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -8,12 +8,14 @@ #include #include +#include "base/i18n/rtl.h" #include "base/mac/bundle_locations.h" #include "base/mac/foundation_util.h" #include "base/mac/mac_util.h" #include "base/mac/scoped_cftyperef.h" #include "base/strings/string_number_conversions.h" #include "base/strings/sys_string_conversions.h" +#include "chrome/browser/browser_process.h" #include "net/base/mac/url_conversions.h" #include "shell/browser/badging/badge_manager.h" #include "shell/browser/mac/dict_util.h" @@ -36,6 +38,13 @@ namespace { +bool IsAppRTL() { + const std::string& locale = g_browser_process->GetApplicationLocale(); + base::i18n::TextDirection text_direction = + base::i18n::GetTextDirectionForLocaleInStartUp(locale.c_str()); + return text_direction == base::i18n::RIGHT_TO_LEFT; +} + NSString* GetAppPathForProtocol(const GURL& url) { NSURL* ns_url = [NSURL URLWithString:base::SysUTF8ToNSString(url.possibly_invalid_spec())]; @@ -306,6 +315,32 @@ return prevent_default; } +// Modified from chrome/browser/ui/cocoa/l10n_util.mm. +void Browser::ApplyForcedRTL() { + NSUserDefaults* defaults = NSUserDefaults.standardUserDefaults; + + auto dir = base::i18n::GetForcedTextDirection(); + + // An Electron app should respect RTL behavior of application locale over + // system locale. + auto should_be_rtl = dir == base::i18n::RIGHT_TO_LEFT || IsAppRTL(); + auto should_be_ltr = dir == base::i18n::LEFT_TO_RIGHT || !IsAppRTL(); + + // -registerDefaults: won't do the trick here because these defaults exist + // (in the global domain) to reflect the system locale. They need to be set + // in Chrome's domain to supersede the system value. + if (should_be_rtl) { + [defaults setBool:YES forKey:@"AppleTextDirection"]; + [defaults setBool:YES forKey:@"NSForceRightToLeftWritingDirection"]; + } else if (should_be_ltr) { + [defaults setBool:YES forKey:@"AppleTextDirection"]; + [defaults setBool:NO forKey:@"NSForceRightToLeftWritingDirection"]; + } else { + [defaults removeObjectForKey:@"AppleTextDirection"]; + [defaults removeObjectForKey:@"NSForceRightToLeftWritingDirection"]; + } +} + Browser::LoginItemSettings Browser::GetLoginItemSettings( const LoginItemSettings& options) { LoginItemSettings settings; diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 64fd9746449d2..2f3446f5d8700 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -382,6 +382,7 @@ int ElectronBrowserMainParts::PreCreateThreads() { #if BUILDFLAG(IS_MAC) ui::InitIdleMonitor(); + Browser::Get()->ApplyForcedRTL(); #endif fake_browser_process_->PreCreateThreads(); From 147c24208f642bbaeffe909f1fb572f1ba9afe93 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 11:56:49 +0100 Subject: [PATCH 027/172] fix: handle null/undefined options for fs.readdir (#36849) fix: handle null/undefined options for fs.readdir (#34764) Co-authored-by: David Sanders Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders --- lib/asar/fs-wrapper.ts | 6 +++--- spec/asar-spec.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/asar/fs-wrapper.ts b/lib/asar/fs-wrapper.ts index 61d55c9f02343..2059dc447fe54 100644 --- a/lib/asar/fs-wrapper.ts +++ b/lib/asar/fs-wrapper.ts @@ -623,11 +623,11 @@ export const wrapFsWithAsar = (fs: Record) => { }; const { readdir } = fs; - fs.readdir = function (pathArgument: string, options: { encoding?: string | null; withFileTypes?: boolean } = {}, callback?: Function) { + fs.readdir = function (pathArgument: string, options?: { encoding?: string | null; withFileTypes?: boolean } | null, callback?: Function) { const pathInfo = splitPath(pathArgument); if (typeof options === 'function') { callback = options; - options = {}; + options = undefined; } if (!pathInfo.isAsar) return readdir.apply(this, arguments); const { asarPath, filePath } = pathInfo; @@ -646,7 +646,7 @@ export const wrapFsWithAsar = (fs: Record) => { return; } - if (options.withFileTypes) { + if (options?.withFileTypes) { const dirents = []; for (const file of files) { const childPath = path.join(filePath, file); diff --git a/spec/asar-spec.ts b/spec/asar-spec.ts index b96b65a4c0995..d835011c69ed4 100644 --- a/spec/asar-spec.ts +++ b/spec/asar-spec.ts @@ -965,6 +965,32 @@ describe('asar package', function () { const err = await new Promise(resolve => fs.readdir(p, resolve)); expect(err.code).to.equal('ENOENT'); }); + + it('handles null for options', function (done) { + const p = path.join(asarDir, 'a.asar', 'dir1'); + fs.readdir(p, null, function (err, dirs) { + try { + expect(err).to.be.null(); + expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2']); + done(); + } catch (e) { + done(e); + } + }); + }); + + it('handles undefined for options', function (done) { + const p = path.join(asarDir, 'a.asar', 'dir1'); + fs.readdir(p, undefined, function (err, dirs) { + try { + expect(err).to.be.null(); + expect(dirs).to.deep.equal(['file1', 'file2', 'file3', 'link1', 'link2']); + done(); + } catch (e) { + done(e); + } + }); + }); }); describe('fs.promises.readdir', function () { From d6e58ec0206af46191c511f73df18cb72d3f00b9 Mon Sep 17 00:00:00 2001 From: "electron-roller[bot]" <84116207+electron-roller[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:07:30 -0500 Subject: [PATCH 028/172] chore: bump chromium to 108.0.5359.179 (22-x-y) (#36877) * chore: bump chromium in DEPS to 108.0.5359.179 * chore: update patches Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- DEPS | 2 +- patches/chromium/scroll_bounce_flag.patch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 7573a903314d9..1d2379c254a78 100644 --- a/DEPS +++ b/DEPS @@ -2,7 +2,7 @@ gclient_gn_args_from = 'src' vars = { 'chromium_version': - '108.0.5359.125', + '108.0.5359.179', 'node_version': 'v16.17.1', 'nan_version': diff --git a/patches/chromium/scroll_bounce_flag.patch b/patches/chromium/scroll_bounce_flag.patch index 33b055b78964c..8e0386d8a800b 100644 --- a/patches/chromium/scroll_bounce_flag.patch +++ b/patches/chromium/scroll_bounce_flag.patch @@ -6,7 +6,7 @@ Subject: scroll_bounce_flag.patch Patch to make scrollBounce option work. diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc -index 17b628006b06fd07c902ef2dcf1de4d5ac918dea..0b49ae9d5312e5fb2ad75ddb1812aa0777ef6e0c 100644 +index 2c2d6bb6d2de1eec73543b2d5fe32cb8b811ddc5..70ffbe58f302f8c6d23aca4e751822cb2ec53ba8 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -1273,7 +1273,7 @@ bool RenderThreadImpl::IsLcdTextEnabled() { From 5e7ae98bec68e4a1f6033b0a42fa03020da0e4a2 Mon Sep 17 00:00:00 2001 From: Robo Date: Thu, 12 Jan 2023 20:22:34 +0900 Subject: [PATCH 029/172] fix: missing libcxx headers (#36865) * chore: add libcxx script to precommit hook * chore: run gen-libc++-filename.js --- filenames.libcxx.gni | 10 ++++++++++ package.json | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/filenames.libcxx.gni b/filenames.libcxx.gni index 3437fdf91f9b9..f2ae44793548b 100644 --- a/filenames.libcxx.gni +++ b/filenames.libcxx.gni @@ -414,7 +414,14 @@ libcxx_headers = [ "//buildtools/third_party/libc++/trunk/include/__memory/uninitialized_algorithms.h", "//buildtools/third_party/libc++/trunk/include/__memory/unique_ptr.h", "//buildtools/third_party/libc++/trunk/include/__memory/uses_allocator.h", + "//buildtools/third_party/libc++/trunk/include/__memory/uses_allocator_construction.h", "//buildtools/third_party/libc++/trunk/include/__memory/voidify.h", + "//buildtools/third_party/libc++/trunk/include/__memory_resource/memory_resource.h", + "//buildtools/third_party/libc++/trunk/include/__memory_resource/monotonic_buffer_resource.h", + "//buildtools/third_party/libc++/trunk/include/__memory_resource/polymorphic_allocator.h", + "//buildtools/third_party/libc++/trunk/include/__memory_resource/pool_options.h", + "//buildtools/third_party/libc++/trunk/include/__memory_resource/synchronized_pool_resource.h", + "//buildtools/third_party/libc++/trunk/include/__memory_resource/unsynchronized_pool_resource.h", "//buildtools/third_party/libc++/trunk/include/__mutex_base", "//buildtools/third_party/libc++/trunk/include/__node_handle", "//buildtools/third_party/libc++/trunk/include/__numeric/accumulate.h", @@ -482,6 +489,7 @@ libcxx_headers = [ "//buildtools/third_party/libc++/trunk/include/__ranges/enable_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/filter_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/iota_view.h", + "//buildtools/third_party/libc++/trunk/include/__ranges/istream_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/join_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/lazy_split_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/non_propagating_cache.h", @@ -495,6 +503,7 @@ libcxx_headers = [ "//buildtools/third_party/libc++/trunk/include/__ranges/size.h", "//buildtools/third_party/libc++/trunk/include/__ranges/subrange.h", "//buildtools/third_party/libc++/trunk/include/__ranges/take_view.h", + "//buildtools/third_party/libc++/trunk/include/__ranges/take_while_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/transform_view.h", "//buildtools/third_party/libc++/trunk/include/__ranges/view_interface.h", "//buildtools/third_party/libc++/trunk/include/__ranges/views.h", @@ -775,6 +784,7 @@ libcxx_headers = [ "//buildtools/third_party/libc++/trunk/include/map", "//buildtools/third_party/libc++/trunk/include/math.h", "//buildtools/third_party/libc++/trunk/include/memory", + "//buildtools/third_party/libc++/trunk/include/memory_resource", "//buildtools/third_party/libc++/trunk/include/module.modulemap.in", "//buildtools/third_party/libc++/trunk/include/mutex", "//buildtools/third_party/libc++/trunk/include/new", diff --git a/package.json b/package.json index 85dc53619c0f9..7ca0296e98e8d 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,8 @@ "ts-node script/check-patch-diff.ts" ], "DEPS": [ - "node script/gen-hunspell-filenames.js" + "node script/gen-hunspell-filenames.js", + "node script/gen-libc++-filenames.js" ] }, "resolutions": { From 1245e23a740a95e0f4b586be6a5cb4ec254d8278 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:21:06 +0100 Subject: [PATCH 030/172] chore: fix typo in promise rejection (#36895) chore: fix typo in promise rejection (#36763) Co-authored-by: Eugene Nesvetaev Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Eugene Nesvetaev --- lib/browser/api/web-contents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 7ca4b09e8b686..43f9158058d58 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -272,7 +272,7 @@ WebContents.prototype.printToPDF = async function (options) { if (options.pageRanges !== undefined) { if (typeof options.pageRanges !== 'string') { - return Promise.reject(new Error('printBackground must be a String')); + return Promise.reject(new Error('pageRanges must be a String')); } printSettings.pageRanges = options.pageRanges; } From 8f5a8c684d2fa895cd4dea9fd2857729890d8b42 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Thu, 12 Jan 2023 07:31:55 -0800 Subject: [PATCH 031/172] docs: update code highlights in tutorial (#36893) docs: update code highlights in tutorial (#36691) docs: fix code highlighting in preload tutorial The highlighted lines in the code snippets were unaligned, which could cause a newcomer unneeded confusion on what lines need to be changed. Co-authored-by: Roger Zurawicki --- docs/tutorial/tutorial-3-preload.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/tutorial-3-preload.md b/docs/tutorial/tutorial-3-preload.md index 251d13aa43cf3..90b8049474fba 100644 --- a/docs/tutorial/tutorial-3-preload.md +++ b/docs/tutorial/tutorial-3-preload.md @@ -81,7 +81,7 @@ contextBridge.exposeInMainWorld('versions', { To attach this script to your renderer process, pass its path to the `webPreferences.preload` option in the BrowserWindow constructor: -```js {8-10} title="main.js" +```js {2,8-10} title="main.js" const { app, BrowserWindow } = require('electron') const path = require('path') From 887595e861bc3fefed1bcb1894d4ea5ad3c04502 Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Thu, 12 Jan 2023 18:07:15 +0100 Subject: [PATCH 032/172] chore: cherry-pick 43637378b14e from chromium (#36884) * chore: cherry-pick 43637378b14e from chromium * chore: update patches Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-43637378b14e.patch | 104 ++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 patches/chromium/cherry-pick-43637378b14e.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index fcb5a7a641d8c..bf3ffb4bffaf9 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -125,3 +125,4 @@ fix_tray_icon_gone_on_lock_screen.patch cherry-pick-2611772cf0a0.patch cherry-pick-3235c1d1955b.patch expose_v8initializer_codegenerationcheckcallbackinmainthread.patch +cherry-pick-43637378b14e.patch diff --git a/patches/chromium/cherry-pick-43637378b14e.patch b/patches/chromium/cherry-pick-43637378b14e.patch new file mode 100644 index 0000000000000..51e18ddf9ca29 --- /dev/null +++ b/patches/chromium/cherry-pick-43637378b14e.patch @@ -0,0 +1,104 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Maks Orlovich +Date: Tue, 22 Nov 2022 22:18:55 +0000 +Subject: Align NetworkContext::SetNetworkConditions better with devtools + emulateNetworkConditions + +The former used values of 0 to disable particular throttles, while the +later documents -1, and looks to be pretty much a direct client, and the +only one. So make NetworkService handle everything <= 0 as a disable, +clamping at intake of config. + +Bug: 1382033 + +(cherry picked from commit ce463c2c939818a12bbcec5e2c91c35f2a0a1f0e) + +Change-Id: I2fd3f075d5071cb0cf647838782115b5c00405bf +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4035891 +Reviewed-by: Ken Buchanan +Reviewed-by: Eric Orth +Commit-Queue: Maks Orlovich +Cr-Original-Commit-Position: refs/heads/main@{#1073566} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4048289 +Cr-Commit-Position: refs/branch-heads/5414@{#188} +Cr-Branched-From: 4417ee59d7bf6df7a9c9ea28f7722d2ee6203413-refs/heads/main@{#1070088} + +diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom +index 8dd936e47c8c528ee2ca777788da5df98342dc7c..97063b8165027c1d9a5e09821f2b3056efc283dd 100644 +--- a/services/network/public/mojom/network_context.mojom ++++ b/services/network/public/mojom/network_context.mojom +@@ -563,11 +563,11 @@ struct NetworkConditions { + // response received. + mojo_base.mojom.TimeDelta latency; + +- // Maximal aggregated download throughput (bytes/sec). 0 disables download ++ // Maximal aggregated download throughput (bytes/sec). <=0 disables download + // throttling. + double download_throughput; + +- // Maximal aggregated upload throughput (bytes/sec). 0 disables upload ++ // Maximal aggregated upload throughput (bytes/sec). <=0 disables upload + // throttling. + double upload_throughput; + }; +diff --git a/services/network/throttling/network_conditions.cc b/services/network/throttling/network_conditions.cc +index f620629af5ae78f22f893bc6edf0e6932c771b36..322c72a76f738b0b56674339701010d16a0d4fc5 100644 +--- a/services/network/throttling/network_conditions.cc ++++ b/services/network/throttling/network_conditions.cc +@@ -4,6 +4,8 @@ + + #include "services/network/throttling/network_conditions.h" + ++#include ++ + namespace network { + + NetworkConditions::NetworkConditions() : NetworkConditions(false) {} +@@ -16,9 +18,9 @@ NetworkConditions::NetworkConditions(bool offline, + double download_throughput, + double upload_throughput) + : offline_(offline), +- latency_(latency), +- download_throughput_(download_throughput), +- upload_throughput_(upload_throughput) {} ++ latency_(std::max(latency, 0.0)), ++ download_throughput_(std::max(download_throughput, 0.0)), ++ upload_throughput_(std::max(upload_throughput, 0.0)) {} + + NetworkConditions::~NetworkConditions() {} + +diff --git a/services/network/throttling/network_conditions.h b/services/network/throttling/network_conditions.h +index 9980dca6e06a02979d217ced4bb3a72ab2b7fce7..8390700f7c38780cdb038073a2645039adc12c99 100644 +--- a/services/network/throttling/network_conditions.h ++++ b/services/network/throttling/network_conditions.h +@@ -28,6 +28,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkConditions { + bool IsThrottling() const; + + bool offline() const { return offline_; } ++ ++ // These are 0 if the corresponding throttle is disabled, >0 otherwise. + double latency() const { return latency_; } + double download_throughput() const { return download_throughput_; } + double upload_throughput() const { return upload_throughput_; } +diff --git a/services/network/throttling/throttling_controller_unittest.cc b/services/network/throttling/throttling_controller_unittest.cc +index a30a5c588c87c5810036d43e24ec67bdf51cfde4..abcd0c55b70c8de5ad3ad8377512ad42105a219c 100644 +--- a/services/network/throttling/throttling_controller_unittest.cc ++++ b/services/network/throttling/throttling_controller_unittest.cc +@@ -297,7 +297,7 @@ TEST(ThrottlingControllerTest, DownloadOnly) { + ThrottlingControllerTestHelper helper; + TestCallback* callback = helper.callback(); + +- helper.SetNetworkState(false, 10000000, 0); ++ helper.SetNetworkState(false, 10000000, -1); + int rv = helper.Start(false); + EXPECT_EQ(rv, net::ERR_IO_PENDING); + helper.FastForwardUntilNoTasksRemain(); +@@ -316,7 +316,7 @@ TEST(ThrottlingControllerTest, UploadOnly) { + ThrottlingControllerTestHelper helper; + TestCallback* callback = helper.callback(); + +- helper.SetNetworkState(false, 0, 1000000); ++ helper.SetNetworkState(false, -2, 1000000); + int rv = helper.Start(true); + EXPECT_EQ(rv, net::OK); + helper.FastForwardUntilNoTasksRemain(); From eb59cb1e1111b64bf398d2273f2293fff3764901 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Fri, 13 Jan 2023 07:27:00 +0100 Subject: [PATCH 033/172] docs: add missing window-placement permission value to setPermissionRequestHandler() (#36777) Co-authored-by: Milan Burda --- docs/api/session.md | 1 + spec/chromium-spec.ts | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/docs/api/session.md b/docs/api/session.md index a9867b4478b4c..b3629fc617817 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -682,6 +682,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => { * `pointerLock` - Request to directly interpret mouse movements as an input method. Click [here](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API) to know more. These requests always appear to originate from the main frame. * `fullscreen` - Request for the app to enter fullscreen mode. * `openExternal` - Request to open links in external applications. + * `window-placement` - Request access to enumerate screens using the [`getScreenDetails`](https://developer.chrome.com/en/articles/multi-screen-window-placement/) API. * `unknown` - An unrecognized permission request * `callback` Function * `permissionGranted` boolean - Allow or deny the permission. diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 0fda4cf4b93be..5564e99624642 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -2494,6 +2494,54 @@ describe('navigator.serial', () => { }); }); +describe('window.getScreenDetails', () => { + let w: BrowserWindow; + before(async () => { + w = new BrowserWindow({ + show: false + }); + await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html')); + }); + + after(closeAllWindows); + afterEach(() => { + session.defaultSession.setPermissionRequestHandler(null); + }); + + const getScreenDetails: any = () => { + return w.webContents.executeJavaScript('window.getScreenDetails().then(data => data.screens).catch(err => err.message)', true); + }; + + it('returns screens when a PermissionRequestHandler is not defined', async () => { + const screens = await getScreenDetails(); + expect(screens).to.not.equal('Read permission denied.'); + }); + + it('returns an error when permission denied', async () => { + session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => { + if (permission === 'window-placement') { + callback(false); + } else { + callback(true); + } + }); + const screens = await getScreenDetails(); + expect(screens).to.equal('Permission denied.'); + }); + + it('returns screens when permission is granted', async () => { + session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => { + if (permission === 'window-placement') { + callback(true); + } else { + callback(false); + } + }); + const screens = await getScreenDetails(); + expect(screens).to.not.equal('Permission denied.'); + }); +}); + describe('navigator.clipboard', () => { let w: BrowserWindow; before(async () => { From 69b5723d8c6b3e79449d4031b6c3f4b3d0154bed Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 13 Jan 2023 19:11:03 +0900 Subject: [PATCH 034/172] fix: use the process cache to reduce the memory for asar file (#36664) * fix: use the process cache to reduce the memory for asar file Co-authored-by: webster.xu * Update shell/common/api/electron_api_asar.cc Co-authored-by: Jeremy Rose Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: webster.xu Co-authored-by: Jeremy Rose --- shell/common/api/electron_api_asar.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/common/api/electron_api_asar.cc b/shell/common/api/electron_api_asar.cc index 0b2397ff2c331..dc98314cb300e 100644 --- a/shell/common/api/electron_api_asar.cc +++ b/shell/common/api/electron_api_asar.cc @@ -39,7 +39,7 @@ class Archive : public node::ObjectWrap { Archive& operator=(const Archive&) = delete; protected: - explicit Archive(std::unique_ptr archive) + explicit Archive(std::shared_ptr archive) : archive_(std::move(archive)) {} static void New(const v8::FunctionCallbackInfo& args) { @@ -52,8 +52,8 @@ class Archive : public node::ObjectWrap { return; } - auto archive = std::make_unique(path); - if (!archive->Init()) { + std::shared_ptr archive = asar::GetOrCreateAsarArchive(path); + if (!archive) { isolate->ThrowException(v8::Exception::Error(node::FIXED_ONE_BYTE_STRING( isolate, "failed to initialize archive"))); return; @@ -190,7 +190,7 @@ class Archive : public node::ObjectWrap { isolate, wrap->archive_ ? wrap->archive_->GetUnsafeFD() : -1)); } - std::unique_ptr archive_; + std::shared_ptr archive_; }; static void InitAsarSupport(const v8::FunctionCallbackInfo& args) { From 312c681adc476cc8d7dd1a6b45992ba8f11165a9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 10:22:15 +0100 Subject: [PATCH 035/172] fix: `getUserMedia` duplicate permissions call (#36873) * fix: getUserMedia duplicate permissions call Co-authored-by: Shelley Vohr * test: add regression test Co-authored-by: Shelley Vohr Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- ...ecks_in_mediastreamdevicescontroller.patch | 94 +++++++++++-------- .../browser/web_contents_permission_helper.cc | 3 +- spec/api-session-spec.ts | 53 +++++++++++ 3 files changed, 109 insertions(+), 41 deletions(-) diff --git a/patches/chromium/short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch b/patches/chromium/short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch index 33a05423137e4..2634a5588a14a 100644 --- a/patches/chromium/short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch +++ b/patches/chromium/short-circuit_permissions_checks_in_mediastreamdevicescontroller.patch @@ -15,60 +15,60 @@ short-circuit all the permissions checks in MSDC for now to allow us to unduplicate this code. diff --git a/components/webrtc/media_stream_devices_controller.cc b/components/webrtc/media_stream_devices_controller.cc -index 7dbbcc13901dcd8b7a9ca9c9bdce4f924c1c6a55..5de44c5c20c92a1793060492f925519d6b8befe5 100644 +index 7dbbcc13901dcd8b7a9ca9c9bdce4f924c1c6a55..f4def7e347aafe30485fd1e6055c97d471b44776 100644 --- a/components/webrtc/media_stream_devices_controller.cc +++ b/components/webrtc/media_stream_devices_controller.cc -@@ -92,10 +92,13 @@ void MediaStreamDevicesController::RequestPermissions( +@@ -56,7 +56,8 @@ bool PermissionIsRequested(blink::PermissionType permission, + void MediaStreamDevicesController::RequestPermissions( + const content::MediaStreamRequest& request, + MediaStreamDeviceEnumerator* enumerator, +- ResultCallback callback) { ++ ResultCallback callback, ++ bool previously_approved) { + content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( + request.render_process_id, request.render_frame_id); + // The RFH may have been destroyed by the time the request is processed. +@@ -92,6 +93,7 @@ void MediaStreamDevicesController::RequestPermissions( std::vector permission_types; +#if 0 content::PermissionController* permission_controller = web_contents->GetBrowserContext()->GetPermissionController(); -+#endif - if (controller->ShouldRequestAudio()) { -+#if 0 - content::PermissionResult permission_status = - permission_controller->GetPermissionResultForCurrentDocument( - blink::PermissionType::AUDIO_CAPTURE, rfh); -@@ -110,10 +113,12 @@ void MediaStreamDevicesController::RequestPermissions( - content::PermissionStatusSource::FENCED_FRAME); - return; +@@ -152,19 +154,25 @@ void MediaStreamDevicesController::RequestPermissions( + permission_types.push_back(blink::PermissionType::CAMERA_PAN_TILT_ZOOM); } -+#endif - - permission_types.push_back(blink::PermissionType::AUDIO_CAPTURE); } - if (controller->ShouldRequestVideo()) { -+#if 0 - content::PermissionResult permission_status = - permission_controller->GetPermissionResultForCurrentDocument( - blink::PermissionType::VIDEO_CAPTURE, rfh); -@@ -128,6 +133,7 @@ void MediaStreamDevicesController::RequestPermissions( - content::PermissionStatusSource::FENCED_FRAME); - return; - } +#endif - permission_types.push_back(blink::PermissionType::VIDEO_CAPTURE); - -@@ -139,6 +145,7 @@ void MediaStreamDevicesController::RequestPermissions( - // pan-tilt-zoom permission and there are suitable PTZ capable devices - // available. - if (request.request_pan_tilt_zoom_permission && has_pan_tilt_zoom_camera) { -+#if 0 - permission_status = - permission_controller->GetPermissionResultForCurrentDocument( - blink::PermissionType::CAMERA_PAN_TILT_ZOOM, rfh); -@@ -148,6 +155,7 @@ void MediaStreamDevicesController::RequestPermissions( - controller->RunCallback(/*blocked_by_permissions_policy=*/false); - return; - } -+#endif + // It is OK to ignore `request.security_origin` because it will be calculated + // from `render_frame_host` and we always ignore `requesting_origin` for + // `AUDIO_CAPTURE` and `VIDEO_CAPTURE`. + // `render_frame_host->GetMainFrame()->GetLastCommittedOrigin()` will be used + // instead. +- rfh->GetBrowserContext() +- ->GetPermissionController() +- ->RequestPermissionsFromCurrentDocument( +- permission_types, rfh, request.user_gesture, +- base::BindOnce( +- &MediaStreamDevicesController::PromptAnsweredGroupedRequest, +- std::move(controller))); ++ if (previously_approved) { ++ controller->PromptAnsweredGroupedRequest({blink::mojom::PermissionStatus::GRANTED /*audio*/, ++ blink::mojom::PermissionStatus::GRANTED /*video*/}); ++ } else { ++ rfh->GetBrowserContext() ++ ->GetPermissionController() ++ ->RequestPermissionsFromCurrentDocument( ++ permission_types, rfh, request.user_gesture, ++ base::BindOnce( ++ &MediaStreamDevicesController::PromptAnsweredGroupedRequest, ++ std::move(controller))); ++ } + } - permission_types.push_back(blink::PermissionType::CAMERA_PAN_TILT_ZOOM); - } + MediaStreamDevicesController::~MediaStreamDevicesController() { @@ -434,6 +442,7 @@ bool MediaStreamDevicesController::PermissionIsBlockedForReason( return false; } @@ -85,3 +85,17 @@ index 7dbbcc13901dcd8b7a9ca9c9bdce4f924c1c6a55..5de44c5c20c92a1793060492f925519d return false; } +diff --git a/components/webrtc/media_stream_devices_controller.h b/components/webrtc/media_stream_devices_controller.h +index b9cf3f6ad047fa16594393134eae5fc5349e7430..5de5e0bf9b455872f69de47d58dda929f00df12c 100644 +--- a/components/webrtc/media_stream_devices_controller.h ++++ b/components/webrtc/media_stream_devices_controller.h +@@ -48,7 +48,8 @@ class MediaStreamDevicesController { + // synchronously or asynchronously returned via |callback|. + static void RequestPermissions(const content::MediaStreamRequest& request, + MediaStreamDeviceEnumerator* enumerator, +- ResultCallback callback); ++ ResultCallback callback, ++ bool previously_approved = false); + + ~MediaStreamDevicesController(); + diff --git a/shell/browser/web_contents_permission_helper.cc b/shell/browser/web_contents_permission_helper.cc index 0e9b42eceab1c..01173c2174904 100644 --- a/shell/browser/web_contents_permission_helper.cc +++ b/shell/browser/web_contents_permission_helper.cc @@ -119,7 +119,8 @@ void MediaAccessAllowed(const content::MediaStreamRequest& request, blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE) { webrtc::MediaStreamDevicesController::RequestPermissions( request, MediaCaptureDevicesDispatcher::GetInstance(), - base::BindOnce(&OnMediaStreamRequestResponse, std::move(callback))); + base::BindOnce(&OnMediaStreamRequestResponse, std::move(callback)), + allowed); } else if (request.video_type == blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE || request.video_type == blink::mojom::MediaStreamType:: diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts index 019317a510095..886f8ed72ef83 100644 --- a/spec/api-session-spec.ts +++ b/spec/api-session-spec.ts @@ -1053,6 +1053,22 @@ describe('session module', () => { describe('ses.setPermissionRequestHandler(handler)', () => { afterEach(closeAllWindows); + // These tests are done on an http server because navigator.userAgentData + // requires a secure context. + let server: http.Server; + let serverUrl: string; + before(async () => { + server = http.createServer((req, res) => { + res.setHeader('Content-Type', 'text/html'); + res.end(''); + }); + await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)); + serverUrl = `http://localhost:${(server.address() as any).port}`; + }); + after(() => { + server.close(); + }); + it('cancels any pending requests when cleared', async () => { const w = new BrowserWindow({ show: false, @@ -1085,6 +1101,43 @@ describe('session module', () => { const [, name] = await result; expect(name).to.deep.equal('SecurityError'); }); + + it('successfully resolves when calling legacy getUserMedia', async () => { + const ses = session.fromPartition('' + Math.random()); + ses.setPermissionRequestHandler( + (_webContents, _permission, callback) => { + callback(true); + } + ); + + const w = new BrowserWindow({ show: false, webPreferences: { session: ses } }); + await w.loadURL(serverUrl); + const { ok, message } = await w.webContents.executeJavaScript(` + new Promise((resolve, reject) => navigator.getUserMedia({ + video: true, + audio: true, + }, x => resolve({ok: x instanceof MediaStream}), e => reject({ok: false, message: e.message}))) + `); + expect(ok).to.be.true(message); + }); + + it('successfully rejects when calling legacy getUserMedia', async () => { + const ses = session.fromPartition('' + Math.random()); + ses.setPermissionRequestHandler( + (_webContents, _permission, callback) => { + callback(false); + } + ); + + const w = new BrowserWindow({ show: false, webPreferences: { session: ses } }); + await w.loadURL(serverUrl); + await expect(w.webContents.executeJavaScript(` + new Promise((resolve, reject) => navigator.getUserMedia({ + video: true, + audio: true, + }, x => resolve({ok: x instanceof MediaStream}), e => reject({ok: false, message: e.message}))) + `)).to.eventually.be.rejectedWith('Permission denied'); + }); }); describe('ses.setPermissionCheckHandler(handler)', () => { From 751ba53a6beebc30e891db0addc44956ddca42aa Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 20:37:28 +0900 Subject: [PATCH 036/172] fix: Cmd+Tab not working when exiting kiosk mode (#36918) Co-authored-by: Shelley Vohr Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- shell/browser/native_window_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index e66745a547b70..55d9d5425823c 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1096,9 +1096,12 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { is_kiosk_ = true; SetFullScreen(true); } else if (!kiosk && is_kiosk_) { - [NSApp setPresentationOptions:kiosk_options_]; is_kiosk_ = false; SetFullScreen(false); + + // Set presentation options *after* asynchronously exiting + // fullscreen to ensure they take effect. + [NSApp setPresentationOptions:kiosk_options_]; } } From 06132f5aa353af8045612a5cfa059d057d974c8a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 17 Jan 2023 13:23:08 +0100 Subject: [PATCH 037/172] build: migrate patch-up to use app creds (#36867) Co-authored-by: Samuel Attard Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard --- package.json | 4 +- script/push-patch.js | 20 ++-- yarn.lock | 267 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 271 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 7ca0296e98e8d..6eb7a751aa728 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "devDependencies": { "@azure/storage-blob": "^12.9.0", "@electron/docs-parser": "^1.0.0", + "@electron/github-app-auth": "^1.5.0", "@electron/typescript-definitions": "^8.10.0", - "@octokit/auth-app": "^2.10.0", "@octokit/rest": "^18.0.3", "@primer/octicons": "^10.0.0", "@types/basic-auth": "^1.1.3", @@ -150,4 +150,4 @@ "resolutions": { "nan": "nodejs/nan#16fa32231e2ccd89d2804b3f765319128b20c4ac" } -} \ No newline at end of file +} diff --git a/script/push-patch.js b/script/push-patch.js index d1dd4b58611f4..b2cdbd2eff784 100644 --- a/script/push-patch.js +++ b/script/push-patch.js @@ -1,4 +1,4 @@ -const { createAppAuth } = require('@octokit/auth-app'); +const { appCredentialsFromString, getTokenForRepo } = require('@electron/github-app-auth'); const cp = require('child_process'); if (!process.env.CIRCLE_BRANCH) { @@ -11,17 +11,15 @@ if (process.env.CIRCLE_PR_NUMBER) { process.exit(1); } -const auth = createAppAuth({ - appId: process.env.PATCH_UP_APP_ID, - privateKey: Buffer.from(process.env.PATCH_UP_PRIVATE_KEY, 'base64').toString('utf8'), - installationId: process.env.PATCH_UP_INSTALLATION_ID, - clientId: process.env.PATCH_UP_CLIENT_ID, - clientSecret: process.env.PATCH_UP_CLIENT_SECRET -}); - async function main () { - const installationAuth = await auth({ type: 'installation' }); - const remoteURL = `https://x-access-token:${installationAuth.token}@github.com/electron/electron.git`; + const token = await getTokenForRepo( + { + name: 'electron', + owner: 'electron' + }, + appCredentialsFromString(process.env.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], { diff --git a/yarn.lock b/yarn.lock index 0fcc08de11206..96fcc5e0e8409 100644 --- a/yarn.lock +++ b/yarn.lock @@ -126,6 +126,14 @@ ora "^4.0.3" pretty-ms "^5.1.0" +"@electron/github-app-auth@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@electron/github-app-auth/-/github-app-auth-1.5.0.tgz#426e64ba50143417d9b68f2795a1b119cb62108b" + integrity sha512-t6Za+3E7jdIf1CX06nNV/avZhqSXNEkCLJ1xeAt5FKU9HdGbjzwSfirM+UlHO7lMGyuf13BGCZOCB1kODhDLWQ== + dependencies: + "@octokit/auth-app" "^3.6.1" + "@octokit/rest" "^18.12.0" + "@electron/typescript-definitions@^8.10.0": version "8.10.0" resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.10.0.tgz#e9cf2b329ec4b0b76947ef751725383a6cf8994d" @@ -203,20 +211,79 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" -"@octokit/auth-app@^2.10.0": - version "2.10.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-2.10.0.tgz#ad79369fca1cc3035859f797310d5e81cc6e49c4" - integrity sha512-mKFU7O5wI651iWgecs4fmJ2aLqOM3sWD1FJsUTm7nx21I4ePDhS+rGQmS5TZk5yz75Va6wEXesxUNFzuqCbP2A== +"@octokit/auth-app@^3.6.1": + version "3.6.1" + resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-3.6.1.tgz#aa5b02cc211175cbc28ce6c03c73373c1206d632" + integrity sha512-6oa6CFphIYI7NxxHrdVOzhG7hkcKyGyYocg7lNDSJVauVOLtylg8hNJzoUyPAYKKK0yUeoZamE/lMs2tG+S+JA== dependencies: - "@octokit/request" "^5.3.0" - "@octokit/request-error" "^2.0.0" - "@octokit/types" "^5.0.0" + "@octokit/auth-oauth-app" "^4.3.0" + "@octokit/auth-oauth-user" "^1.2.3" + "@octokit/request" "^5.6.0" + "@octokit/request-error" "^2.1.0" + "@octokit/types" "^6.0.3" "@types/lru-cache" "^5.1.0" deprecation "^2.3.1" lru-cache "^6.0.0" universal-github-app-jwt "^1.0.1" universal-user-agent "^6.0.0" +"@octokit/auth-oauth-app@^4.3.0": + version "4.3.4" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-4.3.4.tgz#7030955b1a59d4d977904775c606477d95fcfe8e" + integrity sha512-OYOTSSINeUAiLMk1uelaGB/dEkReBqHHr8+hBejzMG4z1vA4c7QSvDAS0RVZSr4oD4PEUPYFzEl34K7uNrXcWA== + dependencies: + "@octokit/auth-oauth-device" "^3.1.1" + "@octokit/auth-oauth-user" "^2.0.0" + "@octokit/request" "^5.6.3" + "@octokit/types" "^6.0.3" + "@types/btoa-lite" "^1.0.0" + btoa-lite "^1.0.0" + universal-user-agent "^6.0.0" + +"@octokit/auth-oauth-device@^3.1.1": + version "3.1.4" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-3.1.4.tgz#703c42f27a1e2eb23498a7001ad8e9ecf4a2f477" + integrity sha512-6sHE/++r+aEFZ/BKXOGPJcH/nbgbBjS1A4CHfq/PbPEwb0kZEt43ykW98GBO/rYBPAYaNpCPvXfGwzgR9yMCXg== + dependencies: + "@octokit/oauth-methods" "^2.0.0" + "@octokit/request" "^6.0.0" + "@octokit/types" "^6.10.0" + universal-user-agent "^6.0.0" + +"@octokit/auth-oauth-device@^4.0.0": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-4.0.3.tgz#00ce77233517e0d7d39e42a02652f64337d9df81" + integrity sha512-KPTx5nMntKjNZzzltO3X4T68v22rd7Cp/TcLJXQE2U8aXPcZ9LFuww9q9Q5WUNSu3jwi3lRwzfkPguRfz1R8Vg== + dependencies: + "@octokit/oauth-methods" "^2.0.0" + "@octokit/request" "^6.0.0" + "@octokit/types" "^8.0.0" + universal-user-agent "^6.0.0" + +"@octokit/auth-oauth-user@^1.2.3": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-1.3.0.tgz#da4e4529145181a6aa717ae858afb76ebd6e3360" + integrity sha512-3QC/TAdk7onnxfyZ24BnJRfZv8TRzQK7SEFUS9vLng4Vv6Hv6I64ujdk/CUkREec8lhrwU764SZ/d+yrjjqhaQ== + dependencies: + "@octokit/auth-oauth-device" "^3.1.1" + "@octokit/oauth-methods" "^1.1.0" + "@octokit/request" "^5.4.14" + "@octokit/types" "^6.12.2" + btoa-lite "^1.0.0" + universal-user-agent "^6.0.0" + +"@octokit/auth-oauth-user@^2.0.0": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-2.0.4.tgz#88f060ec678d7d493695af8d827e115dd064e212" + integrity sha512-HrbDzTPqz6GcGSOUkR+wSeF3vEqsb9NMsmPja/qqqdiGmlk/Czkxctc3KeWYogHonp62Ml4kjz2VxKawrFsadQ== + dependencies: + "@octokit/auth-oauth-device" "^4.0.0" + "@octokit/oauth-methods" "^2.0.0" + "@octokit/request" "^6.0.0" + "@octokit/types" "^8.0.0" + btoa-lite "^1.0.0" + universal-user-agent "^6.0.0" + "@octokit/auth-token@^2.4.0": version "2.4.2" resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.2.tgz#10d0ae979b100fa6b72fa0e8e63e27e6d0dbff8a" @@ -224,6 +291,13 @@ dependencies: "@octokit/types" "^5.0.0" +"@octokit/auth-token@^2.4.4": + version "2.5.0" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" + integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g== + dependencies: + "@octokit/types" "^6.0.3" + "@octokit/core@^3.0.0": version "3.1.1" resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.1.1.tgz#1856745aa8fb154cf1544a2a1b82586c809c5e66" @@ -236,6 +310,19 @@ before-after-hook "^2.1.0" universal-user-agent "^6.0.0" +"@octokit/core@^3.5.1": + version "3.6.0" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" + integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== + dependencies: + "@octokit/auth-token" "^2.4.4" + "@octokit/graphql" "^4.5.8" + "@octokit/request" "^5.6.3" + "@octokit/request-error" "^2.0.5" + "@octokit/types" "^6.0.3" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + "@octokit/endpoint@^6.0.1": version "6.0.5" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.5.tgz#43a6adee813c5ffd2f719e20cfd14a1fee7c193a" @@ -245,6 +332,15 @@ is-plain-object "^4.0.0" universal-user-agent "^6.0.0" +"@octokit/endpoint@^7.0.0": + version "7.0.3" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-7.0.3.tgz#0b96035673a9e3bedf8bab8f7335de424a2147ed" + integrity sha512-57gRlb28bwTsdNXq+O3JTQ7ERmBTuik9+LelgcLIVfYwf235VHbN9QNo4kXExtp/h8T423cR5iJThKtFYxC7Lw== + dependencies: + "@octokit/types" "^8.0.0" + is-plain-object "^5.0.0" + universal-user-agent "^6.0.0" + "@octokit/graphql@^4.3.1": version "4.5.3" resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.3.tgz#d5ff0d4a8a33e98614a2a7359dac98bc285e062f" @@ -254,6 +350,64 @@ "@octokit/types" "^5.0.0" universal-user-agent "^6.0.0" +"@octokit/graphql@^4.5.8": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" + integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg== + dependencies: + "@octokit/request" "^5.6.0" + "@octokit/types" "^6.0.3" + universal-user-agent "^6.0.0" + +"@octokit/oauth-authorization-url@^4.3.1": + version "4.3.3" + resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-4.3.3.tgz#6a6ef38f243086fec882b62744f39b517528dfb9" + integrity sha512-lhP/t0i8EwTmayHG4dqLXgU+uPVys4WD/qUNvC+HfB1S1dyqULm5Yx9uKc1x79aP66U1Cb4OZeW8QU/RA9A4XA== + +"@octokit/oauth-authorization-url@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-5.0.0.tgz#029626ce87f3b31addb98cd0d2355c2381a1c5a1" + integrity sha512-y1WhN+ERDZTh0qZ4SR+zotgsQUE1ysKnvBt1hvDRB2WRzYtVKQjn97HEPzoehh66Fj9LwNdlZh+p6TJatT0zzg== + +"@octokit/oauth-methods@^1.1.0": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-1.2.6.tgz#b9ac65e374b2cc55ee9dd8dcdd16558550438ea7" + integrity sha512-nImHQoOtKnSNn05uk2o76om1tJWiAo4lOu2xMAHYsNr0fwopP+Dv+2MlGvaMMlFjoqVd3fF3X5ZDTKCsqgmUaQ== + dependencies: + "@octokit/oauth-authorization-url" "^4.3.1" + "@octokit/request" "^5.4.14" + "@octokit/request-error" "^2.0.5" + "@octokit/types" "^6.12.2" + btoa-lite "^1.0.0" + +"@octokit/oauth-methods@^2.0.0": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-2.0.4.tgz#6abd9593ca7f91fe5068375a363bd70abd5516dc" + integrity sha512-RDSa6XL+5waUVrYSmOlYROtPq0+cfwppP4VaQY/iIei3xlFb0expH6YNsxNrZktcLhJWSpm9uzeom+dQrXlS3A== + dependencies: + "@octokit/oauth-authorization-url" "^5.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^8.0.0" + btoa-lite "^1.0.0" + +"@octokit/openapi-types@^12.11.0": + version "12.11.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.11.0.tgz#da5638d64f2b919bca89ce6602d059f1b52d3ef0" + integrity sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ== + +"@octokit/openapi-types@^14.0.0": + version "14.0.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-14.0.0.tgz#949c5019028c93f189abbc2fb42f333290f7134a" + integrity sha512-HNWisMYlR8VCnNurDU6os2ikx0s0VyEjDYHNS/h4cgb8DeOxQ0n72HyinUtdDVxJhFy3FWLGl0DJhfEWk3P5Iw== + +"@octokit/plugin-paginate-rest@^2.16.8": + version "2.21.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz#7f12532797775640dbb8224da577da7dc210c87e" + integrity sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw== + dependencies: + "@octokit/types" "^6.40.0" + "@octokit/plugin-paginate-rest@^2.2.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.3.0.tgz#7d1073e56cfd15d3f99dcfe81fa5d2b466f3a6f6" @@ -266,6 +420,11 @@ resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== +"@octokit/plugin-request-log@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" + integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== + "@octokit/plugin-rest-endpoint-methods@4.1.2": version "4.1.2" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.1.2.tgz#546a8f3e0b514f434a4ad4ef926005f1c81a5a5a" @@ -274,6 +433,14 @@ "@octokit/types" "^5.1.1" deprecation "^2.3.1" +"@octokit/plugin-rest-endpoint-methods@^5.12.0": + version "5.16.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz#7ee8bf586df97dd6868cf68f641354e908c25342" + integrity sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw== + dependencies: + "@octokit/types" "^6.39.0" + deprecation "^2.3.1" + "@octokit/request-error@^2.0.0": version "2.0.2" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0" @@ -283,6 +450,24 @@ deprecation "^2.0.0" once "^1.4.0" +"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" + integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== + dependencies: + "@octokit/types" "^6.0.3" + deprecation "^2.0.0" + once "^1.4.0" + +"@octokit/request-error@^3.0.0": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-3.0.2.tgz#f74c0f163d19463b87528efe877216c41d6deb0a" + integrity sha512-WMNOFYrSaX8zXWoJg9u/pKgWPo94JXilMLb2VManNOby9EZxrQaBe/QSC4a1TzpAlpxofg2X/jMnCyZgL6y7eg== + dependencies: + "@octokit/types" "^8.0.0" + deprecation "^2.0.0" + once "^1.4.0" + "@octokit/request@^5.3.0", "@octokit/request@^5.4.0": version "5.4.7" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.7.tgz#fd703ee092e0463ceba49ff7a3e61cb4cf8a0fde" @@ -297,6 +482,30 @@ once "^1.4.0" universal-user-agent "^6.0.0" +"@octokit/request@^5.4.14", "@octokit/request@^5.6.0", "@octokit/request@^5.6.3": + version "5.6.3" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" + integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== + dependencies: + "@octokit/endpoint" "^6.0.1" + "@octokit/request-error" "^2.1.0" + "@octokit/types" "^6.16.1" + is-plain-object "^5.0.0" + node-fetch "^2.6.7" + universal-user-agent "^6.0.0" + +"@octokit/request@^6.0.0": + version "6.2.2" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-6.2.2.tgz#a2ba5ac22bddd5dcb3f539b618faa05115c5a255" + integrity sha512-6VDqgj0HMc2FUX2awIs+sM6OwLgwHvAi4KCK3mT2H2IKRt6oH9d0fej5LluF5mck1lRR/rFWN0YIDSYXYSylbw== + dependencies: + "@octokit/endpoint" "^7.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^8.0.0" + is-plain-object "^5.0.0" + node-fetch "^2.6.7" + universal-user-agent "^6.0.0" + "@octokit/rest@^18.0.3": version "18.0.3" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.0.3.tgz#96a15ddb3a38dca5de9d75121378d6aa4a234fa5" @@ -307,6 +516,16 @@ "@octokit/plugin-request-log" "^1.0.0" "@octokit/plugin-rest-endpoint-methods" "4.1.2" +"@octokit/rest@^18.12.0": + version "18.12.0" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" + integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q== + dependencies: + "@octokit/core" "^3.5.1" + "@octokit/plugin-paginate-rest" "^2.16.8" + "@octokit/plugin-request-log" "^1.0.4" + "@octokit/plugin-rest-endpoint-methods" "^5.12.0" + "@octokit/types@^5.0.0", "@octokit/types@^5.0.1", "@octokit/types@^5.1.1", "@octokit/types@^5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.2.0.tgz#d075dc23bf293f540739250b6879e2c1be2fc20c" @@ -314,6 +533,20 @@ dependencies: "@types/node" ">= 8" +"@octokit/types@^6.0.3", "@octokit/types@^6.10.0", "@octokit/types@^6.12.2", "@octokit/types@^6.16.1", "@octokit/types@^6.39.0", "@octokit/types@^6.40.0": + version "6.41.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04" + integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg== + dependencies: + "@octokit/openapi-types" "^12.11.0" + +"@octokit/types@^8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-8.0.0.tgz#93f0b865786c4153f0f6924da067fe0bb7426a9f" + integrity sha512-65/TPpOJP1i3K4lBJMnWqPUJ6zuOtzhtagDvydAWbEXpbFYA0oMKKyLb95NFZZP0lSh/4b6K+DQlzvYQJQQePg== + dependencies: + "@octokit/openapi-types" "^14.0.0" + "@opentelemetry/api@^1.0.1": version "1.0.4" resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.0.4.tgz#a167e46c10d05a07ab299fc518793b0cff8f6924" @@ -365,6 +598,11 @@ "@types/connect" "*" "@types/node" "*" +"@types/btoa-lite@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/btoa-lite/-/btoa-lite-1.0.0.tgz#e190a5a548e0b348adb0df9ac7fa5f1151c7cca4" + integrity sha512-wJsiX1tosQ+J5+bY5LrSahHxr2wT+uME5UDwdN1kg4frt40euqA+wzECkmq4t5QbveHiJepfdThgQrPw6KiSlg== + "@types/busboy@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@types/busboy/-/busboy-0.2.3.tgz#6697ad29873246c530f09a3ff5a40861824230d5" @@ -1266,6 +1504,11 @@ before-after-hook@^2.1.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== +before-after-hook@^2.2.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" + integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== + big.js@^5.2.2: version "5.2.2" resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" @@ -1317,6 +1560,11 @@ browserslist@^4.14.5: node-releases "^2.0.6" update-browserslist-db "^1.0.4" +btoa-lite@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337" + integrity sha512-gvW7InbIyF8AicrqWoptdW08pUxuhq8BEgowNajy9RhiE86fmGAGl+bLKo6oB8QP0CkqHLowfN0oJdKC/J6LbA== + buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" @@ -3281,6 +3529,11 @@ is-plain-object@^4.0.0: resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-4.1.1.tgz#1a14d6452cbd50790edc7fdaa0aed5a40a35ebb5" integrity sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA== +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + is-regex@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" From 9519ec3afad4d796849d0d7089b42971c6d65832 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 18 Jan 2023 06:12:36 -0500 Subject: [PATCH 038/172] ci: run WOA tests on AppVeyor (22-x-y) (#36927) ci: run WOA tests on AppVeyor --- .github/workflows/electron_woa_testing.yml | 163 ------------ appveyor-bake.yml | 2 +- appveyor-woa.yml | 276 +++++++++++++++++++++ appveyor.yml | 23 +- script/release/ci-release-build.js | 33 +-- 5 files changed, 286 insertions(+), 211 deletions(-) delete mode 100644 .github/workflows/electron_woa_testing.yml create mode 100644 appveyor-woa.yml diff --git a/.github/workflows/electron_woa_testing.yml b/.github/workflows/electron_woa_testing.yml deleted file mode 100644 index 74192bffb328d..0000000000000 --- a/.github/workflows/electron_woa_testing.yml +++ /dev/null @@ -1,163 +0,0 @@ -name: Electron WOA Testing - -on: - push: - branches: '**' - workflow_dispatch: - inputs: - appveyor_job_id: - description: 'Job Id of Appveyor WOA job to test' - type: text - required: true - -jobs: - electron-woa-init: - if: ${{ github.event_name == 'push' && github.repository == 'electron/electron' }} - runs-on: ubuntu-latest - steps: - - name: Dummy step for push event - run: | - echo "This job is a needed initialization step for Electron WOA testing. Another test result will appear once the electron-woa-testing build is done." - - electron-woa-testing: - if: ${{ github.event_name == 'workflow_dispatch' && github.repository == 'electron/electron' }} - runs-on: [self-hosted, woa] - permissions: - checks: write - pull-requests: write - steps: - - uses: LouisBrunner/checks-action@v1.1.1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: electron-woa-testing - status: in_progress - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - output: | - {"summary":"Test In Progress","text_description":"See job details here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"} - - name: Clean Workspace - run: | - Remove-Item * -Recurse -Force - shell: powershell - - name: Checkout - uses: actions/checkout@v3 - with: - path: src\electron - fetch-depth: 0 - - name: Yarn install - run: | - cd src\electron - node script/yarn.js install --frozen-lockfile - - name: Download and extract dist.zip for test - run: | - $localArtifactPath = "$pwd\dist.zip" - $serverArtifactPath = "https://ci.appveyor.com/api/buildjobs/${{ inputs.appveyor_job_id }}/artifacts/dist.zip" - Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.APPVEYOR_TOKEN }}" } - & "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -osrc\out\Default -y $localArtifactPath - shell: powershell - - name: Download and extract native test executables for test - run: | - $localArtifactPath = "src\out\Default\shell_browser_ui_unittests.exe" - $serverArtifactPath = "https://ci.appveyor.com/api/buildjobs/${{ inputs.appveyor_job_id }}/artifacts/shell_browser_ui_unittests.exe" - Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.APPVEYOR_TOKEN }}" } - shell: powershell - - name: Download and extract ffmpeg.zip for test - run: | - $localArtifactPath = "$pwd\ffmpeg.zip" - $serverArtifactPath = "https://ci.appveyor.com/api/buildjobs/${{ inputs.appveyor_job_id }}/artifacts/ffmpeg.zip" - Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.APPVEYOR_TOKEN }}" } - & "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -osrc\out\ffmpeg $localArtifactPath - shell: powershell - - name: Download node headers for test - run: | - $localArtifactPath = "src\node_headers.zip" - $serverArtifactPath = "https://ci.appveyor.com/api/buildjobs/${{ inputs.appveyor_job_id }}/artifacts/node_headers.zip" - Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.APPVEYOR_TOKEN }}" } - cd src - & "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -y node_headers.zip - shell: powershell - - name: Download electron.lib for test - run: | - $localArtifactPath = "src\out\Default\electron.lib" - $serverArtifactPath = "https://ci.appveyor.com/api/buildjobs/${{ inputs.appveyor_job_id }}/artifacts/electron.lib" - Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.APPVEYOR_TOKEN }}" } - shell: powershell - # Uncomment the following block if pdb files are needed to debug issues - # - name: Download pdb files for detailed stacktraces - # if: ${{ github.event_name == 'workflow_dispatch' }} - # run: | - # try { - # $localArtifactPath = "src\pdb.zip" - # $serverArtifactPath = "https://ci.appveyor.com/api/buildjobs/${{ inputs.appveyor_job_id }}/artifacts/pdb.zip" - # Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer ${{ secrets.APPVEYOR_TOKEN }}" } - # cd src - # & "${env:ProgramFiles(x86)}\7-Zip\7z.exe" x -y pdb.zip - # } catch { - # Write-Host "There was an exception encountered while downloading pdb files:" $_.Exception.Message - # } finally { - # $global:LASTEXITCODE = 0 - # } - # shell: powershell - - name: Setup node headers - run: | - New-Item src\out\Default\gen\node_headers\Release -Type directory - Copy-Item -path src\out\Default\electron.lib -destination src\out\Default\gen\node_headers\Release\node.lib - shell: powershell - - name: Run Electron Main process tests - run: | - cd src - set npm_config_nodedir=%cd%\out\Default\gen\node_headers - set npm_config_arch=arm64 - cd electron - node script/yarn test --runners=main --enable-logging --disable-features=CalculateNativeWinOcclusion - env: - ELECTRON_ENABLE_STACK_DUMPING: true - ELECTRON_OUT_DIR: Default - IGNORE_YARN_INSTALL_ERROR: 1 - ELECTRON_TEST_RESULTS_DIR: junit - MOCHA_MULTI_REPORTERS: 'mocha-junit-reporter, tap' - MOCHA_REPORTER: mocha-multi-reporters - ELECTRON_SKIP_NATIVE_MODULE_TESTS: true - - name: Verify ffmpeg - run: | - cd src - echo "Verifying non proprietary ffmpeg" - python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg - shell: cmd - - name: Kill processes left running from last test run - if: ${{ always() }} - run: | - Get-Process | Where Name -Like "electron*" | Stop-Process - Get-Process | Where Name -Like "msedge*" | Stop-Process - shell: powershell - - name: Delete user app data directories - if: ${{ always() }} - run: | - Remove-Item -path $env:APPDATA/Electron* -Recurse -Force -ErrorAction Ignore - shell: powershell - - uses: LouisBrunner/checks-action@v1.1.1 - if: ${{ success() }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: electron-woa-testing - conclusion: "${{ job.status }}" - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - output: | - {"summary":"${{ job.status }}","text_description":"See job details here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"} - - uses: LouisBrunner/checks-action@v1.1.1 - if: ${{ success() }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: electron-woa-testing - conclusion: "${{ job.status }}" - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - output: | - {"summary":"Job Succeeded","text_description":"See job details here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"} - - uses: LouisBrunner/checks-action@v1.1.1 - if: ${{ ! success() }} - with: - token: ${{ secrets.GITHUB_TOKEN }} - name: electron-woa-testing - conclusion: "${{ job.status }}" - details_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - output: | - {"summary":"Job Failed","text_description":"See job details here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"} \ No newline at end of file diff --git a/appveyor-bake.yml b/appveyor-bake.yml index 26bfc782a62ac..445e46bf49342 100644 --- a/appveyor-bake.yml +++ b/appveyor-bake.yml @@ -6,7 +6,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: Windows_Default_Appveyor +image: e-111.0.5518.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/appveyor-woa.yml b/appveyor-woa.yml new file mode 100644 index 0000000000000..4b711509dc53f --- /dev/null +++ b/appveyor-woa.yml @@ -0,0 +1,276 @@ +# NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor.yml +# IF APPLICABLE!!!! +# +# +# The config expects the following environment variables to be set: +# - "GN_CONFIG" Build type. One of {'testing', 'release'}. +# - "GN_EXTRA_ARGS" Additional gn arguments for a build config, +# e.g. 'target_cpu="x86"' to build for a 32bit platform. +# https://gn.googlesource.com/gn/+/master/docs/reference.md#target_cpu +# Don't forget to set up "NPM_CONFIG_ARCH" and "TARGET_ARCH" accordingly +# if you pass a custom value for 'target_cpu'. +# - "ELECTRON_RELEASE" Set it to '1' upload binaries on success. +# - "NPM_CONFIG_ARCH" E.g. 'x86'. Is used to build native Node.js modules. +# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "TARGET_ARCH" value. +# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64', 'mips64el'}. +# Is used in some publishing scripts, but does NOT affect the Electron binary. +# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value. +# - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket. +# Otherwise the release will be uploaded to the GitHub Releases. +# (The value is only checked if "ELECTRON_RELEASE" is defined.) +# +# The publishing scripts expect access tokens to be defined as env vars, +# but those are not covered here. +# +# AppVeyor docs on variables: +# https://www.appveyor.com/docs/environment-variables/ +# https://www.appveyor.com/docs/build-configuration/#secure-variables +# https://www.appveyor.com/docs/build-configuration/#custom-environment-variables + +version: 1.0.{build} +build_cloud: electronhq-16-core +image: e-108.0.5359.179 +environment: + GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache + ELECTRON_OUT_DIR: Default + ELECTRON_ENABLE_STACK_DUMPING: 1 + ELECTRON_ALSO_LOG_TO_STDERR: 1 + MOCHA_REPORTER: mocha-multi-reporters + MOCHA_MULTI_REPORTERS: mocha-appveyor-reporter, tap + GOMA_FALLBACK_ON_AUTH_FAILURE: true + DEPOT_TOOLS_WIN_TOOLCHAIN: 0 + PYTHONIOENCODING: UTF-8 + + matrix: + + - job_name: Build Arm on X64 Windows + - job_name: Test On Windows On Arm Hardware + job_depends_on: Build Arm on X64 Windows + APPVEYOR_BUILD_WORKER_IMAGE: base-woa + APPVEYOR_BUILD_WORKER_CLOUD: electronhq-woa + +clone_folder: C:\projects\src\electron + +# the first failed job cancels other jobs and fails entire build +matrix: + fast_finish: true + +for: + + - matrix: + only: + - job_name: Build Arm on X64 Windows + + build_script: + - ps: | + node script/yarn.js install --frozen-lockfile + node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH + if ($LASTEXITCODE -eq 0) { + Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild + } + $global:LASTEXITCODE = 0 + - cd .. + - ps: Write-Host "Building $env:GN_CONFIG build" + - git config --global core.longpaths true + - ps: >- + if (Test-Path -Path "$pwd\depot_tools") { + Remove-Item -Recurse -Force $pwd\depot_tools + } + - ps: >- + if (Test-Path -Path "$pwd\build-tools") { + Remove-Item -Recurse -Force $pwd\build-tools + } + - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: $env:PATH="$pwd\depot_tools;$env:PATH" + - ps: >- + if (Test-Path -Path "$pwd\src\electron") { + Remove-Item -Recurse -Force $pwd\src\electron + } + - ps: >- + if (Test-Path 'env:RAW_GOMA_AUTH') { + $env:GOMA_OAUTH2_CONFIG_FILE = "$pwd\.goma_oauth2_config" + $env:RAW_GOMA_AUTH | Set-Content $env:GOMA_OAUTH2_CONFIG_FILE + } + - git clone https://github.com/electron/build-tools.git + - cd build-tools + - npm install + - mkdir third_party + - ps: >- + node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })" + - ps: $env:GN_GOMA_FILE = node -e "console.log(require('./src/utils/goma.js').gnFilePath)" + - ps: $env:LOCAL_GOMA_DIR = node -e "console.log(require('./src/utils/goma.js').dir)" + - cd ..\.. + - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR + - ps: >- + if (Test-Path 'env:RAW_GOMA_AUTH') { + $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info + if ($goma_login -eq 'Login as Fermi Planck') { + Write-warning "Goma authentication is correct"; + } else { + Write-warning "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token."; + $host.SetShouldExit(1) + } + } + - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" + - ps: >- + if ($env:GN_CONFIG -ne 'release') { + $env:NINJA_STATUS="[%r processes, %f/%t @ %o/s : %es] " + } + - gclient config --name "src\electron" --unmanaged %GCLIENT_EXTRA_ARGS% "https://github.com/electron/electron" + # Patches are applied in the image bake. Check depshash to see if patches have changed. + - ps: $env:RUN_GCLIENT_SYNC="false" + - ps: $depshash_baked = Get-Content .\src\.depshash -Raw + - ps: cd src\electron + - ps: node script\generate-deps-hash.js + - ps: $depshash = Get-Content .\.depshash -Raw + - ps: cd ..\.. + - ps: >- + if ($depshash_baked -ne $depshash) { + $env:RUN_GCLIENT_SYNC="true" + } + - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks ) + - cd src + - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn + - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% " + - gn check out/Default //electron:electron_lib + - gn check out/Default //electron:electron_app + - gn check out/Default //electron/shell/common/api:mojo + - if DEFINED GN_GOMA_FILE (ninja -j 300 -C out/Default electron:electron_app) else (ninja -C out/Default electron:electron_app) + - if "%GN_CONFIG%"=="testing" ( python C:\depot_tools\post_build_ninja_summary.py -C out\Default ) + - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%" + - ninja -C out/ffmpeg electron:electron_ffmpeg_zip + - ninja -C out/Default electron:electron_dist_zip + - ninja -C out/Default shell_browser_ui_unittests + - gn desc out/Default v8:run_mksnapshot_default args > out/Default/default_mksnapshot_args + # Remove unused args from mksnapshot_args + - ps: >- + Get-Content out/Default/default_mksnapshot_args | Where-Object { -not $_.Contains('--turbo-profiling-input') -And -not $_.Contains('builtins-pgo') } | Set-Content out/Default/mksnapshot_args + - ninja -C out/Default electron:electron_mksnapshot_zip + - cd out\Default + - 7z a mksnapshot.zip mksnapshot_args gen\v8\embedded.S + - cd ..\.. + - ninja -C out/Default electron:hunspell_dictionaries_zip + - ninja -C out/Default electron:electron_chromedriver_zip + - ninja -C out/Default third_party/electron_node:headers + - python %LOCAL_GOMA_DIR%\goma_ctl.py stat + - ps: >- + Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json + - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json + - 7z a node_headers.zip out\Default\gen\node_headers + - ps: >- + if ($env:GN_CONFIG -eq 'release') { + # Needed for msdia140.dll on 64-bit windows + $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" + ninja -C out/Default electron:electron_symbols + } + - ps: >- + if ($env:GN_CONFIG -eq 'release') { + python3 electron\script\zip-symbols.py + appveyor-retry appveyor PushArtifact out/Default/symbols.zip + } else { + # It's useful to have pdb files when debugging testing builds that are + # built on CI. + 7z a pdb.zip out\Default\*.pdb + } + - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + + deploy_script: + - cd electron + - ps: >- + if (Test-Path Env:\ELECTRON_RELEASE) { + if (Test-Path Env:\UPLOAD_TO_STORAGE) { + Write-Output "Uploading Electron release distribution to azure" + & python3 script\release\uploaders\upload.py --verbose --upload_to_storage + } else { + Write-Output "Uploading Electron release distribution to github releases" + & python3 script\release\uploaders\upload.py --verbose + } + } + on_finish: + # Uncomment this lines to enable RDP + # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + - cd C:\projects\src + - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) + - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) + - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) + - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) + - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) + - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) + - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) + - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) + - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) + - ps: >- + if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { + appveyor-retry appveyor PushArtifact pdb.zip + } + - matrix: + only: + - job_name: Test On Windows On Arm Hardware + + environment: + IGNORE_YARN_INSTALL_ERROR: 1 + ELECTRON_TEST_RESULTS_DIR: junit + MOCHA_MULTI_REPORTERS: 'mocha-junit-reporter, tap' + MOCHA_REPORTER: mocha-multi-reporters + ELECTRON_SKIP_NATIVE_MODULE_TESTS: true + + build_script: + - ps: | + node script/yarn.js install --frozen-lockfile + node script/doc-only-change.js --prNumber=$env:APPVEYOR_PULL_REQUEST_NUMBER --prBranch=$env:APPVEYOR_REPO_BRANCH + if ($LASTEXITCODE -eq 0) { + Write-warning "Skipping build for doc only change"; Exit-AppveyorBuild + } + $global:LASTEXITCODE = 0 + - cd .. + - mkdir out\Default + - cd .. + - ps: | + # Download build artifacts + $apiUrl = 'https://ci.appveyor.com/api' + $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID" + $artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','pdb.zip','electron.lib') + foreach ($job in $build_info.build.jobs) { + if ($job.name -eq "Build Arm on X64 Windows") { + $jobId = $job.jobId + foreach($artifact_name in $artifacts_to_download) { + if ($artifact_name -eq 'shell_browser_ui_unittests.exe' -Or $artifact_name -eq 'electron.lib') { + $outfile = "src\out\Default\$artifact_name" + } else { + $outfile = $artifact_name + } + Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile + } + } + } + - ps: | + $out_default_zips = @('dist.zip','pdb.zip') + foreach($zip_name in $out_default_zips) { + 7z x -y -osrc\out\Default $zip_name + } + - ps: 7z x -y -osrc\out\ffmpeg ffmpeg.zip + - ps: 7z x -y -osrc node_headers.zip + + test_script: + # Workaround for https://github.com/appveyor/ci/issues/2420 + - set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core" + - ps: | + cd src + New-Item .\out\Default\gen\node_headers\Release -Type directory + Copy-Item -path .\out\Default\electron.lib -destination .\out\Default\gen\node_headers\Release\node.lib + - set npm_config_nodedir=%cd%\out\Default\gen\node_headers + - set npm_config_arch=arm64 + - cd electron + # Explicitly set npm_config_arch because the .env doesn't persist + - ps: >- + if ($env:TARGET_ARCH -eq 'ia32') { + $env:npm_config_arch = "ia32" + } + - echo Running main test suite & node script/yarn test --runners=main --enable-logging --disable-features=CalculateNativeWinOcclusion + - cd .. + - echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg + + on_finish: + # Uncomment these lines to enable RDP + # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log ) \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index c4a41b875f0ce..20c527f1a46b9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,7 @@ +# NOTE IF CHANGING THIS FILE, ALSO APPLY THE CHANGE TO appveyor-woa.yml +# IF APPLICABLE!!!! +# +# # The config expects the following environment variables to be set: # - "GN_CONFIG" Build type. One of {'testing', 'release'}. # - "GN_EXTRA_ARGS" Additional gn arguments for a build config, @@ -25,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-108.0.5359.125 +image: e-108.0.5359.179 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -55,12 +59,6 @@ for: only: - job_name: Build - init: - - ps: >- - if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { - Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild - } - build_script: - ps: | node script/yarn.js install --frozen-lockfile @@ -185,8 +183,6 @@ for: Write-Output "Uploading Electron release distribution to github releases" & python3 script\release\uploaders\upload.py --verbose } - } elseif (Test-Path Env:\TEST_WOA) { - node script/release/ci-release-build.js --job=electron-woa-testing --ci=GHA --appveyorJobId=$env:APPVEYOR_JOB_ID $env:APPVEYOR_REPO_BRANCH } on_finish: # Uncomment this lines to enable RDP @@ -214,9 +210,6 @@ for: if ($env:RUN_TESTS -ne 'true') { Write-warning "Skipping tests for $env:APPVEYOR_PROJECT_NAME"; Exit-AppveyorBuild } - if(($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME -split "/")[0] -eq ($env:APPVEYOR_REPO_NAME -split "/")[0]) { - Write-warning "Skipping PR build for branch"; Exit-AppveyorBuild - } build_script: - ps: | node script/yarn.js install --frozen-lockfile @@ -276,8 +269,8 @@ for: - echo "Done verifying mksnapshot" - echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd% - echo "Done verifying chromedriver" - - # Uncomment these lines to enable RDP - # on_finish: + + on_finish: + # Uncomment these lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - if exist electron\electron.log ( appveyor-retry appveyor PushArtifact electron\electron.log ) \ No newline at end of file diff --git a/script/release/ci-release-build.js b/script/release/ci-release-build.js index 1121f7b56125d..e79dfc962776d 100644 --- a/script/release/ci-release-build.js +++ b/script/release/ci-release-build.js @@ -24,8 +24,6 @@ const circleCIPublishIndividualArches = { 'linux-publish': ['arm', 'arm64', 'x64'] }; -const GHAJobs = ['electron-woa-testing']; - let jobRequestedCount = 0; async function makeRequest ({ auth, username, password, url, headers, body, method }) { @@ -250,31 +248,6 @@ function buildCircleCI (targetBranch, options) { } } -async function buildGHA (targetBranch, options) { - const { GHA_TOKEN } = process.env; - assert(GHA_TOKEN, `${options.ci} requires the $GHA_TOKEN environment variable to be provided`); - - const octokit = new Octokit({ auth: GHA_TOKEN }); - - assert(GHAJobs.includes(options.job), `Unknown GitHub Actions arm test job name: ${options.job}. Valid values are: ${GHAJobs}.`); - assert(options.commit !== null, 'commit is a required option for GitHub Actions'); - - console.log(`Triggering GitHub Actions to run build on branch: ${targetBranch}.`); - - jobRequestedCount++; - - try { - const response = await octokit.request('POST /repos/electron/electron/actions/workflows/electron_woa_testing.yml/dispatches', { - ref: targetBranch, - inputs: { - appveyor_job_id: `${options.appveyorJobId}` - } - }); - } catch (err) { - console.log('Problem calling GitHub Actions to get build definitions: ', err); - } -} - function runRelease (targetBranch, options) { if (options.ci) { switch (options.ci) { @@ -286,10 +259,6 @@ function runRelease (targetBranch, options) { buildAppVeyor(targetBranch, options); break; } - case 'GHA': { - buildGHA(targetBranch, options); - break; - } default: { console.log(`Error! Unknown CI: ${options.ci}.`); process.exit(1); @@ -311,7 +280,7 @@ if (require.main === module) { const targetBranch = args._[0]; if (args._.length < 1) { console.log(`Trigger CI to build release builds of electron. - Usage: ci-release-build.js [--job=CI_JOB_NAME] [--arch=INDIVIDUAL_ARCH] [--ci=CircleCI|AppVeyor|GHA] + Usage: ci-release-build.js [--job=CI_JOB_NAME] [--arch=INDIVIDUAL_ARCH] [--ci=CircleCI|AppVeyor] [--ghRelease] [--circleBuildNum=xxx] [--appveyorJobId=xxx] [--commit=sha] TARGET_BRANCH `); process.exit(0); From 37267d1bebd2ddee77ae3a95a36b107da02a7f53 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:29:15 -0500 Subject: [PATCH 039/172] fix: webview background color on reload (#36940) Co-authored-by: Shelley Vohr Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- shell/browser/api/electron_api_web_contents.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 8b3482f82eceb..1747611e1aa44 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1520,13 +1520,15 @@ void WebContents::HandleNewRenderFrame( // Set the background color of RenderWidgetHostView. auto* web_preferences = WebContentsPreferences::From(web_contents()); if (web_preferences) { - absl::optional maybe_color = web_preferences->GetBackgroundColor(); - web_contents()->SetPageBaseBackgroundColor(maybe_color); - + auto maybe_color = web_preferences->GetBackgroundColor(); bool guest = IsGuest() || type_ == Type::kBrowserView; - SkColor color = + + // If webPreferences has no color stored we need to explicitly set guest + // webContents background color to transparent. + auto bg_color = maybe_color.value_or(guest ? SK_ColorTRANSPARENT : SK_ColorWHITE); - SetBackgroundColor(rwhv, color); + web_contents()->SetPageBaseBackgroundColor(bg_color); + SetBackgroundColor(rwhv, bg_color); } if (!background_throttling_) From 72bdd5cd4c9d3f3a9f8ac22909957294a9495a2f Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 19 Jan 2023 15:59:08 +0900 Subject: [PATCH 040/172] feat: add label property to Display objects (#36932) Co-authored-by: Milan Burda Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda --- docs/api/structures/display.md | 1 + shell/common/gin_converters/gfx_converter.cc | 1 + spec/api-screen-spec.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/api/structures/display.md b/docs/api/structures/display.md index 8782d34d1b46b..37dfa26b7ae32 100644 --- a/docs/api/structures/display.md +++ b/docs/api/structures/display.md @@ -1,6 +1,7 @@ # Display Object * `id` number - Unique identifier associated with the display. +* `label` string - User-friendly label, determined by the platform. * `rotation` number - Can be 0, 90, 180, 270, represents screen rotation in clock-wise degrees. * `scaleFactor` number - Output device's pixel scale factor. diff --git a/shell/common/gin_converters/gfx_converter.cc b/shell/common/gin_converters/gfx_converter.cc index 23c7d873893db..4fc3294323f78 100644 --- a/shell/common/gin_converters/gfx_converter.cc +++ b/shell/common/gin_converters/gfx_converter.cc @@ -144,6 +144,7 @@ v8::Local Converter::ToV8( gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("id", val.id()); + dict.Set("label", val.label()); dict.Set("bounds", val.bounds()); dict.Set("workArea", val.work_area()); dict.Set("accelerometerSupport", val.accelerometer_support()); diff --git a/spec/api-screen-spec.ts b/spec/api-screen-spec.ts index 102e68155d28b..2f6631e454c4b 100644 --- a/spec/api-screen-spec.ts +++ b/spec/api-screen-spec.ts @@ -34,6 +34,7 @@ describe('screen module', () => { expect(display).to.have.property('scaleFactor').that.is.a('number'); expect(display).to.have.property('id').that.is.a('number'); + expect(display).to.have.property('label').that.is.a('string'); expect(display).to.have.property('rotation').that.is.a('number'); expect(display).to.have.property('touchSupport').that.is.a('string'); expect(display).to.have.property('accelerometerSupport').that.is.a('string'); From 57f2eecb28b9d04e571bce95e26d7c09ce934819 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 19 Jan 2023 18:02:51 -0500 Subject: [PATCH 041/172] docs: Change factuality and word choice in app.runningUnderARM64Translation (#36964) Change factuality and word choice. Added "or WOW" to the phrase, "when they are running the x64 version under Rosetta", to reflect the use of a supported platform, Windows, as a possible scenario. Changed the wording of that same sentence to make it appear clearer. "incorrectly" to "mistakenly" and moved this word to before the verb instead of the end of the sentence. Co-authored-by: GGIEnrike <52293637+GGIEnrike@users.noreply.github.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: GGIEnrike <52293637+GGIEnrike@users.noreply.github.com> --- docs/api/app.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index 4ccd7fde8675d..ffa185b9d5609 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1562,5 +1562,4 @@ an ARM64 translator (like the macOS or Windows [WOW](https://en.wikipedia.org/wiki/Windows_on_Windows)). You can use this property to prompt users to download the arm64 version of -your application when they are running the x64 version under Rosetta -incorrectly. +your application when they are mistakenly running the x64 version under Rosetta or WOW. From b6eef906042d2c2b5a93e27122c34409478dcf7d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 19 Jan 2023 18:08:15 -0500 Subject: [PATCH 042/172] docs: update clipboard fiddles (#36961) Co-authored-by: David Sanders Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders --- docs/api/clipboard.md | 2 +- docs/fiddles/system/clipboard/.keep | 0 docs/fiddles/system/clipboard/copy/index.html | 7 +++---- docs/fiddles/system/clipboard/copy/main.js | 17 +++++++++++++-- docs/fiddles/system/clipboard/copy/preload.js | 5 +++++ .../fiddles/system/clipboard/copy/renderer.js | 2 -- .../fiddles/system/clipboard/paste/index.html | 7 +++---- docs/fiddles/system/clipboard/paste/main.js | 21 +++++++++++++++++-- .../fiddles/system/clipboard/paste/preload.js | 6 ++++++ .../system/clipboard/paste/renderer.js | 8 +++---- 10 files changed, 55 insertions(+), 20 deletions(-) delete mode 100644 docs/fiddles/system/clipboard/.keep create mode 100644 docs/fiddles/system/clipboard/copy/preload.js create mode 100644 docs/fiddles/system/clipboard/paste/preload.js diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index 3d43c3715de4c..813065fa30136 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -2,7 +2,7 @@ > Perform copy and paste operations on the system clipboard. -Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) +Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process) (non-sandboxed only) On Linux, there is also a `selection` clipboard. To manipulate it you need to pass `selection` to each method: diff --git a/docs/fiddles/system/clipboard/.keep b/docs/fiddles/system/clipboard/.keep deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/docs/fiddles/system/clipboard/copy/index.html b/docs/fiddles/system/clipboard/copy/index.html index 2bf063a2f516b..0b02eb7b8904b 100644 --- a/docs/fiddles/system/clipboard/copy/index.html +++ b/docs/fiddles/system/clipboard/copy/index.html @@ -2,12 +2,13 @@ +

Clipboard copy

- Supports: Win, macOS, Linux | Process: Both + Supports: Win, macOS, Linux | Process: Main, Renderer (non-sandboxed only)
@@ -17,8 +18,6 @@

Clipboard copy

+ - diff --git a/docs/fiddles/system/clipboard/copy/main.js b/docs/fiddles/system/clipboard/copy/main.js index 36ad14197f6b7..656b990429ab5 100644 --- a/docs/fiddles/system/clipboard/copy/main.js +++ b/docs/fiddles/system/clipboard/copy/main.js @@ -1,4 +1,5 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow, ipcMain, clipboard } = require('electron') +const path = require('path') let mainWindow = null @@ -8,7 +9,7 @@ function createWindow () { height: 400, title: 'Clipboard copy', webPreferences: { - nodeIntegration: true + preload: path.join(__dirname, 'preload.js') } } @@ -20,6 +21,18 @@ function createWindow () { }) } +ipcMain.handle('clipboard:writeText', (event, text) => { + clipboard.writeText(text) +}) + app.whenReady().then(() => { createWindow() + + app.on('activate', function () { + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit() }) diff --git a/docs/fiddles/system/clipboard/copy/preload.js b/docs/fiddles/system/clipboard/copy/preload.js new file mode 100644 index 0000000000000..f97bfe1fc2e6b --- /dev/null +++ b/docs/fiddles/system/clipboard/copy/preload.js @@ -0,0 +1,5 @@ +const { contextBridge, ipcRenderer } = require('electron') + +contextBridge.exposeInMainWorld('clipboard', { + writeText: (text) => ipcRenderer.invoke('clipboard:writeText', text) +}) diff --git a/docs/fiddles/system/clipboard/copy/renderer.js b/docs/fiddles/system/clipboard/copy/renderer.js index 75e204136e09a..d9af9ce044c1b 100644 --- a/docs/fiddles/system/clipboard/copy/renderer.js +++ b/docs/fiddles/system/clipboard/copy/renderer.js @@ -1,5 +1,3 @@ -const { clipboard } = require('electron') - const copyBtn = document.getElementById('copy-to') const copyInput = document.getElementById('copy-to-input') diff --git a/docs/fiddles/system/clipboard/paste/index.html b/docs/fiddles/system/clipboard/paste/index.html index 9cc2ac5ba7ce8..a7b300ea045b5 100644 --- a/docs/fiddles/system/clipboard/paste/index.html +++ b/docs/fiddles/system/clipboard/paste/index.html @@ -2,12 +2,13 @@ +

Clipboard paste

- Supports: Win, macOS, Linux | Process: Both + Supports: Win, macOS, Linux | Process: Main, Renderer (non-sandboxed only)
@@ -17,8 +18,6 @@

Clipboard paste

+ - diff --git a/docs/fiddles/system/clipboard/paste/main.js b/docs/fiddles/system/clipboard/paste/main.js index b0883e6f4e56f..a1d2f6ad30942 100644 --- a/docs/fiddles/system/clipboard/paste/main.js +++ b/docs/fiddles/system/clipboard/paste/main.js @@ -1,4 +1,5 @@ -const { app, BrowserWindow } = require('electron') +const { app, BrowserWindow, ipcMain, clipboard } = require('electron') +const path = require('path') let mainWindow = null @@ -8,7 +9,7 @@ function createWindow () { height: 400, title: 'Clipboard paste', webPreferences: { - nodeIntegration: true + preload: path.join(__dirname, 'preload.js') } } @@ -20,6 +21,22 @@ function createWindow () { }) } +ipcMain.handle('clipboard:readText', () => { + return clipboard.readText() +}) + +ipcMain.handle('clipboard:writeText', (event, text) => { + clipboard.writeText(text) +}) + app.whenReady().then(() => { createWindow() + + app.on('activate', function () { + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit() }) diff --git a/docs/fiddles/system/clipboard/paste/preload.js b/docs/fiddles/system/clipboard/paste/preload.js new file mode 100644 index 0000000000000..7ea394192ebd3 --- /dev/null +++ b/docs/fiddles/system/clipboard/paste/preload.js @@ -0,0 +1,6 @@ +const { contextBridge, ipcRenderer } = require('electron') + +contextBridge.exposeInMainWorld('clipboard', { + readText: () => ipcRenderer.invoke('clipboard:readText'), + writeText: (text) => ipcRenderer.invoke('clipboard:writeText', text) +}) diff --git a/docs/fiddles/system/clipboard/paste/renderer.js b/docs/fiddles/system/clipboard/paste/renderer.js index 27a52422cf0da..a1562b4f085b6 100644 --- a/docs/fiddles/system/clipboard/paste/renderer.js +++ b/docs/fiddles/system/clipboard/paste/renderer.js @@ -1,9 +1,7 @@ -const { clipboard } = require('electron') - const pasteBtn = document.getElementById('paste-to') -pasteBtn.addEventListener('click', () => { - clipboard.writeText('What a demo!') - const message = `Clipboard contents: ${clipboard.readText()}` +pasteBtn.addEventListener('click', async () => { + await clipboard.writeText('What a demo!') + const message = `Clipboard contents: ${await clipboard.readText()}` document.getElementById('paste-from').innerHTML = message }) From 71e1d8eea1624a347782998ab65ec03eb8eb3827 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sat, 21 Jan 2023 21:40:38 +0900 Subject: [PATCH 043/172] fix: make plugin helper executable unconditional (#36978) Co-authored-by: deepak1556 Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: deepak1556 --- shell/app/electron_main_delegate_mac.mm | 3 --- shell/browser/electron_browser_client.cc | 9 ++------- shell/common/mac/main_application_bundle.mm | 3 --- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/shell/app/electron_main_delegate_mac.mm b/shell/app/electron_main_delegate_mac.mm index b3c3e5df9e0d0..3805ad76a2d6b 100644 --- a/shell/app/electron_main_delegate_mac.mm +++ b/shell/app/electron_main_delegate_mac.mm @@ -15,7 +15,6 @@ #include "base/strings/sys_string_conversions.h" #include "content/common/mac_helpers.h" #include "content/public/common/content_paths.h" -#include "ppapi/buildflags/buildflags.h" #include "shell/browser/mac/electron_application.h" #include "shell/common/application_info.h" #include "shell/common/mac/main_application_bundle.h" @@ -41,11 +40,9 @@ } else if (base::EndsWith(path.value(), content::kMacHelperSuffix_gpu, base::CompareCase::SENSITIVE)) { helper_name += content::kMacHelperSuffix_gpu; -#if BUILDFLAG(ENABLE_PLUGINS) } else if (base::EndsWith(path.value(), content::kMacHelperSuffix_plugin, base::CompareCase::SENSITIVE)) { helper_name += content::kMacHelperSuffix_plugin; -#endif } return frameworks_path.Append(name + " " + helper_name + ".app") diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index f98f0d676b937..31cf7a06434c4 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -475,15 +475,10 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches( content::ChildProcessHost::CHILD_RENDERER); auto gpu_child_path = content::ChildProcessHost::GetChildPath( content::ChildProcessHost::CHILD_GPU); -#if BUILDFLAG(ENABLE_PLUGINS) auto plugin_child_path = content::ChildProcessHost::GetChildPath( content::ChildProcessHost::CHILD_PLUGIN); -#endif - if (program != renderer_child_path && program != gpu_child_path -#if BUILDFLAG(ENABLE_PLUGINS) - && program != plugin_child_path -#endif - ) { + if (program != renderer_child_path && program != gpu_child_path && + program != plugin_child_path) { child_path = content::ChildProcessHost::GetChildPath( content::ChildProcessHost::CHILD_NORMAL); CHECK_EQ(program, child_path) diff --git a/shell/common/mac/main_application_bundle.mm b/shell/common/mac/main_application_bundle.mm index 0e8058e8f90ab..a73275b3f2e04 100644 --- a/shell/common/mac/main_application_bundle.mm +++ b/shell/common/mac/main_application_bundle.mm @@ -11,7 +11,6 @@ #include "base/path_service.h" #include "base/strings/string_util.h" #include "content/common/mac_helpers.h" -#include "ppapi/buildflags/buildflags.h" namespace electron { @@ -33,10 +32,8 @@ bool HasMainProcessKey() { // Up to Contents. if (!HasMainProcessKey() && (base::EndsWith(path.value(), " Helper", base::CompareCase::SENSITIVE) || -#if BUILDFLAG(ENABLE_PLUGINS) base::EndsWith(path.value(), content::kMacHelperSuffix_plugin, base::CompareCase::SENSITIVE) || -#endif base::EndsWith(path.value(), content::kMacHelperSuffix_renderer, base::CompareCase::SENSITIVE) || base::EndsWith(path.value(), content::kMacHelperSuffix_gpu, From e5690f135307f81f9e1cdbe714fc9ebb6e0f9def Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 23 Jan 2023 21:32:13 +0900 Subject: [PATCH 044/172] chore: cherry-pick 5e04f643 from chromium (#36991) --- patches/chromium/.patches | 1 + ...tmarkerrange_should_not_be_backwards.patch | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 patches/chromium/axselectedtextmarkerrange_should_not_be_backwards.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index bf3ffb4bffaf9..270124491cc3a 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -126,3 +126,4 @@ cherry-pick-2611772cf0a0.patch cherry-pick-3235c1d1955b.patch expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch +axselectedtextmarkerrange_should_not_be_backwards.patch diff --git a/patches/chromium/axselectedtextmarkerrange_should_not_be_backwards.patch b/patches/chromium/axselectedtextmarkerrange_should_not_be_backwards.patch new file mode 100644 index 0000000000000..2fd993bdd0c49 --- /dev/null +++ b/patches/chromium/axselectedtextmarkerrange_should_not_be_backwards.patch @@ -0,0 +1,57 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Valerie Young +Date: Mon, 14 Nov 2022 19:53:31 +0000 +Subject: AXSelectedTextMarkerRange should not be backwards + +AXSelectedTextMarkerRange was changed to backwards in this commit: +https://chromium-review.googlesource.com/c/chromium/src/+/2330812 +In response to this bug: +https://bugs.chromium.org/p/chromium/issues/detail?id=1110480 +After switching the range back to forward, the bug above is not +repeatable. + +Fixed: 1172956 +Change-Id: I8f32e807e91514e3d74393b1ec54960ffdfacdcb +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3994770 +Reviewed-by: Aaron Leventhal +Commit-Queue: Valerie Young +Cr-Commit-Position: refs/heads/main@{#1071150} + +diff --git a/content/browser/accessibility/ax_tree_formatter_mac_browsertest.mm b/content/browser/accessibility/ax_tree_formatter_mac_browsertest.mm +index 46426469b3728f470c102812c454fd838b3f006f..250180222304766ca2b25d1dcd5df248f3087833 100644 +--- a/content/browser/accessibility/ax_tree_formatter_mac_browsertest.mm ++++ b/content/browser/accessibility/ax_tree_formatter_mac_browsertest.mm +@@ -206,7 +206,7 @@ AccessibilityNotificationWaiter waiter(shell()->web_contents(), + )~~", + {":3;AXSelectedTextMarkerRange=*"}, R"~~(AXWebArea + ++AXGroup +-++++AXStaticText AXSelectedTextMarkerRange={anchor: {:2, -1, down}, focus: {:3, 0, down}} ++++++AXStaticText AXSelectedTextMarkerRange={anchor: {:3, 0, down}, focus: {:2, -1, down}} + )~~"); + } + +diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm +index 55cce7ff53b355cea2787abca6140f122f6a0369..202923773d7adb2fad5c15be4558bfd548ec6c7d 100644 +--- a/content/browser/accessibility/browser_accessibility_cocoa.mm ++++ b/content/browser/accessibility/browser_accessibility_cocoa.mm +@@ -1347,9 +1347,7 @@ - (id)selectedTextMarkerRange { + if (ax_range.IsNull()) + return nil; + +- // Voiceover expects this range to be backwards in order to read the selected +- // words correctly. +- return AXRangeToAXTextMarkerRange(ax_range.AsBackwardRange()); ++ return AXRangeToAXTextMarkerRange(std::move(ax_range)); + } + + - (NSString*)sortDirection { +diff --git a/content/test/data/accessibility/mac/selection/selectall-textarea-expected.txt b/content/test/data/accessibility/mac/selection/selectall-textarea-expected.txt +index f2638c5d03b16266e781bb74cfc08c65f7c0a60d..34036471ad01d0fcfc7bd9b7213f1b4edcded719 100644 +--- a/content/test/data/accessibility/mac/selection/selectall-textarea-expected.txt ++++ b/content/test/data/accessibility/mac/selection/selectall-textarea-expected.txt +@@ -1,4 +1,4 @@ + textarea_range={anchor: {:3, 0, down}, focus: {:3, 19, down}} + textarea.AXSelectedTextMarkerRange={anchor: {:3, 0, down}, focus: {:3, 19, down}} + AXSelectedTextChanged on AXTextArea AXValue='The quick brown fox' AXTextSelectionDirection=AXTextSelectionDirectionUnknown AXTextSelectionGranularity=AXTextSelectionGranularityUnknown AXTextStateChangeType=AXTextStateChangeTypeSelectionMove +-textarea.AXSelectedTextMarkerRange={anchor: {:3, 19, down}, focus: {:3, 0, down}} ++textarea.AXSelectedTextMarkerRange={anchor: {:3, 0, down}, focus: {:3, 19, down}} From 153abeb351764c604dac922a3c9d382ad5e70cae Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 24 Jan 2023 09:35:00 +0100 Subject: [PATCH 045/172] test: add a `` spec for time type (#36997) spec: add a datalist spec for time type Co-authored-by: Shelley Vohr Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- spec/autofill-spec.ts | 23 +++++++++++++++++++++-- spec/fixtures/pages/datalist-text.html | 15 +++++++++++++++ spec/fixtures/pages/datalist-time.html | 13 +++++++++++++ spec/fixtures/pages/datalist.html | 13 ------------- 4 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 spec/fixtures/pages/datalist-text.html create mode 100644 spec/fixtures/pages/datalist-time.html delete mode 100644 spec/fixtures/pages/datalist.html diff --git a/spec/autofill-spec.ts b/spec/autofill-spec.ts index 4ae39e29f53ad..4917780965ea5 100644 --- a/spec/autofill-spec.ts +++ b/spec/autofill-spec.ts @@ -9,10 +9,11 @@ const fixturesPath = path.resolve(__dirname, 'fixtures'); describe('autofill', () => { afterEach(closeAllWindows); - it('can be selected via keyboard', async () => { + it('can be selected via keyboard for a with text type', async () => { const w = new BrowserWindow({ show: true }); - await w.loadFile(path.join(fixturesPath, 'pages', 'datalist.html')); + await w.loadFile(path.join(fixturesPath, 'pages', 'datalist-text.html')); w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab' }); + const inputText = 'clap'; for (const keyCode of inputText) { w.webContents.sendInputEvent({ type: 'char', keyCode }); @@ -25,4 +26,22 @@ describe('autofill', () => { const value = await w.webContents.executeJavaScript("document.querySelector('input').value"); expect(value).to.equal('Eric Clapton'); }); + + it('can be selected via keyboard for a with time type', async () => { + const w = new BrowserWindow({ show: true }); + await w.loadFile(path.join(fixturesPath, 'pages', 'datalist-time.html')); + + const inputText = '11P'; // 1:01 PM + for (const keyCode of inputText) { + w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab' }); + w.webContents.sendInputEvent({ type: 'keyDown', keyCode }); + w.webContents.sendInputEvent({ type: 'char', keyCode }); + await delay(100); + } + + w.webContents.sendInputEvent({ type: 'keyDown', keyCode: 'Tab' }); + + const value = await w.webContents.executeJavaScript("document.querySelector('input').value"); + expect(value).to.equal('13:01'); + }); }); diff --git a/spec/fixtures/pages/datalist-text.html b/spec/fixtures/pages/datalist-text.html new file mode 100644 index 0000000000000..fc1d2c2801687 --- /dev/null +++ b/spec/fixtures/pages/datalist-text.html @@ -0,0 +1,15 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/spec/fixtures/pages/datalist-time.html b/spec/fixtures/pages/datalist-time.html new file mode 100644 index 0000000000000..f38766eb83bf7 --- /dev/null +++ b/spec/fixtures/pages/datalist-time.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/spec/fixtures/pages/datalist.html b/spec/fixtures/pages/datalist.html deleted file mode 100644 index 8fc56ecbf14b1..0000000000000 --- a/spec/fixtures/pages/datalist.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - From a73332fd9ffdcdfe34f7cdeb142fcdff8f001d44 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Tue, 24 Jan 2023 08:58:16 -0800 Subject: [PATCH 046/172] test: support running tests against Electron releases (#36968) Co-authored-by: Charles Kerr Co-authored-by: Charles Kerr --- package.json | 1 + script/spec-runner.js | 38 ++++++- yarn.lock | 235 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 269 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6eb7a751aa728..13cfaa6607b6d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "devDependencies": { "@azure/storage-blob": "^12.9.0", "@electron/docs-parser": "^1.0.0", + "@electron/fiddle-core": "^1.0.4", "@electron/github-app-auth": "^1.5.0", "@electron/typescript-definitions": "^8.10.0", "@octokit/rest": "^18.0.3", diff --git a/script/spec-runner.js b/script/spec-runner.js index 477a600fac54f..a6f7083b7f07f 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -1,5 +1,6 @@ #!/usr/bin/env node +const { ElectronVersions, Installer } = require('@electron/fiddle-core'); const childProcess = require('child_process'); const crypto = require('crypto'); const fs = require('fs-extra'); @@ -12,7 +13,7 @@ const pass = '✓'.green; const fail = '✗'.red; const args = require('minimist')(process.argv, { - string: ['runners', 'target'], + string: ['runners', 'target', 'electronVersion'], boolean: ['buildNativeTests'], unknown: arg => unknownFlags.push(arg) }); @@ -39,6 +40,15 @@ const runners = new Map([ const specHashPath = path.resolve(__dirname, '../spec/.hash'); +if (args.electronVersion) { + if (args.runners && args.runners !== 'main') { + console.log(`${fail} only 'main' runner can be used with --electronVersion`); + process.exit(1); + } + + args.runners = 'main'; +} + let runnersToRun = null; if (args.runners !== undefined) { runnersToRun = args.runners.split(',').filter(value => value); @@ -52,6 +62,14 @@ if (args.runners !== undefined) { } async function main () { + if (args.electronVersion) { + const versions = await ElectronVersions.create(); + if (!versions.isVersion(args.electronVersion)) { + console.log(`${fail} '${args.electronVersion}' is not a recognized Electron version`); + process.exit(1); + } + } + const [lastSpecHash, lastSpecInstallHash] = loadLastSpecHash(); const [currentSpecHash, currentSpecInstallHash] = await getSpecHash(); const somethingChanged = (currentSpecHash !== lastSpecHash) || @@ -122,7 +140,13 @@ async function runElectronTests () { } async function runTestUsingElectron (specDir, testName) { - let exe = path.resolve(BASE, utils.getElectronExec()); + let exe; + if (args.electronVersion) { + const installer = new Installer(); + exe = await installer.install(args.electronVersion); + } else { + exe = path.resolve(BASE, utils.getElectronExec()); + } const runnerArgs = [`electron/${specDir}`, ...unknownArgs.slice(2)]; if (process.platform === 'linux') { runnerArgs.unshift(path.resolve(__dirname, 'dbus_mock.py'), exe); @@ -212,14 +236,20 @@ async function installSpecModules (dir) { // but don't clobber any other CXXFLAGS that were passed into spec-runner.js const CXXFLAGS = ['-std=c++17', process.env.CXXFLAGS].filter(x => !!x).join(' '); - const nodeDir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); const env = { ...process.env, CXXFLAGS, - npm_config_nodedir: nodeDir, npm_config_msvs_version: '2019', npm_config_yes: 'true' }; + if (args.electronVersion) { + env.npm_config_target = args.electronVersion; + env.npm_config_disturl = 'https://electronjs.org/headers'; + env.npm_config_runtime = 'electron'; + env.npm_config_build_from_source = 'true'; + } else { + env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); + } if (fs.existsSync(path.resolve(dir, 'node_modules'))) { await fs.remove(path.resolve(dir, 'node_modules')); } diff --git a/yarn.lock b/yarn.lock index 96fcc5e0e8409..4822764777640 100644 --- a/yarn.lock +++ b/yarn.lock @@ -126,6 +126,36 @@ ora "^4.0.3" pretty-ms "^5.1.0" +"@electron/fiddle-core@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@electron/fiddle-core/-/fiddle-core-1.0.4.tgz#d28e330c4d88f3916269558a43d214c4312333af" + integrity sha512-gjPz3IAHK+/f0N52cWVeTZpdgENJo3QHBGeGqMDHFUgzSBRTVyAr8z8Lw8wpu6Ocizs154Rtssn4ba1ysABgLA== + dependencies: + "@electron/get" "^2.0.0" + debug "^4.3.3" + env-paths "^2.2.1" + extract-zip "^2.0.1" + fs-extra "^10.0.0" + getos "^3.2.1" + node-fetch "^2.6.1" + semver "^7.3.5" + simple-git "^3.5.0" + +"@electron/get@^2.0.0": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@electron/get/-/get-2.0.2.tgz#ae2a967b22075e9c25aaf00d5941cd79c21efd7e" + integrity sha512-eFZVFoRXb3GFGd7Ak7W4+6jBl9wBtiZ4AaYOse97ej6mKj5tkyO0dUnUChs1IhJZtx1BENo4/p4WUTXpi6vT+g== + dependencies: + debug "^4.1.1" + env-paths "^2.2.0" + fs-extra "^8.1.0" + got "^11.8.5" + progress "^2.0.3" + semver "^6.2.0" + sumchecker "^3.0.1" + optionalDependencies: + global-agent "^3.0.0" + "@electron/github-app-auth@^1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@electron/github-app-auth/-/github-app-auth-1.5.0.tgz#426e64ba50143417d9b68f2795a1b119cb62108b" @@ -190,6 +220,18 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@kwsites/file-exists@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@kwsites/file-exists/-/file-exists-1.1.1.tgz#ad1efcac13e1987d8dbaf235ef3be5b0d96faa99" + integrity sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw== + dependencies: + debug "^4.1.1" + +"@kwsites/promise-deferred@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz#8ace5259254426ccef57f3175bc64ed7095ed919" + integrity sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw== + "@nodelib/fs.scandir@2.1.3": version "2.1.3" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b" @@ -1038,6 +1080,13 @@ tapable "^2.2.0" webpack "^5" +"@types/yauzl@^2.9.1": + version "2.10.0" + resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.10.0.tgz#b3248295276cf8c6f153ebe6a9aba0c988cb2599" + integrity sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw== + dependencies: + "@types/node" "*" + "@typescript-eslint/eslint-plugin@^4.4.1": version "4.4.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.4.1.tgz#b8acea0373bd2a388ac47df44652f00bf8b368f5" @@ -1454,6 +1503,11 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== +async@^3.2.0: + version "3.2.4" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" + integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -1535,6 +1589,11 @@ body-parser@1.19.0: raw-body "2.4.0" type-is "~1.6.17" +boolean@^3.0.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/boolean/-/boolean-3.2.0.tgz#9e5294af4e98314494cbb17979fa54ca159f116b" + integrity sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1565,6 +1624,11 @@ btoa-lite@^1.0.0: resolved "https://registry.yarnpkg.com/btoa-lite/-/btoa-lite-1.0.0.tgz#337766da15801210fdd956c22e9c6891ab9d0337" integrity sha512-gvW7InbIyF8AicrqWoptdW08pUxuhq8BEgowNajy9RhiE86fmGAGl+bLKo6oB8QP0CkqHLowfN0oJdKC/J6LbA== +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ== + buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" @@ -2019,6 +2083,13 @@ debug@^4.0.1, debug@^4.1.1: dependencies: ms "^2.1.1" +debug@^4.1.0, debug@^4.3.3, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + decompress-response@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" @@ -2111,6 +2182,11 @@ destroy@~1.0.4: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= +detect-node@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" + integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== + diff@^3.1.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -2267,6 +2343,11 @@ entities@~2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4" integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw== +env-paths@^2.2.0, env-paths@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" + integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== + envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -2338,6 +2419,11 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +es6-error@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" + integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== + es6-object-assign@^1.0.3: version "1.1.0" resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c" @@ -2358,6 +2444,11 @@ escape-string-regexp@^1.0.5: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + eslint-config-standard-jsx@8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/eslint-config-standard-jsx/-/eslint-config-standard-jsx-8.1.0.tgz#314c62a0e6f51f75547f89aade059bec140edfc7" @@ -2804,6 +2895,17 @@ external-editor@^3.0.3: iconv-lite "^0.4.24" tmp "^0.0.33" +extract-zip@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-2.0.1.tgz#663dca56fe46df890d5f131ef4a06d22bb8ba13a" + integrity sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg== + dependencies: + debug "^4.1.1" + get-stream "^5.1.0" + yauzl "^2.10.0" + optionalDependencies: + "@types/yauzl" "^2.9.1" + fast-deep-equal@^3.1.1: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -2850,6 +2952,13 @@ fault@^2.0.0: dependencies: format "^0.2.0" +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + integrity sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g== + dependencies: + pend "~1.2.0" + figgy-pudding@^3.5.1: version "3.5.2" resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" @@ -2972,6 +3081,15 @@ fresh@0.5.2: resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac= +fs-extra@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" @@ -3061,6 +3179,13 @@ get-stream@^5.0.0, get-stream@^5.1.0: dependencies: pump "^3.0.0" +getos@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5" + integrity sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q== + dependencies: + async "^3.2.0" + glob-parent@^5.0.0, glob-parent@^5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" @@ -3104,6 +3229,18 @@ glob@~7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" +global-agent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/global-agent/-/global-agent-3.0.0.tgz#ae7cd31bd3583b93c5a16437a1afe27cc33a1ab6" + integrity sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q== + dependencies: + boolean "^3.0.1" + es6-error "^4.1.1" + matcher "^3.0.0" + roarr "^2.15.3" + semver "^7.3.2" + serialize-error "^7.0.1" + globals@^12.1.0: version "12.4.0" resolved "https://registry.yarnpkg.com/globals/-/globals-12.4.0.tgz#a18813576a41b00a24a97e7f815918c2e19925f8" @@ -3111,6 +3248,13 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +globalthis@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" + integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== + dependencies: + define-properties "^1.1.3" + globby@^11.0.0, globby@^11.0.1: version "11.0.1" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357" @@ -3657,6 +3801,11 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= +json-stringify-safe@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== + json5@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" @@ -4112,6 +4261,13 @@ matcher-collection@^1.0.0: dependencies: minimatch "^3.0.2" +matcher@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/matcher/-/matcher-3.0.0.tgz#bd9060f4c5b70aa8041ccc6f80368760994f30ca" + integrity sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng== + dependencies: + escape-string-regexp "^4.0.0" + mdast-comment-marker@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/mdast-comment-marker/-/mdast-comment-marker-1.1.1.tgz#9c9c18e1ed57feafc1965d92b028f37c3c8da70d" @@ -4520,6 +4676,13 @@ node-fetch@^2.3.0, node-fetch@^2.6.7: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.1: + version "2.6.8" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.8.tgz#a68d30b162bc1d8fd71a367e81b997e1f4d4937e" + integrity sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg== + dependencies: + whatwg-url "^5.0.0" + node-releases@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" @@ -4892,6 +5055,11 @@ pathval@^1.1.0: resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + integrity sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg== + picocolors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" @@ -5832,6 +6000,18 @@ rimraf@~2.2.6: resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" integrity sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI= +roarr@^2.15.3: + version "2.15.4" + resolved "https://registry.yarnpkg.com/roarr/-/roarr-2.15.4.tgz#f5fe795b7b838ccfe35dc608e0282b9eba2e7afd" + integrity sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A== + dependencies: + boolean "^3.0.1" + detect-node "^2.0.4" + globalthis "^1.0.1" + json-stringify-safe "^5.0.1" + semver-compare "^1.0.0" + sprintf-js "^1.1.2" + run-async@^2.4.0: version "2.4.1" resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" @@ -5912,7 +6092,7 @@ semver@^6.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.2.0.tgz#4d813d9590aaf8a9192693d6c85b9344de5901db" integrity sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A== -semver@^6.1.0, semver@^6.1.2: +semver@^6.1.0, semver@^6.1.2, semver@^6.2.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -5929,6 +6109,13 @@ semver@^7.2.1, semver@^7.3.2: resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== +semver@^7.3.5: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + dependencies: + lru-cache "^6.0.0" + send@0.17.1: version "0.17.1" resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" @@ -5948,6 +6135,13 @@ send@0.17.1: range-parser "~1.2.1" statuses "~1.5.0" +serialize-error@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-7.0.1.tgz#f1360b0447f61ffb483ec4157c737fab7d778e18" + integrity sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw== + dependencies: + type-fest "^0.13.1" + serialize-javascript@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" @@ -6024,6 +6218,15 @@ signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== +simple-git@^3.5.0: + version "3.15.1" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.15.1.tgz#57f595682cb0c2475d5056da078a05c8715a25ef" + integrity sha512-73MVa5984t/JP4JcQt0oZlKGr42ROYWC3BcUZfuHtT3IHKPspIvL0cZBnvPXF7LL3S/qVeVHVdYYmJ3LOTw4Rg== + dependencies: + "@kwsites/file-exists" "^1.1.1" + "@kwsites/promise-deferred" "^1.1.1" + debug "^4.3.4" + slash@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" @@ -6108,6 +6311,11 @@ spdx-license-ids@^3.0.0: resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz#75ecd1a88de8c184ef015eafb51b5b48bfd11bb1" integrity sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA== +sprintf-js@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673" + integrity sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug== + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -6279,6 +6487,13 @@ strip-json-comments@~2.0.1: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= +sumchecker@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/sumchecker/-/sumchecker-3.0.1.tgz#6377e996795abb0b6d348e9b3e1dfb24345a8e42" + integrity sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg== + dependencies: + debug "^4.1.0" + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -6554,6 +6769,11 @@ type-fest@^0.11.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== +type-fest@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" + integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== + type-fest@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1" @@ -6745,6 +6965,11 @@ universalify@^1.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d" integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug== +universalify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -7082,6 +7307,14 @@ yaml@^1.7.2: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== +yauzl@^2.10.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + integrity sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g== + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" + yn@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" From 95772e1feb43b9dab1962c611ecbbf95476d3b84 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 13:06:15 -0800 Subject: [PATCH 047/172] fix: treat maxWidth/Height<=0 as unlimited (#36512) Co-authored-by: Jeremy Rose Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose --- shell/browser/native_window.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 37aff64f5726e..df678b48ea8c3 100755 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -172,7 +172,11 @@ void NativeWindow::InitFromOptions(const gin_helper::Dictionary& options) { int max_width = max_size.width() > 0 ? max_size.width() : INT_MAX; int max_height = max_size.height() > 0 ? max_size.height() : INT_MAX; bool have_max_width = options.Get(options::kMaxWidth, &max_width); + if (have_max_width && max_width <= 0) + max_width = INT_MAX; bool have_max_height = options.Get(options::kMaxHeight, &max_height); + if (have_max_height && max_height <= 0) + max_height = INT_MAX; // By default the window has a default maximum size that prevents it // from being resized larger than the screen, so we should only set this From 19b85bb74ebace16db063599e04ded912b4b5db4 Mon Sep 17 00:00:00 2001 From: Keeley Hammond Date: Wed, 25 Jan 2023 22:44:36 -0800 Subject: [PATCH 048/172] chore: cherry-pick 57c54ae221d6 from chromium (#37022) * chore: [22-x-y] cherry-pick 57c54ae221d6 from chromium * chore: update patches Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-57c54ae221d6.patch | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 patches/chromium/cherry-pick-57c54ae221d6.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 270124491cc3a..1646f6b2fdff0 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -127,3 +127,4 @@ cherry-pick-3235c1d1955b.patch expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch +cherry-pick-57c54ae221d6.patch diff --git a/patches/chromium/cherry-pick-57c54ae221d6.patch b/patches/chromium/cherry-pick-57c54ae221d6.patch new file mode 100644 index 0000000000000..b632c5b6e2dc3 --- /dev/null +++ b/patches/chromium/cherry-pick-57c54ae221d6.patch @@ -0,0 +1,97 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Victor Vasiliev +Date: Wed, 21 Dec 2022 17:26:42 +0000 +Subject: Ensure clean destruction of network::WebTransport + +Once the destruction of the object begins, we should not process any +callbacks, nor should we attempt to reset the streams on a connection +that is already being closed. + +Bug: 1376354 +Change-Id: Ib49e0ce0b177062cccd0e52368782e291cf8166c +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4117501 +Reviewed-by: Eric Orth +Commit-Queue: Victor Vasiliev +Cr-Commit-Position: refs/heads/main@{#1085965} + +diff --git a/services/network/web_transport.cc b/services/network/web_transport.cc +index 8ddbeb9473cb94ebcc64286797ae574ca08d1001..cd92d0f26b23229aeb1e415b81165b2ebf05452f 100644 +--- a/services/network/web_transport.cc ++++ b/services/network/web_transport.cc +@@ -177,7 +177,7 @@ class WebTransport::Stream final { + + ~Stream() { + auto* stream = incoming_ ? incoming_.get() : outgoing_.get(); +- if (!stream) { ++ if (!stream || transport_->closing_ || transport_->torn_down_) { + return; + } + stream->MaybeResetDueToStreamObjectGone(); +@@ -399,7 +399,10 @@ WebTransport::WebTransport( + transport_->Connect(); + } + +-WebTransport::~WebTransport() = default; ++WebTransport::~WebTransport() { ++ // Ensure that we ignore all callbacks while mid-destruction. ++ torn_down_ = true; ++} + + void WebTransport::SendDatagram(base::span data, + base::OnceCallback callback) { +diff --git a/services/network/web_transport_unittest.cc b/services/network/web_transport_unittest.cc +index 81bf26f9e0509e8c56160042519f9ea9034c68df..1a9e6bcfef8b5f7cb642412cb59381c5082e2c19 100644 +--- a/services/network/web_transport_unittest.cc ++++ b/services/network/web_transport_unittest.cc +@@ -610,6 +610,51 @@ TEST_F(WebTransportTest, EchoOnUnidirectionalStreams) { + EXPECT_EQ(0u, resets_sent.size()); + } + ++TEST_F(WebTransportTest, DeleteClientWithStreamsOpen) { ++ base::RunLoop run_loop_for_handshake; ++ mojo::PendingRemote handshake_client; ++ TestHandshakeClient test_handshake_client( ++ handshake_client.InitWithNewPipeAndPassReceiver(), ++ run_loop_for_handshake.QuitClosure()); ++ ++ CreateWebTransport(GetURL("/echo"), ++ url::Origin::Create(GURL("https://example.org/")), ++ std::move(handshake_client)); ++ ++ run_loop_for_handshake.Run(); ++ ++ ASSERT_TRUE(test_handshake_client.has_seen_connection_establishment()); ++ ++ TestClient client(test_handshake_client.PassClientReceiver()); ++ mojo::Remote transport_remote( ++ test_handshake_client.PassTransport()); ++ ++ constexpr int kNumStreams = 10; ++ auto writable_for_outgoing = ++ std::make_unique(kNumStreams); ++ for (int i = 0; i < kNumStreams; i++) { ++ const MojoCreateDataPipeOptions options = { ++ sizeof(options), MOJO_CREATE_DATA_PIPE_FLAG_NONE, 1, 4 * 1024}; ++ mojo::ScopedDataPipeConsumerHandle readable_for_outgoing; ++ ASSERT_EQ(MOJO_RESULT_OK, ++ mojo::CreateDataPipe(&options, writable_for_outgoing[i], ++ readable_for_outgoing)); ++ base::RunLoop run_loop_for_stream_creation; ++ bool stream_created; ++ transport_remote->CreateStream( ++ std::move(readable_for_outgoing), ++ /*writable=*/{}, ++ base::BindLambdaForTesting([&](bool b, uint32_t /*id*/) { ++ stream_created = b; ++ run_loop_for_stream_creation.Quit(); ++ })); ++ run_loop_for_stream_creation.Run(); ++ ASSERT_TRUE(stream_created); ++ } ++ ++ // Keep the streams open so that they are closed via destructor. ++} ++ + // crbug.com/1129847: disabled because it is flaky. + TEST_F(WebTransportTest, DISABLED_EchoOnBidirectionalStream) { + base::RunLoop run_loop_for_handshake; From 786350c22e64a98a969a3f7a2abe046e7696ac3a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 17:27:31 +0900 Subject: [PATCH 049/172] chore: remove crashpad related sandbox policy (#37027) Co-authored-by: deepak1556 Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: deepak1556 --- shell/browser/electron_browser_client.cc | 17 ----------------- shell/browser/electron_browser_client.h | 5 ----- 2 files changed, 22 deletions(-) diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 31cf7a06434c4..2c4323c06904f 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -120,10 +120,6 @@ #include "ui/native_theme/native_theme.h" #include "v8/include/v8.h" -#if BUILDFLAG(IS_WIN) -#include "sandbox/win/src/sandbox_policy.h" -#endif - #if BUILDFLAG(USE_NSS_CERTS) #include "net/ssl/client_cert_store_nss.h" #elif BUILDFLAG(IS_WIN) @@ -1459,19 +1455,6 @@ void ElectronBrowserClient::OverrideURLLoaderFactoryParams( browser_context, origin, is_for_isolated_world, factory_params); } -#if BUILDFLAG(IS_WIN) -bool ElectronBrowserClient::PreSpawnChild(sandbox::TargetPolicy* policy, - sandbox::mojom::Sandbox sandbox_type, - ChildSpawnFlags flags) { - sandbox::ResultCode result = policy->GetConfig()->AddRule( - sandbox::SubSystem::kFiles, sandbox::Semantics::kFilesAllowAny, - L"\\??\\pipe\\crashpad_*"); - if (result != sandbox::SBOX_ALL_OK) - return false; - return true; -} -#endif // BUILDFLAG(IS_WIN) - void ElectronBrowserClient:: RegisterAssociatedInterfaceBindersForRenderFrameHost( content::RenderFrameHost& diff --git a/shell/browser/electron_browser_client.h b/shell/browser/electron_browser_client.h index 00af11c48b000..19b5dc9063e68 100644 --- a/shell/browser/electron_browser_client.h +++ b/shell/browser/electron_browser_client.h @@ -245,11 +245,6 @@ class ElectronBrowserClient : public content::ContentBrowserClient, const url::Origin& origin, bool is_for_isolated_world, network::mojom::URLLoaderFactoryParams* factory_params) override; -#if BUILDFLAG(IS_WIN) - bool PreSpawnChild(sandbox::TargetPolicy* policy, - sandbox::mojom::Sandbox sandbox_type, - ChildSpawnFlags flags) override; -#endif void RegisterAssociatedInterfaceBindersForRenderFrameHost( content::RenderFrameHost& render_frame_host, blink::AssociatedInterfaceRegistry& associated_registry) override; From ef164e7e8db9e80d7d60059b8e1eec558abc924a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 11:25:03 +0100 Subject: [PATCH 050/172] feat: Add BrowserWindow option to hide window in Mission Control (macOS) (#36390) --- docs/api/browser-window.md | 11 +++++++++++ shell/browser/api/electron_api_base_window.cc | 18 ++++++++++++++++++ shell/browser/api/electron_api_base_window.h | 5 +++++ shell/browser/native_window.h | 6 ++++++ shell/browser/native_window_mac.h | 2 ++ shell/browser/native_window_mac.mm | 15 ++++++++++++++- shell/common/options_switches.cc | 2 ++ shell/common/options_switches.h | 1 + spec/api-browser-window-spec.ts | 18 ++++++++++++++++++ 9 files changed, 77 insertions(+), 1 deletion(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 859b1876a1669..66b13027dcdf7 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -192,6 +192,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. macOS. Default is `false`. * `skipTaskbar` boolean (optional) _macOS_ _Windows_ - Whether to show the window in taskbar. Default is `false`. + * `hiddenInMissionControl` boolean (optional) _macOS_ - Whether window should be hidden when the user toggles into mission control. * `kiosk` boolean (optional) - Whether the window is in kiosk mode. Default is `false`. * `title` string (optional) - Default window title. Default is `"Electron"`. If the HTML tag `` is defined in the HTML file loaded by `loadURL()`, this property will be ignored. * `icon` ([NativeImage](native-image.md) | string) (optional) - The window icon. On Windows it is @@ -1255,6 +1256,16 @@ Returns `boolean` - Whether the window can be manually closed by user. On Linux always returns `true`. +#### `win.setHiddenInMissionControl(hidden)` _macOS_ + +* `hidden` boolean + +Sets whether the window will be hidden when the user toggles into mission control. + +#### `win.isHiddenInMissionControl()` _macOS_ + +Returns `boolean` - Whether the window will be hidden when the user toggles into mission control. + #### `win.setAlwaysOnTop(flag[, level][, relativeLevel])` * `flag` boolean diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 6aa498923e94c..6ecc2684d1066 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -881,6 +881,16 @@ gfx::Point BaseWindow::GetTrafficLightPosition() const { } #endif +#if BUILDFLAG(IS_MAC) +bool BaseWindow::IsHiddenInMissionControl() { + return window_->IsHiddenInMissionControl(); +} + +void BaseWindow::SetHiddenInMissionControl(bool hidden) { + window_->SetHiddenInMissionControl(hidden); +} +#endif + void BaseWindow::SetTouchBar( std::vector<gin_helper::PersistentDictionary> items) { window_->SetTouchBar(std::move(items)); @@ -1256,6 +1266,14 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate, .SetMethod("getTrafficLightPosition", &BaseWindow::GetTrafficLightPosition) #endif + +#if BUILDFLAG(IS_MAC) + .SetMethod("isHiddenInMissionControl", + &BaseWindow::IsHiddenInMissionControl) + .SetMethod("setHiddenInMissionControl", + &BaseWindow::SetHiddenInMissionControl) +#endif + .SetMethod("_setTouchBarItems", &BaseWindow::SetTouchBar) .SetMethod("_refreshTouchBarItem", &BaseWindow::RefreshTouchBarItem) .SetMethod("_setEscapeTouchBarItem", &BaseWindow::SetEscapeTouchBarItem) diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index 5500006939b91..9552a13a59834 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -198,6 +198,11 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>, gfx::Point GetTrafficLightPosition() const; #endif +#if BUILDFLAG(IS_MAC) + bool IsHiddenInMissionControl(); + void SetHiddenInMissionControl(bool hidden); +#endif + void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items); void RefreshTouchBarItem(const std::string& item_id); void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item); diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index e81da9619ee90..86c17461eecc3 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -219,6 +219,12 @@ class NativeWindow : public base::SupportsUserData, virtual void UpdateFrame() = 0; #endif +// whether windows should be ignored by mission control +#if BUILDFLAG(IS_MAC) + virtual bool IsHiddenInMissionControl() = 0; + virtual void SetHiddenInMissionControl(bool hidden) = 0; +#endif + // Touchbar API virtual void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items); virtual void RefreshTouchBarItem(const std::string& item_id); diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index 390c2997b2211..6c298fef4c58d 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -102,6 +102,8 @@ class NativeWindowMac : public NativeWindow, void SetDocumentEdited(bool edited) override; bool IsDocumentEdited() override; void SetIgnoreMouseEvents(bool ignore, bool forward) override; + bool IsHiddenInMissionControl() override; + void SetHiddenInMissionControl(bool hidden) override; void SetContentProtection(bool enable) override; void SetFocusable(bool focusable) override; bool IsFocusable() override; diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 55d9d5425823c..e878c9cb73fe8 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -280,6 +280,9 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { std::string windowType; options.Get(options::kType, &windowType); + bool hiddenInMissionControl = false; + options.Get(options::kHiddenInMissionControl, &hiddenInMissionControl); + bool useStandardWindow = true; // eventually deprecate separate "standardWindow" option in favor of // standard / textured window types @@ -418,6 +421,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { options.Get(options::kDisableAutoHideCursor, &disableAutoHideCursor); [window_ setDisableAutoHideCursor:disableAutoHideCursor]; + SetHiddenInMissionControl(hiddenInMissionControl); + // Set maximizable state last to ensure zoom button does not get reset // by calls to other APIs. SetMaximizable(maximizable); @@ -1159,9 +1164,17 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { return [window_ isDocumentEdited]; } +bool NativeWindowMac::IsHiddenInMissionControl() { + NSUInteger collectionBehavior = [window_ collectionBehavior]; + return collectionBehavior & NSWindowCollectionBehaviorTransient; +} + +void NativeWindowMac::SetHiddenInMissionControl(bool hidden) { + SetCollectionBehavior(hidden, NSWindowCollectionBehaviorTransient); +} + void NativeWindowMac::SetIgnoreMouseEvents(bool ignore, bool forward) { [window_ setIgnoresMouseEvents:ignore]; - if (!ignore) { SetForwardMouseMessages(NO); } else { diff --git a/shell/common/options_switches.cc b/shell/common/options_switches.cc index 4a6bef3a694f8..a50ea98c1e780 100644 --- a/shell/common/options_switches.cc +++ b/shell/common/options_switches.cc @@ -39,6 +39,8 @@ const char kOverlaySymbolColor[] = "symbolColor"; // The custom height for Window Controls Overlay. const char kOverlayHeight[] = "height"; +// whether to keep the window out of mission control +const char kHiddenInMissionControl[] = "hiddenInMissionControl"; // Whether the window should show in taskbar. const char kSkipTaskbar[] = "skipTaskbar"; diff --git a/shell/common/options_switches.h b/shell/common/options_switches.h index 6c86d56799ac9..46f966f879c52 100644 --- a/shell/common/options_switches.h +++ b/shell/common/options_switches.h @@ -30,6 +30,7 @@ extern const char kMinimizable[]; extern const char kMaximizable[]; extern const char kFullScreenable[]; extern const char kClosable[]; +extern const char kHiddenInMissionControl[]; extern const char kFullscreen[]; extern const char kSkipTaskbar[]; extern const char kKiosk[]; diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index bc9f23940247b..c4de29de835d1 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -4774,6 +4774,24 @@ describe('BrowserWindow module', () => { }); }); + ifdescribe(process.platform === 'darwin')('isHiddenInMissionControl state', () => { + it('with functions', () => { + it('can be set with ignoreMissionControl constructor option', () => { + const w = new BrowserWindow({ show: false, hiddenInMissionControl: true }); + expect(w.isHiddenInMissionControl()).to.be.true('isHiddenInMissionControl'); + }); + + it('can be changed', () => { + const w = new BrowserWindow({ show: false }); + expect(w.isHiddenInMissionControl()).to.be.false('isHiddenInMissionControl'); + w.setHiddenInMissionControl(true); + expect(w.isHiddenInMissionControl()).to.be.true('isHiddenInMissionControl'); + w.setHiddenInMissionControl(false); + expect(w.isHiddenInMissionControl()).to.be.false('isHiddenInMissionControl'); + }); + }); + }); + // fullscreen events are dispatched eagerly and twiddling things too fast can confuse poor Electron ifdescribe(process.platform === 'darwin')('kiosk state', () => { From 4f5432e9868871f9ee678ff4461cf6441575d238 Mon Sep 17 00:00:00 2001 From: Cheng Zhao <zcbenz@gmail.com> Date: Thu, 26 Jan 2023 21:39:26 +0900 Subject: [PATCH 051/172] fix: fallback to GtkStatusIcon when app indicator is not supported (#37034) * refactor: make StatusIconType an enum class (#36554) Co-authored-by: Milan Burda <miburda@microsoft.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <miburda@microsoft.com> * fix: fallback to GtkStatusIcon when app indicator is not supported (#36815) * chore: get ready for multi backend tray * fix: fallback to GtkStatusIcon when app indicator is not supported * chore: use smart pointers Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <miburda@microsoft.com> --- BUILD.gn | 2 - docs/api/tray.md | 5 +- filenames.gni | 10 +- shell/browser/ui/gtk/menu_gtk.cc | 70 +++++++++++ shell/browser/ui/gtk/menu_gtk.h | 48 ++++++++ shell/browser/ui/status_icon_gtk.cc | 68 +++++++++++ shell/browser/ui/status_icon_gtk.h | 52 ++++++++ shell/browser/ui/tray_icon_gtk.cc | 95 --------------- shell/browser/ui/tray_icon_linux.cc | 115 ++++++++++++++++++ .../ui/{tray_icon_gtk.h => tray_icon_linux.h} | 28 +++-- 10 files changed, 380 insertions(+), 113 deletions(-) create mode 100644 shell/browser/ui/gtk/menu_gtk.cc create mode 100644 shell/browser/ui/gtk/menu_gtk.h create mode 100644 shell/browser/ui/status_icon_gtk.cc create mode 100644 shell/browser/ui/status_icon_gtk.h delete mode 100644 shell/browser/ui/tray_icon_gtk.cc create mode 100644 shell/browser/ui/tray_icon_linux.cc rename shell/browser/ui/{tray_icon_gtk.h => tray_icon_linux.h} (65%) diff --git a/BUILD.gn b/BUILD.gn index c905891eb86fc..7c1b4b6788988 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -631,8 +631,6 @@ source_set("electron_lib") { sources += [ "shell/browser/certificate_manager_model.cc", "shell/browser/certificate_manager_model.h", - "shell/browser/ui/gtk/menu_util.cc", - "shell/browser/ui/gtk/menu_util.h", "shell/browser/ui/gtk_util.cc", "shell/browser/ui/gtk_util.h", ] diff --git a/docs/api/tray.md b/docs/api/tray.md index f64d02debf93a..2514931dd0d10 100644 --- a/docs/api/tray.md +++ b/docs/api/tray.md @@ -29,8 +29,9 @@ __Platform Considerations__ __Linux__ -* Tray icon requires support of [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) - in user's desktop environment. +* Tray icon uses [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) + by default, when it is not available in user's desktop environment the + `GtkStatusIcon` will be used instead. * The `click` event is emitted when the tray icon receives activation from user, however the StatusNotifierItem spec does not specify which action would cause an activation, for some environments it is left mouse click, but for diff --git a/filenames.gni b/filenames.gni index b899c30744639..f63fa362bab98 100644 --- a/filenames.gni +++ b/filenames.gni @@ -35,9 +35,15 @@ filenames = { "shell/browser/relauncher_linux.cc", "shell/browser/ui/electron_desktop_window_tree_host_linux.cc", "shell/browser/ui/file_dialog_gtk.cc", + "shell/browser/ui/gtk/menu_gtk.cc", + "shell/browser/ui/gtk/menu_gtk.h", + "shell/browser/ui/gtk/menu_util.cc", + "shell/browser/ui/gtk/menu_util.h", "shell/browser/ui/message_box_gtk.cc", - "shell/browser/ui/tray_icon_gtk.cc", - "shell/browser/ui/tray_icon_gtk.h", + "shell/browser/ui/status_icon_gtk.cc", + "shell/browser/ui/status_icon_gtk.h", + "shell/browser/ui/tray_icon_linux.cc", + "shell/browser/ui/tray_icon_linux.h", "shell/browser/ui/views/client_frame_view_linux.cc", "shell/browser/ui/views/client_frame_view_linux.h", "shell/common/application_info_linux.cc", diff --git a/shell/browser/ui/gtk/menu_gtk.cc b/shell/browser/ui/gtk/menu_gtk.cc new file mode 100644 index 0000000000000..8e73a50569a56 --- /dev/null +++ b/shell/browser/ui/gtk/menu_gtk.cc @@ -0,0 +1,70 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "shell/browser/ui/gtk/menu_gtk.h" + +#include <gtk/gtk.h> + +#include "shell/browser/ui/gtk/menu_util.h" +#include "ui/base/models/menu_model.h" + +namespace electron { + +namespace gtkui { + +MenuGtk::MenuGtk(ui::MenuModel* model) + : menu_model_(model), gtk_menu_(TakeGObject(gtk_menu_new())) { + if (menu_model_) { + BuildSubmenuFromModel(menu_model_, gtk_menu_, + G_CALLBACK(OnMenuItemActivatedThunk), + &block_activation_, this); + Refresh(); + } +} + +MenuGtk::~MenuGtk() { + gtk_widget_destroy(gtk_menu_); +} + +void MenuGtk::Refresh() { + gtk_container_foreach(GTK_CONTAINER(gtk_menu_.get()), SetMenuItemInfo, + &block_activation_); +} + +GtkMenu* MenuGtk::GetGtkMenu() { + return GTK_MENU(gtk_menu_.get()); +} + +void MenuGtk::OnMenuItemActivated(GtkWidget* menu_item) { + if (block_activation_) + return; + + ui::MenuModel* model = ModelForMenuItem(GTK_MENU_ITEM(menu_item)); + if (!model) { + // There won't be a model for "native" submenus like the "Input Methods" + // context menu. We don't need to handle activation messages for submenus + // anyway, so we can just return here. + DCHECK(gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu_item))); + return; + } + + // The activate signal is sent to radio items as they get deselected; + // ignore it in this case. + if (GTK_IS_RADIO_MENU_ITEM(menu_item) && + !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_item))) { + return; + } + + int id; + if (!GetMenuItemID(menu_item, &id)) + return; + + // The menu item can still be activated by hotkeys even if it is disabled. + if (model->IsEnabledAt(id)) + ExecuteCommand(model, id); +} + +} // namespace gtkui + +} // namespace electron diff --git a/shell/browser/ui/gtk/menu_gtk.h b/shell/browser/ui/gtk/menu_gtk.h new file mode 100644 index 0000000000000..86ad8083d9b32 --- /dev/null +++ b/shell/browser/ui/gtk/menu_gtk.h @@ -0,0 +1,48 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_ +#define ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_ + +#include "base/callback.h" +#include "base/memory/raw_ptr.h" +#include "ui/base/glib/glib_signal.h" +#include "ui/base/glib/scoped_gobject.h" + +typedef struct _GtkMenu GtkMenu; +typedef struct _GtkWidget GtkWidget; + +namespace ui { +class MenuModel; +} + +namespace electron { + +namespace gtkui { + +class MenuGtk { + public: + explicit MenuGtk(ui::MenuModel* model); + virtual ~MenuGtk(); + + // Refreshes all the menu item labels and menu item checked/enabled states. + void Refresh(); + + GtkMenu* GetGtkMenu(); + + private: + // Callback for when a menu item is activated. + CHROMEG_CALLBACK_0(MenuGtk, void, OnMenuItemActivated, GtkWidget*); + + raw_ptr<ui::MenuModel> menu_model_; // not owned + ScopedGObject<GtkWidget> gtk_menu_; + + bool block_activation_ = false; +}; + +} // namespace gtkui + +} // namespace electron + +#endif // ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_ diff --git a/shell/browser/ui/status_icon_gtk.cc b/shell/browser/ui/status_icon_gtk.cc new file mode 100644 index 0000000000000..1c8d0024c92e5 --- /dev/null +++ b/shell/browser/ui/status_icon_gtk.cc @@ -0,0 +1,68 @@ +// Copyright (c) 2023 Microsoft, Inc. +// Copyright (c) 2011 The Chromium Authors. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/browser/ui/status_icon_gtk.h" + +#include <gtk/gtk.h> + +#include "base/strings/utf_string_conversions.h" +#include "shell/browser/ui/gtk/menu_gtk.h" +#include "shell/browser/ui/gtk_util.h" +#include "ui/gfx/image/image_skia.h" + +namespace electron { + +StatusIconGtk::StatusIconGtk() : icon_(TakeGObject(gtk_status_icon_new())) { + g_signal_connect(icon_, "activate", G_CALLBACK(OnClickThunk), this); + g_signal_connect(icon_, "popup_menu", G_CALLBACK(OnContextMenuRequestedThunk), + this); +} + +StatusIconGtk::~StatusIconGtk() = default; + +void StatusIconGtk::SetIcon(const gfx::ImageSkia& image) { + if (image.isNull()) + return; + + GdkPixbuf* pixbuf = gtk_util::GdkPixbufFromSkBitmap(*image.bitmap()); + gtk_status_icon_set_from_pixbuf(icon_, pixbuf); + g_object_unref(pixbuf); +} + +void StatusIconGtk::SetToolTip(const std::u16string& tool_tip) { + gtk_status_icon_set_tooltip_text(icon_, base::UTF16ToUTF8(tool_tip).c_str()); +} + +void StatusIconGtk::UpdatePlatformContextMenu(ui::MenuModel* model) { + if (model) + menu_ = std::make_unique<gtkui::MenuGtk>(model); +} + +void StatusIconGtk::RefreshPlatformContextMenu() { + if (menu_) + menu_->Refresh(); +} + +void StatusIconGtk::OnSetDelegate() { + SetIcon(delegate_->GetImage()); + SetToolTip(delegate_->GetToolTip()); + UpdatePlatformContextMenu(delegate_->GetMenuModel()); + gtk_status_icon_set_visible(icon_, TRUE); +} + +void StatusIconGtk::OnClick(GtkStatusIcon* status_icon) { + delegate_->OnClick(); +} + +void StatusIconGtk::OnContextMenuRequested(GtkStatusIcon* status_icon, + guint button, + guint32 activate_time) { + if (menu_.get()) { + gtk_menu_popup(menu_->GetGtkMenu(), nullptr, nullptr, + gtk_status_icon_position_menu, icon_, button, activate_time); + } +} + +} // namespace electron diff --git a/shell/browser/ui/status_icon_gtk.h b/shell/browser/ui/status_icon_gtk.h new file mode 100644 index 0000000000000..beeff7593043c --- /dev/null +++ b/shell/browser/ui/status_icon_gtk.h @@ -0,0 +1,52 @@ +// Copyright (c) 2023 Microsoft, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef ELECTRON_SHELL_BROWSER_UI_STATUS_ICON_GTK_H_ +#define ELECTRON_SHELL_BROWSER_UI_STATUS_ICON_GTK_H_ + +#include <memory> + +#include "ui/base/glib/glib_integers.h" +#include "ui/base/glib/glib_signal.h" +#include "ui/base/glib/scoped_gobject.h" +#include "ui/linux/status_icon_linux.h" + +typedef struct _GtkStatusIcon GtkStatusIcon; + +namespace electron { + +namespace gtkui { +class MenuGtk; +} + +class StatusIconGtk : public ui::StatusIconLinux { + public: + StatusIconGtk(); + StatusIconGtk(const StatusIconGtk&) = delete; + StatusIconGtk& operator=(const StatusIconGtk&) = delete; + ~StatusIconGtk() override; + + // ui::StatusIconLinux: + void SetIcon(const gfx::ImageSkia& image) override; + void SetToolTip(const std::u16string& tool_tip) override; + void UpdatePlatformContextMenu(ui::MenuModel* model) override; + void RefreshPlatformContextMenu() override; + void OnSetDelegate() override; + + private: + CHROMEG_CALLBACK_0(StatusIconGtk, void, OnClick, GtkStatusIcon*); + CHROMEG_CALLBACK_2(StatusIconGtk, + void, + OnContextMenuRequested, + GtkStatusIcon*, + guint, + guint); + + std::unique_ptr<gtkui::MenuGtk> menu_; + ScopedGObject<GtkStatusIcon> icon_; +}; + +} // namespace electron + +#endif // ELECTRON_SHELL_BROWSER_UI_STATUS_ICON_GTK_H_ diff --git a/shell/browser/ui/tray_icon_gtk.cc b/shell/browser/ui/tray_icon_gtk.cc deleted file mode 100644 index 4302a45d2e302..0000000000000 --- a/shell/browser/ui/tray_icon_gtk.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/browser/ui/tray_icon_gtk.h" - -#include "base/strings/utf_string_conversions.h" -#include "chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h" -#include "ui/gfx/image/image_skia_rep.h" - -namespace electron { - -namespace { - -gfx::ImageSkia GetBestImageRep(const gfx::ImageSkia& image) { - image.EnsureRepsForSupportedScales(); - float best_scale = 0.0f; - SkBitmap best_rep; - for (const auto& rep : image.image_reps()) { - if (rep.scale() > best_scale) { - best_scale = rep.scale(); - best_rep = rep.GetBitmap(); - } - } - // All status icon implementations want the image in pixel coordinates, so use - // a scale factor of 1. - return gfx::ImageSkia::CreateFromBitmap(best_rep, 1.0f); -} - -} // namespace - -TrayIconGtk::TrayIconGtk() - : status_icon_(new StatusIconLinuxDbus), status_icon_type_(kTypeDbus) { - status_icon_->SetDelegate(this); -} - -TrayIconGtk::~TrayIconGtk() = default; - -void TrayIconGtk::SetImage(const gfx::Image& image) { - image_ = GetBestImageRep(image.AsImageSkia()); - if (status_icon_) - status_icon_->SetIcon(image_); -} - -void TrayIconGtk::SetToolTip(const std::string& tool_tip) { - tool_tip_ = base::UTF8ToUTF16(tool_tip); - if (status_icon_) - status_icon_->SetToolTip(tool_tip_); -} - -void TrayIconGtk::SetContextMenu(ElectronMenuModel* menu_model) { - menu_model_ = menu_model; - if (status_icon_) - status_icon_->UpdatePlatformContextMenu(menu_model_); -} - -const gfx::ImageSkia& TrayIconGtk::GetImage() const { - return image_; -} - -const std::u16string& TrayIconGtk::GetToolTip() const { - return tool_tip_; -} - -ui::MenuModel* TrayIconGtk::GetMenuModel() const { - return menu_model_; -} - -void TrayIconGtk::OnImplInitializationFailed() { - switch (status_icon_type_) { - case kTypeDbus: - status_icon_ = nullptr; - status_icon_type_ = kTypeNone; - return; - case kTypeNone: - NOTREACHED(); - } -} - -void TrayIconGtk::OnClick() { - NotifyClicked(); -} - -bool TrayIconGtk::HasClickAction() { - // Returning true will make the tooltip show as an additional context menu - // item, which makes sense in Chrome but not in most Electron apps. - return false; -} - -// static -TrayIcon* TrayIcon::Create(absl::optional<UUID> guid) { - return new TrayIconGtk; -} - -} // namespace electron diff --git a/shell/browser/ui/tray_icon_linux.cc b/shell/browser/ui/tray_icon_linux.cc new file mode 100644 index 0000000000000..6f0a9e1dc50ff --- /dev/null +++ b/shell/browser/ui/tray_icon_linux.cc @@ -0,0 +1,115 @@ +// Copyright (c) 2014 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/browser/ui/tray_icon_linux.h" + +#include "base/strings/utf_string_conversions.h" +#include "chrome/browser/ui/views/status_icons/status_icon_linux_dbus.h" +#include "shell/browser/ui/status_icon_gtk.h" +#include "ui/gfx/image/image_skia_rep.h" + +namespace electron { + +namespace { + +gfx::ImageSkia GetBestImageRep(const gfx::ImageSkia& image) { + image.EnsureRepsForSupportedScales(); + float best_scale = 0.0f; + SkBitmap best_rep; + for (const auto& rep : image.image_reps()) { + if (rep.scale() > best_scale) { + best_scale = rep.scale(); + best_rep = rep.GetBitmap(); + } + } + // All status icon implementations want the image in pixel coordinates, so use + // a scale factor of 1. + return gfx::ImageSkia::CreateFromBitmap(best_rep, 1.0f); +} + +} // namespace + +TrayIconLinux::TrayIconLinux() + : status_icon_dbus_(new StatusIconLinuxDbus), + status_icon_type_(StatusIconType::kDbus) { + status_icon_dbus_->SetDelegate(this); +} + +TrayIconLinux::~TrayIconLinux() = default; + +void TrayIconLinux::SetImage(const gfx::Image& image) { + image_ = GetBestImageRep(image.AsImageSkia()); + if (auto* status_icon = GetStatusIcon()) + status_icon->SetIcon(image_); +} + +void TrayIconLinux::SetToolTip(const std::string& tool_tip) { + tool_tip_ = base::UTF8ToUTF16(tool_tip); + if (auto* status_icon = GetStatusIcon()) + status_icon->SetToolTip(tool_tip_); +} + +void TrayIconLinux::SetContextMenu(ElectronMenuModel* menu_model) { + menu_model_ = menu_model; + if (auto* status_icon = GetStatusIcon()) + status_icon->UpdatePlatformContextMenu(menu_model_); +} + +const gfx::ImageSkia& TrayIconLinux::GetImage() const { + return image_; +} + +const std::u16string& TrayIconLinux::GetToolTip() const { + return tool_tip_; +} + +ui::MenuModel* TrayIconLinux::GetMenuModel() const { + return menu_model_; +} + +void TrayIconLinux::OnImplInitializationFailed() { + switch (status_icon_type_) { + case StatusIconType::kDbus: + status_icon_dbus_.reset(); + status_icon_gtk_ = std::make_unique<StatusIconGtk>(); + status_icon_type_ = StatusIconType::kGtk; + status_icon_gtk_->SetDelegate(this); + return; + case StatusIconType::kGtk: + status_icon_gtk_.reset(); + status_icon_type_ = StatusIconType::kNone; + menu_model_ = nullptr; + return; + case StatusIconType::kNone: + NOTREACHED(); + } +} + +void TrayIconLinux::OnClick() { + NotifyClicked(); +} + +bool TrayIconLinux::HasClickAction() { + // Returning true will make the tooltip show as an additional context menu + // item, which makes sense in Chrome but not in most Electron apps. + return false; +} + +ui::StatusIconLinux* TrayIconLinux::GetStatusIcon() { + switch (status_icon_type_) { + case StatusIconType::kDbus: + return status_icon_dbus_.get(); + case StatusIconType::kGtk: + return status_icon_gtk_.get(); + case StatusIconType::kNone: + return nullptr; + } +} + +// static +TrayIcon* TrayIcon::Create(absl::optional<UUID> guid) { + return new TrayIconLinux; +} + +} // namespace electron diff --git a/shell/browser/ui/tray_icon_gtk.h b/shell/browser/ui/tray_icon_linux.h similarity index 65% rename from shell/browser/ui/tray_icon_gtk.h rename to shell/browser/ui/tray_icon_linux.h index 11feec449a717..76b94433aa946 100644 --- a/shell/browser/ui/tray_icon_gtk.h +++ b/shell/browser/ui/tray_icon_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#ifndef ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_GTK_H_ -#define ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_GTK_H_ +#ifndef ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_LINUX_H_ +#define ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_LINUX_H_ #include <memory> #include <string> @@ -15,10 +15,12 @@ class StatusIconLinuxDbus; namespace electron { -class TrayIconGtk : public TrayIcon, public ui::StatusIconLinux::Delegate { +class StatusIconGtk; + +class TrayIconLinux : public TrayIcon, public ui::StatusIconLinux::Delegate { public: - TrayIconGtk(); - ~TrayIconGtk() override; + TrayIconLinux(); + ~TrayIconLinux() override; // TrayIcon: void SetImage(const gfx::Image& image) override; @@ -28,20 +30,22 @@ class TrayIconGtk : public TrayIcon, public ui::StatusIconLinux::Delegate { // ui::StatusIconLinux::Delegate void OnClick() override; bool HasClickAction() override; - // The following four methods are only used by StatusIconLinuxDbus, which we - // aren't yet using, so they are given stub implementations. const gfx::ImageSkia& GetImage() const override; const std::u16string& GetToolTip() const override; ui::MenuModel* GetMenuModel() const override; void OnImplInitializationFailed() override; private: - enum StatusIconType { - kTypeDbus, - kTypeNone, + enum class StatusIconType { + kDbus, + kGtk, + kNone, }; - scoped_refptr<StatusIconLinuxDbus> status_icon_; + ui::StatusIconLinux* GetStatusIcon(); + + scoped_refptr<StatusIconLinuxDbus> status_icon_dbus_; + std::unique_ptr<StatusIconGtk> status_icon_gtk_; StatusIconType status_icon_type_; gfx::ImageSkia image_; @@ -51,4 +55,4 @@ class TrayIconGtk : public TrayIcon, public ui::StatusIconLinux::Delegate { } // namespace electron -#endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_GTK_H_ +#endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_LINUX_H_ From 5ed0f95d8f65e3673b751c1431bb2439cf8ea386 Mon Sep 17 00:00:00 2001 From: "electron-roller[bot]" <84116207+electron-roller[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 16:18:05 -0500 Subject: [PATCH 052/172] chore: bump chromium to 108.0.5359.215 (22-x-y) (#37019) * chore: bump chromium in DEPS to 108.0.5359.215 * chore: update patches Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- DEPS | 2 +- patches/chromium/printing.patch | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DEPS b/DEPS index 1d2379c254a78..2e1de773529cd 100644 --- a/DEPS +++ b/DEPS @@ -2,7 +2,7 @@ gclient_gn_args_from = 'src' vars = { 'chromium_version': - '108.0.5359.179', + '108.0.5359.215', 'node_version': 'v16.17.1', 'nan_version': diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index 7c352bf0d4750..99282982ac061 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -796,10 +796,10 @@ index 51a5497b809cda82b223138f43507172a9f066ae..71227492fd87e577518f3bf55ded37b0 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Set options for print preset from source PDF document. diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn -index 18328bedfdd0dc735126f7541ee7ed3e736d94b0..e5e28db9a970b49ac5624c59cbaeed9aff5e52d8 100644 +index a73daeeb4b6397db6fff9a9b552007204a376fb5..61454cd1b6e1c3c1d1ee1b901c499d9c802aec81 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn -@@ -2821,8 +2821,9 @@ source_set("browser") { +@@ -2823,8 +2823,9 @@ source_set("browser") { "//ppapi/shared_impl", ] From 21082ae2fb1712b560aa6074b1d4c1249198395b Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 30 Jan 2023 10:58:31 +0100 Subject: [PATCH 053/172] docs: updated deep link docs (#37032) --- .../launch-app-from-URL-in-another-app/main.js | 2 ++ docs/tutorial/launch-app-from-url-in-another-app.md | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js index 5a3b553612de3..6e875809301cd 100644 --- a/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js +++ b/docs/fiddles/system/protocol-handler/launch-app-from-URL-in-another-app/main.js @@ -23,6 +23,8 @@ if (!gotTheLock) { if (mainWindow.isMinimized()) mainWindow.restore() mainWindow.focus() } + + dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop().slice(0,-1)}`) }) // Create mainWindow, load the rest of the app, etc... diff --git a/docs/tutorial/launch-app-from-url-in-another-app.md b/docs/tutorial/launch-app-from-url-in-another-app.md index d99c1f9503342..33b08ea772b66 100644 --- a/docs/tutorial/launch-app-from-url-in-another-app.md +++ b/docs/tutorial/launch-app-from-url-in-another-app.md @@ -61,7 +61,7 @@ const createWindow = () => { In this next step, we will create our `BrowserWindow` and tell our application how to handle an event in which an external protocol is clicked. -This code will be different in Windows compared to MacOS and Linux. This is due to Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](https://www.electronjs.org/docs/api/app#apprequestsingleinstancelock). +This code will be different in Windows compared to MacOS and Linux. This is due to Windows requiring additional code in order to open the contents of the protocol link within the same Electron instance. Read more about this [here](../api/app.md#apprequestsingleinstancelockadditionaldata). #### Windows code: @@ -77,17 +77,15 @@ if (!gotTheLock) { if (mainWindow.isMinimized()) mainWindow.restore() mainWindow.focus() } + // the commandLine is array of strings in which last element is deep link url + // the url str ends with / + dialog.showErrorBox('Welcome Back', `You arrived from: ${commandLine.pop().slice(0, -1)}`) }) // Create mainWindow, load the rest of the app, etc... app.whenReady().then(() => { createWindow() }) - - // Handle the protocol. In this case, we choose to show an Error Box. - app.on('open-url', (event, url) => { - dialog.showErrorBox('Welcome Back', `You arrived from: ${url}`) - }) } ``` From fe3baa83d6d899efb7f3c965e065985a994ebca3 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 31 Jan 2023 12:36:58 -0500 Subject: [PATCH 054/172] ci: ensure correct ninja is used (#37071) * ci: ensure correct ninja is used Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> * chore: remove no longer needed patch * ci: fixup ninja for release (cherry picked from commit 78b83864cd906a03e56eb77efd717c1eb252417d) --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- .circleci/config/base.yml | 15 ++- appveyor-woa.yml | 3 + appveyor.yml | 3 + patches/chromium/.patches | 1 - .../chromium/cherry-pick-57c54ae221d6.patch | 97 ------------------- 5 files changed, 16 insertions(+), 103 deletions(-) delete mode 100644 patches/chromium/cherry-pick-57c54ae221d6.patch diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 036b225447227..0e6f8031a9827 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -484,7 +484,9 @@ step-fix-sync: &step-fix-sync run: name: Fix Sync command: | + SEDOPTION="-i" if [ "`uname`" == "Darwin" ]; then + SEDOPTION="-i ''" # Fix Clang Install (wrong binary) rm -rf src/third_party/llvm-build python3 src/tools/clang/scripts/update.py @@ -494,13 +496,16 @@ step-fix-sync: &step-fix-sync # Remove extra output from calling gclient getdep which always calls update_depot_tools sed -i '' "s/Updating depot_tools... //g" esbuild_ensure_file cipd ensure --root src/third_party/devtools-frontend/src/third_party/esbuild -ensure-file esbuild_ensure_file - - # Fix ninja (wrong binary) - echo 'infra/3pp/tools/ninja/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/tools/ninja/${platform}'` > ninja_ensure_file - sed -i '' "s/Updating depot_tools... //g" ninja_ensure_file - cipd ensure --root src/third_party/ninja -ensure-file ninja_ensure_file fi + # Make sure we are using the right ninja + echo 'infra/3pp/tools/ninja/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/tools/ninja/${platform}'` > ninja_ensure_file + sed $SEDOPTION "s/Updating depot_tools... //g" ninja_ensure_file + cipd ensure --root src/third_party/ninja -ensure-file ninja_ensure_file + + # Explicitly add ninja to the path + echo 'export PATH="$PATH:'"$PWD"'/src/third_party/ninja"' >> $BASH_ENV + cd src/third_party/angle rm .git/objects/info/alternates git remote set-url origin https://chromium.googlesource.com/angle/angle.git diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 4b711509dc53f..4d9dc6f71ab27 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -51,6 +51,8 @@ environment: clone_folder: C:\projects\src\electron +skip_branch_with_pr: true + # the first failed job cancels other jobs and fails entire build matrix: fast_finish: true @@ -130,6 +132,7 @@ for: } - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks ) - cd src + - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH" - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% " - gn check out/Default //electron:electron_lib diff --git a/appveyor.yml b/appveyor.yml index 20c527f1a46b9..c2df5019bea81 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,6 +49,8 @@ environment: clone_folder: C:\projects\src\electron +skip_branch_with_pr: true + # the first failed job cancels other jobs and fails entire build matrix: fast_finish: true @@ -128,6 +130,7 @@ for: } - if "%RUN_GCLIENT_SYNC%"=="true" ( gclient sync --with_branch_heads --with_tags ) else ( gclient runhooks ) - cd src + - ps: $env:PATH="$pwd\third_party\ninja;$env:PATH" - set BUILD_CONFIG_PATH=//electron/build/args/%GN_CONFIG%.gn - gn gen out/Default "--args=import(\"%BUILD_CONFIG_PATH%\") import(\"%GN_GOMA_FILE%\") %GN_EXTRA_ARGS% " - gn check out/Default //electron:electron_lib diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 1646f6b2fdff0..270124491cc3a 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -127,4 +127,3 @@ cherry-pick-3235c1d1955b.patch expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch -cherry-pick-57c54ae221d6.patch diff --git a/patches/chromium/cherry-pick-57c54ae221d6.patch b/patches/chromium/cherry-pick-57c54ae221d6.patch deleted file mode 100644 index b632c5b6e2dc3..0000000000000 --- a/patches/chromium/cherry-pick-57c54ae221d6.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Victor Vasiliev <vasilvv@chromium.org> -Date: Wed, 21 Dec 2022 17:26:42 +0000 -Subject: Ensure clean destruction of network::WebTransport - -Once the destruction of the object begins, we should not process any -callbacks, nor should we attempt to reset the streams on a connection -that is already being closed. - -Bug: 1376354 -Change-Id: Ib49e0ce0b177062cccd0e52368782e291cf8166c -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4117501 -Reviewed-by: Eric Orth <ericorth@chromium.org> -Commit-Queue: Victor Vasiliev <vasilvv@chromium.org> -Cr-Commit-Position: refs/heads/main@{#1085965} - -diff --git a/services/network/web_transport.cc b/services/network/web_transport.cc -index 8ddbeb9473cb94ebcc64286797ae574ca08d1001..cd92d0f26b23229aeb1e415b81165b2ebf05452f 100644 ---- a/services/network/web_transport.cc -+++ b/services/network/web_transport.cc -@@ -177,7 +177,7 @@ class WebTransport::Stream final { - - ~Stream() { - auto* stream = incoming_ ? incoming_.get() : outgoing_.get(); -- if (!stream) { -+ if (!stream || transport_->closing_ || transport_->torn_down_) { - return; - } - stream->MaybeResetDueToStreamObjectGone(); -@@ -399,7 +399,10 @@ WebTransport::WebTransport( - transport_->Connect(); - } - --WebTransport::~WebTransport() = default; -+WebTransport::~WebTransport() { -+ // Ensure that we ignore all callbacks while mid-destruction. -+ torn_down_ = true; -+} - - void WebTransport::SendDatagram(base::span<const uint8_t> data, - base::OnceCallback<void(bool)> callback) { -diff --git a/services/network/web_transport_unittest.cc b/services/network/web_transport_unittest.cc -index 81bf26f9e0509e8c56160042519f9ea9034c68df..1a9e6bcfef8b5f7cb642412cb59381c5082e2c19 100644 ---- a/services/network/web_transport_unittest.cc -+++ b/services/network/web_transport_unittest.cc -@@ -610,6 +610,51 @@ TEST_F(WebTransportTest, EchoOnUnidirectionalStreams) { - EXPECT_EQ(0u, resets_sent.size()); - } - -+TEST_F(WebTransportTest, DeleteClientWithStreamsOpen) { -+ base::RunLoop run_loop_for_handshake; -+ mojo::PendingRemote<mojom::WebTransportHandshakeClient> handshake_client; -+ TestHandshakeClient test_handshake_client( -+ handshake_client.InitWithNewPipeAndPassReceiver(), -+ run_loop_for_handshake.QuitClosure()); -+ -+ CreateWebTransport(GetURL("/echo"), -+ url::Origin::Create(GURL("https://example.org/")), -+ std::move(handshake_client)); -+ -+ run_loop_for_handshake.Run(); -+ -+ ASSERT_TRUE(test_handshake_client.has_seen_connection_establishment()); -+ -+ TestClient client(test_handshake_client.PassClientReceiver()); -+ mojo::Remote<mojom::WebTransport> transport_remote( -+ test_handshake_client.PassTransport()); -+ -+ constexpr int kNumStreams = 10; -+ auto writable_for_outgoing = -+ std::make_unique<mojo::ScopedDataPipeProducerHandle[]>(kNumStreams); -+ for (int i = 0; i < kNumStreams; i++) { -+ const MojoCreateDataPipeOptions options = { -+ sizeof(options), MOJO_CREATE_DATA_PIPE_FLAG_NONE, 1, 4 * 1024}; -+ mojo::ScopedDataPipeConsumerHandle readable_for_outgoing; -+ ASSERT_EQ(MOJO_RESULT_OK, -+ mojo::CreateDataPipe(&options, writable_for_outgoing[i], -+ readable_for_outgoing)); -+ base::RunLoop run_loop_for_stream_creation; -+ bool stream_created; -+ transport_remote->CreateStream( -+ std::move(readable_for_outgoing), -+ /*writable=*/{}, -+ base::BindLambdaForTesting([&](bool b, uint32_t /*id*/) { -+ stream_created = b; -+ run_loop_for_stream_creation.Quit(); -+ })); -+ run_loop_for_stream_creation.Run(); -+ ASSERT_TRUE(stream_created); -+ } -+ -+ // Keep the streams open so that they are closed via destructor. -+} -+ - // crbug.com/1129847: disabled because it is flaky. - TEST_F(WebTransportTest, DISABLED_EchoOnBidirectionalStream) { - base::RunLoop run_loop_for_handshake; From 1106ca998ba381c9b642f99c2f7a011263e9b82f Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 20:53:26 +0900 Subject: [PATCH 055/172] feat: enable whole-program optimization native modules by default (#37047) * feat: enable whole-program optimization Enable whole-program optimization in electron native modules by default. Co-authored-by: Kyrylo Hrechykhin <khrechykhin@microsoft.com> * pass --with-ltcg to configure.py instead of setting variable Co-authored-by: Kyrylo Hrechykhin <khrechykhin@microsoft.com> * enable ltcg only on windows Co-authored-by: Kyrylo Hrechykhin <khrechykhin@microsoft.com> * chore: update patches --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Kyrylo Hrechykhin <khrechykhin@microsoft.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- script/generate-config-gypi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/generate-config-gypi.py b/script/generate-config-gypi.py index 7a3ea6808b42a..8a6f23095234b 100755 --- a/script/generate-config-gypi.py +++ b/script/generate-config-gypi.py @@ -21,6 +21,10 @@ def run_node_configure(target_cpu): # Work around "No acceptable ASM compiler found" error on some System, # it breaks nothing since Electron does not use OpenSSL. args += ['--openssl-no-asm'] + + # Enable whole-program optimization for electron native modules. + if sys.platform == "win32": + args += ['--with-ltcg'] subprocess.check_call([sys.executable, configure] + args) def read_node_config_gypi(): From ab5a5b616f48761c133a41c54b909292960ad7f0 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 20:54:02 +0900 Subject: [PATCH 056/172] docs: remove invalid appcache value from storages in clearStorageData() (#37107) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <milan.burda@gmail.com> --- docs/api/session.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/session.md b/docs/api/session.md index b3629fc617817..94953f0f0387d 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -449,7 +449,7 @@ Clears the session’s HTTP cache. * `origin` string (optional) - Should follow `window.location.origin`’s representation `scheme://host:port`. * `storages` string[] (optional) - The types of storages to clear, can contain: - `appcache`, `cookies`, `filesystem`, `indexdb`, `localstorage`, + `cookies`, `filesystem`, `indexdb`, `localstorage`, `shadercache`, `websql`, `serviceworkers`, `cachestorage`. If not specified, clear all storage types. * `quotas` string[] (optional) - The types of quotas to clear, can contain: From 120fd04f7fdb187e47371d6a209cfcc17b82f7d2 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 14:31:59 +0100 Subject: [PATCH 057/172] docs: use automatic link syntax for symbol server link (#37119) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --- docs/development/debugging-with-symbol-server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development/debugging-with-symbol-server.md b/docs/development/debugging-with-symbol-server.md index 336eb7a54f3f9..0663675306ae2 100644 --- a/docs/development/debugging-with-symbol-server.md +++ b/docs/development/debugging-with-symbol-server.md @@ -15,7 +15,7 @@ calls, and other compiler optimizations. The only workaround is to build an unoptimized local build. The official symbol server URL for Electron is -https://symbols.electronjs.org. +<https://symbols.electronjs.org>. You cannot visit this URL directly, you must add it to the symbol path of your debugging tool. In the examples below, a local cache directory is used to avoid repeatedly fetching the PDB from the server. Replace `c:\code\symbols` with an From dfa48d673f18ff691dad08004d1a96bf75b235a1 Mon Sep 17 00:00:00 2001 From: David Sanders <dsanders11@ucsbalum.com> Date: Mon, 6 Feb 2023 08:56:38 -0800 Subject: [PATCH 058/172] build: fixup release_dependency_versions action (#37111) * build: update release deps workflow * build: fixup release_dependency_versions action --------- Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- .../workflows/release_dependency_versions.yml | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release_dependency_versions.yml b/.github/workflows/release_dependency_versions.yml index 00db1ba079d59..c6dd4cd35031e 100644 --- a/.github/workflows/release_dependency_versions.yml +++ b/.github/workflows/release_dependency_versions.yml @@ -8,24 +8,26 @@ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - check_tag: + trigger_chromedriver: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Check Tag + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag: v3 + - name: Trigger New chromedriver Release run: | - if [[ ${{ github.event.release.tag_name }} =~ ^v[0-9]+\.0\.0$ ]]; then - echo ::set-output name=should_release::true + if [[ ${{ github.event.release.tag_name }} =~ ^v\d+\.\d+\.\d+$ ]]; then + gh api /repos/:owner/chromedriver/actions/workflows/release.yml/dispatches --input - <<< '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}"}}' + else + echo "Not releasing for version ${{ github.event.release.tag_name }}" fi - trigger: + + trigger_mksnapshot: runs-on: ubuntu-latest - needs: check_tag - if: needs.check_tag.outputs.should_release == 'true' steps: - - uses: actions/checkout@v3 - - name: Trigger New chromedriver Release - run: | - gh api /repos/:owner/chromedriver/actions/workflows/release.yml/dispatches --input - <<< '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}"}}' + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag: v3 - name: Trigger New mksnapshot Release run: | - gh api /repos/:owner/mksnapshot/actions/workflows/release.yml/dispatches --input - <<< '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}"}}' + if [[ ${{ github.event.release.tag_name }} =~ ^v\d+\.\d+\.\d+$ ]]; then + gh api /repos/:owner/mksnapshot/actions/workflows/release.yml/dispatches --input - <<< '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}"}}' + else + echo "Not releasing for version ${{ github.event.release.tag_name }}" + fi From 0e508d9c985d2344028d3eede83e7e33e95d73cf Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:03:36 +0100 Subject: [PATCH 059/172] fix: nodeIntegrationInWorker fails to boot in AudioWorklets (#37102) fix: nodeIntegrationInWorker in AudioWorklets Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> --- lib/worker/init.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/worker/init.ts b/lib/worker/init.ts index 6a5b11495a8f4..5c537892caa35 100644 --- a/lib/worker/init.ts +++ b/lib/worker/init.ts @@ -21,8 +21,9 @@ global.module = new Module('electron/js2c/worker_init'); global.require = makeRequireFunction(global.module); // Set the __filename to the path of html file if it is file: protocol. -if (self.location.protocol === 'file:') { - const pathname = process.platform === 'win32' && self.location.pathname[0] === '/' ? self.location.pathname.substr(1) : self.location.pathname; +// NB. 'self' isn't defined in an AudioWorklet. +if (typeof self !== 'undefined' && self.location.protocol === 'file:') { + const pathname = process.platform === 'win32' && self?.location.pathname[0] === '/' ? self?.location.pathname.substr(1) : self?.location.pathname; global.__filename = path.normalize(decodeURIComponent(pathname)); global.__dirname = path.dirname(global.__filename); From dcc99ecb198c60033cdb04b0e3d462ac9a93cd55 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:34:03 -0500 Subject: [PATCH 060/172] docs: use relative links within docs (#37160) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --- docs/tutorial/forge-overview.md | 2 +- docs/tutorial/launch-app-from-url-in-another-app.md | 2 +- docs/tutorial/tray.md | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/tutorial/forge-overview.md b/docs/tutorial/forge-overview.md index 0ec6872ce7fc2..0790e07ed56a5 100644 --- a/docs/tutorial/forge-overview.md +++ b/docs/tutorial/forge-overview.md @@ -33,4 +33,4 @@ template and submit a new issue. [(publish)]: https://www.electronforge.io/cli#publish [GitHub issue tracker]: https://github.com/electron/forge/issues [discord]: https://discord.gg/APGC3k5yaH -[tutorial]: https://www.electronjs.org/docs/latest/tutorial/tutorial-prerequisites +[tutorial]: ./tutorial-1-prerequisites.md diff --git a/docs/tutorial/launch-app-from-url-in-another-app.md b/docs/tutorial/launch-app-from-url-in-another-app.md index 33b08ea772b66..7ed98d34542f0 100644 --- a/docs/tutorial/launch-app-from-url-in-another-app.md +++ b/docs/tutorial/launch-app-from-url-in-another-app.md @@ -12,7 +12,7 @@ hide_title: true <!-- ✍ Update this section if you want to provide more details --> This guide will take you through the process of setting your Electron app as the default -handler for a specific [protocol](https://www.electronjs.org/docs/api/protocol). +handler for a specific [protocol](../api/protocol.md). By the end of this tutorial, we will have set our app to intercept and handle any clicked URLs that start with a specific protocol. In this guide, the protocol diff --git a/docs/tutorial/tray.md b/docs/tutorial/tray.md index 1f0c8e6b6fc88..efa7e2e7a29ab 100644 --- a/docs/tutorial/tray.md +++ b/docs/tutorial/tray.md @@ -13,7 +13,7 @@ hide_title: true <!-- ✍ Update this section if you want to provide more details --> This guide will take you through the process of creating a -[Tray](https://www.electronjs.org/docs/api/tray) icon with +[Tray](../api/tray.md) icon with its own context menu to the system's notification area. On MacOS and Ubuntu, the Tray will be located on the top @@ -31,11 +31,11 @@ const { app, Tray, Menu, nativeImage } = require('electron') ``` Next we will create our Tray. To do this, we will use a -[`NativeImage`](https://www.electronjs.org/docs/api/native-image) icon, +[`NativeImage`](../api/native-image.md) icon, which can be created through any one of these -[methods](https://www.electronjs.org/docs/api/native-image#methods). +[methods](../api/native-image.md#methods). Note that we wrap our Tray creation code within an -[`app.whenReady`](https://www.electronjs.org/docs/api/app#appwhenready) +[`app.whenReady`](../api/app.md#appwhenready) as we will need to wait for our electron app to finish initializing. ```js title='main.js' @@ -64,7 +64,7 @@ tray.setContextMenu(contextMenu) The code above will create 4 separate radio-type items in the context menu. To read more about constructing native menus, click -[here](https://www.electronjs.org/docs/api/menu#menubuildfromtemplatetemplate). +[here](../api/menu.md#menubuildfromtemplatetemplate). Finally, let's give our tray a tooltip and a title. From fc2261f159dc8afd1b1e0aba508fdc42e9e24be5 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:01:49 -0500 Subject: [PATCH 061/172] fix: enable basic a11y when voice control is active (#37146) * fix: enable basic a11y when voice control is active c.f. https://chromium-review.googlesource.com/c/chromium/src/+/2680102 Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * Update shell/browser/mac/electron_application.mm Co-authored-by: Robo <hop2deep@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: Robo <hop2deep@gmail.com> --- shell/browser/mac/electron_application.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell/browser/mac/electron_application.mm b/shell/browser/mac/electron_application.mm index d6ff91475e75e..1c37483834ae9 100644 --- a/shell/browser/mac/electron_application.mm +++ b/shell/browser/mac/electron_application.mm @@ -193,6 +193,18 @@ - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { return [super accessibilitySetValue:value forAttribute:attribute]; } +- (NSAccessibilityRole)accessibilityRole { + // For non-VoiceOver AT, such as Voice Control, Apple recommends turning on + // a11y when an AT accesses the 'accessibilityRole' property. This function + // is accessed frequently so we only change the accessibility state when + // accessibility is disabled. + auto* ax_state = content::BrowserAccessibilityState::GetInstance(); + if (!ax_state->GetAccessibilityMode().has_mode(ui::kAXModeBasic.mode())) { + ax_state->AddAccessibilityModeFlags(ui::kAXModeBasic); + } + return [super accessibilityRole]; +} + - (void)orderFrontStandardAboutPanel:(id)sender { electron::Browser::Get()->ShowAboutPanel(); } From 62e9ffab9b98858f32dc4c0b68dee8778bbc4b6c Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:34:58 +0100 Subject: [PATCH 062/172] fix: expose native bindings by process type (#37175) * fix: expose native bindings by process type Co-authored-by: Milan Burda <milan.burda@gmail.com> * fix test * fix test --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <milan.burda@gmail.com> --- docs/development/creating-api.md | 2 +- shell/common/node_bindings.cc | 61 +++++++++++++++++++++----------- spec/internal-spec.ts | 43 ++++++++++++++++++++++ 3 files changed, 85 insertions(+), 21 deletions(-) diff --git a/docs/development/creating-api.md b/docs/development/creating-api.md index 6b6527c66c424..ae04b753fd154 100644 --- a/docs/development/creating-api.md +++ b/docs/development/creating-api.md @@ -144,7 +144,7 @@ NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_{api_name},Initialize) In your [`shell/common/node_bindings.cc`](https://github.com/electron/electron/blob/main/shell/common/node_bindings.cc) file, add your node binding name to Electron's built-in modules. ```cpp title='shell/common/node_bindings.cc' -#define ELECTRON_BUILTIN_MODULES(V) \ +#define ELECTRON_BROWSER_MODULES(V) \ V(electron_browser_{api_name}) ``` diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index f8ef51aac8008..015af73e0b924 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -24,6 +24,7 @@ #include "base/trace_event/trace_event.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_paths.h" +#include "content/public/common/content_switches.h" #include "electron/buildflags/buildflags.h" #include "electron/fuses.h" #include "shell/browser/api/electron_api_app.h" @@ -43,7 +44,7 @@ #include "shell/common/crash_keys.h" #endif -#define ELECTRON_BUILTIN_MODULES(V) \ +#define ELECTRON_BROWSER_MODULES(V) \ V(electron_browser_app) \ V(electron_browser_auto_updater) \ V(electron_browser_browser_view) \ @@ -76,21 +77,26 @@ V(electron_browser_web_contents_view) \ V(electron_browser_web_frame_main) \ V(electron_browser_web_view_manager) \ - V(electron_browser_window) \ - V(electron_common_asar) \ - V(electron_common_clipboard) \ - V(electron_common_command_line) \ - V(electron_common_crashpad_support) \ - V(electron_common_environment) \ - V(electron_common_features) \ - V(electron_common_native_image) \ - V(electron_common_shell) \ - V(electron_common_v8_util) \ - V(electron_renderer_context_bridge) \ - V(electron_renderer_crash_reporter) \ - V(electron_renderer_ipc) \ - V(electron_renderer_web_frame) \ - V(electron_utility_parent_port) + V(electron_browser_window) + +#define ELECTRON_COMMON_MODULES(V) \ + V(electron_common_asar) \ + V(electron_common_clipboard) \ + V(electron_common_command_line) \ + V(electron_common_crashpad_support) \ + V(electron_common_environment) \ + V(electron_common_features) \ + V(electron_common_native_image) \ + V(electron_common_shell) \ + V(electron_common_v8_util) + +#define ELECTRON_RENDERER_MODULES(V) \ + V(electron_renderer_context_bridge) \ + V(electron_renderer_crash_reporter) \ + V(electron_renderer_ipc) \ + V(electron_renderer_web_frame) + +#define ELECTRON_UTILITY_MODULES(V) V(electron_utility_parent_port) #define ELECTRON_VIEWS_MODULES(V) V(electron_browser_image_view) @@ -104,7 +110,10 @@ // forward declaration. The definitions are in each module's // implementation when calling the NODE_LINKED_MODULE_CONTEXT_AWARE. #define V(modname) void _register_##modname(); -ELECTRON_BUILTIN_MODULES(V) +ELECTRON_BROWSER_MODULES(V) +ELECTRON_COMMON_MODULES(V) +ELECTRON_RENDERER_MODULES(V) +ELECTRON_UTILITY_MODULES(V) #if BUILDFLAG(ENABLE_VIEWS_API) ELECTRON_VIEWS_MODULES(V) #endif @@ -370,13 +379,25 @@ NodeBindings::~NodeBindings() { void NodeBindings::RegisterBuiltinModules() { #define V(modname) _register_##modname(); - ELECTRON_BUILTIN_MODULES(V) + auto* command_line = base::CommandLine::ForCurrentProcess(); + std::string process_type = + command_line->GetSwitchValueASCII(::switches::kProcessType); + if (process_type.empty()) { + ELECTRON_BROWSER_MODULES(V) #if BUILDFLAG(ENABLE_VIEWS_API) - ELECTRON_VIEWS_MODULES(V) + ELECTRON_VIEWS_MODULES(V) #endif #if BUILDFLAG(ENABLE_DESKTOP_CAPTURER) - ELECTRON_DESKTOP_CAPTURER_MODULE(V) + ELECTRON_DESKTOP_CAPTURER_MODULE(V) #endif + } + ELECTRON_COMMON_MODULES(V) + if (process_type == ::switches::kRendererProcess) { + ELECTRON_RENDERER_MODULES(V) + } + if (process_type == ::switches::kUtilityProcess) { + ELECTRON_UTILITY_MODULES(V) + } #if DCHECK_IS_ON() ELECTRON_TESTING_MODULE(V) #endif diff --git a/spec/internal-spec.ts b/spec/internal-spec.ts index 45d5f6605b1b7..b969824d03339 100644 --- a/spec/internal-spec.ts +++ b/spec/internal-spec.ts @@ -1,4 +1,6 @@ import { expect } from 'chai'; +import { BrowserWindow } from 'electron/main'; +import { closeAllWindows } from './window-helpers'; describe('feature-string parsing', () => { it('is indifferent to whitespace around keys and values', () => { @@ -19,3 +21,44 @@ describe('feature-string parsing', () => { checkParse(' a = yes , c = d ', { a: true, c: 'd' }); }); }); + +describe('process._linkedBinding', () => { + describe('in the main process', () => { + it('can access electron_browser bindings', () => { + process._linkedBinding('electron_browser_app'); + }); + + it('can access electron_common bindings', () => { + process._linkedBinding('electron_common_v8_util'); + }); + + it('cannot access electron_renderer bindings', () => { + expect(() => { + process._linkedBinding('electron_renderer_ipc'); + }).to.throw(/No such module was linked: electron_renderer_ipc/); + }); + }); + + describe('in the renderer process', () => { + afterEach(closeAllWindows); + + it('cannot access electron_browser bindings', async () => { + const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } }); + w.loadURL('about:blank'); + await expect(w.webContents.executeJavaScript('void process._linkedBinding(\'electron_browser_app\')')) + .to.eventually.be.rejectedWith(/Script failed to execute/); + }); + + it('can access electron_common bindings', async () => { + const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } }); + w.loadURL('about:blank'); + await w.webContents.executeJavaScript('void process._linkedBinding(\'electron_common_v8_util\')'); + }); + + it('can access electron_renderer bindings', async () => { + const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, contextIsolation: false } }); + w.loadURL('about:blank'); + await w.webContents.executeJavaScript('void process._linkedBinding(\'electron_renderer_ipc\')'); + }); + }); +}); From 1ae86b3becf34abdc969a7abcd0cf251a53470c5 Mon Sep 17 00:00:00 2001 From: Keeley Hammond <vertedinde@electronjs.org> Date: Thu, 9 Feb 2023 03:28:53 -0800 Subject: [PATCH 063/172] chore: cherry-pick e17eee4894be from v8 (#37192) * chore: [22-x-y] cherry-pick e17eee4894be from v8 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/v8/.patches | 1 + patches/v8/cherry-pick-e17eee4894be.patch | 171 ++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 patches/v8/cherry-pick-e17eee4894be.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 4c5e530a4b419..759ec3a4bd17a 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -9,3 +9,4 @@ fix_disable_implies_dcheck_for_node_stream_array_buffers.patch revert_runtime_dhceck_terminating_exception_in_microtasks.patch chore_disable_is_execution_terminating_dcheck.patch force_cppheapcreateparams_to_be_noncopyable.patch +cherry-pick-e17eee4894be.patch diff --git a/patches/v8/cherry-pick-e17eee4894be.patch b/patches/v8/cherry-pick-e17eee4894be.patch new file mode 100644 index 0000000000000..1b11cf6378d20 --- /dev/null +++ b/patches/v8/cherry-pick-e17eee4894be.patch @@ -0,0 +1,171 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Clemens Backes <clemensb@chromium.org> +Date: Thu, 22 Dec 2022 09:43:42 +0100 +Subject: Fix printing of wasm-to-js frames + +After https://crrev.com/c/3859787 those frames would be printed like +standard Wasm frames, but in the place of the WasmInstanceObject, they +have a WasmApiFunctionRef object instead. +So special-case the {WasmToJsFrame::instance()} to load the instance +properly. Also special-case the {position()} accessor for imported +functions. + +R=victorgomes@chromium.org + +Bug: chromium:1402270 +Change-Id: I39805805a50e7a73d7d8075c63c46bdf5a373a33 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4116778 +Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> +Commit-Queue: Clemens Backes <clemensb@chromium.org> +Reviewed-by: Victor Gomes <victorgomes@chromium.org> +Cr-Commit-Position: refs/heads/main@{#84993} + +diff --git a/src/compiler/backend/arm/code-generator-arm.cc b/src/compiler/backend/arm/code-generator-arm.cc +index 4c5accd7a8f352a128499861d5d28a6d9b859f1a..d8a77d70bbd465035ee91dbc57058f83ccf7cf83 100644 +--- a/src/compiler/backend/arm/code-generator-arm.cc ++++ b/src/compiler/backend/arm/code-generator-arm.cc +@@ -3699,6 +3699,10 @@ void CodeGenerator::AssembleConstructFrame() { + if (call_descriptor->IsWasmFunctionCall() || + call_descriptor->IsWasmImportWrapper() || + call_descriptor->IsWasmCapiFunction()) { ++ // For import wrappers and C-API functions, this stack slot is only used ++ // for printing stack traces in V8. Also, it holds a WasmApiFunctionRef ++ // instead of the instance itself, which is taken care of in the frames ++ // accessors. + __ Push(kWasmInstanceRegister); + } + if (call_descriptor->IsWasmCapiFunction()) { +diff --git a/src/compiler/backend/arm64/code-generator-arm64.cc b/src/compiler/backend/arm64/code-generator-arm64.cc +index 60d19c79307529f13f64a1f5c41295d720f31dde..8ad2c88c12763106d7d279372d7f36933755f1e0 100644 +--- a/src/compiler/backend/arm64/code-generator-arm64.cc ++++ b/src/compiler/backend/arm64/code-generator-arm64.cc +@@ -3225,6 +3225,9 @@ void CodeGenerator::AssembleConstructFrame() { + Register scratch = temps.AcquireX(); + __ Mov(scratch, + StackFrame::TypeToMarker(info()->GetOutputStackFrameType())); ++ // This stack slot is only used for printing stack traces in V8. Also, ++ // it holds a WasmApiFunctionRef instead of the instance itself, which ++ // is taken care of in the frames accessors. + __ Push(scratch, kWasmInstanceRegister); + int extra_slots = + call_descriptor->kind() == CallDescriptor::kCallWasmImportWrapper +diff --git a/src/compiler/backend/ia32/code-generator-ia32.cc b/src/compiler/backend/ia32/code-generator-ia32.cc +index 5afd119ff506ddd07f719d539ad6e9592f967201..d13310cfcc244ea2c61766a9960dbab29779bf52 100644 +--- a/src/compiler/backend/ia32/code-generator-ia32.cc ++++ b/src/compiler/backend/ia32/code-generator-ia32.cc +@@ -4026,6 +4026,10 @@ void CodeGenerator::AssembleConstructFrame() { + if (call_descriptor->IsWasmFunctionCall() || + call_descriptor->IsWasmImportWrapper() || + call_descriptor->IsWasmCapiFunction()) { ++ // For import wrappers and C-API functions, this stack slot is only used ++ // for printing stack traces in V8. Also, it holds a WasmApiFunctionRef ++ // instead of the instance itself, which is taken care of in the frames ++ // accessors. + __ push(kWasmInstanceRegister); + } + if (call_descriptor->IsWasmCapiFunction()) { +diff --git a/src/compiler/backend/x64/code-generator-x64.cc b/src/compiler/backend/x64/code-generator-x64.cc +index e3f759f570050c183d133854f83d02d9b442d8f9..0e02c63ace62caf2fcb5642db82d0c07af2cc2ba 100644 +--- a/src/compiler/backend/x64/code-generator-x64.cc ++++ b/src/compiler/backend/x64/code-generator-x64.cc +@@ -4841,10 +4841,10 @@ void CodeGenerator::AssembleConstructFrame() { + if (call_descriptor->IsWasmFunctionCall() || + call_descriptor->IsWasmImportWrapper() || + call_descriptor->IsWasmCapiFunction()) { +- // We do not use this stack value in import wrappers and capi functions. +- // We push it anyway to satisfy legacy assumptions about these frames' +- // size and order. +- // TODO(manoskouk): Consider fixing this. ++ // For import wrappers and C-API functions, this stack slot is only used ++ // for printing stack traces in V8. Also, it holds a WasmApiFunctionRef ++ // instead of the instance itself, which is taken care of in the frames ++ // accessors. + __ pushq(kWasmInstanceRegister); + } + if (call_descriptor->IsWasmCapiFunction()) { +diff --git a/src/diagnostics/objects-printer.cc b/src/diagnostics/objects-printer.cc +index ce4d15b2c27e145be7e8dd2b98f1519ed11ce2f6..71604afa7a067e14a891057de4011416f45f4f19 100644 +--- a/src/diagnostics/objects-printer.cc ++++ b/src/diagnostics/objects-printer.cc +@@ -2137,6 +2137,7 @@ void WasmApiFunctionRef::WasmApiFunctionRefPrint(std::ostream& os) { + os << "\n - isolate_root: " << reinterpret_cast<void*>(isolate_root()); + os << "\n - native_context: " << Brief(native_context()); + os << "\n - callable: " << Brief(callable()); ++ os << "\n - instance: " << Brief(instance()); + os << "\n - suspend: " << suspend(); + os << "\n"; + } +diff --git a/src/execution/frames.cc b/src/execution/frames.cc +index 0ca10a21e190f5113e0a84687ae6fa1d2882d3ee..c18ce06a87f94431c503997913e9c1993e6be804 100644 +--- a/src/execution/frames.cc ++++ b/src/execution/frames.cc +@@ -2500,7 +2500,7 @@ void WasmFrame::Print(StringStream* accumulator, PrintMode mode, + return; + } + wasm::WasmCodeRefScope code_ref_scope; +- accumulator->Add("Wasm ["); ++ accumulator->Add(is_wasm_to_js() ? "Wasm-to-JS [" : "Wasm ["); + accumulator->PrintName(script().name()); + Address instruction_start = wasm_code()->instruction_start(); + base::Vector<const uint8_t> raw_func_name = +@@ -2631,6 +2631,15 @@ void WasmDebugBreakFrame::Print(StringStream* accumulator, PrintMode mode, + if (mode != OVERVIEW) accumulator->Add("\n"); + } + ++WasmInstanceObject WasmToJsFrame::wasm_instance() const { ++ // WasmToJsFrames hold the {WasmApiFunctionRef} object in the instance slot. ++ // Load the instance from there. ++ const int offset = WasmFrameConstants::kWasmInstanceOffset; ++ Object func_ref_obj(Memory<Address>(fp() + offset)); ++ WasmApiFunctionRef func_ref = WasmApiFunctionRef::cast(func_ref_obj); ++ return WasmInstanceObject::cast(func_ref.instance()); ++} ++ + void JsToWasmFrame::Iterate(RootVisitor* v) const { + CodeLookupResult lookup_result = GetContainingCode(isolate(), pc()); + CHECK(lookup_result.IsFound()); +diff --git a/src/execution/frames.h b/src/execution/frames.h +index c72b7acef4b532fec8c55b698711a4897b1494c9..f6cf5360ce94fe62ce9076abb929b42e13c60b6a 100644 +--- a/src/execution/frames.h ++++ b/src/execution/frames.h +@@ -1035,7 +1035,7 @@ class WasmFrame : public TypedFrame { + void Iterate(RootVisitor* v) const override; + + // Accessors. +- V8_EXPORT_PRIVATE WasmInstanceObject wasm_instance() const; ++ virtual V8_EXPORT_PRIVATE WasmInstanceObject wasm_instance() const; + V8_EXPORT_PRIVATE wasm::NativeModule* native_module() const; + wasm::WasmCode* wasm_code() const; + int function_index() const; +@@ -1101,6 +1101,9 @@ class WasmToJsFrame : public WasmFrame { + public: + Type type() const override { return WASM_TO_JS; } + ++ int position() const override { return 0; } ++ WasmInstanceObject wasm_instance() const override; ++ + protected: + inline explicit WasmToJsFrame(StackFrameIteratorBase* iterator); + +diff --git a/test/mjsunit/regress/asm/regress-1402270.js b/test/mjsunit/regress/asm/regress-1402270.js +new file mode 100644 +index 0000000000000000000000000000000000000000..77badd768f6f502ee3bacec73049f25cd8af40b7 +--- /dev/null ++++ b/test/mjsunit/regress/asm/regress-1402270.js +@@ -0,0 +1,16 @@ ++// Copyright 2022 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++function print_stack(unused_arg) { ++ console.trace(); ++} ++function asm(_, imports) { ++ 'use asm'; ++ var print_stack = imports.print_stack; ++ function f() { ++ print_stack(1); ++ } ++ return f; ++} ++asm({}, {'print_stack': print_stack})(); From b0c7515e6af8f47f32d3fde41c73032e8e478d3a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 14:31:07 +0100 Subject: [PATCH 064/172] docs: add missing clipboard-sanitized-write permission value to setPermissionRequestHandler() (#37207) docs: add missing clipboard-sanitized-write permission value to setPermissionRequestHandler() (#37173) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <milan.burda@gmail.com> --- docs/api/session.md | 1 + spec/chromium-spec.ts | 56 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/api/session.md b/docs/api/session.md index 94953f0f0387d..f952ccdc3607b 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -672,6 +672,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => { * `webContents` [WebContents](web-contents.md) - WebContents requesting the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin. * `permission` string - The type of requested permission. * `clipboard-read` - Request access to read from the clipboard. + * `clipboard-sanitized-write` - Request access to write to the clipboard. * `media` - Request access to media devices such as camera, microphone and speakers. * `display-capture` - Request access to capture the screen. * `mediaKeySystem` - Request access to DRM protected content. diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 5564e99624642..06f0519ff48c5 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -2542,14 +2542,10 @@ describe('window.getScreenDetails', () => { }); }); -describe('navigator.clipboard', () => { +describe('navigator.clipboard.read', () => { let w: BrowserWindow; before(async () => { - w = new BrowserWindow({ - webPreferences: { - enableBlinkFeatures: 'Serial' - } - }); + w = new BrowserWindow(); await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html')); }); @@ -2594,6 +2590,54 @@ describe('navigator.clipboard', () => { }); }); +describe('navigator.clipboard.write', () => { + let w: BrowserWindow; + before(async () => { + w = new BrowserWindow(); + await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html')); + }); + + const writeClipboard: any = () => { + return w.webContents.executeJavaScript(` + navigator.clipboard.writeText('Hello World!').catch(err => err.message); + `, true); + }; + + after(closeAllWindows); + afterEach(() => { + session.defaultSession.setPermissionRequestHandler(null); + }); + + it('returns clipboard contents when a PermissionRequestHandler is not defined', async () => { + const clipboard = await writeClipboard(); + expect(clipboard).to.not.equal('Write permission denied.'); + }); + + it('returns an error when permission denied', async () => { + session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => { + if (permission === 'clipboard-sanitized-write') { + callback(false); + } else { + callback(true); + } + }); + const clipboard = await writeClipboard(); + expect(clipboard).to.equal('Write permission denied.'); + }); + + it('returns clipboard contents when permission is granted', async () => { + session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => { + if (permission === 'clipboard-sanitized-write') { + callback(true); + } else { + callback(false); + } + }); + const clipboard = await writeClipboard(); + expect(clipboard).to.not.equal('Write permission denied.'); + }); +}); + ifdescribe((process.platform !== 'linux' || app.isUnityRunning()))('navigator.setAppBadge/clearAppBadge', () => { let w: BrowserWindow; From 2a4aed7f7a28ca97d8b6fc4215bd9c376d8764c8 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt <jkleinsc@electronjs.org> Date: Sat, 11 Feb 2023 13:37:08 -0500 Subject: [PATCH 065/172] ci: update appveyor image (22-x-y) (#37227) ci update appveyor image (cherry picked from commit 454dc6aa318cadeb45a07cb311eccdd5a3a3670e) --- appveyor-bake.yml | 88 +++++++++++++++++++++++++++++++------- appveyor-woa.yml | 4 +- appveyor.yml | 4 +- script/prepare-appveyor.js | 4 +- 4 files changed, 78 insertions(+), 22 deletions(-) diff --git a/appveyor-bake.yml b/appveyor-bake.yml index 445e46bf49342..919545dcd0b16 100644 --- a/appveyor-bake.yml +++ b/appveyor-bake.yml @@ -6,7 +6,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-111.0.5518.0 +image: e-111.0.5560.0-2 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -16,17 +16,61 @@ environment: GOMA_FALLBACK_ON_AUTH_FAILURE: true DEPOT_TOOLS_WIN_TOOLCHAIN: 0 PYTHONIOENCODING: UTF-8 + +# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) +# init: +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# - appveyor version +# - ps: $ErrorActionPreference = 'Stop' +# - ps: 'Write-Host "OS Build: $((Get-CimInstance Win32_OperatingSystem).BuildNumber)"' + +# clone_folder: '%USERPROFILE%\image-bake-scripts' + +# clone_script: +# - ps: Invoke-WebRequest "https://github.com/appveyor/build-images/archive/1f90d94e74c8243c909a09b994e527584dfcb838.zip" -OutFile "$env:temp\scripts.zip" +# - ps: Expand-Archive -Path "$env:temp\scripts.zip" -DestinationPath "$env:temp\scripts" -Force +# - ps: Copy-Item -Path "$env:temp\scripts\build-images-1f90d94e74c8243c909a09b994e527584dfcb838\scripts\Windows\*" -Destination $env:APPVEYOR_BUILD_FOLDER -Recurse + build_script: - - ps: Resize-Partition -DriveLetter C -Size (256GB) # ensure initial partition size - - ps: Get-Partition -DriveLetter C +# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) + # - ps: .\init_server.ps1 + # - ps: .\extend_system_volume.ps1 + + # # Restart VM + # - ps: Start-Sleep -s 5; Restart-Computer + # - ps: Start-Sleep -s 5 + + # - appveyor version + # - ps: .\install_path_utils.ps1 + # - ps: .\install_powershell_core.ps1 + # - ps: .\install_powershell_get.ps1 + # - ps: .\install_7zip.ps1 + # - ps: .\install_chocolatey.ps1 + # - ps: .\install_webpi.ps1 + # - ps: .\install_nuget.ps1 + # - ps: .\install_pstools.ps1 + + # - ps: .\install_git.ps1 + # - ps: .\install_git_lfs.ps1 + + # # Restart VM + # - ps: Start-Sleep -s 5; Restart-Computer + # - ps: Start-Sleep -s 5 +# END LINES FOR COMPLETELY NEW IMAGE + - git config --global core.longpaths true - - cd .. - - mkdir src - - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - - ps: $env:PATH="$pwd\depot_tools;$env:PATH" + - ps: >- + if (-not (Test-Path -Path C:\projects\src)) { + New-Item -Path C:\projects\src -ItemType Directory + } + + - cd C:\projects\ + - git clone -q --branch=%APPVEYOR_REPO_BRANCH% https://github.com/electron/electron.git C:\projects\src\electron + - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - update_depot_tools.bat - - ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron - - src\electron\script\setup-win-for-dev.bat + # Uncomment the following line if windows deps change + # - src\electron\script\setup-win-for-dev.bat - >- gclient config --name "src\electron" @@ -40,13 +84,25 @@ build_script: - ps: cd ..\.. - gclient sync --with_branch_heads --with_tags --nohooks - ps: regsvr32 /s "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll" + +# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) + # # Restart VM + # - ps: Start-Sleep -s 5; Restart-Computer + # - ps: Start-Sleep -s 5 + + # - cd %USERPROFILE%\image-bake-scripts + # - appveyor version + # - ps: .\optimize_dotnet_runtime.ps1 + # - ps: .\disable_windows_background_services.ps1 + # - ps: .\enforce_windows_firewall.ps1 + # - ps: .\cleanup_windows.ps1 +# END LINES FOR COMPLETELY NEW IMAGE on_image_bake: - ps: >- echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD" - - ps: Remove-Item -Recurse -Force $pwd\depot_tools - - ps: Remove-Item -Recurse -Force $pwd\src\electron -# Uncomment these lines to enable RDP -#on_finish: -# - ps: >- -# $env:APPVEYOR_RDP_PASSWORD = "electron" -# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) \ No newline at end of file + - ps: Remove-Item -Recurse -Force C:\projects\depot_tools + - ps: Remove-Item -Recurse -Force C:\projects\src\electron +# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP after bake is done +# # on_finish: +# - ps: >- +# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 4d9dc6f71ab27..0116cd64dc89b 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-108.0.5359.179 +image: e-108.0.5359.215 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -82,7 +82,7 @@ for: if (Test-Path -Path "$pwd\build-tools") { Remove-Item -Recurse -Force $pwd\build-tools } - - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { diff --git a/appveyor.yml b/appveyor.yml index c2df5019bea81..81dc092a8da16 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-108.0.5359.179 +image: e-108.0.5359.215 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -80,7 +80,7 @@ for: if (Test-Path -Path "$pwd\build-tools") { Remove-Item -Recurse -Force $pwd\build-tools } - - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { diff --git a/script/prepare-appveyor.js b/script/prepare-appveyor.js index 9960b877f5df6..210aec54c7900 100644 --- a/script/prepare-appveyor.js +++ b/script/prepare-appveyor.js @@ -14,8 +14,8 @@ const ROLLER_BRANCH_PATTERN = /^roller\/chromium$/; const DEFAULT_BUILD_CLOUD_ID = '1598'; const DEFAULT_BUILD_CLOUD = 'electronhq-16-core'; -const DEFAULT_BAKE_BASE_IMAGE = 'Windows_Default_Appveyor'; -const DEFAULT_BUILD_IMAGE = 'Windows_Default_Appveyor'; +const DEFAULT_BAKE_BASE_IMAGE = 'e-111.0.5560.0-2'; +const DEFAULT_BUILD_IMAGE = 'e-111.0.5560.0-2'; const appveyorBakeJob = 'electron-bake-image'; const appVeyorJobs = { From 299756c5b19513491e57e0c88d37e4f556a9ae15 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 16:34:32 +0900 Subject: [PATCH 066/172] chore: update https://cs.chromium.org/ links to https://source.chromium.org/ (#37237) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <miburda@microsoft.com> --- docs/api/browser-window.md | 2 +- docs/api/webview-tag.md | 2 +- docs/development/chromium-development.md | 4 ++-- shell/utility/electron_content_utility_client.cc | 3 +-- spec/api-dialog-spec.ts | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 66b13027dcdf7..c286d2b63fa11 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1898,7 +1898,7 @@ removed in future Electron releases. On a Window with Window Controls Overlay already enabled, this method updates the style of the title bar overlay. -[runtime-enabled-features]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70 +[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5 [page-visibility-api]: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API [quick-look]: https://en.wikipedia.org/wiki/Quick_Look [vibrancy-docs]: https://developer.apple.com/documentation/appkit/nsvisualeffectview?preferredLanguage=objc diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 499d348b4c507..31ac575cc5a10 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -993,7 +993,7 @@ Emitted when DevTools is closed. Emitted when DevTools is focused / opened. -[runtime-enabled-features]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70 +[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5 [chrome-webview]: https://developer.chrome.com/docs/extensions/reference/webviewTag/ ### Event: 'context-menu' diff --git a/docs/development/chromium-development.md b/docs/development/chromium-development.md index 6ad450dfbcb55..fc427b5d22a79 100644 --- a/docs/development/chromium-development.md +++ b/docs/development/chromium-development.md @@ -18,8 +18,8 @@ See also [V8 Development](v8-development.md) ### Code Resources -- [Code Search](https://cs.chromium.org/) - Indexed and searchable source code for Chromium and associated projects. -- [Source Code](https://cs.chromium.org/chromium/src/) - The source code for Chromium itself. +- [Code Search](https://source.chromium.org/chromium) - Indexed and searchable source code for Chromium and associated projects. +- [Source Code](https://source.chromium.org/chromium/chromium/src) - The source code for Chromium itself. - [Chromium Review](https://chromium-review.googlesource.com) - The searchable code host which facilitates code reviews for Chromium and related projects. ### Informational Resources diff --git a/shell/utility/electron_content_utility_client.cc b/shell/utility/electron_content_utility_client.cc index a21b3543a313b..750dfcfd20366 100644 --- a/shell/utility/electron_content_utility_client.cc +++ b/shell/utility/electron_content_utility_client.cc @@ -85,8 +85,7 @@ ElectronContentUtilityClient::ElectronContentUtilityClient() = default; ElectronContentUtilityClient::~ElectronContentUtilityClient() = default; // The guts of this came from the chromium implementation -// https://cs.chromium.org/chromium/src/chrome/utility/ -// chrome_content_utility_client.cc?sq=package:chromium&dr=CSs&g=0&l=142 +// https://source.chromium.org/chromium/chromium/src/+/main:chrome/utility/chrome_content_utility_client.cc void ElectronContentUtilityClient::ExposeInterfacesToBrowser( mojo::BinderMap* binders) { #if BUILDFLAG(IS_WIN) diff --git a/spec/api-dialog-spec.ts b/spec/api-dialog-spec.ts index 2b520075ae85a..5621213c83a0d 100644 --- a/spec/api-dialog-spec.ts +++ b/spec/api-dialog-spec.ts @@ -80,7 +80,7 @@ describe('dialog module', () => { afterEach(closeAllWindows); // parentless message boxes are synchronous on macOS - // dangling message boxes on windows cause a DCHECK: https://cs.chromium.org/chromium/src/base/win/message_window.cc?l=68&rcl=7faa4bf236a866d007dc5672c9ce42660e67a6a6 + // dangling message boxes on windows cause a DCHECK: https://source.chromium.org/chromium/chromium/src/+/main:base/win/message_window.cc;drc=7faa4bf236a866d007dc5672c9ce42660e67a6a6;l=68 ifit(process.platform !== 'darwin' && process.platform !== 'win32')('should not throw for a parentless message box', () => { expect(() => { dialog.showMessageBox({ message: 'i am message' }); From d6bcc07688c1f8bc50b1f84476fc47c4793c3387 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:09:37 +0100 Subject: [PATCH 067/172] build: set make_latest correctly on published releases (#37241) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> --- package.json | 2 +- script/release/release.js | 11 ++- yarn.lock | 156 +++++++++++++++++--------------------- 3 files changed, 79 insertions(+), 90 deletions(-) diff --git a/package.json b/package.json index 13cfaa6607b6d..fa5bbf3f39acc 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@electron/fiddle-core": "^1.0.4", "@electron/github-app-auth": "^1.5.0", "@electron/typescript-definitions": "^8.10.0", - "@octokit/rest": "^18.0.3", + "@octokit/rest": "^19.0.7", "@primer/octicons": "^10.0.0", "@types/basic-auth": "^1.1.3", "@types/busboy": "^0.2.3", diff --git a/script/release/release.js b/script/release/release.js index f600d7a27c42c..0116113524e42 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -13,6 +13,7 @@ const fs = require('fs'); const { execSync } = require('child_process'); const got = require('got'); const path = require('path'); +const semver = require('semver'); const temp = require('temp').track(); const { URL } = require('url'); const { BlobServiceClient } = require('@azure/storage-blob'); @@ -317,12 +318,20 @@ function saveShaSumFile (checksums, fileName) { } async function publishRelease (release) { + const currentLatest = await octokit.repos.getLatestRelease({ + owner: 'electron', + repo: targetRepo + }); + + const makeLatest = !release.prerelease && semver.gte(release.tag_name, currentLatest.data.tag_name); + return octokit.repos.updateRelease({ owner: 'electron', repo: targetRepo, release_id: release.id, tag_name: release.tag_name, - draft: false + draft: false, + make_latest: makeLatest ? 'true' : 'false' }).catch(err => { console.log(`${fail} Error publishing release:`, err); process.exit(1); diff --git a/yarn.lock b/yarn.lock index 4822764777640..b20dc8f88c51c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -326,13 +326,6 @@ btoa-lite "^1.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-token@^2.4.0": - version "2.4.2" - resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.2.tgz#10d0ae979b100fa6b72fa0e8e63e27e6d0dbff8a" - integrity sha512-jE/lE/IKIz2v1+/P0u4fJqv0kYwXOTujKemJMFr6FeopsxlIK3+wKDCJGnysg81XID5TgZQbIfuJ5J0lnTiuyQ== - dependencies: - "@octokit/types" "^5.0.0" - "@octokit/auth-token@^2.4.4": version "2.5.0" resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" @@ -340,17 +333,12 @@ dependencies: "@octokit/types" "^6.0.3" -"@octokit/core@^3.0.0": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.1.1.tgz#1856745aa8fb154cf1544a2a1b82586c809c5e66" - integrity sha512-cQ2HGrtyNJ1IBxpTP1U5m/FkMAJvgw7d2j1q3c9P0XUuYilEgF6e4naTpsgm4iVcQeOnccZlw7XHRIUBy0ymcg== +"@octokit/auth-token@^3.0.0": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-3.0.3.tgz#ce7e48a3166731f26068d7a7a7996b5da58cbe0c" + integrity sha512-/aFM2M4HVDBT/jjDBa84sJniv1t9Gm/rLkalaz9htOm+L+8JMj1k9w0CkUdcxNyNxZPlTxKPVko+m1VlM58ZVA== dependencies: - "@octokit/auth-token" "^2.4.0" - "@octokit/graphql" "^4.3.1" - "@octokit/request" "^5.4.0" - "@octokit/types" "^5.0.0" - before-after-hook "^2.1.0" - universal-user-agent "^6.0.0" + "@octokit/types" "^9.0.0" "@octokit/core@^3.5.1": version "3.6.0" @@ -365,6 +353,19 @@ before-after-hook "^2.2.0" universal-user-agent "^6.0.0" +"@octokit/core@^4.1.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.0.tgz#8c253ba9605aca605bc46187c34fcccae6a96648" + integrity sha512-AgvDRUg3COpR82P7PBdGZF/NNqGmtMq2NiPqeSsDIeCfYFOZ9gddqWNQHnFdEUf+YwOj4aZYmJnlPp7OXmDIDg== + dependencies: + "@octokit/auth-token" "^3.0.0" + "@octokit/graphql" "^5.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + "@octokit/endpoint@^6.0.1": version "6.0.5" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.5.tgz#43a6adee813c5ffd2f719e20cfd14a1fee7c193a" @@ -383,15 +384,6 @@ is-plain-object "^5.0.0" universal-user-agent "^6.0.0" -"@octokit/graphql@^4.3.1": - version "4.5.3" - resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.3.tgz#d5ff0d4a8a33e98614a2a7359dac98bc285e062f" - integrity sha512-JyYvi3j2tOb5ofASEpcg1Advs07H+Ag+I+ez7buuZfNVAmh1IYcDTuxd4gnYH8S2PSGu+f5IdDGxMmkK+5zsdA== - dependencies: - "@octokit/request" "^5.3.0" - "@octokit/types" "^5.0.0" - universal-user-agent "^6.0.0" - "@octokit/graphql@^4.5.8": version "4.8.0" resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" @@ -401,6 +393,15 @@ "@octokit/types" "^6.0.3" universal-user-agent "^6.0.0" +"@octokit/graphql@^5.0.0": + version "5.0.5" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-5.0.5.tgz#a4cb3ea73f83b861893a6370ee82abb36e81afd2" + integrity sha512-Qwfvh3xdqKtIznjX9lz2D458r7dJPP8l6r4GQkIdWQouZwHQK0mVT88uwiU2bdTU2OtT1uOlKpRciUWldpG0yQ== + dependencies: + "@octokit/request" "^6.0.0" + "@octokit/types" "^9.0.0" + universal-user-agent "^6.0.0" + "@octokit/oauth-authorization-url@^4.3.1": version "4.3.3" resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-4.3.3.tgz#6a6ef38f243086fec882b62744f39b517528dfb9" @@ -443,6 +444,11 @@ resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-14.0.0.tgz#949c5019028c93f189abbc2fb42f333290f7134a" integrity sha512-HNWisMYlR8VCnNurDU6os2ikx0s0VyEjDYHNS/h4cgb8DeOxQ0n72HyinUtdDVxJhFy3FWLGl0DJhfEWk3P5Iw== +"@octokit/openapi-types@^16.0.0": + version "16.0.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-16.0.0.tgz#d92838a6cd9fb4639ca875ddb3437f1045cc625e" + integrity sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA== + "@octokit/plugin-paginate-rest@^2.16.8": version "2.21.3" resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz#7f12532797775640dbb8224da577da7dc210c87e" @@ -450,31 +456,18 @@ dependencies: "@octokit/types" "^6.40.0" -"@octokit/plugin-paginate-rest@^2.2.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.3.0.tgz#7d1073e56cfd15d3f99dcfe81fa5d2b466f3a6f6" - integrity sha512-Ye2ZJreP0ZlqJQz8fz+hXvrEAEYK4ay7br1eDpWzr6j76VXs/gKqxFcH8qRzkB3fo/2xh4Vy9VtGii4ZDc9qlA== +"@octokit/plugin-paginate-rest@^6.0.0": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.0.0.tgz#f34b5a7d9416019126042cd7d7b811e006c0d561" + integrity sha512-Sq5VU1PfT6/JyuXPyt04KZNVsFOSBaYOAq2QRZUwzVlI10KFvcbUo8lR258AAQL1Et60b0WuVik+zOWKLuDZxw== dependencies: - "@octokit/types" "^5.2.0" - -"@octokit/plugin-request-log@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" - integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== + "@octokit/types" "^9.0.0" "@octokit/plugin-request-log@^1.0.4": version "1.0.4" resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== -"@octokit/plugin-rest-endpoint-methods@4.1.2": - version "4.1.2" - resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.1.2.tgz#546a8f3e0b514f434a4ad4ef926005f1c81a5a5a" - integrity sha512-PTI7wpbGEZ2IR87TVh+TNWaLcgX/RsZQalFbQCq8XxYUrQ36RHyERrHSNXFy5gkWpspUAOYRSV707JJv6BhqJA== - dependencies: - "@octokit/types" "^5.1.1" - deprecation "^2.3.1" - "@octokit/plugin-rest-endpoint-methods@^5.12.0": version "5.16.2" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz#7ee8bf586df97dd6868cf68f641354e908c25342" @@ -483,14 +476,13 @@ "@octokit/types" "^6.39.0" deprecation "^2.3.1" -"@octokit/request-error@^2.0.0": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0" - integrity sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw== +"@octokit/plugin-rest-endpoint-methods@^7.0.0": + version "7.0.1" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.0.1.tgz#f7ebe18144fd89460f98f35a587b056646e84502" + integrity sha512-pnCaLwZBudK5xCdrR823xHGNgqOzRnJ/mpC/76YPpNP7DybdsJtP7mdOwh+wYZxK5jqeQuhu59ogMI4NRlBUvA== dependencies: - "@octokit/types" "^5.0.1" - deprecation "^2.0.0" - once "^1.4.0" + "@octokit/types" "^9.0.0" + deprecation "^2.3.1" "@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": version "2.1.0" @@ -510,20 +502,6 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@^5.3.0", "@octokit/request@^5.4.0": - version "5.4.7" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.7.tgz#fd703ee092e0463ceba49ff7a3e61cb4cf8a0fde" - integrity sha512-FN22xUDP0i0uF38YMbOfx6TotpcENP5W8yJM1e/LieGXn6IoRxDMnBf7tx5RKSW4xuUZ/1P04NFZy5iY3Rax1A== - dependencies: - "@octokit/endpoint" "^6.0.1" - "@octokit/request-error" "^2.0.0" - "@octokit/types" "^5.0.0" - deprecation "^2.0.0" - is-plain-object "^4.0.0" - node-fetch "^2.3.0" - once "^1.4.0" - universal-user-agent "^6.0.0" - "@octokit/request@^5.4.14", "@octokit/request@^5.6.0", "@octokit/request@^5.6.3": version "5.6.3" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" @@ -548,16 +526,6 @@ node-fetch "^2.6.7" universal-user-agent "^6.0.0" -"@octokit/rest@^18.0.3": - version "18.0.3" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.0.3.tgz#96a15ddb3a38dca5de9d75121378d6aa4a234fa5" - integrity sha512-GubgemnLvUJlkhouTM2BtX+g/voYT/Mqh0SASGwTnLvSkW1irjt14N911/ABb6m1Hru0TwScOgFgMFggp3igfQ== - dependencies: - "@octokit/core" "^3.0.0" - "@octokit/plugin-paginate-rest" "^2.2.0" - "@octokit/plugin-request-log" "^1.0.0" - "@octokit/plugin-rest-endpoint-methods" "4.1.2" - "@octokit/rest@^18.12.0": version "18.12.0" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" @@ -568,7 +536,17 @@ "@octokit/plugin-request-log" "^1.0.4" "@octokit/plugin-rest-endpoint-methods" "^5.12.0" -"@octokit/types@^5.0.0", "@octokit/types@^5.0.1", "@octokit/types@^5.1.1", "@octokit/types@^5.2.0": +"@octokit/rest@^19.0.7": + version "19.0.7" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-19.0.7.tgz#d2e21b4995ab96ae5bfae50b4969da7e04e0bb70" + integrity sha512-HRtSfjrWmWVNp2uAkEpQnuGMJsu/+dBr47dRc5QVgsCbnIc1+GFEaoKBWkYG+zjrsHpSqcAElMio+n10c0b5JA== + dependencies: + "@octokit/core" "^4.1.0" + "@octokit/plugin-paginate-rest" "^6.0.0" + "@octokit/plugin-request-log" "^1.0.4" + "@octokit/plugin-rest-endpoint-methods" "^7.0.0" + +"@octokit/types@^5.0.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.2.0.tgz#d075dc23bf293f540739250b6879e2c1be2fc20c" integrity sha512-XjOk9y4m8xTLIKPe1NFxNWBdzA2/z3PFFA/bwf4EoH6oS8hM0Y46mEa4Cb+KCyj/tFDznJFahzQ0Aj3o1FYq4A== @@ -589,6 +567,13 @@ dependencies: "@octokit/openapi-types" "^14.0.0" +"@octokit/types@^9.0.0": + version "9.0.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-9.0.0.tgz#6050db04ddf4188ec92d60e4da1a2ce0633ff635" + integrity sha512-LUewfj94xCMH2rbD5YJ+6AQ4AVjFYTgpp6rboWM5T7N3IsIF65SBEOVcYMGAEzO/kKNiNaW4LoWtoThOhH06gw== + dependencies: + "@octokit/openapi-types" "^16.0.0" + "@opentelemetry/api@^1.0.1": version "1.0.4" resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.0.4.tgz#a167e46c10d05a07ab299fc518793b0cff8f6924" @@ -1553,11 +1538,6 @@ base64-js@^1.3.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -before-after-hook@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" - integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== - before-after-hook@^2.2.0: version "2.2.3" resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" @@ -4669,13 +4649,6 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== -node-fetch@^2.3.0, node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - node-fetch@^2.6.1: version "2.6.8" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.8.tgz#a68d30b162bc1d8fd71a367e81b997e1f4d4937e" @@ -4683,6 +4656,13 @@ node-fetch@^2.6.1: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + node-releases@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503" From 72984eb31b435d0bbfd3083f645843830592cf32 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:52:09 +0100 Subject: [PATCH 068/172] docs: add `win.isFocusable()` return type (#37262) docs: fix `win.isFocusable()` return type Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Andrew Ferreira <andrew.shien2@gmail.com> --- docs/api/browser-window.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index c286d2b63fa11..b760a36e91897 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1764,7 +1764,7 @@ On macOS it does not remove the focus from the window. #### `win.isFocusable()` _macOS_ _Windows_ -Returns whether the window can be focused. +Returns `boolean` - Whether the window can be focused. #### `win.setParentWindow(parent)` From 5692fd89d6cb0c58b2dc946877275bfff7d36744 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:55:30 +0100 Subject: [PATCH 069/172] refactor: simplify Node.js event loop with `SpinEventLoop` (#37257) refactor: simplify Node.js event loop with SpinEventLoop Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/app/node_main.cc | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index 63b51496b795f..6b4747ea974c2 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -246,37 +246,9 @@ int NodeMain(int argc, char* argv[]) { v8::HandleScope scope(isolate); node::LoadEnvironment(env, node::StartExecutionCallback{}); - env->set_trace_sync_io(env->options()->trace_sync_io); - - { - v8::SealHandleScope seal(isolate); - bool more; - env->performance_state()->Mark( - node::performance::NODE_PERFORMANCE_MILESTONE_LOOP_START); - do { - uv_run(env->event_loop(), UV_RUN_DEFAULT); - - gin_env.platform()->DrainTasks(isolate); - - more = uv_loop_alive(env->event_loop()); - if (more && !env->is_stopping()) - continue; - - if (!uv_loop_alive(env->event_loop())) { - EmitBeforeExit(env); - } - - // Emit `beforeExit` if the loop became alive either after emitting - // event, or after running some callbacks. - more = uv_loop_alive(env->event_loop()); - } while (more && !env->is_stopping()); - env->performance_state()->Mark( - node::performance::NODE_PERFORMANCE_MILESTONE_LOOP_EXIT); - } - - env->set_trace_sync_io(false); - - exit_code = node::EmitExit(env); + // Potential reasons we get Nothing here may include: the env + // is stopping, or the user hooks process.emit('exit'). + exit_code = node::SpinEventLoop(env).FromMaybe(1); node::ResetStdio(); From a7bd7334626c7f9f8a917b07629d618ca61e4c40 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 11:55:52 +0100 Subject: [PATCH 070/172] fix: `BrowserView` crash when 'beforeunload' prevented (#37266) fix: crash when beforeunload prevented Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/browser/api/electron_api_browser_window.cc | 2 +- shell/browser/api/electron_api_web_contents.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index ea30dba67fd7d..b92954814daa2 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -127,7 +127,6 @@ BrowserWindow::~BrowserWindow() { api_web_contents_->RemoveObserver(this); // Destroy the WebContents. OnCloseContents(); - api_web_contents_->Destroy(); } } @@ -155,6 +154,7 @@ void BrowserWindow::WebContentsDestroyed() { void BrowserWindow::OnCloseContents() { BaseWindow::ResetBrowserViews(); + api_web_contents_->Destroy(); } void BrowserWindow::OnRendererResponsive(content::RenderProcessHost*) { diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 1747611e1aa44..015e27406e932 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1221,7 +1221,9 @@ void WebContents::CloseContents(content::WebContents* source) { for (ExtendedWebContentsObserver& observer : observers_) observer.OnCloseContents(); - Destroy(); + // If there are observers, OnCloseContents will call Destroy() + if (observers_.empty()) + Destroy(); } void WebContents::ActivateContents(content::WebContents* source) { From da55d6bfda10e911ed6c3620d021c149da9b64f4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 12:37:55 +0100 Subject: [PATCH 071/172] fix: cookies filter secure invalid (#37247) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Black-Hole <158blackhole@gmail.com> --- shell/browser/api/electron_api_cookies.cc | 4 +- spec/api-net-spec.ts | 65 +++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index e4cebe4fb572c..50208a28ccd0c 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -128,10 +128,10 @@ bool MatchesCookie(const base::Value::Dict& filter, !MatchesDomain(*str, cookie.Domain())) return false; absl::optional<bool> secure_filter = filter.FindBool("secure"); - if (secure_filter && *secure_filter == cookie.IsSecure()) + if (secure_filter && *secure_filter != cookie.IsSecure()) return false; absl::optional<bool> session_filter = filter.FindBool("session"); - if (session_filter && *session_filter != !cookie.IsPersistent()) + if (session_filter && *session_filter == cookie.IsPersistent()) return false; return true; } diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index fc70135fa38ed..2629e5a6544b9 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -796,6 +796,71 @@ describe('net module', () => { }); } + it('should be able correctly filter out cookies that are secure', async () => { + const sess = session.fromPartition(`cookie-tests-${Math.random()}`); + + await Promise.all([ + sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'electronjs.org', + name: 'cookie1', + value: '1', + secure: true + }), + sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'electronjs.org', + name: 'cookie2', + value: '2', + secure: false + }) + ]); + + const secureCookies = await sess.cookies.get({ + secure: true + }); + expect(secureCookies).to.have.lengthOf(1); + expect(secureCookies[0].name).to.equal('cookie1'); + + const cookies = await sess.cookies.get({ + secure: false + }); + expect(cookies).to.have.lengthOf(1); + expect(cookies[0].name).to.equal('cookie2'); + }); + + it('should be able correctly filter out cookies that are session', async () => { + const sess = session.fromPartition(`cookie-tests-${Math.random()}`); + + await Promise.all([ + sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'electronjs.org', + name: 'cookie1', + value: '1' + }), + sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'electronjs.org', + name: 'cookie2', + value: '2', + expirationDate: Math.round(Date.now() / 1000) + 10000 + }) + ]); + + const sessionCookies = await sess.cookies.get({ + session: true + }); + expect(sessionCookies).to.have.lengthOf(1); + expect(sessionCookies[0].name).to.equal('cookie1'); + + const cookies = await sess.cookies.get({ + session: false + }); + expect(cookies).to.have.lengthOf(1); + expect(cookies[0].name).to.equal('cookie2'); + }); + describe('when {"credentials":"omit"}', () => { it('should not send cookies'); it('should not store cookies'); From 54436d204808495a0b2884a6d9692fa365b998f5 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 15 Feb 2023 19:59:13 +0100 Subject: [PATCH 072/172] feat: include all standard paper sizes for webContents.print() (#37263) feat: include standard paper sizes for webContents.print() Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- docs/api/web-contents.md | 4 +- lib/browser/api/web-contents.ts | 72 ++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index b26b0dc0432fb..59d4c451ad94a 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1416,8 +1416,8 @@ Returns `Promise<PrinterInfo[]>` - Resolves with a [`PrinterInfo[]`](structures/ * `vertical` number (optional) - The vertical dpi. * `header` string (optional) - string to be printed as page header. * `footer` string (optional) - string to be printed as page footer. - * `pageSize` string | Size (optional) - Specify page size of the printed document. Can be `A3`, - `A4`, `A5`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width`. + * `pageSize` string | Size (optional) - Specify page size of the printed document. Can be `A0`, `A1`, `A2`, `A3`, + `A4`, `A5`, `A6`, `Legal`, `Letter`, `Tabloid` or an Object containing `height` and `width`. * `callback` Function (optional) * `success` boolean - Indicates success of the print call. * `failureReason` string - Error description called back if the print fails. diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 43f9158058d58..78081e5f4fbcd 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -28,24 +28,11 @@ type PostData = LoadURLOptions['postData'] // Stock page sizes const PDFPageSizes: Record<string, ElectronInternal.MediaSize> = { - A5: { - custom_display_name: 'A5', - height_microns: 210000, - name: 'ISO_A5', - width_microns: 148000 - }, - A4: { - custom_display_name: 'A4', - height_microns: 297000, - name: 'ISO_A4', - is_default: 'true', - width_microns: 210000 - }, - A3: { - custom_display_name: 'A3', - height_microns: 420000, - name: 'ISO_A3', - width_microns: 297000 + Letter: { + custom_display_name: 'Letter', + height_microns: 279400, + name: 'NA_LETTER', + width_microns: 215900 }, Legal: { custom_display_name: 'Legal', @@ -53,17 +40,54 @@ const PDFPageSizes: Record<string, ElectronInternal.MediaSize> = { name: 'NA_LEGAL', width_microns: 215900 }, - Letter: { - custom_display_name: 'Letter', - height_microns: 279400, - name: 'NA_LETTER', - width_microns: 215900 - }, Tabloid: { height_microns: 431800, name: 'NA_LEDGER', width_microns: 279400, custom_display_name: 'Tabloid' + }, + A0: { + custom_display_name: 'A0', + height_microns: 1189000, + name: 'ISO_A0', + width_microns: 841000 + }, + A1: { + custom_display_name: 'A1', + height_microns: 841000, + name: 'ISO_A1', + width_microns: 594000 + }, + A2: { + custom_display_name: 'A2', + height_microns: 594000, + name: 'ISO_A2', + width_microns: 420000 + }, + A3: { + custom_display_name: 'A3', + height_microns: 420000, + name: 'ISO_A3', + width_microns: 297000 + }, + A4: { + custom_display_name: 'A4', + height_microns: 297000, + name: 'ISO_A4', + is_default: 'true', + width_microns: 210000 + }, + A5: { + custom_display_name: 'A5', + height_microns: 210000, + name: 'ISO_A5', + width_microns: 148000 + }, + A6: { + custom_display_name: 'A6', + height_microns: 148000, + name: 'ISO_A6', + width_microns: 105000 } } as const; From 03a1deb25cb3863a77f0e60a820ab62f10abfd8c Mon Sep 17 00:00:00 2001 From: Keeley Hammond <vertedinde@electronjs.org> Date: Wed, 15 Feb 2023 17:50:10 -0800 Subject: [PATCH 073/172] build: use node 18.12 in AppVeyor (22-x-y) (#37284) * build: use node18.12 appveyor image * build: use e-108.0.5359.215-node18 --- appveyor-bake.yml | 2 +- appveyor.yml | 2 +- script/prepare-appveyor.js | 4 ++-- script/setup-win-for-dev.bat | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/appveyor-bake.yml b/appveyor-bake.yml index 919545dcd0b16..cea07d20a9808 100644 --- a/appveyor-bake.yml +++ b/appveyor-bake.yml @@ -6,7 +6,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-111.0.5560.0-2 +image: e-111.0.5560.0-node18 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/appveyor.yml b/appveyor.yml index 81dc092a8da16..5f7f59cd32b28 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-108.0.5359.215 +image: e-108.0.5359.215-node18 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/script/prepare-appveyor.js b/script/prepare-appveyor.js index 210aec54c7900..aef52619038c4 100644 --- a/script/prepare-appveyor.js +++ b/script/prepare-appveyor.js @@ -14,8 +14,8 @@ const ROLLER_BRANCH_PATTERN = /^roller\/chromium$/; const DEFAULT_BUILD_CLOUD_ID = '1598'; const DEFAULT_BUILD_CLOUD = 'electronhq-16-core'; -const DEFAULT_BAKE_BASE_IMAGE = 'e-111.0.5560.0-2'; -const DEFAULT_BUILD_IMAGE = 'e-111.0.5560.0-2'; +const DEFAULT_BAKE_BASE_IMAGE = 'e-111.0.5560.0-node18'; +const DEFAULT_BUILD_IMAGE = 'e-111.0.5560.0-node18'; const appveyorBakeJob = 'electron-bake-image'; const appVeyorJobs = { diff --git a/script/setup-win-for-dev.bat b/script/setup-win-for-dev.bat index 2b5fb9a2eabfa..d311c0fc6226b 100644 --- a/script/setup-win-for-dev.bat +++ b/script/setup-win-for-dev.bat @@ -56,7 +56,8 @@ REM Install Windows SDK choco install windows-sdk-10-version-2104-all REM Install nodejs python git and yarn needed dependencies -choco install -y nodejs-lts python2 git yarn +choco install -y --force nodejs --version=18.12.1 +choco install -y python2 git yarn choco install python --version 3.7.9 call C:\ProgramData\chocolatey\bin\RefreshEnv.cmd SET PATH=C:\Python27\;C:\Python27\Scripts;C:\Python39\;C:\Python39\Scripts;%PATH% From 5f115c89671a36b8e4687ab834bcaaea5d15830e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 16 Feb 2023 15:56:32 -0800 Subject: [PATCH 074/172] docs: only macOS 10.13+ is supported now (#37289) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <miburda@microsoft.com> --- docs/api/browser-window.md | 4 ++-- docs/api/menu-item.md | 2 +- docs/api/system-preferences.md | 8 ++------ docs/api/tray.md | 2 +- docs/breaking-changes.md | 7 +++++++ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index b760a36e91897..0d22576ec9837 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -269,7 +269,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. zoom to the width of the screen. This will also affect the behavior when calling `maximize()` directly. Default is `false`. * `tabbingIdentifier` string (optional) _macOS_ - Tab group name, allows - opening the window as a native tab on macOS 10.12+. Windows with the same + opening the window as a native tab. Windows with the same tabbing identifier will be grouped together. This also adds a native new tab button to your window's tab bar and allows your `app` and window to receive the `new-window-for-tab` event. @@ -1847,7 +1847,7 @@ frameless window. Sets the touchBar layout for the current window. Specifying `null` or `undefined` clears the touch bar. This method only has an effect if the -machine has a touch bar and is running on macOS 10.12.1+. +machine has a touch bar. **Note:** The TouchBar API is currently experimental and may change or be removed in future Electron releases. diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index eefd4a53fc9f0..41bec7cd3b71b 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -51,7 +51,7 @@ See [`Menu`](menu.md) for examples. the placement of their containing group after the containing group of the item with the specified label. -**Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development. This property is only usable on macOS High Sierra 10.13 or newer. +**Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development. ### Roles diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md index 2c57be7701660..041ccc19db90a 100644 --- a/docs/api/system-preferences.md +++ b/docs/api/system-preferences.md @@ -394,8 +394,6 @@ system default and override the value of `getEffectiveAppearance`. Returns `boolean` - whether or not this device has the ability to use Touch ID. -**NOTE:** This API will return `false` on macOS systems older than Sierra 10.12.2. - ### `systemPreferences.promptTouchID(reason)` _macOS_ * `reason` string - The reason you are asking for Touch ID authentication @@ -414,8 +412,6 @@ systemPreferences.promptTouchID('To get consent for a Security-Gated Thing').the This API itself will not protect your user data; rather, it is a mechanism to allow you to do so. Native apps will need to set [Access Control Constants](https://developer.apple.com/documentation/security/secaccesscontrolcreateflags?language=objc) like [`kSecAccessControlUserPresence`](https://developer.apple.com/documentation/security/secaccesscontrolcreateflags/ksecaccesscontroluserpresence?language=objc) on their keychain entry so that reading it would auto-prompt for Touch ID biometric consent. This could be done with [`node-keytar`](https://github.com/atom/node-keytar), such that one would store an encryption key with `node-keytar` and only fetch it if `promptTouchID()` resolves. -**NOTE:** This API will return a rejected Promise on macOS systems older than Sierra 10.12.2. - ### `systemPreferences.isTrustedAccessibilityClient(prompt)` _macOS_ * `prompt` boolean - whether or not the user will be informed via prompt if the current process is untrusted. @@ -428,7 +424,7 @@ Returns `boolean` - `true` if the current process is a trusted accessibility cli Returns `string` - Can be `not-determined`, `granted`, `denied`, `restricted` or `unknown`. -This user consent was not required on macOS 10.13 High Sierra or lower so this method will always return `granted`. +This user consent was not required on macOS 10.13 High Sierra so this method will always return `granted`. macOS 10.14 Mojave or higher requires consent for `microphone` and `camera` access. macOS 10.15 Catalina or higher requires consent for `screen` access. @@ -443,7 +439,7 @@ Returns `Promise<boolean>` - A promise that resolves with `true` if consent was **Important:** In order to properly leverage this API, you [must set](https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos?language=objc) the `NSMicrophoneUsageDescription` and `NSCameraUsageDescription` strings in your app's `Info.plist` file. The values for these keys will be used to populate the permission dialogs so that the user will be properly informed as to the purpose of the permission request. See [Electron Application Distribution](../tutorial/application-distribution.md#rebranding-with-downloaded-binaries) for more information about how to set these in the context of Electron. -This user consent was not required until macOS 10.14 Mojave, so this method will always return `true` if your system is running 10.13 High Sierra or lower. +This user consent was not required until macOS 10.14 Mojave, so this method will always return `true` if your system is running 10.13 High Sierra. ### `systemPreferences.getAnimationSettings()` diff --git a/docs/api/tray.md b/docs/api/tray.md index 2514931dd0d10..e531778ba0e4c 100644 --- a/docs/api/tray.md +++ b/docs/api/tray.md @@ -235,7 +235,7 @@ Sets the hover text for this tray icon. * `title` string * `options` Object (optional) - * `fontType` string (optional) - The font family variant to display, can be `monospaced` or `monospacedDigit`. `monospaced` is available in macOS 10.15+ and `monospacedDigit` is available in macOS 10.11+. When left blank, the title uses the default system font. + * `fontType` string (optional) - The font family variant to display, can be `monospaced` or `monospacedDigit`. `monospaced` is available in macOS 10.15+ When left blank, the title uses the default system font. Sets the title displayed next to the tray icon in the status bar (Support ANSI colors). diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 31d950f354019..01aff3c085b22 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -146,6 +146,13 @@ webContents.printToPDF({ ## Planned Breaking API Changes (20.0) +### Removed: macOS 10.11 / 10.12 support + +macOS 10.11 (El Capitan) and macOS 10.12 (Sierra) are no longer supported by [Chromium](https://chromium-review.googlesource.com/c/chromium/src/+/3646050). + +Older versions of Electron will continue to run on these operating systems, but macOS 10.13 (High Sierra) +or later will be required to run Electron v20.0.0 and higher. + ### Default Changed: renderers without `nodeIntegration: true` are sandboxed by default Previously, renderers that specified a preload script defaulted to being From 9db65bac75220907556f42f83d5f54dc73e8ecf9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sun, 19 Feb 2023 01:26:35 -0800 Subject: [PATCH 075/172] test: fix "crash cases" tests not failing properly (#37324) * test: fix "crash cases" tests not failing properly Co-authored-by: Alexey Kuzmin <alex.s.kuzmin@gmail.com> * fixup! test: fix "crash cases" tests not failing properly Co-authored-by: Alexey Kuzmin <alex.s.kuzmin@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Alexey Kuzmin <alex.s.kuzmin@gmail.com> --- spec/crash-spec.ts | 21 ++++++++++++--------- spec/modules-spec.ts | 6 +++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/spec/crash-spec.ts b/spec/crash-spec.ts index dae3c75cec4a2..f2ef00021d93e 100644 --- a/spec/crash-spec.ts +++ b/spec/crash-spec.ts @@ -8,7 +8,7 @@ const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases'); let children: cp.ChildProcessWithoutNullStreams[] = []; -const runFixtureAndEnsureCleanExit = (args: string[]) => { +const runFixtureAndEnsureCleanExit = async (args: string[]) => { let out = ''; const child = cp.spawn(process.execPath, args); children.push(child); @@ -18,17 +18,20 @@ const runFixtureAndEnsureCleanExit = (args: string[]) => { child.stderr.on('data', (chunk: Buffer) => { out += chunk.toString(); }); - return new Promise<void>((resolve) => { + + type CodeAndSignal = {code: number | null, signal: NodeJS.Signals | null}; + const { code, signal } = await new Promise<CodeAndSignal>((resolve) => { child.on('exit', (code, signal) => { - if (code !== 0 || signal !== null) { - console.error(out); - } - expect(signal).to.equal(null, 'exit signal should be null'); - expect(code).to.equal(0, 'should have exited with code 0'); - children = children.filter(c => c !== child); - resolve(); + resolve({ code, signal }); }); }); + if (code !== 0 || signal !== null) { + console.error(out); + } + children = children.filter(c => c !== child); + + expect(signal).to.equal(null, 'exit signal should be null'); + expect(code).to.equal(0, 'should have exited with code 0'); }; const shouldRunCase = (crashCase: string) => { diff --git a/spec/modules-spec.ts b/spec/modules-spec.ts index 3654100345b94..75ce818c6154c 100644 --- a/spec/modules-spec.ts +++ b/spec/modules-spec.ts @@ -62,10 +62,10 @@ describe('modules support', () => { ifit(features.isRunAsNodeEnabled())('can be required in node binary', async function () { const child = childProcess.fork(path.join(fixtures, 'module', 'uv-dlopen.js')); - await new Promise<void>(resolve => child.once('exit', (exitCode) => { - expect(exitCode).to.equal(0); - resolve(); + const exitCode = await new Promise<number | null>(resolve => child.once('exit', (exitCode) => { + resolve(exitCode); })); + expect(exitCode).to.equal(0); }); }); From 1df44118af1884b73f80a1087280ea694e0457dc Mon Sep 17 00:00:00 2001 From: Keeley Hammond <vertedinde@electronjs.org> Date: Mon, 20 Feb 2023 03:31:27 -0800 Subject: [PATCH 076/172] chore: cherry-pick e0efbd45ea74 from webrtc (#37298) --- patches/webrtc/.patches | 1 + patches/webrtc/cherry-pick-e0efbd45ea74.patch | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 patches/webrtc/cherry-pick-e0efbd45ea74.patch diff --git a/patches/webrtc/.patches b/patches/webrtc/.patches index e69de29bb2d1d..9c8215e984e93 100644 --- a/patches/webrtc/.patches +++ b/patches/webrtc/.patches @@ -0,0 +1 @@ +cherry-pick-e0efbd45ea74.patch diff --git a/patches/webrtc/cherry-pick-e0efbd45ea74.patch b/patches/webrtc/cherry-pick-e0efbd45ea74.patch new file mode 100644 index 0000000000000..7e62974f93689 --- /dev/null +++ b/patches/webrtc/cherry-pick-e0efbd45ea74.patch @@ -0,0 +1,57 @@ +From e0efbd45ea7421fb944c7343254ac5dc22bee541 Mon Sep 17 00:00:00 2001 +From: Henrik Boström <hbos@webrtc.org> +Date: Fri, 20 Jan 2023 10:48:31 +0100 +Subject: [PATCH] [Merge-110] [Stats] Handle the case of missing certificates. + +Certificates being missing is a sign of a bug (e.g. webrtc:14844, to be +fixed separately) which is why we have a DCHECK. But this DCHECK does +not protect against accessing the invalid iterator if it is a release +build. This CL makes that safe. + +# Mobile bots not running properly +NOTRY=True + +(cherry picked from commit 124d7c3fe5bdc79a355c9df02d07f25331631a68) + +Bug: chromium:1408392 +Change-Id: I97a82786028e41c58ef8ef15002c3f959bbec7f1 +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291109 +Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> +Commit-Queue: Henrik Boström <hbos@webrtc.org> +Cr-Original-Commit-Position: refs/heads/main@{#39159} +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291380 +Cr-Commit-Position: refs/branch-heads/5481@{#2} +Cr-Branched-From: 2e1a9a4ae0234d4b1ea7a6fd4188afa1fb20379d-refs/heads/main@{#38901} +--- + +diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc +index d500a7b..1d88566 100644 +--- a/pc/rtc_stats_collector.cc ++++ b/pc/rtc_stats_collector.cc +@@ -2192,16 +2192,17 @@ + // exist. + const auto& certificate_stats_it = + transport_cert_stats.find(transport_name); ++ std::string local_certificate_id, remote_certificate_id; + RTC_DCHECK(certificate_stats_it != transport_cert_stats.cend()); +- std::string local_certificate_id; +- if (certificate_stats_it->second.local) { +- local_certificate_id = RTCCertificateIDFromFingerprint( +- certificate_stats_it->second.local->fingerprint); +- } +- std::string remote_certificate_id; +- if (certificate_stats_it->second.remote) { +- remote_certificate_id = RTCCertificateIDFromFingerprint( +- certificate_stats_it->second.remote->fingerprint); ++ if (certificate_stats_it != transport_cert_stats.cend()) { ++ if (certificate_stats_it->second.local) { ++ local_certificate_id = RTCCertificateIDFromFingerprint( ++ certificate_stats_it->second.local->fingerprint); ++ } ++ if (certificate_stats_it->second.remote) { ++ remote_certificate_id = RTCCertificateIDFromFingerprint( ++ certificate_stats_it->second.remote->fingerprint); ++ } + } + + // There is one transport stats for each channel. From 87ec774248d93657d472c13005ff3bff64198983 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:49:07 +0900 Subject: [PATCH 077/172] fix: restoring X11 window should not remove previous maximize state (#37360) * fix: restoring X11 window should not remove previous maximize state Co-authored-by: Cheng Zhao <zcbenz@gmail.com> * chore: update patches --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Cheng Zhao <zcbenz@gmail.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + ...w_restore_minimized_maximized_window.patch | 55 +++++++++++++++++++ spec/api-browser-window-spec.ts | 18 ++++++ 3 files changed, 74 insertions(+) create mode 100644 patches/chromium/fix_x11_window_restore_minimized_maximized_window.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 270124491cc3a..5313c5c8bf0c1 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -127,3 +127,4 @@ cherry-pick-3235c1d1955b.patch expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch +fix_x11_window_restore_minimized_maximized_window.patch diff --git a/patches/chromium/fix_x11_window_restore_minimized_maximized_window.patch b/patches/chromium/fix_x11_window_restore_minimized_maximized_window.patch new file mode 100644 index 0000000000000..b5e9702f8d1bc --- /dev/null +++ b/patches/chromium/fix_x11_window_restore_minimized_maximized_window.patch @@ -0,0 +1,55 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cheng Zhao <zcbenz@gmail.com> +Date: Wed, 15 Feb 2023 11:30:56 +0900 +Subject: fix: restoring a X11 window should not remove its previous maximized + state + +On Linux after minimizing a maximized window, it will have both the +"maximized" and "hidden" states, and restoring the window should only remove +the "hidden" state, which makes it back a maximized window. + +However in the implementation of `X11Window::Restore`, both "maximized" and +"hidden" states are removed, and a maximized window that was minimized will +be resized to its normal size after calling Restore, while the correct +behavior should be going back to the maximized state. + +Backported from: +https://chromium-review.googlesource.com/c/chromium/src/+/4252946 + +diff --git a/ui/ozone/platform/x11/x11_window.cc b/ui/ozone/platform/x11/x11_window.cc +index 45e0a75a643c2d7a70af37cbf38dcbde52fdd0cf..b229800eafabb0c810430d615cc165ff1e356491 100644 +--- a/ui/ozone/platform/x11/x11_window.cc ++++ b/ui/ozone/platform/x11/x11_window.cc +@@ -729,11 +729,16 @@ void X11Window::Minimize() { + } + + void X11Window::Restore() { +- should_maximize_after_map_ = false; +- restore_in_flight_ = true; +- SetWMSpecState(false, x11::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), +- x11::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); +- SetWMSpecState(false, x11::GetAtom("_NET_WM_STATE_HIDDEN"), x11::Atom::None); ++ if (IsMinimized()) { ++ restore_in_flight_ = true; ++ SetWMSpecState(false, x11::GetAtom("_NET_WM_STATE_HIDDEN"), ++ x11::Atom::None); ++ } else if (IsMaximized()) { ++ restore_in_flight_ = true; ++ should_maximize_after_map_ = false; ++ SetWMSpecState(false, x11::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), ++ x11::GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); ++ } + } + + PlatformWindowState X11Window::GetPlatformWindowState() const { +@@ -1884,6 +1889,10 @@ bool X11Window::IsMinimized() const { + } + + bool X11Window::IsMaximized() const { ++ // In X11, if a maximized window is minimized, it will have both the "hidden" ++ // and "maximized" states. ++ if (IsMinimized()) ++ return false; + return (HasWMSpecProperty(window_properties_, + x11::GetAtom("_NET_WM_STATE_MAXIMIZED_VERT")) && + HasWMSpecProperty(window_properties_, diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index c4de29de835d1..f8422eda0491a 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -3977,6 +3977,24 @@ describe('BrowserWindow module', () => { w.hide(); w.show(); }); + + // TODO(zcbenz): + // This test does not run on Linux CI. See: + // https://github.com/electron/electron/issues/28699 + ifit(process.platform === 'linux' && !process.env.CI)('should bring a minimized maximized window back to maximized state', async () => { + const w = new BrowserWindow({}); + const maximize = emittedOnce(w, 'maximize'); + w.maximize(); + await maximize; + const minimize = emittedOnce(w, 'minimize'); + w.minimize(); + await minimize; + expect(w.isMaximized()).to.equal(false); + const restore = emittedOnce(w, 'restore'); + w.restore(); + await restore; + expect(w.isMaximized()).to.equal(true); + }); }); // TODO(dsanders11): Enable once maximize event works on Linux again on CI From 7e02e1d6da6fceb7cded5a99ecb029b4979e863d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 1 Mar 2023 12:24:26 +0100 Subject: [PATCH 078/172] fix: `Notification` with reply obscuring first action on macOS (#37447) fix: Notification with reply obscuring first action Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- .../notifications/mac/cocoa_notification.mm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/shell/browser/notifications/mac/cocoa_notification.mm b/shell/browser/notifications/mac/cocoa_notification.mm index 92ec55a6ab5ca..06f896d8131fa 100644 --- a/shell/browser/notifications/mac/cocoa_notification.mm +++ b/shell/browser/notifications/mac/cocoa_notification.mm @@ -58,7 +58,11 @@ [notification_ setSoundName:base::SysUTF16ToNSString(options.sound)]; } - [notification_ setHasActionButton:false]; + if (options.has_reply) { + [notification_ setHasReplyButton:true]; + [notification_ setResponsePlaceholder:base::SysUTF16ToNSString( + options.reply_placeholder)]; + } int i = 0; action_index_ = UINT_MAX; @@ -66,7 +70,10 @@ [[[NSMutableArray alloc] init] autorelease]; for (const auto& action : options.actions) { if (action.type == u"button") { - if (action_index_ == UINT_MAX) { + // If the notification has both a reply and actions, + // the reply takes precedence and the actions all + // become additional actions. + if (!options.has_reply && action_index_ == UINT_MAX) { // First button observed is the displayed action [notification_ setHasActionButton:true]; [notification_ @@ -86,16 +93,11 @@ } i++; } + if ([additionalActions count] > 0) { [notification_ setAdditionalActions:additionalActions]; } - if (options.has_reply) { - [notification_ setResponsePlaceholder:base::SysUTF16ToNSString( - options.reply_placeholder)]; - [notification_ setHasReplyButton:true]; - } - if (!options.close_button_text.empty()) { [notification_ setOtherButtonTitle:base::SysUTF16ToNSString( options.close_button_text)]; From 0384c57eb543dc8abf96d5314e735bdeafcddf1b Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:22:45 +0100 Subject: [PATCH 079/172] fix: min/max width/height enforcement when `aspectRatio` is set (#37458) fix: min/max width/height with aspect ratio Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- .../ui/cocoa/electron_ns_window_delegate.mm | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/shell/browser/ui/cocoa/electron_ns_window_delegate.mm b/shell/browser/ui/cocoa/electron_ns_window_delegate.mm index 243c2d3993dc3..b8556ba422fe3 100644 --- a/shell/browser/ui/cocoa/electron_ns_window_delegate.mm +++ b/shell/browser/ui/cocoa/electron_ns_window_delegate.mm @@ -128,16 +128,17 @@ - (void)windowDidResignKey:(NSNotification*)notification { - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize { NSSize newSize = frameSize; double aspectRatio = shell_->GetAspectRatio(); + NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); if (aspectRatio > 0.0) { gfx::Size windowSize = shell_->GetSize(); gfx::Size contentSize = shell_->GetContentSize(); gfx::Size extraSize = shell_->GetAspectRatioExtraSize(); + double titleBarHeight = windowSize.height() - contentSize.height(); double extraWidthPlusFrame = windowSize.width() - contentSize.width() + extraSize.width(); - double extraHeightPlusFrame = - windowSize.height() - contentSize.height() + extraSize.height(); + double extraHeightPlusFrame = titleBarHeight + extraSize.height(); newSize.width = roundf((frameSize.height - extraHeightPlusFrame) * aspectRatio + @@ -145,10 +146,44 @@ - (NSSize)windowWillResize:(NSWindow*)sender toSize:(NSSize)frameSize { newSize.height = roundf((newSize.width - extraWidthPlusFrame) / aspectRatio + extraHeightPlusFrame); + + // Clamp to minimum width/height while ensuring aspect ratio remains. + NSSize minSize = [window minSize]; + NSSize zeroSize = + shell_->has_frame() ? NSMakeSize(0, titleBarHeight) : NSZeroSize; + if (!NSEqualSizes(minSize, zeroSize)) { + double minWidthForAspectRatio = + (minSize.height - titleBarHeight) * aspectRatio; + bool atMinHeight = + minSize.height > zeroSize.height && newSize.height <= minSize.height; + newSize.width = atMinHeight ? minWidthForAspectRatio + : std::max(newSize.width, minSize.width); + + double minHeightForAspectRatio = minSize.width / aspectRatio; + bool atMinWidth = + minSize.width > zeroSize.width && newSize.width <= minSize.width; + newSize.height = atMinWidth ? minHeightForAspectRatio + : std::max(newSize.height, minSize.height); + } + + // Clamp to maximum width/height while ensuring aspect ratio remains. + NSSize maxSize = [window maxSize]; + if (!NSEqualSizes(maxSize, NSMakeSize(FLT_MAX, FLT_MAX))) { + double maxWidthForAspectRatio = maxSize.height * aspectRatio; + bool atMaxHeight = + maxSize.height < FLT_MAX && newSize.height >= maxSize.height; + newSize.width = atMaxHeight ? maxWidthForAspectRatio + : std::min(newSize.width, maxSize.width); + + double maxHeightForAspectRatio = maxSize.width / aspectRatio; + bool atMaxWidth = + maxSize.width < FLT_MAX && newSize.width >= maxSize.width; + newSize.height = atMaxWidth ? maxHeightForAspectRatio + : std::min(newSize.height, maxSize.height); + } } if (!resizingHorizontally_) { - NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); const auto widthDelta = frameSize.width - [window frame].size.width; const auto heightDelta = frameSize.height - [window frame].size.height; resizingHorizontally_ = std::abs(widthDelta) > std::abs(heightDelta); From 5d3eea593437830ea16e4901f0410feadb0718d4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:49:02 +0100 Subject: [PATCH 080/172] chore: improve `contents.takeHeapSnapshot` error messages (#37459) * chore: improve contents.takeHeapSnapshot error messages Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * fix wstring conversion issue Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- .../browser/api/electron_api_web_contents.cc | 16 +++++++++++---- spec/api-web-contents-spec.ts | 20 +++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 015e27406e932..ab338d399762d 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -3528,18 +3528,26 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot( base::File file(file_path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); if (!file.IsValid()) { - promise.RejectWithErrorMessage("takeHeapSnapshot failed"); + promise.RejectWithErrorMessage( + "Failed to take heap snapshot with invalid file path " + +#if BUILDFLAG(IS_WIN) + base::WideToUTF8(file_path.value())); +#else + file_path.value()); +#endif return handle; } auto* frame_host = web_contents()->GetPrimaryMainFrame(); if (!frame_host) { - promise.RejectWithErrorMessage("takeHeapSnapshot failed"); + promise.RejectWithErrorMessage( + "Failed to take heap snapshot with invalid webContents main frame"); return handle; } if (!frame_host->IsRenderFrameLive()) { - promise.RejectWithErrorMessage("takeHeapSnapshot failed"); + promise.RejectWithErrorMessage( + "Failed to take heap snapshot with nonexistent render frame"); return handle; } @@ -3559,7 +3567,7 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot( if (success) { promise.Resolve(); } else { - promise.RejectWithErrorMessage("takeHeapSnapshot failed"); + promise.RejectWithErrorMessage("Failed to take heap snapshot"); } }, base::Owned(std::move(electron_renderer)), std::move(promise))); diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index 1b999d348ff9a..b35fa5a1923f4 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -1836,8 +1836,24 @@ describe('webContents module', () => { await w.loadURL('about:blank'); - const promise = w.webContents.takeHeapSnapshot(''); - return expect(promise).to.be.eventually.rejectedWith(Error, 'takeHeapSnapshot failed'); + const badPath = path.join('i', 'am', 'a', 'super', 'bad', 'path'); + const promise = w.webContents.takeHeapSnapshot(badPath); + return expect(promise).to.be.eventually.rejectedWith(Error, `Failed to take heap snapshot with invalid file path ${badPath}`); + }); + + it('fails with invalid render process', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { + sandbox: true + } + }); + + const filePath = path.join(app.getPath('temp'), 'test.heapsnapshot'); + + w.webContents.destroy(); + const promise = w.webContents.takeHeapSnapshot(filePath); + return expect(promise).to.be.eventually.rejectedWith(Error, 'Failed to take heap snapshot with nonexistent render frame'); }); }); From 0b529388528317ee881dbb6550c924e509096646 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 6 Mar 2023 11:04:10 +0100 Subject: [PATCH 081/172] chore: cherry-pick aeec1ba5893d from chromium (#37481) * chore: [22-x-y] cherry-pick aeec1ba5893d from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-aeec1ba5893d.patch | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 patches/chromium/cherry-pick-aeec1ba5893d.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 5313c5c8bf0c1..2aa60e753c234 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,3 +128,4 @@ expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch fix_x11_window_restore_minimized_maximized_window.patch +cherry-pick-aeec1ba5893d.patch diff --git a/patches/chromium/cherry-pick-aeec1ba5893d.patch b/patches/chromium/cherry-pick-aeec1ba5893d.patch new file mode 100644 index 0000000000000..9ddb0390d3d94 --- /dev/null +++ b/patches/chromium/cherry-pick-aeec1ba5893d.patch @@ -0,0 +1,89 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Peng Huang <penghuang@chromium.org> +Date: Mon, 13 Feb 2023 22:10:44 +0000 +Subject: Fix UAF problem in AngleVulkanImageBacking + +Right now, we use vulkan fence helper to release the backing. +It is right, if the last usage of the backing is by skia. +If the last usage is by gl, the fence helper(skia) isn't aware of +the submitted work from ANGLE, skia may call flush finish callback +to release the backing while the backing is still being referenced +by works in ANGLE. Fix the problem by calling glFinish() if the last +usage is GL. + +Know issue: the finish callback of skia flush() is not always called +in order. So in edge cases, the UAF problem can still happen. + +(cherry picked from commit d5143b14a00807b40eada4dfb0bce610ffc1477a) + +Bug: 1309035 +Change-Id: I3562043650dd2b27bde3a370bef45b1226cdd48c +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4232858 +Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> +Commit-Queue: Peng Huang <penghuang@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1102905} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4245959 +Cr-Commit-Position: refs/branch-heads/5481@{#1119} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.cc b/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.cc +index a2239f19b8d1002bbf511ba53a9eab6b39b84653..c8b53477a7e7dd5685be1b4aef725911e605825b 100644 +--- a/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.cc ++++ b/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.cc +@@ -161,6 +161,11 @@ AngleVulkanImageBacking::~AngleVulkanImageBacking() { + + passthrough_texture_.reset(); + egl_image_.reset(); ++ ++ if (need_gl_finish_before_destroy_ && have_context()) { ++ gl::GLApi* api = gl::g_current_gl_context; ++ api->glFinishFn(); ++ } + } + + if (vulkan_image_) { +@@ -325,8 +330,9 @@ void AngleVulkanImageBacking::GLTextureImageRepresentationEndAccess( + --gl_reads_in_process_; + + // For the last GL read access, release texture from ANGLE. +- if (gl_reads_in_process_ == 0) ++ if (gl_reads_in_process_ == 0) { + ReleaseTextureANGLE(); ++ } + + return; + } +@@ -356,6 +362,9 @@ void AngleVulkanImageBacking::ReleaseTextureANGLE() { + GLuint texture = passthrough_texture_->service_id(); + // Release the texture from ANGLE, so it can be used elsewhere. + api->glReleaseTexturesANGLEFn(1, &texture, &layout_); ++ // Releasing the texture will submit all related works to queue, so to be ++ // safe, glFinish() should be called before releasing the VkImage. ++ need_gl_finish_before_destroy_ = true; + } + + void AngleVulkanImageBacking::PrepareBackendTexture() { +@@ -435,6 +444,11 @@ void AngleVulkanImageBacking::EndAccessSkia() { + return; + } + ++ // The backing is used by skia, so skia should submit related work to the ++ // queue, and we can use vulkan fence helper to release the VkImage. ++ // glFinish() is not necessary anymore. ++ need_gl_finish_before_destroy_ = false; ++ + SyncImageLayoutFromBackendTexture(); + + if (gl_reads_in_process_ > 0) { +diff --git a/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.h b/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.h +index e773aed4b20db46d7a12a10961d88ff643f9c8ec..9306868802d81af87b8a3d6a0e5ea69d57ac6685 100644 +--- a/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.h ++++ b/gpu/command_buffer/service/shared_image/angle_vulkan_image_backing.h +@@ -80,6 +80,7 @@ class AngleVulkanImageBacking : public ClearTrackingSharedImageBacking, + bool is_gl_write_in_process_ = false; + int skia_reads_in_process_ = 0; + int gl_reads_in_process_ = 0; ++ bool need_gl_finish_before_destroy_ = false; + }; + + } // namespace gpu From 76f5059db421fe5ff822989ae89e6f5ab1f7d070 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 6 Mar 2023 11:44:03 +0100 Subject: [PATCH 082/172] chore: cherry-pick 218b56e51638 from webrtc (#37485) --- patches/webrtc/.patches | 1 + patches/webrtc/cherry-pick-218b56e51638.patch | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 patches/webrtc/cherry-pick-218b56e51638.patch diff --git a/patches/webrtc/.patches b/patches/webrtc/.patches index 9c8215e984e93..ff43ad9385c19 100644 --- a/patches/webrtc/.patches +++ b/patches/webrtc/.patches @@ -1 +1,2 @@ cherry-pick-e0efbd45ea74.patch +cherry-pick-218b56e51638.patch diff --git a/patches/webrtc/cherry-pick-218b56e51638.patch b/patches/webrtc/cherry-pick-218b56e51638.patch new file mode 100644 index 0000000000000..3d24052a2a2e2 --- /dev/null +++ b/patches/webrtc/cherry-pick-218b56e51638.patch @@ -0,0 +1,60 @@ +From 218b56e516386cd57c7513197528c3124bcd7ef3 Mon Sep 17 00:00:00 2001 +From: Alexander Cooper <alcooper@chromium.org> +Date: Wed, 08 Feb 2023 14:16:01 -0800 +Subject: [PATCH] Fix Destruction inside WGC Callback + +If we are notified of the destruction of the window before a +CaptureFrame call can fail, then we may end up attempting to destroy the +underlying WGC object inside it's own event handler. This can be +problematic, as the class itself may want to run other code. Instead, +we just unsubscribe and signal that any future CaptureFrame calls should +reject. + +This also removes setting "is_capture_started_=false" in the item closed +handler, as all that served to do is cause the WgcCapturerWin code to +attempt to restart the capturer, and somewhat muddies up our metrics. + +(cherry picked from commit 318cf28945d80a0ac6f09382e507c95e649cc4c1) + +Bug: chromium:1413005 +No-Try: True +Change-Id: Ibccb7a2e7ce531ba80b4b331b9bc2cda0ff75f4e +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/292762 +Auto-Submit: Alexander Cooper <alcooper@chromium.org> +Reviewed-by: Mark Foltz <mfoltz@chromium.org> +Commit-Queue: Mark Foltz <mfoltz@chromium.org> +Commit-Queue: Alexander Cooper <alcooper@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#39275} +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/293246 +Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> +Cr-Commit-Position: refs/branch-heads/5481@{#5} +Cr-Branched-From: 2e1a9a4ae0234d4b1ea7a6fd4188afa1fb20379d-refs/heads/main@{#38901} +--- + +diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc +index e165291..ea5565c 100644 +--- a/modules/desktop_capture/win/wgc_capture_session.cc ++++ b/modules/desktop_capture/win/wgc_capture_session.cc +@@ -397,17 +397,14 @@ + + RTC_LOG(LS_INFO) << "Capture target has been closed."; + item_closed_ = true; +- is_capture_started_ = false; + + RemoveEventHandlers(); + +- mapped_texture_ = nullptr; +- session_ = nullptr; +- frame_pool_ = nullptr; +- direct3d_device_ = nullptr; +- item_ = nullptr; +- d3d11_device_ = nullptr; +- ++ // Do not attempt to free resources in the OnItemClosed handler, as this ++ // causes a race where we try to delete the item that is calling us. Removing ++ // the event handlers and setting `item_closed_` above is sufficient to ensure ++ // that the resources are no longer used, and the next time the capturer tries ++ // to get a frame, we will report a permanent failure and be destroyed. + return S_OK; + } + From 8352346fff5b81582e1ca4c3d2fb510b5468c48e Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 6 Mar 2023 15:47:16 +0000 Subject: [PATCH 083/172] chore: cherry-pick 06851790480e from chromium (#37483) * chore: cherry-pick 06851790480e from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-06851790480e.patch | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 patches/chromium/cherry-pick-06851790480e.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 2aa60e753c234..e661282d020bf 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,4 +128,5 @@ expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch fix_x11_window_restore_minimized_maximized_window.patch +cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch diff --git a/patches/chromium/cherry-pick-06851790480e.patch b/patches/chromium/cherry-pick-06851790480e.patch new file mode 100644 index 0000000000000..d961eeefae8ec --- /dev/null +++ b/patches/chromium/cherry-pick-06851790480e.patch @@ -0,0 +1,91 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: "Tommy C. Li" <tommycli@chromium.org> +Date: Tue, 21 Feb 2023 18:55:00 +0000 +Subject: Exclude Policy and Play API engines from Sync merging + +There's a security bug in which the call to ResetTemplateURLGUID can +cause a policy-created engine to be deleted. This means that after +the call, either the current `conflicting_turl` pointer, or future +iterations in the loop may point to an already-freed TemplateURL, +causing the use-after free bug. + +This CL addresses that by forbidding Policy-created and Play API +engines from being merged into Synced engines. + +Although Play API engines aren't directly affected, they seem to also +not be something that should be merged to Synced engines. + +(cherry picked from commit 315632458eb795ef9d9dce3fd1062f9e6f2c2077) + +Bug: 1414224 +Change-Id: Ide43d71e9844e04a7ffe2e7ad2a522b6ca1535a3 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4250623 +Reviewed-by: Matthew Denton <mpdenton@chromium.org> +Reviewed-by: Mikel Astiz <mastiz@chromium.org> +Commit-Queue: Tommy Li <tommycli@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1106249} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4274984 +Reviewed-by: Tommy Li <tommycli@chromium.org> +Commit-Queue: Krishna Govind <govind@chromium.org> +Cr-Commit-Position: refs/branch-heads/5481@{#1238} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc +index 2de150bbca0bf9032e207754203e60f2ee1f115f..b552f1d844e44b34eadaca850408754488b9d27b 100644 +--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc ++++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc +@@ -732,6 +732,34 @@ TEST_F(TemplateURLServiceSyncTest, MergeAddFromNewerSyncData) { + processor()->change_for_guid("localguid3").change_type()); + } + ++TEST_F(TemplateURLServiceSyncTest, MergeIgnoresPolicyAndPlayAPIEngines) { ++ // Add a policy-created engine. ++ model()->Add(CreateTestTemplateURL(u"key1", "http://key1.com", "localguid1", ++ base::Time::FromTimeT(100), ++ /*safe_for_autoreplace=*/false, ++ /*created_by_policy=*/true)); ++ ++ { ++ auto play_api_engine = CreateTestTemplateURL( ++ u"key2", "http://key2.com", "localguid2", base::Time::FromTimeT(100)); ++ TemplateURLData data(play_api_engine->data()); ++ data.created_from_play_api = true; ++ play_api_engine = std::make_unique<TemplateURL>(data); ++ model()->Add(std::move(play_api_engine)); ++ } ++ ++ ASSERT_EQ(1U, model()->GetAllSyncData(syncer::SEARCH_ENGINES).size()); ++ MergeAndExpectNotify(CreateInitialSyncData(), 1); ++ ++ // The policy engine should be ignored when it comes to conflict resolution. ++ EXPECT_TRUE(model()->GetTemplateURLForGUID("guid1")); ++ EXPECT_TRUE(model()->GetTemplateURLForGUID("localguid1")); ++ ++ // The Play API engine should be ignored when it comes to conflict resolution. ++ EXPECT_TRUE(model()->GetTemplateURLForGUID("guid2")); ++ EXPECT_TRUE(model()->GetTemplateURLForGUID("localguid2")); ++} ++ + TEST_F(TemplateURLServiceSyncTest, ProcessChangesEmptyModel) { + // We initially have no data. + MergeAndExpectNotify({}, 0); +diff --git a/components/search_engines/template_url_service.cc b/components/search_engines/template_url_service.cc +index 61e7fabfed76c251ee2e3186ab60c56da54be551..824383536eed1560aa50b6892603e3a1aa601c53 100644 +--- a/components/search_engines/template_url_service.cc ++++ b/components/search_engines/template_url_service.cc +@@ -2175,7 +2175,14 @@ void TemplateURLService::MergeInSyncTemplateURL( + keyword_to_turl_and_length_.equal_range(sync_turl->keyword()); + for (auto it = match_range.first; it != match_range.second; ++it) { + TemplateURL* local_turl = it->second.first; +- if (local_turl->type() == TemplateURL::NORMAL) { ++ // The conflict resolution code below sometimes resets the TemplateURL's ++ // GUID, which can trigger deleting any Policy-created engines. Avoid this ++ // use-after-free bug by excluding any Policy-created engines. Also exclude ++ // Play API created engines, as those also seem local-only and should not ++ // be merged into Synced engines. crbug.com/1414224. ++ if (local_turl->type() == TemplateURL::NORMAL && ++ !local_turl->created_by_policy() && ++ !local_turl->created_from_play_api()) { + local_duplicates.push_back(local_turl); + } + } From d44fd392720b097f3664161efff0fde12cc30b65 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 7 Mar 2023 21:35:29 +0100 Subject: [PATCH 084/172] fix: don't double-log unhandled rejections (#37502) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/browser/electron_browser_main_parts.cc | 2 +- shell/renderer/electron_renderer_client.cc | 2 +- .../api/unhandled-rejection-handled.js | 13 +++++++ spec/fixtures/api/unhandled-rejection.js | 5 +++ spec/node-spec.ts | 36 +++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/api/unhandled-rejection-handled.js create mode 100644 spec/fixtures/api/unhandled-rejection.js diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 2f3446f5d8700..952856ffd7611 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -279,7 +279,7 @@ void ElectronBrowserMainParts::PostEarlyInitialization() { env->set_trace_sync_io(env->options()->trace_sync_io); // We do not want to crash the main process on unhandled rejections. - env->options()->unhandled_rejections = "warn"; + env->options()->unhandled_rejections = "warn-with-error-code"; // Add Electron extended APIs. electron_bindings_->BindTo(js_env_->isolate(), env->process_object()); diff --git a/shell/renderer/electron_renderer_client.cc b/shell/renderer/electron_renderer_client.cc index c3884cb6ba191..a5ce46e989673 100644 --- a/shell/renderer/electron_renderer_client.cc +++ b/shell/renderer/electron_renderer_client.cc @@ -96,7 +96,7 @@ void ElectronRendererClient::DidCreateScriptContext( env->options()->force_context_aware = true; // We do not want to crash the renderer process on unhandled rejections. - env->options()->unhandled_rejections = "warn"; + env->options()->unhandled_rejections = "warn-with-error-code"; environments_.insert(env); diff --git a/spec/fixtures/api/unhandled-rejection-handled.js b/spec/fixtures/api/unhandled-rejection-handled.js new file mode 100644 index 0000000000000..17557fbfaece8 --- /dev/null +++ b/spec/fixtures/api/unhandled-rejection-handled.js @@ -0,0 +1,13 @@ +const { app } = require('electron'); + +const handleUnhandledRejection = (reason) => { + console.error(`Unhandled Rejection: ${reason.stack}`); + app.quit(); +}; + +const main = async () => { + process.on('unhandledRejection', handleUnhandledRejection); + throw new Error('oops'); +}; + +main(); diff --git a/spec/fixtures/api/unhandled-rejection.js b/spec/fixtures/api/unhandled-rejection.js new file mode 100644 index 0000000000000..fa47d6c56a7fc --- /dev/null +++ b/spec/fixtures/api/unhandled-rejection.js @@ -0,0 +1,5 @@ +const main = async () => { + throw new Error('oops'); +}; + +main(); diff --git a/spec/node-spec.ts b/spec/node-spec.ts index d30b1f8a5ba61..11bbd50661792 100644 --- a/spec/node-spec.ts +++ b/spec/node-spec.ts @@ -226,6 +226,42 @@ describe('node feature', () => { })); expect(result).to.equal('hello'); }); + + it('does not log the warning more than once when the rejection is unhandled', async () => { + const appPath = path.join(mainFixturesPath, 'api', 'unhandled-rejection.js'); + const appProcess = childProcess.spawn(process.execPath, [appPath]); + + let output = ''; + const out = (data: string) => { + output += data; + if (/UnhandledPromiseRejectionWarning/.test(data)) { + appProcess.kill(); + } + }; + appProcess.stdout!.on('data', out); + appProcess.stderr!.on('data', out); + + await emittedOnce(appProcess, 'exit'); + expect(/UnhandledPromiseRejectionWarning/.test(output)).to.equal(true); + const matches = output.match(/Error: oops/gm); + expect(matches).to.have.lengthOf(1); + }); + + it('does not log the warning more than once when the rejection is handled', async () => { + const appPath = path.join(mainFixturesPath, 'api', 'unhandled-rejection-handled.js'); + const appProcess = childProcess.spawn(process.execPath, [appPath]); + + let output = ''; + const out = (data: string) => { output += data; }; + appProcess.stdout!.on('data', out); + appProcess.stderr!.on('data', out); + + const [code] = await emittedOnce(appProcess, 'exit'); + expect(code).to.equal(0); + expect(/UnhandledPromiseRejectionWarning/.test(output)).to.equal(false); + const matches = output.match(/Error: oops/gm); + expect(matches).to.have.lengthOf(1); + }); }); }); From e4800bab8603e4f3cdf75bdb9ee7d02bc0077d30 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Tue, 7 Mar 2023 20:35:47 +0000 Subject: [PATCH 085/172] chore: cherry-pick e79b89b47dac from chromium (#37479) * chore: [22-x-y] cherry-pick e79b89b47dac from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-e79b89b47dac.patch | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 patches/chromium/cherry-pick-e79b89b47dac.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index e661282d020bf..82bf06ee9da50 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,5 +128,6 @@ expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch fix_x11_window_restore_minimized_maximized_window.patch +cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch diff --git a/patches/chromium/cherry-pick-e79b89b47dac.patch b/patches/chromium/cherry-pick-e79b89b47dac.patch new file mode 100644 index 0000000000000..9f8e447fbd595 --- /dev/null +++ b/patches/chromium/cherry-pick-e79b89b47dac.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Vasiliy Telezhnikov <vasilyt@chromium.org> +Date: Fri, 10 Feb 2023 17:36:57 +0000 +Subject: CHECK that YUV readback finished synchronously + +DoReadbackYUVImagePixelsINTERNAL is implemented using skia asynchronous +readback and to make it synchronous we use sync cpu and gpu. In some +edge cases on linux we saw that doesn't happen if readback triggered +vulkan device lost. + +To avoid use after free, CHECK that callback was actually called. In +case of device-lost gpu process will restart anyway, so while this is +not proper fix of the problem, it doesn't result in worse user visible +behaviour. + +(cherry picked from commit 081df1e7d3712131bcaa575bda2e37ec7f6aa83d) + +Bug: 1399742 +Change-Id: Ie2172539bb907b9696ef62c70d398aca3967177c +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4143606 +Reviewed-by: Peng Huang <penghuang@chromium.org> +Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1093064} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4239960 +Cr-Commit-Position: refs/branch-heads/5481@{#1084} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/gpu/command_buffer/service/raster_decoder.cc b/gpu/command_buffer/service/raster_decoder.cc +index d2ac0ac70902d68b95417d2a95da153a7fc38128..ef79b5cbcc83d5ed12a9627ce76692476ace10a0 100644 +--- a/gpu/command_buffer/service/raster_decoder.cc ++++ b/gpu/command_buffer/service/raster_decoder.cc +@@ -2485,6 +2485,7 @@ void RasterDecoderImpl::DoReadbackARGBImagePixelsINTERNAL( + namespace { + struct YUVReadbackResult { + std::unique_ptr<const SkImage::AsyncReadResult> async_result; ++ bool finished = false; + }; + + void OnReadYUVImagePixelsDone( +@@ -2492,6 +2493,7 @@ void OnReadYUVImagePixelsDone( + std::unique_ptr<const SkImage::AsyncReadResult> async_result) { + YUVReadbackResult* context = reinterpret_cast<YUVReadbackResult*>(raw_ctx); + context->async_result = std::move(async_result); ++ context->finished = true; + } + } // namespace + +@@ -2689,6 +2691,10 @@ void RasterDecoderImpl::DoReadbackYUVImagePixelsINTERNAL( + // asynchronous by removing this flush and implementing a query that can + // signal back to client process. + gr_context()->flushAndSubmit(true); ++ ++ // The call above will sync up gpu and CPU, resulting in callback being run ++ // during flushAndSubmit. To prevent UAF make sure it indeed happened. ++ CHECK(yuv_result.finished); + if (!yuv_result.async_result) { + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadbackYUVImagePixels", + "Failed to read pixels from SkImage"); From 432eba940631d551542a6317e8f59bc750e3e9d6 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 9 Mar 2023 03:02:48 +0000 Subject: [PATCH 086/172] chore: cherry-pick 999cc7185e93 and 0f0b3a54c53c from chromium (#37477) * chore: [22-x-y] cherry-pick 999cc7185e93 and 0f0b3a54c53c from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 2 + ..._webmediaplayermscompositor_lifetime.patch | 381 ++++++++++++++++++ ...bmediaplayermscompositor_destruction.patch | 124 ++++++ 3 files changed, 507 insertions(+) create mode 100644 patches/chromium/m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch create mode 100644 patches/chromium/m108-lts_simplify_webmediaplayermscompositor_destruction.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 82bf06ee9da50..59fea467ce60d 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,6 +128,8 @@ expose_v8initializer_codegenerationcheckcallbackinmainthread.patch cherry-pick-43637378b14e.patch axselectedtextmarkerrange_should_not_be_backwards.patch fix_x11_window_restore_minimized_maximized_window.patch +m108-lts_simplify_webmediaplayermscompositor_destruction.patch +m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch diff --git a/patches/chromium/m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch b/patches/chromium/m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch new file mode 100644 index 0000000000000..27a6e56980549 --- /dev/null +++ b/patches/chromium/m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch @@ -0,0 +1,381 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dale Curtis <dalecurtis@chromium.org> +Date: Mon, 20 Feb 2023 13:16:32 +0000 +Subject: Further simplify WebMediaPlayerMSCompositor lifetime. + +M108 merge issues: + third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc: + - video_task_runner_ is named io_task_runner_ in 108 + + third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc: + - video_task_runner_ is named io_task_runner_ in 108 (conflict in ReplaceCurrentFrameWithACopy) + +Due to the raw pointer held by VideoFrameSubmitter, there may be +tasks pending on the compositor task runner after the RefCounted +traits have "destructed" WebMediaPlayerMSCompositor. Through this +raw pointer VFS was invoking OnContextLost which attempts to use +the zero ref count compositor. + +The solution here is again similar to VideoFrameCompositor, its +destruction should be explicit instead of a tangle of RefCounted +owners. + +(cherry picked from commit 1622bffc6534a0cc4f53d07c43e0cd8f49975d10) + +Fixed: 1407701, 1411601 +Change-Id: Ic77294d1113d54ab83bc0f5b625a997edf57bf7c +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4210508 +Commit-Queue: Tony Herre <toprice@chromium.org> +Auto-Submit: Dale Curtis <dalecurtis@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1099726} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4225393 +Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> +Reviewed-by: Oleh Lamzin <lamzin@google.com> +Owners-Override: Oleh Lamzin <lamzin@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1392} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/third_party/blink/public/web/modules/mediastream/webmediaplayer_ms.h b/third_party/blink/public/web/modules/mediastream/webmediaplayer_ms.h +index f8c640d4f866afafa6fab82d67fe5f866810f828..955f867cc24152fa88dd6c20de006425a20b77c5 100644 +--- a/third_party/blink/public/web/modules/mediastream/webmediaplayer_ms.h ++++ b/third_party/blink/public/web/modules/mediastream/webmediaplayer_ms.h +@@ -211,6 +211,8 @@ class BLINK_MODULES_EXPORT WebMediaPlayerMS + static const gfx::Size kUseGpuMemoryBufferVideoFramesMinResolution; + #endif // BUILDFLAG(IS_WIN) + ++ void ReplaceCurrentFrameWithACopy(); ++ + bool IsInPictureInPicture() const; + + // Switch to SurfaceLayer, either initially or from VideoLayer. +@@ -313,7 +315,7 @@ class BLINK_MODULES_EXPORT WebMediaPlayerMS + // Used for DCHECKs to ensure methods calls executed in the correct thread. + THREAD_CHECKER(thread_checker_); + +- scoped_refptr<WebMediaPlayerMSCompositor> compositor_; ++ std::unique_ptr<WebMediaPlayerMSCompositor> compositor_; + + const WebString initial_audio_output_device_id_; + +diff --git a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc +index e4eb2b0053384d3e89545928c22bc2e1a12580fa..a85406d39037a8003eaffd1a91c8021ad38e0267 100644 +--- a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc ++++ b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc +@@ -399,8 +399,9 @@ WebMediaPlayerMS::~WebMediaPlayerMS() { + SendLogMessage( + String::Format("%s() [delegate_id=%d]", __func__, delegate_id_)); + +- if (!web_stream_.IsNull()) ++ if (!web_stream_.IsNull()) { + web_stream_.RemoveObserver(this); ++ } + + // Destruct compositor resources in the proper order. + get_client()->SetCcLayer(nullptr); +@@ -409,14 +410,35 @@ WebMediaPlayerMS::~WebMediaPlayerMS() { + video_layer_->StopUsingProvider(); + } + +- if (frame_deliverer_) +- io_task_runner_->DeleteSoon(FROM_HERE, frame_deliverer_.release()); ++ if (frame_deliverer_) { ++ io_task_runner_->DeleteSoon(FROM_HERE, std::move(frame_deliverer_)); ++ } + +- if (video_frame_provider_) ++ if (video_frame_provider_) { + video_frame_provider_->Stop(); ++ } + +- if (audio_renderer_) ++ // This must be destroyed before `compositor_` since it will grab a couple of ++ // final metrics during destruction. ++ watch_time_reporter_.reset(); ++ ++ if (compositor_) { ++ // `compositor_` receives frames on `io_task_runner_` from ++ // `frame_deliverer_` and operates on the `compositor_task_runner_`, so ++ // must trampoline through both to ensure a safe destruction. ++ PostCrossThreadTask( ++ *io_task_runner_, FROM_HERE, ++ WTF::CrossThreadBindOnce( ++ [](scoped_refptr<base::SingleThreadTaskRunner> task_runner, ++ std::unique_ptr<WebMediaPlayerMSCompositor> compositor) { ++ task_runner->DeleteSoon(FROM_HERE, std::move(compositor)); ++ }, ++ compositor_task_runner_, std::move(compositor_))); ++ } ++ ++ if (audio_renderer_) { + audio_renderer_->Stop(); ++ } + + media_log_->AddEvent<media::MediaLogEvent::kWebMediaPlayerDestroyed>(); + +@@ -457,7 +479,7 @@ WebMediaPlayer::LoadTiming WebMediaPlayerMS::Load( + + watch_time_reporter_.reset(); + +- compositor_ = base::MakeRefCounted<WebMediaPlayerMSCompositor>( ++ compositor_ = std::make_unique<WebMediaPlayerMSCompositor>( + compositor_task_runner_, io_task_runner_, web_stream_, + std::move(submitter_), use_surface_layer_, weak_this_); + +@@ -480,7 +502,7 @@ WebMediaPlayer::LoadTiming WebMediaPlayerMS::Load( + frame_deliverer_ = std::make_unique<WebMediaPlayerMS::FrameDeliverer>( + weak_this_, + CrossThreadBindRepeating(&WebMediaPlayerMSCompositor::EnqueueFrame, +- compositor_), ++ CrossThreadUnretained(compositor_.get())), + media_task_runner_, worker_task_runner_, gpu_factories_); + video_frame_provider_ = renderer_factory_->GetVideoRenderer( + web_stream_, +@@ -826,7 +848,19 @@ void WebMediaPlayerMS::Pause() { + video_frame_provider_->Pause(); + + compositor_->StopRendering(); +- compositor_->ReplaceCurrentFrameWithACopy(); ++ ++ // Bounce this call off of video task runner to since there might still be ++ // frames passed on video task runner. ++ PostCrossThreadTask( ++ *io_task_runner_, FROM_HERE, ++ WTF::CrossThreadBindOnce( ++ [](scoped_refptr<base::SingleThreadTaskRunner> task_runner, ++ WTF::CrossThreadOnceClosure copy_cb) { ++ PostCrossThreadTask(*task_runner, FROM_HERE, std::move(copy_cb)); ++ }, ++ main_render_task_runner_, ++ WTF::CrossThreadBindOnce( ++ &WebMediaPlayerMS::ReplaceCurrentFrameWithACopy, weak_this_))); + + if (audio_renderer_) + audio_renderer_->Pause(); +@@ -841,6 +875,11 @@ void WebMediaPlayerMS::Pause() { + paused_ = true; + } + ++void WebMediaPlayerMS::ReplaceCurrentFrameWithACopy() { ++ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); ++ compositor_->ReplaceCurrentFrameWithACopy(); ++} ++ + void WebMediaPlayerMS::Seek(double seconds) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + } +@@ -1192,7 +1231,8 @@ void WebMediaPlayerMS::ActivateSurfaceLayerForVideo( + PostCrossThreadTask( + *compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::EnableSubmission, +- compositor_, bridge_->GetSurfaceId(), video_transform, ++ CrossThreadUnretained(compositor_.get()), ++ bridge_->GetSurfaceId(), video_transform, + IsInPictureInPicture())); + + // If the element is already in Picture-in-Picture mode, it means that it +diff --git a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc +index acbdf1c64f0efed4c665de270d712bf446eb2106..67f0c200d85073ecd677e467bc1d624b1817dde0 100644 +--- a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc ++++ b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc +@@ -197,18 +197,18 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( + dropped_frame_count_(0), + stopped_(true), + render_started_(!stopped_) { ++ weak_this_ = weak_ptr_factory_.GetWeakPtr(); + if (use_surface_layer) { + submitter_ = std::move(submitter); + + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::InitializeSubmitter, +- weak_ptr_factory_.GetWeakPtr())); ++ weak_this_)); + update_submission_state_callback_ = base::BindPostTask( + video_frame_compositor_task_runner_, + ConvertToBaseRepeatingCallback(CrossThreadBindRepeating( +- &WebMediaPlayerMSCompositor::SetIsSurfaceVisible, +- weak_ptr_factory_.GetWeakPtr()))); ++ &WebMediaPlayerMSCompositor::SetIsSurfaceVisible, weak_this_))); + } + + HeapVector<Member<MediaStreamComponent>> video_components; +@@ -236,27 +236,12 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( + } + + WebMediaPlayerMSCompositor::~WebMediaPlayerMSCompositor() { +- // Ensured by destructor traits. + DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); + if (video_frame_provider_client_) { + video_frame_provider_client_->StopUsingProvider(); + } + } + +-// static +-void WebMediaPlayerMSCompositorTraits::Destruct( +- const WebMediaPlayerMSCompositor* compositor) { +- if (!compositor->video_frame_compositor_task_runner_ +- ->BelongsToCurrentThread()) { +- PostCrossThreadTask( +- *compositor->video_frame_compositor_task_runner_, FROM_HERE, +- CrossThreadBindOnce(&WebMediaPlayerMSCompositorTraits::Destruct, +- CrossThreadUnretained(compositor))); +- return; +- } +- delete compositor; +-} +- + void WebMediaPlayerMSCompositor::InitializeSubmitter() { + DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); + submitter_->Initialize(this, /*is_media_stream=*/true); +@@ -302,7 +287,7 @@ void WebMediaPlayerMSCompositor::SetForceBeginFrames(bool enable) { + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::SetForceBeginFrames, +- weak_ptr_factory_.GetWeakPtr(), enable)); ++ weak_this_, enable)); + return; + } + +@@ -604,7 +589,7 @@ void WebMediaPlayerMSCompositor::StartRendering() { + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::StartRenderingInternal, +- WrapRefCounted(this))); ++ weak_this_)); + } + + void WebMediaPlayerMSCompositor::StopRendering() { +@@ -612,18 +597,7 @@ void WebMediaPlayerMSCompositor::StopRendering() { + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::StopRenderingInternal, +- WrapRefCounted(this))); +-} +- +-void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopy() { +- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); +- // Bounce this call off of IO thread to since there might still be frames +- // passed on IO thread. +- io_task_runner_->PostTask( +- FROM_HERE, +- media::BindToCurrentLoop(WTF::BindOnce( +- &WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopyInternal, +- WrapRefCounted(this)))); ++ weak_this_)); + } + + bool WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks( +@@ -690,7 +664,7 @@ void WebMediaPlayerMSCompositor::RenderWithoutAlgorithm( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce( + &WebMediaPlayerMSCompositor::RenderWithoutAlgorithmOnCompositor, +- WrapRefCounted(this), std::move(frame), is_copy)); ++ weak_this_, std::move(frame), is_copy)); + } + + void WebMediaPlayerMSCompositor::RenderWithoutAlgorithmOnCompositor( +@@ -790,9 +764,8 @@ void WebMediaPlayerMSCompositor::SetCurrentFrame( + PostCrossThreadTask( + *video_frame_compositor_task_runner_, FROM_HERE, + CrossThreadBindOnce(&WebMediaPlayerMSCompositor::CheckForFrameChanges, +- WrapRefCounted(this), is_first_frame, +- has_frame_size_changed, std::move(new_transform), +- std::move(new_opacity))); ++ weak_this_, is_first_frame, has_frame_size_changed, ++ std::move(new_transform), std::move(new_opacity))); + } + + void WebMediaPlayerMSCompositor::CheckForFrameChanges( +@@ -859,7 +832,7 @@ void WebMediaPlayerMSCompositor::StopRenderingInternal() { + video_frame_provider_client_->StopRendering(); + } + +-void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopyInternal() { ++void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopy() { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + scoped_refptr<media::VideoFrame> current_frame_ref; + { +diff --git a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h +index ffeb448be295223f1f997b47eddff37d04bc8f16..197a0f0d02e84378f7f697213aa613e73c9f79f7 100644 +--- a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h ++++ b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h +@@ -24,7 +24,6 @@ + #include "third_party/blink/renderer/modules/mediastream/video_renderer_algorithm_wrapper.h" + #include "third_party/blink/renderer/modules/modules_export.h" + #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" +-#include "third_party/blink/renderer/platform/wtf/thread_safe_ref_counted.h" + + namespace base { + class SingleThreadTaskRunner; +@@ -46,7 +45,6 @@ class SurfaceId; + namespace blink { + class MediaStreamDescriptor; + class WebMediaPlayerMS; +-struct WebMediaPlayerMSCompositorTraits; + + // This class is designed to handle the work load on compositor thread for + // WebMediaPlayerMS. It will be instantiated on the main thread, but destroyed +@@ -58,9 +56,7 @@ struct WebMediaPlayerMSCompositorTraits; + // Otherwise, WebMediaPlayerMSCompositor will simply store the most recent + // frame, and submit it whenever asked by the compositor. + class MODULES_EXPORT WebMediaPlayerMSCompositor +- : public cc::VideoFrameProvider, +- public WTF::ThreadSafeRefCounted<WebMediaPlayerMSCompositor, +- WebMediaPlayerMSCompositorTraits> { ++ : public cc::VideoFrameProvider { + public: + using OnNewFramePresentedCB = base::OnceClosure; + +@@ -76,6 +72,7 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + std::unique_ptr<WebVideoFrameSubmitter> submitter, + bool use_surface_layer, + const base::WeakPtr<WebMediaPlayerMS>& player); ++ ~WebMediaPlayerMSCompositor() override; + + WebMediaPlayerMSCompositor(const WebMediaPlayerMSCompositor&) = delete; + WebMediaPlayerMSCompositor& operator=(const WebMediaPlayerMSCompositor&) = +@@ -143,10 +140,7 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + Metadata GetMetadata(); + + private: +- friend class WTF::ThreadSafeRefCounted<WebMediaPlayerMSCompositor, +- WebMediaPlayerMSCompositorTraits>; + friend class WebMediaPlayerMSTest; +- friend struct WebMediaPlayerMSCompositorTraits; + + // Struct used to keep information about frames pending in + // |rendering_frame_buffer_|. +@@ -157,8 +151,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + bool is_copy; + }; + +- ~WebMediaPlayerMSCompositor() override; +- + // Ran on the |video_frame_compositor_task_runner_| to initialize + // |submitter_| + void InitializeSubmitter(); +@@ -204,7 +196,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + + void StartRenderingInternal(); + void StopRenderingInternal(); +- void ReplaceCurrentFrameWithACopyInternal(); + + void SetAlgorithmEnabledForTesting(bool algorithm_enabled); + void RecordFrameDisplayedStats(base::TimeTicks frame_displayed_time); +@@ -314,15 +305,10 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + // |dropped_frame_count_|, |current_metadata_| and |render_started_|. + base::Lock current_frame_lock_; + ++ base::WeakPtr<WebMediaPlayerMSCompositor> weak_this_; + base::WeakPtrFactory<WebMediaPlayerMSCompositor> weak_ptr_factory_{this}; + }; + +-struct WebMediaPlayerMSCompositorTraits { +- // Ensure destruction occurs on main thread so that "Web" and other resources +- // are destroyed on the correct thread. +- static void Destruct(const WebMediaPlayerMSCompositor* player); +-}; +- + } // namespace blink + + #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIASTREAM_WEBMEDIAPLAYER_MS_COMPOSITOR_H_ diff --git a/patches/chromium/m108-lts_simplify_webmediaplayermscompositor_destruction.patch b/patches/chromium/m108-lts_simplify_webmediaplayermscompositor_destruction.patch new file mode 100644 index 0000000000000..13a9d09a0379b --- /dev/null +++ b/patches/chromium/m108-lts_simplify_webmediaplayermscompositor_destruction.patch @@ -0,0 +1,124 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dale Curtis <dalecurtis@chromium.org> +Date: Mon, 20 Feb 2023 10:08:49 +0000 +Subject: Simplify WebMediaPlayerMSCompositor destruction. + +The code was only sometimes calling StopUsingProvider() and posted +the submitter destruction unnecessarily. + +Destruction now works the same as in VideoFrameCompositor, where the +class itself is responsible for calling StopUsingProvider() during +its own destruction. + +(cherry picked from commit cbd238e85903b7d94910bd2c6362ff9abf9908cc) + +Fixed: 1407701 +Disallow-Recycled-Builds: test-failures +Change-Id: Ia649cb5532519468eea34e12745ed9c990580d82 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4195824 +Auto-Submit: Dale Curtis <dalecurtis@chromium.org> +Commit-Queue: Tony Herre <toprice@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1098505} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4225498 +Reviewed-by: Oleh Lamzin <lamzin@google.com> +Owners-Override: Oleh Lamzin <lamzin@google.com> +Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1391} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc +index 01b3e059e339341995deb9c27e248ab272acd1b2..e4eb2b0053384d3e89545928c22bc2e1a12580fa 100644 +--- a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc ++++ b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms.cc +@@ -412,9 +412,6 @@ WebMediaPlayerMS::~WebMediaPlayerMS() { + if (frame_deliverer_) + io_task_runner_->DeleteSoon(FROM_HERE, frame_deliverer_.release()); + +- if (compositor_) +- compositor_->StopUsingProvider(); +- + if (video_frame_provider_) + video_frame_provider_->Stop(); + +diff --git a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc +index 63957929facc933c23eef3fc200f140b73cb3f50..acbdf1c64f0efed4c665de270d712bf446eb2106 100644 +--- a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc ++++ b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.cc +@@ -238,13 +238,8 @@ WebMediaPlayerMSCompositor::WebMediaPlayerMSCompositor( + WebMediaPlayerMSCompositor::~WebMediaPlayerMSCompositor() { + // Ensured by destructor traits. + DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); +- +- if (submitter_) { +- video_frame_compositor_task_runner_->DeleteSoon(FROM_HERE, +- std::move(submitter_)); +- } else { +- DCHECK(!video_frame_provider_client_) +- << "Must call StopUsingProvider() before dtor!"; ++ if (video_frame_provider_client_) { ++ video_frame_provider_client_->StopUsingProvider(); + } + } + +@@ -264,7 +259,7 @@ void WebMediaPlayerMSCompositorTraits::Destruct( + + void WebMediaPlayerMSCompositor::InitializeSubmitter() { + DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); +- submitter_->Initialize(this, /* is_media_stream = */ true); ++ submitter_->Initialize(this, /*is_media_stream=*/true); + } + + void WebMediaPlayerMSCompositor::SetIsSurfaceVisible( +@@ -631,15 +626,6 @@ void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopy() { + WrapRefCounted(this)))); + } + +-void WebMediaPlayerMSCompositor::StopUsingProvider() { +- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); +- PostCrossThreadTask( +- *video_frame_compositor_task_runner_, FROM_HERE, +- CrossThreadBindOnce( +- &WebMediaPlayerMSCompositor::StopUsingProviderInternal, +- WrapRefCounted(this))); +-} +- + bool WebMediaPlayerMSCompositor::MapTimestampsToRenderTimeTicks( + const std::vector<base::TimeDelta>& timestamps, + std::vector<base::TimeTicks>* wall_clock_times) { +@@ -873,13 +859,6 @@ void WebMediaPlayerMSCompositor::StopRenderingInternal() { + video_frame_provider_client_->StopRendering(); + } + +-void WebMediaPlayerMSCompositor::StopUsingProviderInternal() { +- DCHECK(video_frame_compositor_task_runner_->BelongsToCurrentThread()); +- if (video_frame_provider_client_) +- video_frame_provider_client_->StopUsingProvider(); +- video_frame_provider_client_ = nullptr; +-} +- + void WebMediaPlayerMSCompositor::ReplaceCurrentFrameWithACopyInternal() { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + scoped_refptr<media::VideoFrame> current_frame_ref; +diff --git a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h +index a82497399be7588298f4c740ef67e18ee429967d..ffeb448be295223f1f997b47eddff37d04bc8f16 100644 +--- a/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h ++++ b/third_party/blink/renderer/modules/mediastream/webmediaplayer_ms_compositor.h +@@ -119,10 +119,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + void StopRendering(); + void ReplaceCurrentFrameWithACopy(); + +- // Tell |video_frame_provider_client_| to stop using this instance in +- // preparation for dtor. +- void StopUsingProvider(); +- + // Sets a hook to be notified when a new frame is presented, to fulfill a + // prending video.requestAnimationFrame() request. + // Can be called from any thread. +@@ -208,7 +204,6 @@ class MODULES_EXPORT WebMediaPlayerMSCompositor + + void StartRenderingInternal(); + void StopRenderingInternal(); +- void StopUsingProviderInternal(); + void ReplaceCurrentFrameWithACopyInternal(); + + void SetAlgorithmEnabledForTesting(bool algorithm_enabled); From a831d69dfdd74655e95f93130c286662e1ba343d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 14 Mar 2023 20:20:18 -0400 Subject: [PATCH 087/172] docs: clarify `open-url` not preventable (#37574) docs: clarify open-url not preventable Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- docs/api/app.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index ffa185b9d5609..c4679c6939b35 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -128,8 +128,6 @@ Emitted when the user wants to open a URL with the application. Your application `Info.plist` file must define the URL scheme within the `CFBundleURLTypes` key, and set `NSPrincipalClass` to `AtomApplication`. -You should call `event.preventDefault()` if you want to handle this event. - As with the `open-file` event, be sure to register a listener for the `open-url` event early in your application startup to detect if the the application being is being opened to handle a URL. If you register the listener in response to a From 24ce94856c4459ec9336ebb69f24ece0509bc13c Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 16 Mar 2023 13:48:29 +0100 Subject: [PATCH 088/172] fix: don't set delegate for `QLPreviewPanel` (#37576) fix: don't set delegate for QLPreviewPanel Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Spiegel <jeremy.spiegel@frontapp.com> --- shell/browser/ui/cocoa/electron_ns_window.mm | 2 -- spec/api-browser-window-spec.ts | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 0ad17da24e967..cab135a8167fb 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -185,12 +185,10 @@ - (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel*)panel { } - (void)beginPreviewPanelControl:(QLPreviewPanel*)panel { - panel.delegate = [self delegate]; panel.dataSource = static_cast<id<QLPreviewPanelDataSource>>([self delegate]); } - (void)endPreviewPanelControl:(QLPreviewPanel*)panel { - panel.delegate = nil; panel.dataSource = nil; } diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index f8422eda0491a..8cfc6dd9821f3 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -5202,6 +5202,22 @@ describe('BrowserWindow module', () => { w.closeFilePreview(); }).to.not.throw(); }); + + it('should not call BrowserWindow show event', async () => { + const w = new BrowserWindow({ show: false }); + const shown = emittedOnce(w, 'show'); + w.show(); + await shown; + + let showCalled = false; + w.on('show', () => { + showCalled = true; + }); + + w.previewFile(__filename); + await delay(500); + expect(showCalled).to.equal(false, 'should not have called show twice'); + }); }); // TODO (jkleinsc) renable these tests on mas arm64 From 14707ad2b54a4254ccc8c2c476e2c57b1299b2d9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:22:40 +0100 Subject: [PATCH 089/172] fix: properly bubble up cookie creation failure message (#37595) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/browser/api/electron_api_cookies.cc | 15 ++++++++++----- spec/api-net-spec.ts | 10 ++++++++++ spec/api-session-spec.ts | 4 ++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index 50208a28ccd0c..edc980aa8feeb 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -177,7 +177,7 @@ std::string InclusionStatusToString(net::CookieInclusionStatus status) { return "Failed to parse cookie"; if (status.HasExclusionReason( net::CookieInclusionStatus::EXCLUDE_INVALID_DOMAIN)) - return "Failed to get cookie domain"; + return "Failed to set cookie with an invalid domain attribute"; if (status.HasExclusionReason( net::CookieInclusionStatus::EXCLUDE_INVALID_PREFIX)) return "Failed because the cookie violated prefix rules."; @@ -315,19 +315,24 @@ v8::Local<v8::Promise> Cookies::Set(v8::Isolate* isolate, return handle; } + net::CookieInclusionStatus status; auto canonical_cookie = net::CanonicalCookie::CreateSanitizedCookie( url, name ? *name : "", value ? *value : "", domain ? *domain : "", path ? *path : "", ParseTimeProperty(details.FindDouble("creationDate")), ParseTimeProperty(details.FindDouble("expirationDate")), ParseTimeProperty(details.FindDouble("lastAccessDate")), secure, http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, same_party, - absl::nullopt); + absl::nullopt, &status); + if (!canonical_cookie || !canonical_cookie->IsCanonical()) { - promise.RejectWithErrorMessage( - InclusionStatusToString(net::CookieInclusionStatus( - net::CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE))); + promise.RejectWithErrorMessage(InclusionStatusToString( + !status.IsInclude() + ? status + : net::CookieInclusionStatus( + net::CookieInclusionStatus::EXCLUDE_FAILURE_TO_STORE))); return handle; } + net::CookieOptions options; if (http_only) { options.set_include_httponly(); diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index 2629e5a6544b9..c808b2c5abf18 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -829,6 +829,16 @@ describe('net module', () => { expect(cookies[0].name).to.equal('cookie2'); }); + it('throws when an invalid domain is passed', async () => { + const sess = session.fromPartition(`cookie-tests-${Math.random()}`); + + await expect(sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'wssss.iamabaddomain.fun', + name: 'cookie1' + })).to.eventually.be.rejectedWith(/Failed to set cookie with an invalid domain attribute/); + }); + it('should be able correctly filter out cookies that are session', async () => { const sess = session.fromPartition(`cookie-tests-${Math.random()}`); diff --git a/spec/api-session-spec.ts b/spec/api-session-spec.ts index 886f8ed72ef83..8f574877193c7 100644 --- a/spec/api-session-spec.ts +++ b/spec/api-session-spec.ts @@ -129,7 +129,7 @@ describe('session module', () => { await expect( cookies.set({ url: '', name, value }) - ).to.eventually.be.rejectedWith('Failed to get cookie domain'); + ).to.eventually.be.rejectedWith('Failed to set cookie with an invalid domain attribute'); }); it('yields an error when setting a cookie with an invalid URL', async () => { @@ -139,7 +139,7 @@ describe('session module', () => { await expect( cookies.set({ url: 'asdf', name, value }) - ).to.eventually.be.rejectedWith('Failed to get cookie domain'); + ).to.eventually.be.rejectedWith('Failed to set cookie with an invalid domain attribute'); }); it('should overwrite previous cookies', async () => { From bb88e69ccc05798755df3d16acf27a00341cd225 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 20:47:23 -0400 Subject: [PATCH 090/172] fix: invoke `app.dock.{hide|show}` instead of duplicating logic (#37623) fix: invoke app.dock.{hide|show} instead of duplicating logic Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/browser/native_window_mac.mm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index e878c9cb73fe8..577a6fa1bc056 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -22,6 +22,7 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/desktop_media_id.h" +#include "shell/browser/browser.h" #include "shell/browser/javascript_environment.h" #include "shell/browser/native_browser_view_mac.h" #include "shell/browser/ui/cocoa/electron_native_widget_mac.h" @@ -1348,18 +1349,15 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { void NativeWindowMac::SetVisibleOnAllWorkspaces(bool visible, bool visibleOnFullScreen, bool skipTransformProcessType) { - // In order for NSWindows to be visible on fullscreen we need to functionally - // mimic app.dock.hide() since Apple changed the underlying functionality of + // In order for NSWindows to be visible on fullscreen we need to invoke + // app.dock.hide() since Apple changed the underlying functionality of // NSWindows starting with 10.14 to disallow NSWindows from floating on top of // fullscreen apps. if (!skipTransformProcessType) { - ProcessSerialNumber psn = {0, kCurrentProcess}; if (visibleOnFullScreen) { - [window_ setCanHide:NO]; - TransformProcessType(&psn, kProcessTransformToUIElementApplication); + Browser::Get()->DockHide(); } else { - [window_ setCanHide:YES]; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); + Browser::Get()->DockShow(JavascriptEnvironment::GetIsolate()); } } From c8fea8abcfcadb6e826bb734e69d6b6a0eed5ae5 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Wed, 22 Mar 2023 23:56:13 +0000 Subject: [PATCH 091/172] chore: cherry-pick 26bfa5807606 from chromium (#37648) * chore: [22-x-y] cherry-pick 26bfa5807606 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-26bfa5807606.patch | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 patches/chromium/cherry-pick-26bfa5807606.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 59fea467ce60d..c06b2b88a6957 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,3 +133,4 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +cherry-pick-26bfa5807606.patch diff --git a/patches/chromium/cherry-pick-26bfa5807606.patch b/patches/chromium/cherry-pick-26bfa5807606.patch new file mode 100644 index 0000000000000..54805c0053c1a --- /dev/null +++ b/patches/chromium/cherry-pick-26bfa5807606.patch @@ -0,0 +1,61 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: "Steinar H. Gunderson" <sesse@chromium.org> +Date: Tue, 14 Mar 2023 15:53:57 +0000 +Subject: In Typed CSSOM, reject adding to something that is not a list. + +M108 merge issues: + third_party/blink/renderer/core/css/cssom/style_property_map.cc: + The check before the added IsValueList check isn't present in 108 + +(cherry picked from commit 7301cf1e40fdd97594ea491676b867cf4e577edc) + +Fixed: 1417176 +Change-Id: Idef1a81af46d334c181979778c28f19ce6369718 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4293477 +Commit-Queue: Steinar H Gunderson <sesse@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1110281} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4306796 +Commit-Queue: Zakhar Voit <voit@google.com> +Reviewed-by: Steinar H Gunderson <sesse@chromium.org> +Owners-Override: Achuith Bhandarkar <achuith@chromium.org> +Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> +Cr-Commit-Position: refs/branch-heads/5359@{#1405} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/third_party/blink/renderer/core/css/cssom/style_property_map.cc b/third_party/blink/renderer/core/css/cssom/style_property_map.cc +index 2c1bcba6022519c3a865ae8e3c2ffcd5bc385cf3..0cde402b49510514599201d2b3104e56ddd7b572 100644 +--- a/third_party/blink/renderer/core/css/cssom/style_property_map.cc ++++ b/third_party/blink/renderer/core/css/cssom/style_property_map.cc +@@ -365,6 +365,17 @@ void StylePropertyMap::append( + + CSSValueList* current_value = nullptr; + if (const CSSValue* css_value = GetProperty(property_id)) { ++ if (!css_value->IsValueList()) { ++ // The standard doesn't seem to cover this explicitly ++ // (https://github.com/w3c/css-houdini-drafts/issues/823), ++ // but the only really reasonable solution seems to be ++ // to throw a TypeError. ++ // ++ // This covers e.g. system-wide CSS keywords, like inherit. ++ exception_state.ThrowTypeError( ++ "Cannot append to something that is not a list"); ++ return; ++ } + current_value = To<CSSValueList>(css_value)->Copy(); + } else { + current_value = CssValueListForPropertyID(property_id); +diff --git a/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html b/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html +index ee9a9e4ddbcf78a7517d8d038d66844880719e63..f80875622366939f48a7471513fb6319f75be718 100644 +--- a/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html ++++ b/third_party/blink/web_tests/external/wpt/css/css-typed-om/the-stylepropertymap/inline/append.tentative.html +@@ -56,4 +56,10 @@ test(t => { + assert_style_value_array_equals(result, [CSS.s(5), CSS.s(10), CSS.s(1), CSS.s(2)]); + }, 'StylePropertyMap.append is case-insensitive'); + ++// https://crbug.com/1417176 ++test(t => { ++ let styleMap = createInlineStyleMap(t, 'transition-duration: inherit'); ++ assert_throws_js(TypeError, () => styleMap.append('transition-duration', '1s')); ++}, 'StylePropertyMap.append rejects appending to CSS-wide keywords'); ++ + </script> From 2d1ba5626be5a61b6455cddaa4a6995cce59a3bb Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 23 Mar 2023 00:11:38 +0000 Subject: [PATCH 092/172] chore: cherry-pick 55e2b6daba9d from angle (#37656) * chore: [22-x-y] cherry-pick 55e2b6daba9d from angle * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/angle/.patches | 1 + patches/angle/cherry-pick-55e2b6daba9d.patch | 136 +++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 patches/angle/cherry-pick-55e2b6daba9d.patch diff --git a/patches/angle/.patches b/patches/angle/.patches index ca864b58a91d0..dbd34bebf0d81 100644 --- a/patches/angle/.patches +++ b/patches/angle/.patches @@ -1 +1,2 @@ fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch +cherry-pick-55e2b6daba9d.patch diff --git a/patches/angle/cherry-pick-55e2b6daba9d.patch b/patches/angle/cherry-pick-55e2b6daba9d.patch new file mode 100644 index 0000000000000..ea06c77c43c60 --- /dev/null +++ b/patches/angle/cherry-pick-55e2b6daba9d.patch @@ -0,0 +1,136 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shahbaz Youssefi <syoussefi@chromium.org> +Date: Thu, 16 Feb 2023 23:16:46 -0500 +Subject: Vulkan: Don't close render pass if rebind to same fbo + +M108 merge issues: + src/libANGLE/renderer/vulkan/ContextVk.cpp: + - hasActiveRenderPass named hasStartedRenderPass in 108 + - getLastRenderPassQueueSerial named getLastRenderPassSerial in 108 + +In the Vulkan backend, the render pass can occasionally (and +transiently) be in a state of "open but inactive". This is when the +render pass is closed, but has the potential for future modifications +(for example to add a resolve attachment). Under many circumstances, it +is expected that an open render pass cannot be in such a state. + +This assumption can be broken in this scenario: + +- Open render pass, draw, etc +- Change framebuffer binding +- Change framebuffer binding back to original +- Masked Clear + +When ContextVk is synced before clear, it sees that the framebuffer +binding is changed (though it hasn't really), and it closes the render +passes and sets the render pass dirty bit. If a draw were to follow, a +new render pass would have started (unnecessarily). However, in the +case of a masked clear, UtilsVk notices that the render pass is started, +assumes it must be active, and continues recording to it. While the +operation itself succeeds, the assumption that the render pass is active +is false (and fails assertion). + +This change makes sure that framebuffer binding change is no-oped if the +framebuffer is the same one that has opened the current render pass. If +any application does unnecessary binding changes and back, it will be +optimized by this change as well. + +Bug: chromium:1411210 +Change-Id: I37a3a9f2eaa1a81a1b3393840b9458ec71a87377 +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4261215 +Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> +(cherry picked from commit 05e62f39412e8c6bfc98582f5e7a49041991c97b) +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4303738 +Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> + +diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp +index f08877444f66ac2d61953c9c56d4c71d253d53c6..31e1882c8923b81bf5fd74fbe40d8233c7551ec9 100644 +--- a/src/libANGLE/renderer/vulkan/ContextVk.cpp ++++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp +@@ -5022,6 +5022,15 @@ angle::Result ContextVk::syncState(const gl::Context *context, + // as some optimizations in non-draw commands require the render pass to remain + // open, such as invalidate or blit. Note that we always start a new command buffer + // because we currently can only support one open RenderPass at a time. ++ // ++ // The render pass is not closed if binding is changed to the same framebuffer as ++ // before. ++ if (hasStartedRenderPass() && ++ hasStartedRenderPassWithSerial(drawFramebufferVk->getLastRenderPassSerial())) ++ { ++ break; ++ } ++ + onRenderPassFinished(RenderPassClosureReason::FramebufferBindingChange); + if (getFeatures().preferSubmitAtFBOBoundary.enabled) + { +diff --git a/src/tests/gl_tests/ClearTest.cpp b/src/tests/gl_tests/ClearTest.cpp +index 1a6b425da6be1e1c2526a8f5e5d84ea8049ee7ab..41e3ea7efe26d1aa0e0dd0e8e9d5bcd7b6472017 100644 +--- a/src/tests/gl_tests/ClearTest.cpp ++++ b/src/tests/gl_tests/ClearTest.cpp +@@ -2864,6 +2864,26 @@ TEST_P(ClearTest, DISABLED_ClearReachesWindow) + angle::Sleep(2000); + } + ++// Tests that masked clear after a no-op framebuffer binding change with an open render pass works. ++TEST_P(ClearTest, DrawThenChangeFBOBindingAndBackThenMaskedClear) ++{ ++ ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue()); ++ ++ // Draw blue. ++ drawQuad(blueProgram, essl1_shaders::PositionAttrib(), 0.5f); ++ ++ // Change framebuffer and back ++ glBindFramebuffer(GL_FRAMEBUFFER, mFBOs[0]); ++ glBindFramebuffer(GL_FRAMEBUFFER, 0); ++ ++ // Masked clear ++ glColorMask(1, 0, 0, 1); ++ glClearColor(1.0f, 0.5f, 0.5f, 1.0f); ++ glClear(GL_COLOR_BUFFER_BIT); ++ ++ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::magenta); ++} ++ + // Test that clearing slices of a 3D texture and reading them back works. + TEST_P(ClearTestES3, ClearAndReadPixels3DTexture) + { +diff --git a/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp b/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp +index 7268d08da90e27022f7139aa98b5972e1dfe62f1..6a91ecc2b4329696f573db3451dac35a0a795c8c 100644 +--- a/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp ++++ b/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp +@@ -5,7 +5,7 @@ + // + // VulkanPerformanceCounterTest: + // Validates specific GL call patterns with ANGLE performance counters. +-// For example we can verify a certain call set doesn't break the RenderPass. ++// For example we can verify a certain call set doesn't break the render pass. + + #include "test_utils/ANGLETest.h" + #include "test_utils/angle_test_instantiate.h" +@@ -6991,6 +6991,26 @@ TEST_P(VulkanPerformanceCounterTest, EndXfbAfterRenderPassClosed) + EXPECT_EQ(getPerfCounters().renderPasses, expectedRenderPassCount); + } + ++// Verify that changing framebuffer and back doesn't break the render pass. ++TEST_P(VulkanPerformanceCounterTest, FBOChangeAndBackDoesNotBreakRenderPass) ++{ ++ uint64_t expectedRenderPassCount = getPerfCounters().renderPasses + 1; ++ ++ ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red()); ++ drawQuad(drawRed, essl1_shaders::PositionAttrib(), 0); ++ ++ GLFramebuffer fbo; ++ glBindFramebuffer(GL_FRAMEBUFFER, fbo); ++ glBindFramebuffer(GL_FRAMEBUFFER, 0); ++ ++ drawQuad(drawRed, essl1_shaders::PositionAttrib(), 0); ++ ++ // Verify render pass count. ++ EXPECT_EQ(getPerfCounters().renderPasses, expectedRenderPassCount); ++ ++ EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); ++} ++ + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VulkanPerformanceCounterTest); + ANGLE_INSTANTIATE_TEST(VulkanPerformanceCounterTest, ES3_VULKAN(), ES3_VULKAN_SWIFTSHADER()); + From cedf0014f6e24cbb3d1dd6e3f65a885b4fba806e Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 23 Mar 2023 00:14:38 +0000 Subject: [PATCH 093/172] chore: cherry-pick f6ddbf42b1ea from v8 (#37663) * chore: cherry-pick f6ddbf42b1ea from v8 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/v8/.patches | 1 + patches/v8/cherry-pick-f6ddbf42b1ea.patch | 109 ++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 patches/v8/cherry-pick-f6ddbf42b1ea.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 759ec3a4bd17a..01e27ecdbd3fe 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -10,3 +10,4 @@ revert_runtime_dhceck_terminating_exception_in_microtasks.patch chore_disable_is_execution_terminating_dcheck.patch force_cppheapcreateparams_to_be_noncopyable.patch cherry-pick-e17eee4894be.patch +cherry-pick-f6ddbf42b1ea.patch diff --git a/patches/v8/cherry-pick-f6ddbf42b1ea.patch b/patches/v8/cherry-pick-f6ddbf42b1ea.patch new file mode 100644 index 0000000000000..0bfb4eb43a6c4 --- /dev/null +++ b/patches/v8/cherry-pick-f6ddbf42b1ea.patch @@ -0,0 +1,109 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tobias Tebbi <tebbi@chromium.org> +Date: Wed, 15 Feb 2023 16:35:18 +0100 +Subject: check if maps become deprecated during optimization + +(cherry picked from commit f82d802a20aa62e42269f977302f26c5c3ed031b) + +Bug: chromium:1417585 +No-Try: true +No-Presubmit: true +No-Tree-Checks: true +Change-Id: Ie8eb76d2afb3ee4be66cf5d1c4bff8f745dc145b +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4255648 +Commit-Queue: Tobias Tebbi <tebbi@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#85848} +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4294983 +Reviewed-by: Tobias Tebbi <tebbi@chromium.org> +Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> +Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> +Reviewed-by: Leszek Swirski <leszeks@chromium.org> +Cr-Commit-Position: refs/branch-heads/10.8@{#50} +Cr-Branched-From: f1bc03fd6b4c201abd9f0fd9d51fb989150f97b9-refs/heads/10.8.168@{#1} +Cr-Branched-From: 237de893e1c0a0628a57d0f5797483d3add7f005-refs/heads/main@{#83672} + +diff --git a/src/codegen/bailout-reason.h b/src/codegen/bailout-reason.h +index cdd9e123185d142dfeac1e422f345a6a5955658f..33a12a67e4464a907124bb2f45a224f43ed7ec3a 100644 +--- a/src/codegen/bailout-reason.h ++++ b/src/codegen/bailout-reason.h +@@ -94,19 +94,20 @@ namespace internal { + V(kUnexpectedThreadInWasmSet, "thread_in_wasm flag was already set") \ + V(kUnexpectedThreadInWasmUnset, "thread_in_wasm flag was not set") + +-#define BAILOUT_MESSAGES_LIST(V) \ +- V(kNoReason, "no reason") \ +- \ +- V(kBailedOutDueToDependencyChange, "Bailed out due to dependency change") \ +- V(kCodeGenerationFailed, "Code generation failed") \ +- V(kFunctionBeingDebugged, "Function is being debugged") \ +- V(kGraphBuildingFailed, "Optimized graph construction failed") \ +- V(kFunctionTooBig, "Function is too big to be optimized") \ +- V(kTooManyArguments, "Function contains a call with too many arguments") \ +- V(kLiveEdit, "LiveEdit") \ +- V(kNativeFunctionLiteral, "Native function literal") \ +- V(kOptimizationDisabled, "Optimization disabled") \ +- V(kHigherTierAvailable, "A higher tier is already available") \ ++#define BAILOUT_MESSAGES_LIST(V) \ ++ V(kNoReason, "no reason") \ ++ \ ++ V(kBailedOutDueToDependencyChange, "Bailed out due to dependency change") \ ++ V(kConcurrentMapDeprecation, "Maps became deprecated during optimization") \ ++ V(kCodeGenerationFailed, "Code generation failed") \ ++ V(kFunctionBeingDebugged, "Function is being debugged") \ ++ V(kGraphBuildingFailed, "Optimized graph construction failed") \ ++ V(kFunctionTooBig, "Function is too big to be optimized") \ ++ V(kTooManyArguments, "Function contains a call with too many arguments") \ ++ V(kLiveEdit, "LiveEdit") \ ++ V(kNativeFunctionLiteral, "Native function literal") \ ++ V(kOptimizationDisabled, "Optimization disabled") \ ++ V(kHigherTierAvailable, "A higher tier is already available") \ + V(kNeverOptimize, "Optimization is always disabled") + + #define ERROR_MESSAGES_CONSTANTS(C, T) C, +diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc +index a142d46a4760d65b09419211afa0972e1f5e6205..7e066adf0a0d04ca332e6b04a253937e51b1d367 100644 +--- a/src/compiler/pipeline.cc ++++ b/src/compiler/pipeline.cc +@@ -728,7 +728,10 @@ class PipelineImpl final { + // Step D. Run the code finalization pass. + MaybeHandle<Code> FinalizeCode(bool retire_broker = true); + +- // Step E. Install any code dependencies. ++ // Step E. Ensure all embedded maps are non-deprecated. ++ bool CheckNoDeprecatedMaps(Handle<Code> code); ++ ++ // Step F. Install any code dependencies. + bool CommitDependencies(Handle<Code> code); + + void VerifyGeneratedCodeIsIdempotent(); +@@ -1272,6 +1275,9 @@ PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl( + } + return FAILED; + } ++ if (!pipeline_.CheckNoDeprecatedMaps(code)) { ++ return RetryOptimization(BailoutReason::kConcurrentMapDeprecation); ++ } + if (!pipeline_.CommitDependencies(code)) { + return RetryOptimization(BailoutReason::kBailedOutDueToDependencyChange); + } +@@ -3961,6 +3967,20 @@ MaybeHandle<Code> PipelineImpl::GenerateCode(CallDescriptor* call_descriptor) { + return FinalizeCode(); + } + ++// We must not embed deprecated maps, as we rely in the compiler on all explicit ++// maps not being deprecated. ++bool PipelineImpl::CheckNoDeprecatedMaps(Handle<Code> code) { ++ int mode_mask = RelocInfo::EmbeddedObjectModeMask(); ++ for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { ++ DCHECK(RelocInfo::IsEmbeddedObjectMode(it.rinfo()->rmode())); ++ HeapObject obj = it.rinfo()->target_object(data_->isolate()); ++ if (obj.IsMap() && Map::cast(obj).is_deprecated()) { ++ return false; ++ } ++ } ++ return true; ++} ++ + bool PipelineImpl::CommitDependencies(Handle<Code> code) { + return data_->dependencies() == nullptr || + data_->dependencies()->Commit(code); From f2719edd1db6dd1e8fe58a4432599afb1ffb893c Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 23 Mar 2023 14:53:20 +0000 Subject: [PATCH 094/172] chore: cherry-pick 8731bd8a30f6 from chromium (#37657) * chore: cherry-pick 8731bd8a30f6 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-8731bd8a30f6.patch | 595 ++++++++++++++++++ 2 files changed, 596 insertions(+) create mode 100644 patches/chromium/cherry-pick-8731bd8a30f6.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index c06b2b88a6957..111abbc2e5ae3 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,4 +133,5 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch diff --git a/patches/chromium/cherry-pick-8731bd8a30f6.patch b/patches/chromium/cherry-pick-8731bd8a30f6.patch new file mode 100644 index 0000000000000..38cf91e17e264 --- /dev/null +++ b/patches/chromium/cherry-pick-8731bd8a30f6.patch @@ -0,0 +1,595 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Alex Moshchuk <alexmos@chromium.org> +Date: Fri, 3 Mar 2023 22:17:24 +0000 +Subject: Use optional SafeRef to save RenderFrameHost in NavigationRequest + +This prevents use-after-free if NavigationRequests somehow still +points to an already-deleted RFH, which is currently possible (see bug). + +Also converts usages of `render_frame_host_` to use the +GetRenderFrameHost() function to ensure that they are all called after +the final RenderFrameHost is picked for the navigation. + +(cherry picked from commit 7b75ae34df6d15acf4e5a45f12c9dca4ce7f2586) + +Bug: 1416916 +Change-Id: I45569e7bb1f160158dc3139fc9e49d7d6bb56738 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4278923 +Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> +Commit-Queue: Rakina Zata Amni <rakina@chromium.org> +Reviewed-by: Alex Moshchuk <alexmos@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1112656} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4308070 +Reviewed-by: Charlie Reis <creis@chromium.org> +Commit-Queue: Alex Moshchuk <alexmos@chromium.org> +Cr-Commit-Position: refs/branch-heads/5481@{#1322} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc +index 1496adf92d0e0c7868869263eba5c7786bed6bd8..f6f25544bd36fceb60ada013178cc8fb67e7b10a 100644 +--- a/content/browser/renderer_host/navigation_request.cc ++++ b/content/browser/renderer_host/navigation_request.cc +@@ -1450,7 +1450,7 @@ NavigationRequest::CreateForSynchronousRendererCommit( + subresource_web_bundle_navigation_info->token(), + subresource_web_bundle_navigation_info->render_process_id())); + } +- navigation_request->render_frame_host_ = render_frame_host; ++ navigation_request->render_frame_host_ = render_frame_host->GetSafeRef(); + navigation_request->coep_reporter_ = std::move(coep_reporter); + navigation_request->isolation_info_for_subresources_ = + isolation_info_for_subresources; +@@ -1964,7 +1964,7 @@ NavigationRequest::GetCommitDeferringConditionForTesting() { + void NavigationRequest::BeginNavigation() { + EnterChildTraceEvent("BeginNavigation", this); + DCHECK(!loader_); +- DCHECK(!render_frame_host_); ++ DCHECK(!HasRenderFrameHost()); + ScopedCrashKeys crash_keys(*this); + + if (begin_navigation_callback_for_testing_) { +@@ -2342,7 +2342,7 @@ void NavigationRequest::BeginNavigationImpl() { + // expect us to use the current RenderFrameHost for this NavigationRequest, + // and https://crbug.com/1125106. + if (IsSameDocument()) { +- render_frame_host_ = frame_tree_node_->current_frame_host(); ++ render_frame_host_ = frame_tree_node_->current_frame_host()->GetSafeRef(); + } else { + // [spec]: https://html.spec.whatwg.org/C/#process-a-navigate-response + // 4. if [...] the result of checking a navigation response's adherence to +@@ -2368,11 +2368,12 @@ void NavigationRequest::BeginNavigationImpl() { + origin, net::NetworkAnonymizationKey(site, site)); + + // Select an appropriate RenderFrameHost. +- render_frame_host_ = +- frame_tree_node_->render_manager()->GetFrameHostForNavigation(this); ++ render_frame_host_ = frame_tree_node_->render_manager() ++ ->GetFrameHostForNavigation(this) ++ ->GetSafeRef(); + + CHECK(Navigator::CheckWebUIRendererDoesNotDisplayNormalURL( +- render_frame_host_, GetUrlInfo(), ++ &*render_frame_host_.value(), GetUrlInfo(), + /*is_renderer_initiated_check=*/false)); + } + +@@ -2601,8 +2602,8 @@ void NavigationRequest::ResetForCrossDocumentRestart() { + + // Reset the previously selected RenderFrameHost. This is expected to be null + // at the beginning of a new navigation. See https://crbug.com/936962. +- DCHECK(render_frame_host_); +- render_frame_host_ = nullptr; ++ DCHECK(HasRenderFrameHost()); ++ render_frame_host_ = absl::nullopt; + + // Convert the navigation type to the appropriate cross-document one. + common_params_->navigation_type = +@@ -2660,7 +2661,7 @@ mojom::NavigationClient* NavigationRequest::GetCommitNavigationClient() { + + // Instantiate a new NavigationClient interface. + commit_navigation_client_ = +- render_frame_host_->GetNavigationClientFromInterfaceProvider(); ++ GetRenderFrameHost()->GetNavigationClientFromInterfaceProvider(); + HandleInterfaceDisconnection( + &commit_navigation_client_, + base::BindOnce( +@@ -2731,7 +2732,7 @@ void NavigationRequest::CreateCoepReporter( + common_params_->url, + policies.cross_origin_embedder_policy.reporting_endpoint, + policies.cross_origin_embedder_policy.report_only_reporting_endpoint, +- render_frame_host_->GetFrameToken().value(), ++ GetRenderFrameHost()->GetFrameToken().value(), + isolation_info_for_subresources_.network_anonymization_key()); + } + +@@ -3133,7 +3134,7 @@ void NavigationRequest::DetermineOriginAgentClusterEndResult() { + ? url::Origin::Create(common_params_->base_url_for_data_url) + : url::Origin::Create(common_params_->url); + const IsolationContext& isolation_context = +- render_frame_host_->GetSiteInstance()->GetIsolationContext(); ++ GetRenderFrameHost()->GetSiteInstance()->GetIsolationContext(); + + bool is_requested = IsOriginAgentClusterOptInRequested(); + bool expects_origin_agent_cluster = is_requested || IsIsolationImplied(); +@@ -3241,7 +3242,7 @@ void NavigationRequest::ProcessOriginAgentClusterEndResult() { + origin_agent_cluster_end_result_ == + OriginAgentClusterEndResult::kExplicitlyRequestedButNotOriginKeyed) { + GetContentClient()->browser()->LogWebFeatureForCurrentPage( +- render_frame_host_, ++ GetRenderFrameHost(), + blink::mojom::WebFeature::kOriginAgentClusterHeader); + } + +@@ -3251,7 +3252,7 @@ void NavigationRequest::ProcessOriginAgentClusterEndResult() { + OriginAgentClusterEndResult::kRequestedButNotOriginKeyed || + origin_agent_cluster_end_result_ == + OriginAgentClusterEndResult::kExplicitlyRequestedButNotOriginKeyed) { +- render_frame_host_->AddMessageToConsole( ++ GetRenderFrameHost()->AddMessageToConsole( + blink::mojom::ConsoleMessageLevel::kWarning, + base::StringPrintf( + "The page requested an origin-keyed agent cluster using the " +@@ -3266,7 +3267,7 @@ void NavigationRequest::ProcessOriginAgentClusterEndResult() { + OriginAgentClusterEndResult::kNotRequestedButOriginKeyed || + origin_agent_cluster_end_result_ == + OriginAgentClusterEndResult::kExplicitlyNotRequestedButOriginKeyed) { +- render_frame_host_->AddMessageToConsole( ++ GetRenderFrameHost()->AddMessageToConsole( + blink::mojom::ConsoleMessageLevel::kWarning, + base::StringPrintf( + "The page did not request an origin-keyed agent cluster, but was " +@@ -3281,7 +3282,7 @@ void NavigationRequest::PopulateDocumentTokenForCrossDocumentNavigation() { + DCHECK(!IsSameDocument()); + DCHECK_GE(state_, READY_TO_COMMIT); + const auto* token_to_reuse = +- render_frame_host_->GetDocumentTokenForCrossDocumentNavigationReuse( ++ GetRenderFrameHost()->GetDocumentTokenForCrossDocumentNavigationReuse( + /* passkey */ {}); + document_token_.emplace(token_to_reuse ? *token_to_reuse + : blink::DocumentToken()); +@@ -3805,45 +3806,47 @@ void NavigationRequest::OnResponseStarted( + BackForwardCacheImpl::Entry* entry = + controller->GetBackForwardCache().GetEntry(nav_entry_id_); + CHECK(entry); +- render_frame_host_ = entry->render_frame_host(); +- CHECK(render_frame_host_); ++ CHECK(entry->render_frame_host()); ++ render_frame_host_ = entry->render_frame_host()->GetSafeRef(); + } else if (IsPrerenderedPageActivation()) { + // Prerendering requires changing pages starting at the root node. + DCHECK(IsInMainFrame()); + +- render_frame_host_ = +- GetPrerenderHostRegistry().GetRenderFrameHostForReservedHost( +- prerender_frame_tree_node_id_.value()); +- // TODO(https://crbug.com/1181712): Handle the cases when the prerender is +- // cancelled and RFH is destroyed while NavigationRequest is alive. ++ render_frame_host_ = GetPrerenderHostRegistry() ++ .GetRenderFrameHostForReservedHost( ++ prerender_frame_tree_node_id_.value()) ++ ->GetSafeRef(); + } else if (response_should_be_rendered_) { +- render_frame_host_ = +- frame_tree_node_->render_manager()->GetFrameHostForNavigation(this); ++ render_frame_host_ = frame_tree_node_->render_manager() ++ ->GetFrameHostForNavigation(this) ++ ->GetSafeRef(); + + // Update the associated RenderFrameHost type, which could have changed + // due to redirects during navigation. + set_associated_rfh_type( +- render_frame_host_ == ++ GetRenderFrameHost() == + frame_tree_node_->render_manager()->current_frame_host() + ? AssociatedRenderFrameHostType::CURRENT + : AssociatedRenderFrameHostType::SPECULATIVE); + + if (!Navigator::CheckWebUIRendererDoesNotDisplayNormalURL( +- render_frame_host_, GetUrlInfo(), ++ GetRenderFrameHost(), GetUrlInfo(), + /* is_renderer_initiated_check */ false)) { + CHECK(false); + } + } else { +- render_frame_host_ = nullptr; ++ render_frame_host_ = absl::nullopt; + } +- if (!render_frame_host_) ++ if (!HasRenderFrameHost()) { + DCHECK(!response_should_be_rendered_); ++ } + +- if (render_frame_host_) ++ if (HasRenderFrameHost()) { + DetermineOriginAgentClusterEndResult(); ++ } + +- if (!commit_params_->is_browser_initiated && render_frame_host_ && +- render_frame_host_->GetProcess() != ++ if (!commit_params_->is_browser_initiated && HasRenderFrameHost() && ++ GetRenderFrameHost()->GetProcess() != + frame_tree_node_->current_frame_host()->GetProcess()) { + // Allow the embedder to cancel the cross-process commit if needed. + if (!frame_tree_node_->navigator() +@@ -3864,12 +3867,12 @@ void NavigationRequest::OnResponseStarted( + + subresource_loader_params_ = std::move(subresource_loader_params); + +- if (render_frame_host_) { ++ if (HasRenderFrameHost()) { + // Set the site URL now if it hasn't been set already. If the site requires + // a dedicated process, this will lock the process to that site, which will + // prevent other sites from incorrectly reusing this process. See + // https://crbug.com/738634. +- SiteInstanceImpl* instance = render_frame_host_->GetSiteInstance(); ++ SiteInstanceImpl* instance = GetRenderFrameHost()->GetSiteInstance(); + if (!instance->HasSite() && + SiteInstanceImpl::ShouldAssignSiteForURL(common_params_->url)) { + instance->ConvertToDefaultOrSetSite(GetUrlInfo()); +@@ -3891,7 +3894,7 @@ void NavigationRequest::OnResponseStarted( + // navigation, and in the meantime another navigation reads the incorrect + // IsUnused() value from the same process when making a process reuse + // decision. +- render_frame_host_->GetProcess()->SetIsUsed(); ++ GetRenderFrameHost()->GetProcess()->SetIsUsed(); + + // Now that we know the IsolationContext for the assigned SiteInstance, we + // opt the origin into OAC here if needed. Note that this doesn't need to +@@ -4005,7 +4008,7 @@ void NavigationRequest::OnResponseStarted( + return; + } + +- if (render_frame_host_ && ++ if (HasRenderFrameHost() && + !CheckPermissionsPoliciesForFencedFrames(GetOriginToCommit())) { + OnRequestFailedInternal( + network::URLLoaderCompletionStatus(net::ERR_ABORTED), +@@ -4035,7 +4038,7 @@ NavigationRequest::CreateNavigationEarlyHintsManagerParams( + const network::mojom::EarlyHints& early_hints) { + // Early Hints preloads should happen only before the final response is + // received, and limited only in the main frame for now. +- CHECK(!render_frame_host_); ++ CHECK(!HasRenderFrameHost()); + CHECK(loader_); + CHECK_LT(state_, WILL_PROCESS_RESPONSE); + CHECK(!IsSameDocument()); +@@ -4178,12 +4181,12 @@ void NavigationRequest::OnRequestFailedInternal( + // Sanity check that we haven't changed the RenderFrameHost picked for the + // error page in OnRequestFailedInternal when running the WillFailRequest + // checks. +- CHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); +- render_frame_host_ = render_frame_host; ++ CHECK(!HasRenderFrameHost() || GetRenderFrameHost() == render_frame_host); ++ render_frame_host_ = render_frame_host->GetSafeRef(); + + // Update the associated RenderFrameHost type. + set_associated_rfh_type( +- render_frame_host_ == ++ GetRenderFrameHost() == + frame_tree_node_->render_manager()->current_frame_host() + ? AssociatedRenderFrameHostType::CURRENT + : AssociatedRenderFrameHostType::SPECULATIVE); +@@ -4191,17 +4194,17 @@ void NavigationRequest::OnRequestFailedInternal( + // Set the site URL now if it hasn't been set already. It's possible to get + // here if we navigate to an error out of an initial "blank" SiteInstance. + // Also mark the process as used, since it will be hosting an error page. +- SiteInstanceImpl* instance = render_frame_host_->GetSiteInstance(); ++ SiteInstanceImpl* instance = GetRenderFrameHost()->GetSiteInstance(); + if (!instance->HasSite()) + instance->ConvertToDefaultOrSetSite(GetUrlInfo()); +- render_frame_host_->GetProcess()->SetIsUsed(); ++ GetRenderFrameHost()->GetProcess()->SetIsUsed(); + + // The check for WebUI should be performed only if error page isolation is + // enabled for this failed navigation. It is possible for subframe error page + // to be committed in a WebUI process as shown in https://crbug.com/944086. + if (frame_tree_node_->IsErrorPageIsolationEnabled()) { + if (!Navigator::CheckWebUIRendererDoesNotDisplayNormalURL( +- render_frame_host_, GetUrlInfo(), ++ GetRenderFrameHost(), GetUrlInfo(), + /* is_renderer_initiated_check */ false)) { + CHECK(false); + } +@@ -4520,7 +4523,7 @@ void NavigationRequest::OnStartChecksComplete( + ->CreateURLLoaderNetworkObserverForNavigationRequest(*this), + NetworkServiceDevToolsObserver::MakeSelfOwned(frame_tree_node_), + std::move(cached_response_head), std::move(interceptor)); +- DCHECK(!render_frame_host_); ++ DCHECK(!HasRenderFrameHost()); + + base::UmaHistogramTimes( + base::StrCat({"Navigation.WillStartRequestToLoaderStart.", +@@ -4792,7 +4795,10 @@ void NavigationRequest::OnWillProcessResponseChecksComplete( + !response_should_be_rendered_) { + // Reset the RenderFrameHost that had been computed for the commit of the + // navigation. +- render_frame_host_ = nullptr; ++ // TODO(https://crbug.com/1416916): Reconsider if we really need to unset ++ // the `render_frame_host_` here, as the NavigationRequest might stay alive ++ // for a bit longer to commit an error page. ++ render_frame_host_ = absl::nullopt; + + // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. + if (!response_should_be_rendered_) { +@@ -4821,7 +4827,10 @@ void NavigationRequest::OnWillProcessResponseChecksComplete( + DCHECK_EQ(net::ERR_BLOCKED_BY_RESPONSE, result.net_error_code()); + // Reset the RenderFrameHost that had been computed for the commit of the + // navigation. +- render_frame_host_ = nullptr; ++ // TODO(https://crbug.com/1416916): Reconsider if we really need to unset ++ // the `render_frame_host_` here, as the NavigationRequest might stay alive ++ // for a bit longer to commit an error page. ++ render_frame_host_ = absl::nullopt; + OnRequestFailedInternal( + network::URLLoaderCompletionStatus(result.net_error_code()), + true /* skip_throttles */, result.error_page_content(), +@@ -4894,7 +4903,7 @@ void NavigationRequest::CommitErrorPage( + commit_params_->origin_to_commit = + url::Origin::Create(common_params_->url).DeriveNewOpaqueOrigin(); + if (request_navigation_client_.is_bound()) { +- if (render_frame_host_ == frame_tree_node()->current_frame_host()) { ++ if (GetRenderFrameHost() == frame_tree_node()->current_frame_host()) { + // Reuse the request NavigationClient for commit. + commit_navigation_client_ = std::move(request_navigation_client_); + } else { +@@ -4909,7 +4918,7 @@ void NavigationRequest::CommitErrorPage( + PopulateDocumentTokenForCrossDocumentNavigation(); + // Use a separate cache shard, and no cookies, for error pages. + isolation_info_for_subresources_ = net::IsolationInfo::CreateTransient(); +- render_frame_host_->FailedNavigation( ++ GetRenderFrameHost()->FailedNavigation( + this, *common_params_, *commit_params_, has_stale_copy_in_cache_, + net_error_, extended_error_code_, error_page_content, *document_token_); + +@@ -4976,7 +4985,7 @@ void NavigationRequest::CommitNavigation() { + // TODO(crbug.com/979296): Consider changing this code to copy an origin + // instead of creating one from a URL which lacks opacity information. + isolation_info_for_subresources_ = +- render_frame_host_->ComputeIsolationInfoForSubresourcesForPendingCommit( ++ GetRenderFrameHost()->ComputeIsolationInfoForSubresourcesForPendingCommit( + origin, is_anonymous(), ComputeFencedFrameNonce()); + DCHECK(!isolation_info_for_subresources_.IsEmpty()); + +@@ -4984,9 +4993,9 @@ void NavigationRequest::CommitNavigation() { + // moment. We will be able to use it once the browser can compute the origin + // to commit. + absl::optional<base::UnguessableToken> nonce = +- render_frame_host_->ComputeNonce(is_anonymous(), ++ GetRenderFrameHost()->ComputeNonce(is_anonymous(), + ComputeFencedFrameNonce()); +- commit_params_->storage_key = render_frame_host_->CalculateStorageKey( ++ commit_params_->storage_key = GetRenderFrameHost()->CalculateStorageKey( + GetOriginToCommit(), base::OptionalToPtr(nonce)); + + if (IsServedFromBackForwardCache() || IsPrerenderedPageActivation()) { +@@ -5007,13 +5016,13 @@ void NavigationRequest::CommitNavigation() { + if (!weak_self) + return; + +- DCHECK(render_frame_host_ == ++ DCHECK(GetRenderFrameHost() == + frame_tree_node_->render_manager()->current_frame_host() || +- render_frame_host_ == ++ GetRenderFrameHost() == + frame_tree_node_->render_manager()->speculative_frame_host()); + + if (request_navigation_client_.is_bound()) { +- if (render_frame_host_ == frame_tree_node()->current_frame_host()) { ++ if (GetRenderFrameHost() == frame_tree_node()->current_frame_host()) { + // Reuse the request NavigationClient for commit. + commit_navigation_client_ = std::move(request_navigation_client_); + } else { +@@ -5023,9 +5032,9 @@ void NavigationRequest::CommitNavigation() { + } + } + +- CreateCoepReporter(render_frame_host_->GetProcess()->GetStoragePartition()); ++ CreateCoepReporter(GetRenderFrameHost()->GetProcess()->GetStoragePartition()); + coop_status_.UpdateReporterStoragePartition( +- render_frame_host_->GetProcess()->GetStoragePartition()); ++ GetRenderFrameHost()->GetProcess()->GetStoragePartition()); + + BrowserContext* browser_context = + frame_tree_node_->navigator().controller().GetBrowserContext(); +@@ -5070,7 +5079,7 @@ void NavigationRequest::CommitNavigation() { + // Notify the service worker navigation handle that navigation commit is + // about to go. + service_worker_handle_->OnBeginNavigationCommit( +- render_frame_host_->GetGlobalId(), ++ GetRenderFrameHost()->GetGlobalId(), + policy_container_builder_->FinalPolicies(), std::move(reporter_remote), + &service_worker_container_info, commit_params_->document_ukm_source_id); + } +@@ -5141,7 +5150,7 @@ void NavigationRequest::CommitNavigation() { + std::move(subresource_loader_params_->prefetched_signed_exchanges); + } + +- render_frame_host_->CommitNavigation( ++ GetRenderFrameHost()->CommitNavigation( + this, std::move(common_params), std::move(commit_params), + std::move(response_head), std::move(response_body_), + std::move(url_loader_client_endpoints_), +@@ -5154,7 +5163,7 @@ void NavigationRequest::CommitNavigation() { + // BrowserContext. This is mostly needed to make sure the spare is warmed-up + // if it wasn't done in RenderProcessHostImpl::GetProcessHostForSiteInstance. + RenderProcessHostImpl::NotifySpareManagerAboutRecentlyUsedBrowserContext( +- render_frame_host_->GetSiteInstance()->GetBrowserContext()); ++ GetRenderFrameHost()->GetSiteInstance()->GetBrowserContext()); + + SendDeferredConsoleMessages(); + } +@@ -5831,14 +5840,14 @@ void NavigationRequest::OnRendererRequestedNavigationCancellation() { + // The cancellation happens before READY_TO_COMMIT. + frame_tree_node_->navigator().CancelNavigation( + frame_tree_node_, NavigationDiscardReason::kCancelled); +- } else if (render_frame_host_ == ++ } else if (GetRenderFrameHost() == + frame_tree_node_->render_manager()->current_frame_host() || +- !render_frame_host_->IsRenderFrameLive()) { ++ !GetRenderFrameHost()->IsRenderFrameLive()) { + // If the NavigationRequest has already reached READY_TO_COMMIT, + // `render_frame_host_` owns `this`. Cache any needed state in stack + // variables to avoid a use-after-free. + FrameTreeNode* frame_tree_node = frame_tree_node_; +- render_frame_host_->NavigationRequestCancelled(this); ++ GetRenderFrameHost()->NavigationRequestCancelled(this); + // Ensure that the speculative RFH, if any, is also cleaned up. In theory, + // `ResetNavigationRequest()` should handle this; however, it early-returns + // if there is no navigation request associated with the FrameTreeNode. +@@ -6267,7 +6276,7 @@ void NavigationRequest::DidCommitNavigation( + // Navigations in non-primary frame trees or portals don't appear in history. + if ((should_update_history_ && IsSameDocument() && !HasUserGesture() && + params.url == previous_main_frame_url) || +- !render_frame_host_->GetPage().IsPrimary() || ++ !GetRenderFrameHost()->GetPage().IsPrimary() || + frame_tree_node()->frame_tree()->IsPortal()) { + should_update_history_ = false; + } +@@ -6322,7 +6331,7 @@ void NavigationRequest::DidCommitNavigation( + ui::PageTransition transition = + ui::PageTransitionFromInt(common_params_->transition); + absl::optional<bool> is_background = +- render_frame_host_->GetProcess()->IsProcessBackgrounded(); ++ GetRenderFrameHost()->GetProcess()->IsProcessBackgrounded(); + + RecordStartToCommitMetrics( + common_params_->navigation_start, transition, ready_to_commit_time_, +@@ -6483,7 +6492,7 @@ void NavigationRequest::ReadyToCommitNavigation(bool is_error) { + // disconnection from the renderer NavigationClient; but browser-initiated + // navigations do not, so we must look explicitly. We should not proceed and + // claim "ReadyToCommitNavigation" to the delegate if the renderer is gone. +- if (!render_frame_host_->IsRenderFrameLive()) { ++ if (!GetRenderFrameHost()->IsRenderFrameLive()) { + OnRendererRequestedNavigationCancellation(); + // DO NOT ADD CODE AFTER THIS, as the NavigationHandle has been deleted + // by the previous call. +@@ -6496,20 +6505,20 @@ void NavigationRequest::ReadyToCommitNavigation(bool is_error) { + // where the FrameTreeNode has no NavigationRequest, yet the + // RenderFrameHostImpl is not marked as loading yet, causing + // FrameTreeNode::IsLoading() to incorrectly return false. +- frame_tree_node_->TransferNavigationRequestOwnership(render_frame_host_); ++ frame_tree_node_->TransferNavigationRequestOwnership(GetRenderFrameHost()); + + // When a speculative RenderFrameHost reaches ReadyToCommitNavigation, the + // browser process has asked the renderer to commit the navigation and is + // waiting for confirmation of the commit. Update the LifecycleStateImpl to + // kPendingCommit as RenderFrameHost isn't considered speculative anymore and + // was chosen to commit as this navigation's final RenderFrameHost. +- if (render_frame_host_->lifecycle_state() == ++ if (GetRenderFrameHost()->lifecycle_state() == + RenderFrameHostImpl::LifecycleStateImpl::kSpeculative) { + // Only cross-RenderFrameHost navigations create speculative + // RenderFrameHosts whereas SameDocument, BackForwardCache and + // PrerenderedActivation navigations don't. + DCHECK(!IsSameDocument() && !IsPageActivation()); +- render_frame_host_->SetLifecycleState( ++ GetRenderFrameHost()->SetLifecycleState( + RenderFrameHostImpl::LifecycleStateImpl::kPendingCommit); + } + +@@ -6531,11 +6540,11 @@ void NavigationRequest::ReadyToCommitNavigation(bool is_error) { + // Record metrics for the time it takes to get to this state from the + // beginning of the navigation. + if (!IsSameDocument() && !is_error) { +- is_same_process_ = render_frame_host_->GetProcess()->GetID() == ++ is_same_process_ = GetRenderFrameHost()->GetProcess()->GetID() == + previous_render_frame_host->GetProcess()->GetID(); + + RecordReadyToCommitMetrics( +- previous_render_frame_host, render_frame_host_, *common_params_.get(), ++ previous_render_frame_host, GetRenderFrameHost(), *common_params_.get(), + ready_to_commit_time_, origin_agent_cluster_end_result_, + did_receive_early_hints_before_cross_origin_redirect_); + } +@@ -6544,7 +6553,7 @@ void NavigationRequest::ReadyToCommitNavigation(bool is_error) { + same_origin_ = (previous_render_frame_host->GetLastCommittedOrigin() == + GetOriginToCommit()); + +- SetExpectedProcess(render_frame_host_->GetProcess()); ++ SetExpectedProcess(GetRenderFrameHost()->GetProcess()); + + commit_params_->is_load_data_with_base_url = IsLoadDataWithBaseURL(); + +@@ -6568,7 +6577,7 @@ void NavigationRequest::ReadyToCommitNavigation(bool is_error) { + NavigationEntry* entry = GetNavigationEntry(); + if (entry && entry->IsViewSourceMode()) { + // Put the renderer in view source mode. +- render_frame_host_->GetAssociatedLocalFrame()->EnableViewSourceMode(); ++ GetRenderFrameHost()->GetAssociatedLocalFrame()->EnableViewSourceMode(); + } + } + +@@ -6892,7 +6901,7 @@ NavigationRequest::MakeDidCommitProvisionalLoadParamsForActivation() { + // Use the DidCommitProvisionalLoadParams last used to commit the frame being + // restored as a starting point. + mojom::DidCommitProvisionalLoadParamsPtr params = +- render_frame_host_->TakeLastCommitParams(); ++ GetRenderFrameHost()->TakeLastCommitParams(); + + // Params must have been set when the RFH being restored from the cache last + // navigated. +@@ -7159,7 +7168,10 @@ RenderFrameHostImpl* NavigationRequest::GetRenderFrameHost() const { + } + static_assert(WILL_FAIL_REQUEST > WILL_PROCESS_RESPONSE, + "WillFailRequest state should come after WillProcessResponse"); +- return render_frame_host_; ++ if (HasRenderFrameHost()) { ++ return &*render_frame_host_.value(); ++ } ++ return nullptr; + } + + const net::HttpRequestHeaders& NavigationRequest::GetRequestHeaders() { +@@ -7619,7 +7631,8 @@ bool NavigationRequest::CoopCoepSanityCheck() { + // TODO(https://crbug.com/1278207) add other embedded cases if needed. + network::mojom::CrossOriginOpenerPolicyValue coop_value = + GetParentFrameOrOuterDocument() +- ? render_frame_host_->GetOutermostMainFrame() ++ ? GetRenderFrameHost() ++ ->GetOutermostMainFrame() + ->cross_origin_opener_policy() + .value + : policies.cross_origin_opener_policy.value; +@@ -8182,8 +8195,8 @@ void NavigationRequest::SendDeferredConsoleMessages() { + for (auto& message : console_messages_) { + // TODO(https://crbug.com/721329): We should have a way of sending console + // messaged to devtools without going through the renderer. +- render_frame_host_->AddMessageToConsole(message.level, +- std::move(message.message)); ++ GetRenderFrameHost()->AddMessageToConsole(message.level, ++ std::move(message.message)); + } + console_messages_.clear(); + } +diff --git a/content/browser/renderer_host/navigation_request.h b/content/browser/renderer_host/navigation_request.h +index 8d6debbd09392d954d05c06c5e0b2d7a7be29bd3..6c715d5e85f2dc90dc17f9a237c69ede69c533e6 100644 +--- a/content/browser/renderer_host/navigation_request.h ++++ b/content/browser/renderer_host/navigation_request.h +@@ -459,6 +459,8 @@ class CONTENT_EXPORT NavigationRequest + associated_rfh_type_ = type; + } + ++ bool HasRenderFrameHost() const { return render_frame_host_.has_value(); } ++ + void set_was_discarded() { commit_params_->was_discarded = true; } + + void set_net_error(net::Error net_error) { net_error_ = net_error; } +@@ -1632,8 +1634,17 @@ class CONTENT_EXPORT NavigationRequest + // - the synchronous about:blank navigation. + const bool is_synchronous_renderer_commit_; + +- // Invariant: At least one of |loader_| or |render_frame_host_| is null. +- raw_ptr<RenderFrameHostImpl> render_frame_host_ = nullptr; ++ // The RenderFrameHost that this navigation intends to commit in. The value ++ // will be set when we know the final RenderFrameHost that the navigation will ++ // commit in (i.e. when we receive the final network response for most ++ // navigations). Note that currently this can be reset to absl::nullopt for ++ // cross-document restarts and some failed navigations. ++ // TODO(https://crbug.com/1416916): Don't reset this on failed navigations, ++ // and ensure the NavigationRequest doesn't outlive the `render_frame_host_` ++ // picked for failed Back/Forward Cache restores. ++ // Invariant: At least one of |loader_| or |render_frame_host_| is ++ // null/absl::nullopt. ++ absl::optional<base::SafeRef<RenderFrameHostImpl>> render_frame_host_; + + // Initialized on creation of the NavigationRequest. Sent to the renderer when + // the navigation is ready to commit. From 550b0d5a4354f1637596af6cdb40f9a0c08bea89 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 23 Mar 2023 16:34:26 +0000 Subject: [PATCH 095/172] chore: cherry-pick 546e00df97ac from v8 (#37671) * chore: cherry-pick 546e00df97ac from v8 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/v8/.patches | 1 + patches/v8/cherry-pick-546e00df97ac.patch | 75 +++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 patches/v8/cherry-pick-546e00df97ac.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 01e27ecdbd3fe..7fd06b1bd97ba 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -10,4 +10,5 @@ revert_runtime_dhceck_terminating_exception_in_microtasks.patch chore_disable_is_execution_terminating_dcheck.patch force_cppheapcreateparams_to_be_noncopyable.patch cherry-pick-e17eee4894be.patch +cherry-pick-546e00df97ac.patch cherry-pick-f6ddbf42b1ea.patch diff --git a/patches/v8/cherry-pick-546e00df97ac.patch b/patches/v8/cherry-pick-546e00df97ac.patch new file mode 100644 index 0000000000000..c2cc2f0351782 --- /dev/null +++ b/patches/v8/cherry-pick-546e00df97ac.patch @@ -0,0 +1,75 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Joyee Cheung <joyee@igalia.com> +Date: Tue, 14 Feb 2023 00:58:04 +0100 +Subject: Merged: [ic] store slow stubs for objects with access checks in + DefineNamedIC + +The CheckIfCanDefine() used to check the attributes of the object +as well as reporting to access check failure callbacks can update +the lookup iterator, resulting in wrong store handlers being +installed. Restart the lookup iterator in this case to make +sure that slow handlers are installed. + +Bug: chromium:1415249 +(cherry picked from commit da2df213bc70437ef76f47e0ab6995fa45f8014a) + +Change-Id: I92d60af7ea798d80b1115e63b7fce8e2e8026ed9 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4290868 +Reviewed-by: Leszek Swirski <leszeks@chromium.org> +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.0@{#33} +Cr-Branched-From: 06097c6f0c5af54fd5d6965d37027efb72decd4f-refs/heads/11.0.226@{#1} +Cr-Branched-From: 6bf3344f5d9940de1ab253f1817dcb99c641c9d3-refs/heads/main@{#84857} + +diff --git a/src/ic/ic.cc b/src/ic/ic.cc +index ae1dde1a8c587dfc80a0a62e96b7bbfe6ba5eea5..fff21e90bad3451e2d942ec327cb02f394fecc46 100644 +--- a/src/ic/ic.cc ++++ b/src/ic/ic.cc +@@ -1818,6 +1818,11 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name, + if (!can_define.FromJust()) { + return isolate()->factory()->undefined_value(); + } ++ // Restart the lookup iterator updated by CheckIfCanDefine() for ++ // UpdateCaches() to handle access checks. ++ if (use_ic && object->IsAccessCheckNeeded()) { ++ it.Restart(); ++ } + } + + if (use_ic) { +diff --git a/test/mjsunit/regress/regress-crbug-1415249.js b/test/mjsunit/regress/regress-crbug-1415249.js +new file mode 100644 +index 0000000000000000000000000000000000000000..5715e0107a4b6e9dded9ca92c7b766c4cce0af72 +--- /dev/null ++++ b/test/mjsunit/regress/regress-crbug-1415249.js +@@ -0,0 +1,30 @@ ++// Copyright 2023 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Flags: --always-turbofan ++{ ++ const realm = Realm.createAllowCrossRealmAccess(); ++ const global = Realm.global(realm); ++ function Base() { return global; } ++ let i = 0; ++ class Klass extends Base { ++ field = i++; ++ } ++ let a = new Klass(); ++ assertEquals(a.field, 0); ++ a = new Klass(); ++ assertEquals(a.field, 1); ++} ++ ++{ ++ const realm = Realm.create(); ++ const global = Realm.global(realm); ++ function Base() { return global; } ++ let i = 0; ++ class Klass extends Base { ++ field = i++; ++ } ++ assertThrows(() => new Klass(), Error, /no access/); ++ assertThrows(() => new Klass(), Error, /no access/); ++} From f89e3e37de1fb7e0d130ce4b420cf5d2b024104f Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 23 Mar 2023 18:35:16 +0000 Subject: [PATCH 096/172] chore: cherry-pick 38de42d2bbc3 from chromium (#37667) * chore: cherry-pick 38de42d2bbc3 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-38de42d2bbc3.patch | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 patches/chromium/cherry-pick-38de42d2bbc3.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 111abbc2e5ae3..a61573d95f212 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,5 +133,6 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +cherry-pick-38de42d2bbc3.patch cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch diff --git a/patches/chromium/cherry-pick-38de42d2bbc3.patch b/patches/chromium/cherry-pick-38de42d2bbc3.patch new file mode 100644 index 0000000000000..68735ef396370 --- /dev/null +++ b/patches/chromium/cherry-pick-38de42d2bbc3.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Will Harris <wfh@chromium.org> +Date: Thu, 2 Mar 2023 10:23:28 +0000 +Subject: Fix potential out of bounds write in base::SampleVectorBase + +BUG=1417185 + +(cherry picked from commit 552939b035e724e022fedb90fd80cd008e441fcf) + +Change-Id: I70719d0f9afb81dda373f88ab3a1c177397659ec +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4265437 +Commit-Queue: Will Harris <wfh@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1106984} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4289351 +Commit-Queue: Zakhar Voit <voit@google.com> +Reviewed-by: Victor-Gabriel Savu <vsavu@google.com> +Owners-Override: Victor-Gabriel Savu <vsavu@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1397} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/base/metrics/sample_vector.cc b/base/metrics/sample_vector.cc +index cec7687eeeb3daea85f5bec24765bb5aed5f1c6a..a6995578515a292631dca6044e5ee23c14803e5a 100644 +--- a/base/metrics/sample_vector.cc ++++ b/base/metrics/sample_vector.cc +@@ -274,6 +274,12 @@ void SampleVectorBase::MoveSingleSampleToCounts() { + if (sample.count == 0) + return; + ++ // Stop here if the sample bucket would be out of range for the AtomicCount ++ // array. ++ if (sample.bucket >= counts_size()) { ++ return; ++ } ++ + // Move the value into storage. Sum and redundant-count already account + // for this entry so no need to call IncreaseSumAndCount(). + subtle::NoBarrier_AtomicIncrement(&counts()[sample.bucket], sample.count); From c43eed8782541682422b7893874e0739acf073a9 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:52:38 -0400 Subject: [PATCH 097/172] ci: fixup gn check to actually run gn check (#37681) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- .circleci/config/base.yml | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 0e6f8031a9827..9c4c8b0293653 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -1011,26 +1011,13 @@ step-ts-compile: &step-ts-compile # List of all steps. steps-electron-gn-check: &steps-electron-gn-check steps: - - *step-checkout-electron - - *step-depot-tools-get - - *step-depot-tools-add-to-path - install-python2-mac - - *step-setup-env-for-build - *step-setup-goma-for-build - - *step-generate-deps-hash - - *step-touch-sync-done - - maybe-restore-portaled-src-cache - - run: - name: Ensure src checkout worked - command: | - if [ ! -d "src/third_party/blink" ]; then - echo src cache was not restored for an unknown reason - exit 1 - fi - - run: - name: Wipe Electron - command: rm -rf src/electron - - *step-checkout-electron + - checkout-from-cache + - *step-setup-env-for-build + - *step-wait-for-goma + - *step-gn-gen-default + - *step-gn-check steps-electron-ts-compile-for-doc-change: &steps-electron-ts-compile-for-doc-change steps: From 8a2e93605365d346bc635d8a5fd2ec53bf694bf1 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 23 Mar 2023 23:08:00 +0000 Subject: [PATCH 098/172] chore: cherry-pick 86fc0e9bedaf and 8d52bc14b306 from chromium (#37669) * chore: cherry-pick 86fc0e9bedaf from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 2 + ...browser_watcher_activity_report_with.patch | 72 +++++++++++++++++++ ...revent_potential_integer_overflow_in.patch | 64 +++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 patches/chromium/m108-lts_do_not_register_browser_watcher_activity_report_with.patch create mode 100644 patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index a61573d95f212..0acc2aac705a5 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,6 +133,8 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +m108-lts_prevent_potential_integer_overflow_in.patch +m108-lts_do_not_register_browser_watcher_activity_report_with.patch cherry-pick-38de42d2bbc3.patch cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch diff --git a/patches/chromium/m108-lts_do_not_register_browser_watcher_activity_report_with.patch b/patches/chromium/m108-lts_do_not_register_browser_watcher_activity_report_with.patch new file mode 100644 index 0000000000000..6e2324efa470a --- /dev/null +++ b/patches/chromium/m108-lts_do_not_register_browser_watcher_activity_report_with.patch @@ -0,0 +1,72 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Will Harris <wfh@chromium.org> +Date: Thu, 2 Mar 2023 17:01:49 +0000 +Subject: Do not register browser_watcher activity report with crashpad + +BUG=1415328 + +(cherry picked from commit f93c88303ccbb64014a575b8ae093aa166832922) + +Change-Id: I109f6dac083a69a26841ee5e975e02093ca4cbf6 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4257669 +Commit-Queue: Will Harris <wfh@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1106253} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4279942 +Reviewed-by: Victor-Gabriel Savu <vsavu@google.com> +Commit-Queue: Zakhar Voit <voit@google.com> +Owners-Override: Victor-Gabriel Savu <vsavu@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1401} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/components/crash/core/app/BUILD.gn b/components/crash/core/app/BUILD.gn +index 09219dd91f4205b38b36d3f62483cf2e9fc3782b..a45dec6b0708a0b0df1fc0f62283c730611b93b7 100644 +--- a/components/crash/core/app/BUILD.gn ++++ b/components/crash/core/app/BUILD.gn +@@ -159,7 +159,6 @@ if (is_win) { + deps = [ + "//base", + "//build:chromeos_buildflags", +- "//components/browser_watcher:activity_report", + "//components/gwp_asan/buildflags", + "//third_party/crashpad/crashpad/client", + "//third_party/crashpad/crashpad/handler", +diff --git a/components/crash/core/app/DEPS b/components/crash/core/app/DEPS +index 9717215396c918c46e683321115ed55ebcf6534d..9053a97a7068d5c3a240c9c7e99b0f7c2c2c038d 100644 +--- a/components/crash/core/app/DEPS ++++ b/components/crash/core/app/DEPS +@@ -3,7 +3,6 @@ include_rules = [ + "+third_party/breakpad", + + "+components/crash/android/jni_headers", +- "+components/browser_watcher/activity_report_user_stream_data_source.h", + "+components/gwp_asan/buildflags/buildflags.h", + "+components/gwp_asan/crash_handler/crash_handler.h", + "+content/public/common/content_descriptors.h", +diff --git a/components/crash/core/app/run_as_crashpad_handler_win.cc b/components/crash/core/app/run_as_crashpad_handler_win.cc +index 5ae2702540dd635fa208f01ee84e92b2c2f1e220..ac2a160a172a75e6e4d12033b62c73551fb3e288 100644 +--- a/components/crash/core/app/run_as_crashpad_handler_win.cc ++++ b/components/crash/core/app/run_as_crashpad_handler_win.cc +@@ -16,7 +16,6 @@ + #include "base/strings/string_util.h" + #include "base/strings/utf_string_conversions.h" + #include "base/threading/platform_thread.h" +-#include "components/browser_watcher/activity_report_user_stream_data_source.h" + #include "components/gwp_asan/buildflags/buildflags.h" + #include "third_party/crashpad/crashpad/client/crashpad_info.h" + #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" +@@ -81,15 +80,6 @@ int RunAsCrashpadHandler(const base::CommandLine& command_line, + argv.clear(); + + crashpad::UserStreamDataSources user_stream_data_sources; +- // Interpret an empty user data directory as a missing value. +- if (!user_data_dir.empty()) { +- // Register an extension to collect stability information. The extension +- // will be invoked for any registered process' crashes, but information only +- // exists for instrumented browser processes. +- user_stream_data_sources.push_back( +- std::make_unique<browser_watcher::ActivityReportUserStreamDataSource>( +- user_data_dir)); +- } + + #if BUILDFLAG(ENABLE_GWP_ASAN) + user_stream_data_sources.push_back( diff --git a/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch b/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch new file mode 100644 index 0000000000000..38363c3fa6000 --- /dev/null +++ b/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch @@ -0,0 +1,64 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Will Harris <wfh@chromium.org> +Date: Thu, 2 Mar 2023 17:21:30 +0000 +Subject: Prevent potential integer overflow in PersistentMemoryAllocator + +https://crrev.com/c/4250177 added an extra check for potential +integer overflow in GetAllocSize but forgot to add the same +check in GetBlock. + +This meant that it was possible to get a pointer to a block +but calling GetAllocSize on the same block would return zero. + +This change makes the two functions consistent with each other +so calling GetBlock on invalid data will return nullptr. + +BUG=1417317,1415328 + +(cherry picked from commit 81be8e8f2e13a9f1fe6d3150205a3c13af1db6e9) + +Change-Id: I8eb3d91bae4528fc97517d202baf337536a4c81f +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4264177 +Commit-Queue: Alexei Svitkine <asvitkine@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1107105} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4280124 +Owners-Override: Victor-Gabriel Savu <vsavu@google.com> +Reviewed-by: Victor-Gabriel Savu <vsavu@google.com> +Commit-Queue: Zakhar Voit <voit@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1402} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc +index bc4618bf30832d010570e8a490d3d893f064237b..d8146e96cf425adbf79a4ec484fcf72d151a888d 100644 +--- a/base/metrics/persistent_memory_allocator.cc ++++ b/base/metrics/persistent_memory_allocator.cc +@@ -881,8 +881,13 @@ PersistentMemoryAllocator::GetBlock(Reference ref, + if (ref % kAllocAlignment != 0) + return nullptr; + size += sizeof(BlockHeader); +- if (ref + size > mem_size_) ++ uint32_t total_size; ++ if (!base::CheckAdd(ref, size).AssignIfValid(&total_size)) { + return nullptr; ++ } ++ if (total_size > mem_size_) { ++ return nullptr; ++ } + + // Validation of referenced block-header. + if (!free_ok) { +@@ -892,8 +897,13 @@ PersistentMemoryAllocator::GetBlock(Reference ref, + return nullptr; + if (block->size < size) + return nullptr; +- if (ref + block->size > mem_size_) ++ uint32_t block_size; ++ if (!base::CheckAdd(ref, block->size).AssignIfValid(&block_size)) { + return nullptr; ++ } ++ if (block_size > mem_size_) { ++ return nullptr; ++ } + if (type_id != 0 && + block->type_id.load(std::memory_order_relaxed) != type_id) { + return nullptr; From 3931d5a84ff0d0d3ef4bdd6d4743f8881977bd5b Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 14:36:30 +0100 Subject: [PATCH 099/172] chore: cherry-pick a0d16d18d072 from pdfium (#37698) --- patches/config.json | 4 +- patches/pdfium/.patches | 1 + patches/pdfium/cherry-pick-a0d16d18d072.patch | 164 ++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 patches/pdfium/.patches create mode 100644 patches/pdfium/cherry-pick-a0d16d18d072.patch diff --git a/patches/config.json b/patches/config.json index bac8c8b9a4586..32ae78a4fa1d3 100644 --- a/patches/config.json +++ b/patches/config.json @@ -21,5 +21,7 @@ "src/electron/patches/Mantle": "src/third_party/squirrel.mac/vendor/Mantle", - "src/electron/patches/ReactiveObjC": "src/third_party/squirrel.mac/vendor/ReactiveObjC" + "src/electron/patches/ReactiveObjC": "src/third_party/squirrel.mac/vendor/ReactiveObjC", + + "src/electron/patches/pdfium": "src/third_party/pdfium" } diff --git a/patches/pdfium/.patches b/patches/pdfium/.patches new file mode 100644 index 0000000000000..3dc9951c0b7c4 --- /dev/null +++ b/patches/pdfium/.patches @@ -0,0 +1 @@ +cherry-pick-a0d16d18d072.patch diff --git a/patches/pdfium/cherry-pick-a0d16d18d072.patch b/patches/pdfium/cherry-pick-a0d16d18d072.patch new file mode 100644 index 0000000000000..3e355c3ba7bad --- /dev/null +++ b/patches/pdfium/cherry-pick-a0d16d18d072.patch @@ -0,0 +1,164 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom Sepez <tsepez@chromium.org> +Date: Tue, 14 Mar 2023 21:18:45 +0000 +Subject: M110: Observe CPWL_* object destruction across CPDFSDK_Widget methods + +This is a simple fix to stop the symptoms while we investigate +how to avoid mutations at these points in the first place. + +-- fix some nearby braces and annoying blank lines while at it. + +Bug: chromium:1419831 +Change-Id: I20c38806b91c7c0c9016bb1b567a04ce319243d8 +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/104397 +Commit-Queue: Tom Sepez <tsepez@chromium.org> +Reviewed-by: Lei Zhang <thestig@chromium.org> +(cherry picked from commit 63e3719f1ec20ee6db804b2b2d4b00680db18d9c) +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/104833 +Auto-Submit: Tom Sepez <tsepez@chromium.org> + +diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp +index 2cea0e0ad0d13149a6e7e499c5ea3366d84c9aaa..7c875486016b0b4205b31b9db077850663bc33af 100644 +--- a/fpdfsdk/formfiller/cffl_checkbox.cpp ++++ b/fpdfsdk/formfiller/cffl_checkbox.cpp +@@ -65,9 +65,13 @@ bool CFFL_CheckBox::OnChar(CPDFSDK_Widget* pWidget, + CFFL_FormField::OnChar(pWidget, nChar, nFlags); + + CPWL_CheckBox* pWnd = CreateOrUpdatePWLCheckBox(pPageView); +- if (pWnd && !pWnd->IsReadOnly()) +- pWnd->SetCheck(!pWidget->IsChecked()); +- ++ if (pWnd && !pWnd->IsReadOnly()) { ++ ObservedPtr<CPWL_CheckBox> pObservedBox(pWnd); ++ const bool is_checked = pWidget->IsChecked(); ++ if (pObservedBox) { ++ pObservedBox->SetCheck(!is_checked); ++ } ++ } + return CommitData(pPageView, nFlags); + } + default: +@@ -80,14 +84,17 @@ bool CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView, + Mask<FWL_EVENTFLAG> nFlags, + const CFX_PointF& point) { + CFFL_Button::OnLButtonUp(pPageView, pWidget, nFlags, point); +- +- if (!IsValid()) ++ if (!IsValid()) { + return true; +- ++ } + CPWL_CheckBox* pWnd = CreateOrUpdatePWLCheckBox(pPageView); +- if (pWnd) +- pWnd->SetCheck(!pWidget->IsChecked()); +- ++ if (pWnd) { ++ ObservedPtr<CPWL_CheckBox> pObservedBox(pWnd); ++ const bool is_checked = pWidget->IsChecked(); ++ if (pObservedBox) { ++ pObservedBox->SetCheck(!is_checked); ++ } ++ } + return CommitData(pPageView, nFlags); + } + +diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp +index 96b4aea8e74a629d201cd780d631d4e82d5b284c..4bb100014c804adcfc7f1f2023cd1870f81c85e8 100644 +--- a/fpdfsdk/formfiller/cffl_listbox.cpp ++++ b/fpdfsdk/formfiller/cffl_listbox.cpp +@@ -105,11 +105,15 @@ bool CFFL_ListBox::IsDataChanged(const CPDFSDK_PageView* pPageView) { + + void CFFL_ListBox::SaveData(const CPDFSDK_PageView* pPageView) { + CPWL_ListBox* pListBox = GetPWLListBox(pPageView); +- if (!pListBox) ++ if (!pListBox) { + return; +- ++ } + int32_t nNewTopIndex = pListBox->GetTopVisibleIndex(); ++ ObservedPtr<CPWL_ListBox> observed_box(pListBox); + m_pWidget->ClearSelection(); ++ if (!observed_box) { ++ return; ++ } + if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) { + for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) { + if (pListBox->IsItemSelected(i)) +@@ -121,17 +125,17 @@ void CFFL_ListBox::SaveData(const CPDFSDK_PageView* pPageView) { + ObservedPtr<CPDFSDK_Widget> observed_widget(m_pWidget.Get()); + ObservedPtr<CFFL_ListBox> observed_this(this); + m_pWidget->SetTopVisibleIndex(nNewTopIndex); +- if (!observed_widget) ++ if (!observed_widget) { + return; +- ++ } + m_pWidget->ResetFieldAppearance(); +- if (!observed_widget) ++ if (!observed_widget) { + return; +- ++ } + m_pWidget->UpdateField(); +- if (!observed_widget || !observed_this) ++ if (!observed_widget || !observed_this) { + return; +- ++ } + SetChangeMark(); + } + +diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp +index 5ae3e94cd185e56d759cb99dbc90997caa606283..2ceedde4a765e765e75e478ebee43204fe440fe4 100644 +--- a/fpdfsdk/formfiller/cffl_textfield.cpp ++++ b/fpdfsdk/formfiller/cffl_textfield.cpp +@@ -142,26 +142,29 @@ bool CFFL_TextField::IsDataChanged(const CPDFSDK_PageView* pPageView) { + } + + void CFFL_TextField::SaveData(const CPDFSDK_PageView* pPageView) { +- CPWL_Edit* pWnd = GetPWLEdit(pPageView); +- if (!pWnd) ++ ObservedPtr<CPWL_Edit> observed_edit(GetPWLEdit(pPageView)); ++ if (!observed_edit) { + return; +- ++ } + WideString sOldValue = m_pWidget->GetValue(); +- WideString sNewValue = pWnd->GetText(); ++ if (!observed_edit) { ++ return; ++ } ++ WideString sNewValue = observed_edit->GetText(); + ObservedPtr<CPDFSDK_Widget> observed_widget(m_pWidget.Get()); + ObservedPtr<CFFL_TextField> observed_this(this); + m_pWidget->SetValue(sNewValue); +- if (!observed_widget) ++ if (!observed_widget) { + return; +- ++ } + m_pWidget->ResetFieldAppearance(); +- if (!observed_widget) ++ if (!observed_widget) { + return; +- ++ } + m_pWidget->UpdateField(); +- if (!observed_widget || !observed_this) ++ if (!observed_widget || !observed_this) { + return; +- ++ } + SetChangeMark(); + } + +@@ -172,9 +175,7 @@ void CFFL_TextField::GetActionData(const CPDFSDK_PageView* pPageView, + case CPDF_AAction::kKeyStroke: + if (CPWL_Edit* pWnd = GetPWLEdit(pPageView)) { + fa.bFieldFull = pWnd->IsTextFull(); +- + fa.sValue = pWnd->GetText(); +- + if (fa.bFieldFull) { + fa.sChange.clear(); + fa.sChangeEx.clear(); From f19e6d516a2a68b703616cc89a38fdf34aa2b868 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 16:18:58 +0100 Subject: [PATCH 100/172] chore: cherry-pick ce029c91a662 from angle (#37696) * chore: [22-x-y] cherry-pick ce029c91a662 from angle * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/angle/.patches | 1 + patches/angle/cherry-pick-ce029c91a662.patch | 158 +++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 patches/angle/cherry-pick-ce029c91a662.patch diff --git a/patches/angle/.patches b/patches/angle/.patches index dbd34bebf0d81..f6886ebbdb5fe 100644 --- a/patches/angle/.patches +++ b/patches/angle/.patches @@ -1,2 +1,3 @@ fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch cherry-pick-55e2b6daba9d.patch +cherry-pick-ce029c91a662.patch diff --git a/patches/angle/cherry-pick-ce029c91a662.patch b/patches/angle/cherry-pick-ce029c91a662.patch new file mode 100644 index 0000000000000..0bc21d9d539f0 --- /dev/null +++ b/patches/angle/cherry-pick-ce029c91a662.patch @@ -0,0 +1,158 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Geoff Lang <geofflang@chromium.org> +Date: Fri, 10 Mar 2023 13:48:03 -0500 +Subject: M110: D3D11: Add logic to disassociate EGL image storages. + +The TextureStorage classes for External and EGLImages were missing the +logic to disassociate from images. This lead to the images continuing +to hold references to deleted storages. + +Bug: chromium:1415330 +Change-Id: I8303f6751d87a9b0a52993c7d4e9509b086b93f3 +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4328347 +Reviewed-by: Peng Huang <penghuang@chromium.org> +Commit-Queue: Geoff Lang <geofflang@chromium.org> +(cherry picked from commit a8720455fda43167465c3d2f9a13fca60c21f56e) +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4348335 +Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> + +diff --git a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp +index f1277462a929ed867a325f12db5fbf011b3f678e..c2fe439ca826e86b023dbe982ff44dd3bfb56470 100644 +--- a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp ++++ b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp +@@ -1652,7 +1652,8 @@ TextureStorage11_External::TextureStorage11_External( + egl::Stream *stream, + const egl::Stream::GLTextureDescription &glDesc, + const std::string &label) +- : TextureStorage11(renderer, D3D11_BIND_SHADER_RESOURCE, 0, glDesc.internalFormat, label) ++ : TextureStorage11(renderer, D3D11_BIND_SHADER_RESOURCE, 0, glDesc.internalFormat, label), ++ mAssociatedImage(nullptr) + { + ASSERT(stream->getProducerType() == egl::Stream::ProducerType::D3D11Texture); + auto *producer = static_cast<StreamProducerD3DTexture *>(stream->getImplementation()); +@@ -1678,6 +1679,15 @@ angle::Result TextureStorage11_External::onDestroy(const gl::Context *context) + mRenderer->getStateManager()->invalidateBoundViews(); + } + ++ if (mAssociatedImage != nullptr) ++ { ++ mAssociatedImage->verifyAssociatedStorageValid(this); ++ ++ // We must let the Images recover their data before we delete it from the ++ // TextureStorage. ++ ANGLE_TRY(mAssociatedImage->recoverFromAssociatedStorage(context)); ++ } ++ + return angle::Result::Continue; + } + +@@ -1885,7 +1895,8 @@ TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer, + mImage(eglImage), + mCurrentRenderTarget(0), + mSwizzleTexture(), +- mSwizzleRenderTargets(gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS) ++ mSwizzleRenderTargets(gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS), ++ mAssociatedImage(nullptr) + { + mCurrentRenderTarget = reinterpret_cast<uintptr_t>(renderTarget11); + +@@ -1897,6 +1908,20 @@ TextureStorage11_EGLImage::TextureStorage11_EGLImage(Renderer11 *renderer, + + TextureStorage11_EGLImage::~TextureStorage11_EGLImage() {} + ++angle::Result TextureStorage11_EGLImage::onDestroy(const gl::Context *context) ++{ ++ if (mAssociatedImage != nullptr) ++ { ++ mAssociatedImage->verifyAssociatedStorageValid(this); ++ ++ // We must let the Images recover their data before we delete it from the ++ // TextureStorage. ++ ANGLE_TRY(mAssociatedImage->recoverFromAssociatedStorage(context)); ++ } ++ ++ return angle::Result::Continue; ++} ++ + angle::Result TextureStorage11_EGLImage::getSubresourceIndex(const gl::Context *context, + const gl::ImageIndex &index, + UINT *outSubresourceIndex) const +@@ -2120,6 +2145,42 @@ void TextureStorage11_EGLImage::onLabelUpdate() + } + } + ++void TextureStorage11_EGLImage::associateImage(Image11 *image, const gl::ImageIndex &index) ++{ ++ ASSERT(index.getLevelIndex() == 0); ++ mAssociatedImage = image; ++} ++ ++void TextureStorage11_EGLImage::verifyAssociatedImageValid(const gl::ImageIndex &index, ++ Image11 *expectedImage) ++{ ++ ASSERT(index.getLevelIndex() == 0 && mAssociatedImage == expectedImage); ++} ++ ++void TextureStorage11_EGLImage::disassociateImage(const gl::ImageIndex &index, ++ Image11 *expectedImage) ++{ ++ ASSERT(index.getLevelIndex() == 0); ++ ASSERT(mAssociatedImage == expectedImage); ++ mAssociatedImage = nullptr; ++} ++ ++angle::Result TextureStorage11_EGLImage::releaseAssociatedImage(const gl::Context *context, ++ const gl::ImageIndex &index, ++ Image11 *incomingImage) ++{ ++ ASSERT(index.getLevelIndex() == 0); ++ ++ if (mAssociatedImage != nullptr && mAssociatedImage != incomingImage) ++ { ++ mAssociatedImage->verifyAssociatedStorageValid(this); ++ ++ ANGLE_TRY(mAssociatedImage->recoverFromAssociatedStorage(context)); ++ } ++ ++ return angle::Result::Continue; ++} ++ + TextureStorage11_Cube::TextureStorage11_Cube(Renderer11 *renderer, + GLenum internalformat, + BindFlags bindFlags, +diff --git a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h +index 72bc1b802c5d4f2befe7a440aae8e115d5b94c8a..7c5245acd8fcb7880f19905c0f69c7b7886e9e72 100644 +--- a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h ++++ b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.h +@@ -492,6 +492,8 @@ class TextureStorage11_EGLImage final : public TextureStorage11ImmutableBase + const std::string &label); + ~TextureStorage11_EGLImage() override; + ++ angle::Result onDestroy(const gl::Context *context) override; ++ + angle::Result getSubresourceIndex(const gl::Context *context, + const gl::ImageIndex &index, + UINT *outSubresourceIndex) const override; +@@ -518,6 +520,13 @@ class TextureStorage11_EGLImage final : public TextureStorage11ImmutableBase + bool useLevelZeroTexture) override; + void onLabelUpdate() override; + ++ void associateImage(Image11 *image, const gl::ImageIndex &index) override; ++ void disassociateImage(const gl::ImageIndex &index, Image11 *expectedImage) override; ++ void verifyAssociatedImageValid(const gl::ImageIndex &index, Image11 *expectedImage) override; ++ angle::Result releaseAssociatedImage(const gl::Context *context, ++ const gl::ImageIndex &index, ++ Image11 *incomingImage) override; ++ + protected: + angle::Result getSwizzleTexture(const gl::Context *context, + const TextureHelper11 **outTexture) override; +@@ -545,6 +554,8 @@ class TextureStorage11_EGLImage final : public TextureStorage11ImmutableBase + // Swizzle-related variables + TextureHelper11 mSwizzleTexture; + std::vector<d3d11::RenderTargetView> mSwizzleRenderTargets; ++ ++ Image11 *mAssociatedImage; + }; + + class TextureStorage11_Cube : public TextureStorage11 From c0caa6102279dc8a5dad6bd7b5903ef53f92fe55 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 17:21:26 +0100 Subject: [PATCH 101/172] chore: cherry-pick 1235110fce18 from chromium (#37691) * chore: [22-x-y] cherry-pick 1235110fce18 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-1235110fce18.patch | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 patches/chromium/cherry-pick-1235110fce18.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 0acc2aac705a5..69e83da4afc22 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -138,3 +138,4 @@ m108-lts_do_not_register_browser_watcher_activity_report_with.patch cherry-pick-38de42d2bbc3.patch cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch +cherry-pick-1235110fce18.patch diff --git a/patches/chromium/cherry-pick-1235110fce18.patch b/patches/chromium/cherry-pick-1235110fce18.patch new file mode 100644 index 0000000000000..040c4e3f9ed6b --- /dev/null +++ b/patches/chromium/cherry-pick-1235110fce18.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Geoff Lang <geofflang@chromium.org> +Date: Tue, 14 Mar 2023 21:15:46 +0000 +Subject: Disable glShaderBinary in the passthrough cmd decoder. + +This matches the behaviour of the validating command decoder. The client +does not use this function and it's not exposed to WebGL. + +(cherry picked from commit 4a81311a62d853a43e002f45c6867f73c0accdab) + +Bug: 1422594 +Change-Id: I87c670e4e80b0078fddb9f089b7ac7777a6debfa +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4324998 +Reviewed-by: Kenneth Russell <kbr@chromium.org> +Commit-Queue: Geoff Lang <geofflang@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1115379} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4335184 +Cr-Commit-Position: refs/branch-heads/5481@{#1357} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc +index 9b09ddfe074ebe2786c7bc341b84a5eb5b7b73c9..373dab1c379152c45878faa60a5648bf0bc662e7 100644 +--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc ++++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough_doers.cc +@@ -2666,6 +2666,10 @@ error::Error GLES2DecoderPassthroughImpl::DoShaderBinary(GLsizei n, + GLenum binaryformat, + const void* binary, + GLsizei length) { ++#if 1 // No binary shader support. ++ InsertError(GL_INVALID_ENUM, "Invalid enum."); ++ return error::kNoError; ++#else + std::vector<GLuint> service_shaders(n, 0); + for (GLsizei i = 0; i < n; i++) { + service_shaders[i] = GetShaderServiceID(shaders[i], resources_); +@@ -2673,6 +2677,7 @@ error::Error GLES2DecoderPassthroughImpl::DoShaderBinary(GLsizei n, + api()->glShaderBinaryFn(n, service_shaders.data(), binaryformat, binary, + length); + return error::kNoError; ++#endif + } + + error::Error GLES2DecoderPassthroughImpl::DoShaderSource(GLuint shader, From 565c4fe9a70def1a8987ff9f7388098b9e62dbb7 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 18:50:20 +0100 Subject: [PATCH 102/172] chore: cherry-pick 9aa4c45f21b1 from chromium (#37650) * chore: [22-x-y] cherry-pick 9aa4c45f21b1 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-9aa4c45f21b1.patch | 88 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 patches/chromium/cherry-pick-9aa4c45f21b1.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 69e83da4afc22..77fbef5bece68 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,6 +133,7 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +cherry-pick-9aa4c45f21b1.patch m108-lts_prevent_potential_integer_overflow_in.patch m108-lts_do_not_register_browser_watcher_activity_report_with.patch cherry-pick-38de42d2bbc3.patch diff --git a/patches/chromium/cherry-pick-9aa4c45f21b1.patch b/patches/chromium/cherry-pick-9aa4c45f21b1.patch new file mode 100644 index 0000000000000..a9db77874d315 --- /dev/null +++ b/patches/chromium/cherry-pick-9aa4c45f21b1.patch @@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= <hbos@chromium.org> +Date: Tue, 14 Mar 2023 13:07:19 +0000 +Subject: Shutdown RtpContributingSourceCache in Dispose(). +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The cache is an off-heap object, but it is owned by an on-heap object +(RTCPeerConnection). Dispoing the owning object poisons memory owned by +it, but the cache may have in-flight tasks (cache doing ClearCache in a +delayed microtask). This CL adds a Shutdown() method to ensure the +cache isn't doing anything in the next microtask after disposal. + +No reliable way to repro this has been found but the change should be +safe so hoping we can land without tests. + +(cherry picked from commit 4d450ecd6ec7776c7505dcf7d2f04157ff3ba0eb) + +Bug: 1413628 +Change-Id: I479aace9859f4c10cd75d4aa5a34808b4726299d +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4247023 +Commit-Queue: Henrik Boström <hbos@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1105653} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4291513 +Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> +Owners-Override: Achuith Bhandarkar <achuith@chromium.org> +Reviewed-by: Henrik Boström <hbos@chromium.org> +Commit-Queue: Zakhar Voit <voit@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1404} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc +index e951bf3faa35a8634ae2c8b90446843d77e509a9..8aeb3497e7b036904a25e807bc2a6ca654cd3752 100644 +--- a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc ++++ b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc +@@ -643,12 +643,18 @@ RTCPeerConnection::~RTCPeerConnection() { + } + + void RTCPeerConnection::Dispose() { +- // Promptly clears the handler +- // so that content/ doesn't access it in a lazy sweeping phase. +- // Other references to the handler use a weak pointer, preventing access. ++ // Promptly clears the handler so that content doesn't access it in a lazy ++ // sweeping phase. Other references to the handler use a weak pointer, ++ // preventing access. + if (peer_handler_) { + peer_handler_.reset(); + } ++ // Memory owned by RTCPeerConnection must not be touched after Dispose(). ++ // Shut down the cache to cancel any in-flight tasks that may otherwise have ++ // used the cache. ++ if (rtp_contributing_source_cache_.has_value()) { ++ rtp_contributing_source_cache_.value().Shutdown(); ++ } + } + + ScriptPromise RTCPeerConnection::createOffer(ScriptState* script_state, +diff --git a/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.cc b/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.cc +index 1f91cf9c128a1bb19fb0a63ea9d869a5c4e6d07d..5ad457fae9bc62a252ca94297fc4231a886b62b9 100644 +--- a/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.cc ++++ b/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.cc +@@ -102,6 +102,10 @@ RtpContributingSourceCache::RtpContributingSourceCache( + DCHECK(worker_thread_runner_); + } + ++void RtpContributingSourceCache::Shutdown() { ++ weak_factory_.InvalidateWeakPtrs(); ++} ++ + HeapVector<Member<RTCRtpSynchronizationSource>> + RtpContributingSourceCache::getSynchronizationSources( + ScriptState* script_state, +diff --git a/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.h b/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.h +index 0d0ef9d1c59328e04217d9fca3f4e59b01ecca96..3a42751ab02f5680758c2b3ebce8a599f751c1ca 100644 +--- a/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.h ++++ b/third_party/blink/renderer/modules/peerconnection/rtp_contributing_source_cache.h +@@ -43,6 +43,10 @@ class RtpContributingSourceCache { + RTCPeerConnection* pc, + scoped_refptr<base::SingleThreadTaskRunner> worker_thread_runner); + ++ // When the owner of this object is Disposed(), this method must be called to ++ // cancel any in-flight tasks. ++ void Shutdown(); ++ + HeapVector<Member<RTCRtpSynchronizationSource>> getSynchronizationSources( + ScriptState* script_state, + ExceptionState& exception_state, From be71423d321bc44b37079df6927938eccf484c7e Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 19:48:44 +0100 Subject: [PATCH 103/172] chore: cherry-pick aeceeb2187a6 from v8 (#37654) * chore: [22-x-y] cherry-pick aeceeb2187a6 from v8 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/v8/.patches | 1 + patches/v8/cherry-pick-aeceeb2187a6.patch | 90 +++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 patches/v8/cherry-pick-aeceeb2187a6.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 7fd06b1bd97ba..5dae5521ba989 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -10,5 +10,6 @@ revert_runtime_dhceck_terminating_exception_in_microtasks.patch chore_disable_is_execution_terminating_dcheck.patch force_cppheapcreateparams_to_be_noncopyable.patch cherry-pick-e17eee4894be.patch +cherry-pick-aeceeb2187a6.patch cherry-pick-546e00df97ac.patch cherry-pick-f6ddbf42b1ea.patch diff --git a/patches/v8/cherry-pick-aeceeb2187a6.patch b/patches/v8/cherry-pick-aeceeb2187a6.patch new file mode 100644 index 0000000000000..01098ae6be719 --- /dev/null +++ b/patches/v8/cherry-pick-aeceeb2187a6.patch @@ -0,0 +1,90 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marja=20H=C3=B6ltt=C3=A4?= <marja@chromium.org> +Date: Tue, 21 Feb 2023 13:38:34 +0100 +Subject: Merged [valueserializer] Fix map transition chain following w/ + dictionary maps +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Map::Update might return a dictionary map, and the calling code didn't +take it into account. + +Bug: chromium:1412487 +(cherry picked from commit b0db6637936a88807b5512a4de68145d0a9d6f02) + +Change-Id: Ib5e55aa60719e4ac2f14d993a3fc3e908cd43d2e +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4290145 +Reviewed-by: Marja Hölttä <marja@chromium.org> +Reviewed-by: Lutz Vahl <vahl@chromium.org> +Commit-Queue: Lutz Vahl <vahl@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.0@{#35} +Cr-Branched-From: 06097c6f0c5af54fd5d6965d37027efb72decd4f-refs/heads/11.0.226@{#1} +Cr-Branched-From: 6bf3344f5d9940de1ab253f1817dcb99c641c9d3-refs/heads/main@{#84857} + +diff --git a/src/objects/value-serializer.cc b/src/objects/value-serializer.cc +index 61a7cae8e8a900694ba22637d04368dac56ebd5f..640f8621719fa5dee4909e215ae788b09f1b0ba5 100644 +--- a/src/objects/value-serializer.cc ++++ b/src/objects/value-serializer.cc +@@ -2408,37 +2408,38 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties( + // Deserializaton of |value| might have deprecated current |target|, + // ensure we are working with the up-to-date version. + target = Map::Update(isolate_, target); +- +- InternalIndex descriptor(properties.size()); +- PropertyDetails details = +- target->instance_descriptors(isolate_).GetDetails(descriptor); +- Representation expected_representation = details.representation(); +- if (value->FitsRepresentation(expected_representation)) { +- if (expected_representation.IsHeapObject() && +- !target->instance_descriptors(isolate_) +- .GetFieldType(descriptor) +- .NowContains(value)) { +- Handle<FieldType> value_type = +- value->OptimalType(isolate_, expected_representation); +- MapUpdater::GeneralizeField(isolate_, target, descriptor, +- details.constness(), +- expected_representation, value_type); +- } +- DCHECK(target->instance_descriptors(isolate_) ++ if (!target->is_dictionary_map()) { ++ InternalIndex descriptor(properties.size()); ++ PropertyDetails details = ++ target->instance_descriptors(isolate_).GetDetails(descriptor); ++ Representation expected_representation = details.representation(); ++ if (value->FitsRepresentation(expected_representation)) { ++ if (expected_representation.IsHeapObject() && ++ !target->instance_descriptors(isolate_) + .GetFieldType(descriptor) +- .NowContains(value)); +- properties.push_back(value); +- map = target; +- continue; +- } else { +- transitioning = false; ++ .NowContains(value)) { ++ Handle<FieldType> value_type = ++ value->OptimalType(isolate_, expected_representation); ++ MapUpdater::GeneralizeField(isolate_, target, descriptor, ++ details.constness(), ++ expected_representation, value_type); ++ } ++ DCHECK(target->instance_descriptors(isolate_) ++ .GetFieldType(descriptor) ++ .NowContains(value)); ++ properties.push_back(value); ++ map = target; ++ continue; ++ } + } ++ transitioning = false; + } + + // Fell out of transitioning fast path. Commit the properties gathered so + // far, and then start setting properties slowly instead. + DCHECK(!transitioning); + CHECK_LT(properties.size(), std::numeric_limits<uint32_t>::max()); ++ CHECK(!map->is_dictionary_map()); + CommitProperties(object, map, properties); + num_properties = static_cast<uint32_t>(properties.size()); + From 94c7ad9ee26e19b74700a76d3dabb0f14886a180 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 23:19:18 +0100 Subject: [PATCH 104/172] chore: cherry-pick bfd926be8178 from chromium (#37659) * chore: cherry-pick bfd926be8178 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-bfd926be8178.patch | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 patches/chromium/cherry-pick-bfd926be8178.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 77fbef5bece68..33204df2c5751 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,6 +133,7 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +cherry-pick-bfd926be8178.patch cherry-pick-9aa4c45f21b1.patch m108-lts_prevent_potential_integer_overflow_in.patch m108-lts_do_not_register_browser_watcher_activity_report_with.patch diff --git a/patches/chromium/cherry-pick-bfd926be8178.patch b/patches/chromium/cherry-pick-bfd926be8178.patch new file mode 100644 index 0000000000000..b2a39ccbdf04f --- /dev/null +++ b/patches/chromium/cherry-pick-bfd926be8178.patch @@ -0,0 +1,134 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eugene Zemtsov <eugene@chromium.org> +Date: Thu, 23 Feb 2023 23:29:10 +0000 +Subject: webcodecs: Fix VP9 p2 encoding of NV12 frames + +(cherry picked from commit 503831d1bdfdbe20c096f04cefc2231efd9ca4c0) + +Bug: 1412991 +Change-Id: I2e596f65170c1fc98c122bfb0ecff4b241feee15 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4250421 +Commit-Queue: Eugene Zemtsov <eugene@chromium.org> +Reviewed-by: Dale Curtis <dalecurtis@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1105528} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288113 +Cr-Commit-Position: refs/branch-heads/5481@{#1271} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/media/video/BUILD.gn b/media/video/BUILD.gn +index ce155164c821ddf60f73f7b0af0dce6e3d399af4..da517ef08a4cd1094f8e1660dfb5e4b7d847c979 100644 +--- a/media/video/BUILD.gn ++++ b/media/video/BUILD.gn +@@ -169,6 +169,7 @@ source_set("unit_tests") { + "//media:test_support", + "//testing/gmock", + "//testing/gtest", ++ "//third_party/libvpx:libvpx", + "//third_party/libyuv:libyuv", + "//ui/gfx", + ] +diff --git a/media/video/software_video_encoder_test.cc b/media/video/software_video_encoder_test.cc +index 2059f4e076ff9fa1720683ac5dfb90312df2183e..318c743bddcf9bec3a994f125ea329d45f8c4376 100644 +--- a/media/video/software_video_encoder_test.cc ++++ b/media/video/software_video_encoder_test.cc +@@ -40,6 +40,8 @@ + #if BUILDFLAG(ENABLE_LIBVPX) + #include "media/filters/vpx_video_decoder.h" + #include "media/video/vpx_video_encoder.h" ++#include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" ++#include "third_party/libvpx/source/libvpx/vpx/vpx_codec.h" + #endif + + #if BUILDFLAG(ENABLE_LIBAOM) +@@ -74,6 +76,9 @@ class SoftwareVideoEncoderTest + pixel_format_ = args.pixel_format; + codec_ = args.codec; + encoder_ = CreateEncoder(codec_); ++ if (!encoder_) { ++ GTEST_SKIP() << "Encoder is not supported on the platform"; ++ } + } + + void TearDown() override { +@@ -200,6 +205,12 @@ class SoftwareVideoEncoderTest + case media::VideoCodec::kVP8: + case media::VideoCodec::kVP9: + #if BUILDFLAG(ENABLE_LIBVPX) ++ if (profile_ == VP9PROFILE_PROFILE2) { ++ vpx_codec_caps_t codec_caps = vpx_codec_get_caps(vpx_codec_vp9_cx()); ++ if ((codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) == 0) { ++ return nullptr; ++ } ++ } + return std::make_unique<media::VpxVideoEncoder>(); + #else + return nullptr; +@@ -303,6 +314,11 @@ class SoftwareVideoEncoderTest + return diff_cnt; + } + ++ VideoPixelFormat GetExpectedOutputPixelFormat(VideoCodecProfile profile) { ++ return profile == VP9PROFILE_PROFILE2 ? PIXEL_FORMAT_YUV420P10 ++ : PIXEL_FORMAT_I420; ++ } ++ + protected: + VideoCodec codec_; + VideoCodecProfile profile_; +@@ -488,7 +504,7 @@ TEST_P(SoftwareVideoEncoderTest, EncodeAndDecode) { + EXPECT_EQ(decoded_frame->timestamp(), original_frame->timestamp()); + EXPECT_EQ(decoded_frame->visible_rect().size(), + original_frame->visible_rect().size()); +- EXPECT_EQ(decoded_frame->format(), PIXEL_FORMAT_I420); ++ EXPECT_EQ(decoded_frame->format(), GetExpectedOutputPixelFormat(profile_)); + if (decoded_frame->format() == original_frame->format()) { + EXPECT_LE(CountDifferentPixels(*decoded_frame, *original_frame), + original_frame->visible_rect().width()); +@@ -890,6 +906,9 @@ SwVideoTestParams kVpxParams[] = { + {VideoCodec::kVP9, VP9PROFILE_PROFILE0, PIXEL_FORMAT_I420}, + {VideoCodec::kVP9, VP9PROFILE_PROFILE0, PIXEL_FORMAT_NV12}, + {VideoCodec::kVP9, VP9PROFILE_PROFILE0, PIXEL_FORMAT_XRGB}, ++ {VideoCodec::kVP9, VP9PROFILE_PROFILE2, PIXEL_FORMAT_I420}, ++ {VideoCodec::kVP9, VP9PROFILE_PROFILE2, PIXEL_FORMAT_NV12}, ++ {VideoCodec::kVP9, VP9PROFILE_PROFILE2, PIXEL_FORMAT_XRGB}, + {VideoCodec::kVP8, VP8PROFILE_ANY, PIXEL_FORMAT_I420}, + {VideoCodec::kVP8, VP8PROFILE_ANY, PIXEL_FORMAT_XRGB}}; + +diff --git a/media/video/vpx_video_encoder.cc b/media/video/vpx_video_encoder.cc +index 7787b765899bc57395fea1a06d5c9c5a925b8910..c4ad642e453c9582b9ada11ad99c6b1c969b27b5 100644 +--- a/media/video/vpx_video_encoder.cc ++++ b/media/video/vpx_video_encoder.cc +@@ -427,12 +427,20 @@ void VpxVideoEncoder::Encode(scoped_refptr<VideoFrame> frame, + } + } + +- const bool is_yuv = IsYuvPlanar(frame->format()); +- if (frame->visible_rect().size() != options_.frame_size || !is_yuv) { ++ // Unfortunately libyuv lacks direct NV12 to I010 conversion, and we ++ // have to do an extra conversion to I420. ++ // TODO(https://crbug.com/libyuv/954) Use NV12ToI010() when implemented ++ const bool vp9_p2_needs_nv12_to_i420 = ++ frame->format() == PIXEL_FORMAT_NV12 && profile_ == VP9PROFILE_PROFILE2; ++ const bool needs_conversion_to_i420 = ++ !IsYuvPlanar(frame->format()) || vp9_p2_needs_nv12_to_i420; ++ if (frame->visible_rect().size() != options_.frame_size || ++ needs_conversion_to_i420) { ++ auto new_pixel_format = ++ needs_conversion_to_i420 ? PIXEL_FORMAT_I420 : frame->format(); + auto resized_frame = frame_pool_.CreateFrame( +- is_yuv ? frame->format() : PIXEL_FORMAT_I420, options_.frame_size, +- gfx::Rect(options_.frame_size), options_.frame_size, +- frame->timestamp()); ++ new_pixel_format, options_.frame_size, gfx::Rect(options_.frame_size), ++ options_.frame_size, frame->timestamp()); + + if (!resized_frame) { + std::move(done_cb).Run( +@@ -454,6 +462,7 @@ void VpxVideoEncoder::Encode(scoped_refptr<VideoFrame> frame, + + switch (profile_) { + case VP9PROFILE_PROFILE2: ++ DCHECK_EQ(frame->format(), PIXEL_FORMAT_I420); + // Profile 2 uses 10bit color, + libyuv::I420ToI010( + frame->visible_data(VideoFrame::kYPlane), From 978cc7bd7d7850937807dd3ba66214671fe43652 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 27 Mar 2023 23:20:02 +0100 Subject: [PATCH 105/172] chore: cherry-pick 56bd20b295b4 from chromium (#37652) * chore: [22-x-y] cherry-pick 56bd20b295b4 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-56bd20b295b4.patch | 130 ++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 patches/chromium/cherry-pick-56bd20b295b4.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 33204df2c5751..0cda83292275f 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -140,4 +140,5 @@ m108-lts_do_not_register_browser_watcher_activity_report_with.patch cherry-pick-38de42d2bbc3.patch cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch +cherry-pick-56bd20b295b4.patch cherry-pick-1235110fce18.patch diff --git a/patches/chromium/cherry-pick-56bd20b295b4.patch b/patches/chromium/cherry-pick-56bd20b295b4.patch new file mode 100644 index 0000000000000..2a84818e6f6b1 --- /dev/null +++ b/patches/chromium/cherry-pick-56bd20b295b4.patch @@ -0,0 +1,130 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Robert Sesek <rsesek@chromium.org> +Date: Mon, 27 Feb 2023 21:25:11 +0000 +Subject: Update Crashpad to 3e8727238bae3c069bd71cfb3b2bbaa98b55f05b + +3e8727238bae win: Only process up to EXCEPTION_MAXIMUM_PARAMETERS in an + EXCEPTION_RECORD + +(cherry picked from commit d05bea76b7ce72d66507ebbe00caf5e45afd587a) + +Fixed: 1412658 +Change-Id: I7461602d1a18d44ea1a11ac19f1487fbdb92acf6 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4285061 +Commit-Queue: Robert Sesek <rsesek@chromium.org> +Commit-Queue: Alex Gough <ajgo@chromium.org> +Reviewed-by: Alex Gough <ajgo@chromium.org> +Auto-Submit: Robert Sesek <rsesek@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1108722} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4295200 +Cr-Commit-Position: refs/branch-heads/5481@{#1298} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/third_party/crashpad/README.chromium b/third_party/crashpad/README.chromium +index 29ad402c3558b7c75b68339e0f07ad004170fe76..2be0ee4d29e445b5531fc3fddcc3efa28ef968f1 100644 +--- a/third_party/crashpad/README.chromium ++++ b/third_party/crashpad/README.chromium +@@ -2,7 +2,7 @@ Name: Crashpad + Short Name: crashpad + URL: https://crashpad.chromium.org/ + Version: unknown +-Revision: 9f472e5a18d7611adaeb5df727b51102f35e109e ++Revision: 9f472e5a18d7611adaeb5df727b51102f35e109e with 3e8727238bae3c069bd71cfb3b2bbaa98b55f05b cherry-picked + License: Apache 2.0 + License File: crashpad/LICENSE + Security Critical: yes +diff --git a/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc b/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc +index 2a70c5c0cea234ee1d81262738d7c4e48736b78e..b8931444ac8b11044a6fa7ce2a5ccf34aa4409c8 100644 +--- a/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc ++++ b/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win.cc +@@ -14,6 +14,8 @@ + + #include "snapshot/win/exception_snapshot_win.h" + ++#include <algorithm> ++ + #include "base/logging.h" + #include "snapshot/capture_memory.h" + #include "snapshot/memory_snapshot.h" +@@ -261,8 +263,12 @@ bool ExceptionSnapshotWin::InitializeFromExceptionPointers( + exception_code_ = first_record.ExceptionCode; + exception_flags_ = first_record.ExceptionFlags; + exception_address_ = first_record.ExceptionAddress; +- for (DWORD i = 0; i < first_record.NumberParameters; ++i) ++ ++ const DWORD number_parameters = std::min<DWORD>( ++ first_record.NumberParameters, EXCEPTION_MAXIMUM_PARAMETERS); ++ for (DWORD i = 0; i < number_parameters; ++i) { + codes_.push_back(first_record.ExceptionInformation[i]); ++ } + if (first_record.ExceptionRecord) { + // https://crashpad.chromium.org/bug/43 + LOG(WARNING) << "dropping chained ExceptionRecord"; +diff --git a/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win_test.cc b/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win_test.cc +index dcdc3cf4d6f4c1298905e5fba6580e73fca014e0..aa78e5579319341c08a6866fb7ae1272d403d23c 100644 +--- a/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win_test.cc ++++ b/third_party/crashpad/crashpad/snapshot/win/exception_snapshot_win_test.cc +@@ -14,11 +14,14 @@ + + #include "snapshot/win/exception_snapshot_win.h" + ++#include <windows.h> ++ + #include <string> + + #include "base/files/file_path.h" + #include "base/strings/utf_string_conversions.h" + #include "gtest/gtest.h" ++#include "snapshot/win/exception_snapshot_win.h" + #include "snapshot/win/process_snapshot_win.h" + #include "test/errors.h" + #include "test/test_paths.h" +@@ -315,6 +318,48 @@ TEST(SimulateCrash, ChildDumpWithoutCrashingWOW64) { + } + #endif // ARCH_CPU_64_BITS + ++TEST(ExceptionSnapshot, TooManyExceptionParameters) { ++ ProcessReaderWin process_reader; ++ ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), ++ ProcessSuspensionState::kRunning)); ++ ++ // Construct a fake exception record and CPU context. ++ auto exception_record = std::make_unique<EXCEPTION_RECORD>(); ++ exception_record->ExceptionCode = STATUS_FATAL_APP_EXIT; ++ exception_record->ExceptionFlags = EXCEPTION_NONCONTINUABLE; ++ exception_record->ExceptionAddress = reinterpret_cast<PVOID>(0xFA15E); ++ // One more than is permitted in the struct. ++ exception_record->NumberParameters = EXCEPTION_MAXIMUM_PARAMETERS + 1; ++ for (int i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; ++i) { ++ exception_record->ExceptionInformation[i] = 1000 + i; ++ } ++ ++ auto cpu_context = std::make_unique<internal::CPUContextUnion>(); ++ ++ auto exception_pointers = std::make_unique<EXCEPTION_POINTERS>(); ++ exception_pointers->ExceptionRecord = ++ reinterpret_cast<PEXCEPTION_RECORD>(exception_record.get()); ++ exception_pointers->ContextRecord = ++ reinterpret_cast<PCONTEXT>(cpu_context.get()); ++ ++ internal::ExceptionSnapshotWin snapshot; ++ ASSERT_TRUE(snapshot.Initialize( ++ &process_reader, ++ GetCurrentThreadId(), ++ reinterpret_cast<WinVMAddress>(exception_pointers.get()), ++ nullptr)); ++ ++ EXPECT_EQ(STATUS_FATAL_APP_EXIT, snapshot.Exception()); ++ EXPECT_EQ(static_cast<uint32_t>(EXCEPTION_NONCONTINUABLE), ++ snapshot.ExceptionInfo()); ++ EXPECT_EQ(0xFA15Eu, snapshot.ExceptionAddress()); ++ EXPECT_EQ(static_cast<size_t>(EXCEPTION_MAXIMUM_PARAMETERS), ++ snapshot.Codes().size()); ++ for (size_t i = 0; i < EXCEPTION_MAXIMUM_PARAMETERS; ++i) { ++ EXPECT_EQ(1000 + i, snapshot.Codes()[i]); ++ } ++} ++ + } // namespace + } // namespace test + } // namespace crashpad From 4a7bf76fa1c588515aaa1db8c8141a1e71cc48f7 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Tue, 28 Mar 2023 00:56:27 +0100 Subject: [PATCH 106/172] chore: cherry-pick 0407102d19b9 and 183a57f4eabc from chromium (#37661) * chore: cherry-pick 0407102d19b9 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 2 + .../chromium/cherry-pick-0407102d19b9.patch | 91 +++++++++++++++ .../fix_crash_in_annotationagentimpl.patch | 107 ++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 patches/chromium/cherry-pick-0407102d19b9.patch create mode 100644 patches/chromium/fix_crash_in_annotationagentimpl.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 0cda83292275f..84301a0aac5e3 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,6 +133,8 @@ m108-lts_further_simplify_webmediaplayermscompositor_lifetime.patch cherry-pick-e79b89b47dac.patch cherry-pick-06851790480e.patch cherry-pick-aeec1ba5893d.patch +cherry-pick-0407102d19b9.patch +fix_crash_in_annotationagentimpl.patch cherry-pick-bfd926be8178.patch cherry-pick-9aa4c45f21b1.patch m108-lts_prevent_potential_integer_overflow_in.patch diff --git a/patches/chromium/cherry-pick-0407102d19b9.patch b/patches/chromium/cherry-pick-0407102d19b9.patch new file mode 100644 index 0000000000000..02caf570617c4 --- /dev/null +++ b/patches/chromium/cherry-pick-0407102d19b9.patch @@ -0,0 +1,91 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Peter=20Bostr=C3=B6m?= <pbos@chromium.org> +Date: Tue, 14 Mar 2023 16:49:10 +0000 +Subject: Convert known it != end() DCHECK failures to CHECK +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +These have hit on DCHECK builds in the wild and precede erasing or +dereferencing an iterator that is UB. + +This CL excludes DCHECK failures that precede non-DCHECK handling of the +it != end() failures. Those should probably be rewritten as CHECKs +but are less urgent and semi-orthogonal. + +Known crashes (one per file) are: + +crash/dc49e3cadab36d4c +crash/0ee3427d25937024 +crash/b89303e84d123019 +crash/cc35183b861a4992 + +(cherry picked from commit 1aec0b297900a7b59bd24314dff239f3c5697f45) + +Bug: 1418734 +Change-Id: I81ed7b45be33769e250c65c8bb7334a34be4380e +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288168 +Commit-Queue: Peter Boström <pbos@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1109350} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4296138 +Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> +Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> +Owners-Override: Achuith Bhandarkar <achuith@chromium.org> +Reviewed-by: Peter Boström <pbos@chromium.org> +Cr-Commit-Position: refs/branch-heads/5359@{#1406} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/base/scoped_multi_source_observation.h b/base/scoped_multi_source_observation.h +index 07ea3edd71246f02fe0044b33129f13699ce43b2..cd368c23956078acd6d5694f7f16c106f6461b31 100644 +--- a/base/scoped_multi_source_observation.h ++++ b/base/scoped_multi_source_observation.h +@@ -68,7 +68,7 @@ class ScopedMultiSourceObservation { + // Remove the object passed to the constructor as an observer from |source|. + void RemoveObservation(Source* source) { + auto it = base::ranges::find(sources_, source); +- DCHECK(it != sources_.end()); ++ CHECK(it != sources_.end()); + sources_.erase(it); + (source->*RemoveObsFn)(observer_); + } +diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc +index 8a49e44647d8c6d35e7fa04dafbd32c06c153927..4ad050db8a3e590742501507d7777ba923ad3832 100644 +--- a/cc/tiles/gpu_image_decode_cache.cc ++++ b/cc/tiles/gpu_image_decode_cache.cc +@@ -1379,8 +1379,8 @@ Iterator GpuImageDecodeCache::RemoveFromPersistentCache(Iterator it) { + } + + auto entries_it = paint_image_entries_.find(it->second->paint_image_id); +- DCHECK(entries_it != paint_image_entries_.end()); +- DCHECK_GT(entries_it->second.count, 0u); ++ CHECK(entries_it != paint_image_entries_.end()); ++ CHECK_GT(entries_it->second.count, 0u); + + // If this is the last entry for this image, remove its tracking. + --entries_it->second.count; +diff --git a/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc b/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc +index 4f4fbb6c8775e1019a6c2938812f5535737433a3..9e9181677fb676100ff2a20890e902f298b16644 100644 +--- a/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc ++++ b/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc +@@ -117,7 +117,7 @@ void AnnotationAgentImpl::ScrollIntoView() const { + + EphemeralRangeInFlatTree range = attached_range_->ToEphemeralRange(); + +- DCHECK(range.Nodes().begin() != range.Nodes().end()); ++ CHECK(range.Nodes().begin() != range.Nodes().end()); + + Node& first_node = *range.Nodes().begin(); + +diff --git a/ui/base/interaction/element_tracker_mac.mm b/ui/base/interaction/element_tracker_mac.mm +index d3b8d98e499a074678d7e06efcc2146d92ae3eb4..b467aa234043ebc8537bb4576ce0eed713593597 100644 +--- a/ui/base/interaction/element_tracker_mac.mm ++++ b/ui/base/interaction/element_tracker_mac.mm +@@ -50,7 +50,7 @@ void AddElement(ElementIdentifier identifier, + + void ActivateElement(ElementIdentifier identifier) { + const auto it = elements_.find(identifier); +- DCHECK(it != elements_.end()); ++ CHECK(it != elements_.end()); + ui::ElementTracker::GetFrameworkDelegate()->NotifyElementActivated( + it->second.get()); + } diff --git a/patches/chromium/fix_crash_in_annotationagentimpl.patch b/patches/chromium/fix_crash_in_annotationagentimpl.patch new file mode 100644 index 0000000000000..18c04bbb8a40d --- /dev/null +++ b/patches/chromium/fix_crash_in_annotationagentimpl.patch @@ -0,0 +1,107 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: David Bokan <bokan@chromium.org> +Date: Fri, 3 Mar 2023 21:54:38 +0000 +Subject: Fix crash in AnnotationAgentImpl + +This crash was occurring because the EphemeralRangeInFlatTree didn't +produce a Node. This is surprising since the RangeInFlatTree that it +comes from is checked for !IsCollapsed(). + +It turns out it's possible for RangeInFlatTree to be !IsCollapsed but +converting to EphemeralRangeInFlatTree causes IsCollapsed. + +This CL ensures we early-out in the case that's tripping the CHECK. It +keeps the early-out exactly matching the CHECK since it must be merged +so we want to be extra sure. A followup will change this condition to +!EphemeralRangeInFlatTree::IsCollapsed which should be equivalent. + +(cherry picked from commit 92782b6d34b7a5e26d184e217f8f44e97539686e) + +Bug: 1419712 +Change-Id: Id1d66a7a67711d463780b37c00600183d6c14f32 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4304486 +Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> +Commit-Queue: David Bokan <bokan@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1112568} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4305328 +Commit-Queue: Krishna Govind <govind@chromium.org> +Reviewed-by: David Bokan <bokan@chromium.org> +Cr-Commit-Position: refs/branch-heads/5481@{#1321} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc b/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc +index 9e9181677fb676100ff2a20890e902f298b16644..a5553945fb5923b93dbdf37c6b7b539049018dbb 100644 +--- a/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc ++++ b/third_party/blink/renderer/core/annotation/annotation_agent_impl.cc +@@ -117,7 +117,11 @@ void AnnotationAgentImpl::ScrollIntoView() const { + + EphemeralRangeInFlatTree range = attached_range_->ToEphemeralRange(); + +- CHECK(range.Nodes().begin() != range.Nodes().end()); ++ // TODO(bokan): This should be checked in IsAttached. ++ bool range_has_nodes = range.Nodes().begin() != range.Nodes().end(); ++ if (!range_has_nodes) { ++ return; ++ } + + Node& first_node = *range.Nodes().begin(); + +diff --git a/third_party/blink/renderer/core/annotation/annotation_agent_impl_test.cc b/third_party/blink/renderer/core/annotation/annotation_agent_impl_test.cc +index 08b6bc177e684c83f51227dc41dc0b894be8a2a7..fbb6f5f1f34b4b26459450ebe35e917e02e47f10 100644 +--- a/third_party/blink/renderer/core/annotation/annotation_agent_impl_test.cc ++++ b/third_party/blink/renderer/core/annotation/annotation_agent_impl_test.cc +@@ -643,4 +643,54 @@ TEST_F(AnnotationAgentImplTest, AgentScrollIntoViewZoomed) { + EXPECT_TRUE(ExpectInViewport(*element_foo)); + } + ++// Degenerate case but make sure it doesn't crash. This constructs a ++// RangeInFlatTree that isn't collapsed but turns into a collapsed ++// EphmemeralRangeInFlatTree. ++TEST_F(AnnotationAgentImplTest, ScrollIntoViewCollapsedRange) { ++ SimRequest request("https://example.com/test.html", "text/html"); ++ LoadURL("https://example.com/test.html"); ++ request.Complete(R"HTML( ++ <!DOCTYPE html> ++ <style> ++ p { ++ position: absolute; ++ top: 2000px; ++ } ++ </style> ++ <p id='text'>a</p> ++ ++ )HTML"); ++ ++ Compositor().BeginFrame(); ++ ++ Element* element_text = GetDocument().getElementById("text"); ++ ++ const auto& range_start = ++ Position(element_text->firstChild(), PositionAnchorType::kBeforeAnchor); ++ const auto& range_end = Position(element_text, 0); ++ ++ RangeInFlatTree* range = MakeGarbageCollected<RangeInFlatTree>( ++ ToPositionInFlatTree(range_start), ToPositionInFlatTree(range_end)); ++ ++ // TODO(bokan): Is this an editing bug? ++ ASSERT_FALSE(range->IsCollapsed()); ++ ASSERT_TRUE(range->ToEphemeralRange().IsCollapsed()); ++ ++ auto* agent = CreateAgentForRange(range); ++ ASSERT_TRUE(agent); ++ ++ ASSERT_EQ(GetDocument().View()->GetRootFrameViewport()->GetScrollOffset(), ++ ScrollOffset()); ++ ++ MockAnnotationAgentHost host; ++ host.BindToAgent(*agent); ++ agent->Attach(); ++ ++ // Ensure calling ScrollIntoView doesn't crash. ++ host.agent_->ScrollIntoView(); ++ host.FlushForTesting(); ++ EXPECT_EQ(GetDocument().View()->GetRootFrameViewport()->GetScrollOffset().y(), ++ 0); ++} ++ + } // namespace blink From 352ab576701f1fd868bcb83faa8e53412690a1db Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:39:01 -0400 Subject: [PATCH 107/172] fix: crash in `MessagePortMain` with some `postMessage` params (#37725) * fix: crash in MessagePortMain postMessage Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update shell/browser/api/message_port.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/browser/api/message_port.cc | 44 +++++++++++++++++++++++++++---- spec/api-ipc-spec.ts | 27 ++++++++++++++++++- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/shell/browser/api/message_port.cc b/shell/browser/api/message_port.cc index d261a9066f092..10ebaf3921d17 100644 --- a/shell/browser/api/message_port.cc +++ b/shell/browser/api/message_port.cc @@ -25,6 +25,25 @@ namespace electron { +namespace { + +bool IsValidWrappable(const v8::Local<v8::Value>& obj) { + v8::Local<v8::Object> port = v8::Local<v8::Object>::Cast(obj); + + if (!port->IsObject()) + return false; + + if (port->InternalFieldCount() != gin::kNumberOfInternalFields) + return false; + + const auto* info = static_cast<gin::WrapperInfo*>( + port->GetAlignedPointerFromInternalField(gin::kWrapperInfoIndex)); + + return info && info->embedder == gin::kEmbedderNativeGin; +} + +} // namespace + gin::WrapperInfo MessagePort::kWrapperInfo = {gin::kEmbedderNativeGin}; MessagePort::MessagePort() = default; @@ -47,10 +66,11 @@ void MessagePort::PostMessage(gin::Arguments* args) { DCHECK(!IsNeutered()); blink::TransferableMessage transferable_message; + gin_helper::ErrorThrower thrower(args->isolate()); v8::Local<v8::Value> message_value; if (!args->GetNext(&message_value)) { - args->ThrowTypeError("Expected at least one argument to postMessage"); + thrower.ThrowTypeError("Expected at least one argument to postMessage"); return; } @@ -60,8 +80,23 @@ void MessagePort::PostMessage(gin::Arguments* args) { v8::Local<v8::Value> transferables; std::vector<gin::Handle<MessagePort>> wrapped_ports; if (args->GetNext(&transferables)) { + std::vector<v8::Local<v8::Value>> wrapped_port_values; + if (!gin::ConvertFromV8(args->isolate(), transferables, + &wrapped_port_values)) { + thrower.ThrowTypeError("transferables must be an array of MessagePorts"); + return; + } + + for (unsigned i = 0; i < wrapped_port_values.size(); ++i) { + if (!IsValidWrappable(wrapped_port_values[i])) { + thrower.ThrowTypeError("Port at index " + base::NumberToString(i) + + " is not a valid port"); + return; + } + } + if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) { - args->ThrowError(); + thrower.ThrowTypeError("Passed an invalid MessagePort"); return; } } @@ -69,9 +104,8 @@ void MessagePort::PostMessage(gin::Arguments* args) { // Make sure we aren't connected to any of the passed-in ports. for (unsigned i = 0; i < wrapped_ports.size(); ++i) { if (wrapped_ports[i].get() == this) { - gin_helper::ErrorThrower(args->isolate()) - .ThrowError("Port at index " + base::NumberToString(i) + - " contains the source port."); + thrower.ThrowError("Port at index " + base::NumberToString(i) + + " contains the source port."); return; } } diff --git a/spec/api-ipc-spec.ts b/spec/api-ipc-spec.ts index c63c9ba94eb85..c0cb5706c568d 100644 --- a/spec/api-ipc-spec.ts +++ b/spec/api-ipc-spec.ts @@ -357,6 +357,31 @@ describe('ipc module', () => { expect(port2).not.to.be.null(); }); + it('throws an error when an invalid parameter is sent to postMessage', () => { + const { port1 } = new MessageChannelMain(); + + expect(() => { + const buffer = new ArrayBuffer(10) as any; + port1.postMessage(null, [buffer]); + }).to.throw(/Port at index 0 is not a valid port/); + + expect(() => { + port1.postMessage(null, ['1' as any]); + }).to.throw(/Port at index 0 is not a valid port/); + + expect(() => { + port1.postMessage(null, [new Date() as any]); + }).to.throw(/Port at index 0 is not a valid port/); + }); + + it('throws when postMessage transferables contains the source port', () => { + const { port1 } = new MessageChannelMain(); + + expect(() => { + port1.postMessage(null, [port1]); + }).to.throw(/Port at index 0 contains the source port./); + }); + it('can send messages within the process', async () => { const { port1, port2 } = new MessageChannelMain(); port2.postMessage('hello'); @@ -425,7 +450,7 @@ describe('ipc module', () => { const { port1 } = new MessageChannelMain(); expect(() => { port1.postMessage(null, [null] as any); - }).to.throw(/conversion failure/); + }).to.throw(/Port at index 0 is not a valid port/); }); it('throws when passing duplicate ports', () => { From ba1a2f3d0f377f1c6d04104b935e9f223f26c14e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:50:05 -0400 Subject: [PATCH 108/172] docs: fixup incorrect value for disabling sandbox (#37722) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Peter Xu <sysu.peter.hsu@gmail.com> --- docs/tutorial/sandbox.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/sandbox.md b/docs/tutorial/sandbox.md index 5081d557ba0db..0a2a4267c0b67 100644 --- a/docs/tutorial/sandbox.md +++ b/docs/tutorial/sandbox.md @@ -84,7 +84,7 @@ the `sandbox: false` preference in the [`BrowserWindow`][browser-window] constru app.whenReady().then(() => { const win = new BrowserWindow({ webPreferences: { - sandbox: true + sandbox: false } }) win.loadURL('https://google.com') From de3bc8cb4c34e2570b53b5482109ea9957398fe5 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 28 Mar 2023 11:39:36 -0400 Subject: [PATCH 109/172] chore: generator objects can't be sent over the context bridge (#37728) chore: generator objects can't be sent over the context bridge (#37593) * chore: generator objects can't be sent over the context bridge * Trigger Build --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- shell/renderer/api/electron_api_context_bridge.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index af4a141aa21c4..31b7b30eaea7e 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -96,9 +96,9 @@ bool IsPlainObject(const v8::Local<v8::Value>& object) { object->IsWeakMap() || object->IsWeakSet() || object->IsArrayBuffer() || object->IsArrayBufferView() || object->IsArray() || object->IsDataView() || - object->IsSharedArrayBuffer() || object->IsProxy() || + object->IsSharedArrayBuffer() || object->IsGeneratorObject() || object->IsWasmModuleObject() || object->IsWasmMemoryObject() || - object->IsModuleNamespaceObject()); + object->IsModuleNamespaceObject() || object->IsProxy()); } bool IsPlainArray(const v8::Local<v8::Value>& arr) { From 4b5998e51a812454e660c272e6fb3c3b6feabde1 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 29 Mar 2023 12:08:53 +0200 Subject: [PATCH 110/172] fix: allow cancelling of bluetooth requests (#37739) fix: allow cancelling of bluetooth requests (#37601) (cherry picked from commit 6a6908c4c887c5f685f5e172ff01afc02ebcbc65) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- docs/api/web-contents.md | 23 ++++++++----- .../fiddles/features/web-bluetooth/index.html | 1 + docs/fiddles/features/web-bluetooth/main.js | 27 +++++++++++---- .../fiddles/features/web-bluetooth/preload.js | 1 + .../features/web-bluetooth/renderer.js | 10 ++++-- shell/browser/lib/bluetooth_chooser.cc | 34 ++++++++----------- shell/browser/lib/bluetooth_chooser.h | 1 - 7 files changed, 61 insertions(+), 36 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 59d4c451ad94a..c39f2142dd4cd 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -713,20 +713,24 @@ Returns: * `callback` Function * `deviceId` string -Emitted when bluetooth device needs to be selected on call to -`navigator.bluetooth.requestDevice`. To use `navigator.bluetooth` api -`webBluetooth` should be enabled. If `event.preventDefault` is not called, -first available device will be selected. `callback` should be called with -`deviceId` to be selected, passing empty string to `callback` will -cancel the request. +Emitted when a bluetooth device needs to be selected when a call to +`navigator.bluetooth.requestDevice` is made. `callback` should be called with +the `deviceId` of the device to be selected. Passing an empty string to +`callback` will cancel the request. -If no event listener is added for this event, all bluetooth requests will be cancelled. +If an event listener is not added for this event, or if `event.preventDefault` +is not called when handling this event, the first available device will be +automatically selected. + +Due to the nature of bluetooth, scanning for devices when +`navigator.bluetooth.requestDevice` is called may take time and will cause +`select-bluetooth-device` to fire multiple times until `callback` is called +with either a device id or an empty string to cancel the request. ```javascript const { app, BrowserWindow } = require('electron') let win = null -app.commandLine.appendSwitch('enable-experimental-web-platform-features') app.whenReady().then(() => { win = new BrowserWindow({ width: 800, height: 600 }) @@ -736,6 +740,9 @@ app.whenReady().then(() => { return device.deviceName === 'test' }) if (!result) { + // The device wasn't found so we need to either wait longer (eg until the + // device is turned on) or cancel the request by calling the callback + // with an empty string. callback('') } else { callback(result.deviceId) diff --git a/docs/fiddles/features/web-bluetooth/index.html b/docs/fiddles/features/web-bluetooth/index.html index b2be53d400a6a..5b0158fa36424 100644 --- a/docs/fiddles/features/web-bluetooth/index.html +++ b/docs/fiddles/features/web-bluetooth/index.html @@ -9,6 +9,7 @@ <h1>Web Bluetooth API</h1> <button id="clickme">Test Bluetooth</button> + <button id="cancel">Cancel Bluetooth Request</button> <p>Currently selected bluetooth device: <strong id="device-name""></strong></p> diff --git a/docs/fiddles/features/web-bluetooth/main.js b/docs/fiddles/features/web-bluetooth/main.js index 5d560579cc05f..4d6e6d38e27ce 100644 --- a/docs/fiddles/features/web-bluetooth/main.js +++ b/docs/fiddles/features/web-bluetooth/main.js @@ -1,21 +1,36 @@ const {app, BrowserWindow, ipcMain} = require('electron') const path = require('path') +let bluetoothPinCallback +let selectBluetoothCallback + function createWindow () { const mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js') - } + } }) mainWindow.webContents.on('select-bluetooth-device', (event, deviceList, callback) => { event.preventDefault() - if (deviceList && deviceList.length > 0) { - callback(deviceList[0].deviceId) - } + selectBluetoothCallback = callback + const result = deviceList.find((device) => { + return device.deviceName === 'test' + }) + if (result) { + callback(result.deviceId) + } else { + // The device wasn't found so we need to either wait longer (eg until the + // device is turned on) or until the user cancels the request + } + }) + + ipcMain.on('cancel-bluetooth-request', (event) => { + selectBluetoothCallback('') }) + // Listen for a message from the renderer to get the response for the Bluetooth pairing. ipcMain.on('bluetooth-pairing-response', (event, response) => { @@ -27,14 +42,14 @@ function createWindow () { bluetoothPinCallback = callback // Send a message to the renderer to prompt the user to confirm the pairing. mainWindow.webContents.send('bluetooth-pairing-request', details) - }) + }) mainWindow.loadFile('index.html') } app.whenReady().then(() => { createWindow() - + app.on('activate', function () { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) diff --git a/docs/fiddles/features/web-bluetooth/preload.js b/docs/fiddles/features/web-bluetooth/preload.js index 0c21fcce93881..a8d30560368e4 100644 --- a/docs/fiddles/features/web-bluetooth/preload.js +++ b/docs/fiddles/features/web-bluetooth/preload.js @@ -1,6 +1,7 @@ const { contextBridge, ipcRenderer } = require('electron') contextBridge.exposeInMainWorld('electronAPI', { + cancelBluetoothRequest: (callback) => ipcRenderer.send('cancel-bluetooth-request', callback), bluetoothPairingRequest: (callback) => ipcRenderer.on('bluetooth-pairing-request', callback), bluetoothPairingResponse: (response) => ipcRenderer.send('bluetooth-pairing-response', response) }) \ No newline at end of file diff --git a/docs/fiddles/features/web-bluetooth/renderer.js b/docs/fiddles/features/web-bluetooth/renderer.js index 080fb6105b287..d71ba11b5f134 100644 --- a/docs/fiddles/features/web-bluetooth/renderer.js +++ b/docs/fiddles/features/web-bluetooth/renderer.js @@ -7,9 +7,15 @@ async function testIt() { document.getElementById('clickme').addEventListener('click',testIt) +function cancelRequest() { + window.electronAPI.cancelBluetoothRequest() +} + +document.getElementById('cancel').addEventListener('click', cancelRequest) + window.electronAPI.bluetoothPairingRequest((event, details) => { const response = {} - + switch (details.pairingKind) { case 'confirm': { response.confirmed = confirm(`Do you want to connect to device ${details.deviceId}?`) @@ -31,4 +37,4 @@ window.electronAPI.bluetoothPairingRequest((event, details) => { } window.electronAPI.bluetoothPairingResponse(response) -}) \ No newline at end of file +}) diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc index 7c9942d7ba584..7d84cff45e2c0 100644 --- a/shell/browser/lib/bluetooth_chooser.cc +++ b/shell/browser/lib/bluetooth_chooser.cc @@ -27,8 +27,6 @@ namespace electron { namespace { -const int kMaxScanRetries = 5; - void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler, const std::string& device_id) { if (device_id.empty()) { @@ -66,29 +64,15 @@ void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) { } void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) { + bool idle_state = false; switch (state) { case DiscoveryState::FAILED_TO_START: refreshing_ = false; event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, ""); - break; + return; case DiscoveryState::IDLE: refreshing_ = false; - if (device_map_.empty()) { - auto event = ++num_retries_ > kMaxScanRetries - ? content::BluetoothChooserEvent::CANCELLED - : content::BluetoothChooserEvent::RESCAN; - event_handler_.Run(event, ""); - } else { - bool prevent_default = api_web_contents_->Emit( - "select-bluetooth-device", GetDeviceList(), - base::BindOnce(&OnDeviceChosen, event_handler_)); - if (!prevent_default) { - auto it = device_map_.begin(); - auto device_id = it->first; - event_handler_.Run(content::BluetoothChooserEvent::SELECTED, - device_id); - } - } + idle_state = true; break; case DiscoveryState::DISCOVERING: // The first time this state fires is due to a rescan triggering so set a @@ -101,6 +85,18 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) { } break; } + bool prevent_default = + api_web_contents_->Emit("select-bluetooth-device", GetDeviceList(), + base::BindOnce(&OnDeviceChosen, event_handler_)); + if (!prevent_default && idle_state) { + if (device_map_.empty()) { + event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, ""); + } else { + auto it = device_map_.begin(); + auto device_id = it->first; + event_handler_.Run(content::BluetoothChooserEvent::SELECTED, device_id); + } + } } void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id, diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h index 8143e4ce5cfe9..aed252c556866 100644 --- a/shell/browser/lib/bluetooth_chooser.h +++ b/shell/browser/lib/bluetooth_chooser.h @@ -44,7 +44,6 @@ class BluetoothChooser : public content::BluetoothChooser { std::map<std::string, std::u16string> device_map_; api::WebContents* api_web_contents_; EventHandler event_handler_; - int num_retries_ = 0; bool refreshing_ = false; bool rescan_ = false; }; From f557f99631f5b1540d77acb17305a4a12bc6b9fb Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Wed, 29 Mar 2023 11:14:34 +0100 Subject: [PATCH 111/172] chore: cherry-pick b041159d06ad from chromium (#37694) * chore: [22-x-y] cherry-pick b041159d06ad from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-b041159d06ad.patch | 506 ++++++++++++++++++ 2 files changed, 507 insertions(+) create mode 100644 patches/chromium/cherry-pick-b041159d06ad.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 84301a0aac5e3..82e5eb439af2d 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -144,3 +144,4 @@ cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch cherry-pick-56bd20b295b4.patch cherry-pick-1235110fce18.patch +cherry-pick-b041159d06ad.patch diff --git a/patches/chromium/cherry-pick-b041159d06ad.patch b/patches/chromium/cherry-pick-b041159d06ad.patch new file mode 100644 index 0000000000000..59bf583caca7f --- /dev/null +++ b/patches/chromium/cherry-pick-b041159d06ad.patch @@ -0,0 +1,506 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Matt Reynolds <mattreynolds@google.com> +Date: Wed, 8 Mar 2023 23:55:10 +0000 +Subject: hid: Handle empty input reports + +It's possible for a HID device to define its report descriptor such that +one or more reports have no data fields within the report. When receiving these reports, the report buffer should contain only the +report ID byte and no other data. + +Ensure that we do not read past the end of the buffer when handling +zero-length input reports. + +(cherry picked from commit c9d77da78bc66c135520ac77873d67b89cdcaee6) + +Bug: 1419718 +Change-Id: I51d32c20f6b16f0d2b0172e0a165469b6b79748c +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4296562 +Reviewed-by: Reilly Grant <reillyg@chromium.org> +Commit-Queue: Matt Reynolds <mattreynolds@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1112009} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4320692 +Commit-Queue: Reilly Grant <reillyg@chromium.org> +Auto-Submit: Matt Reynolds <mattreynolds@chromium.org> +Cr-Commit-Position: refs/branch-heads/5481@{#1341} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/services/device/hid/hid_connection_impl.cc b/services/device/hid/hid_connection_impl.cc +index c413123e12191c413ae327732c9e95caa696e0ff..adfaa66b7601dce4a267e0113c3e14cdc9445f3e 100644 +--- a/services/device/hid/hid_connection_impl.cc ++++ b/services/device/hid/hid_connection_impl.cc +@@ -54,11 +54,12 @@ void HidConnectionImpl::OnInputReport( + scoped_refptr<base::RefCountedBytes> buffer, + size_t size) { + DCHECK(client_); +- uint8_t report_id = buffer->data()[0]; +- uint8_t* begin = &buffer->data()[1]; +- uint8_t* end = buffer->data().data() + size; +- std::vector<uint8_t> data(begin, end); +- client_->OnInputReport(report_id, data); ++ DCHECK_GE(size, 1u); ++ std::vector<uint8_t> data; ++ if (size > 1) { ++ data = std::vector<uint8_t>(buffer->front() + 1, buffer->front() + size); ++ } ++ client_->OnInputReport(/*report_id=*/buffer->data()[0], data); + } + + void HidConnectionImpl::Read(ReadCallback callback) { +diff --git a/services/device/hid/hid_connection_impl_unittest.cc b/services/device/hid/hid_connection_impl_unittest.cc +index 25f715fa5bd0584228b5d6dd7c27103ce5a61885..3d2e74aeaa6676af88719d56fd9c889a296eccd3 100644 +--- a/services/device/hid/hid_connection_impl_unittest.cc ++++ b/services/device/hid/hid_connection_impl_unittest.cc +@@ -8,17 +8,28 @@ + #include "base/callback_helpers.h" + #include "base/memory/raw_ptr.h" + #include "base/memory/ref_counted_memory.h" ++#include "base/test/repeating_test_future.h" ++#include "base/test/test_future.h" + #include "build/build_config.h" + #include "mojo/public/cpp/bindings/pending_receiver.h" + #include "mojo/public/cpp/bindings/receiver.h" + #include "mojo/public/cpp/bindings/self_owned_receiver.h" + #include "services/device/device_service_test_base.h" ++#include "testing/gmock/include/gmock/gmock.h" + #include "testing/gtest/include/gtest/gtest.h" + + namespace device { + + namespace { + ++using ::testing::ElementsAre; ++ ++using ReadFuture = base::test:: ++ TestFuture<bool, uint8_t, const absl::optional<std::vector<uint8_t>>&>; ++using WriteFuture = base::test::TestFuture<bool>; ++using GetFeatureFuture = ++ base::test::TestFuture<bool, const absl::optional<std::vector<uint8_t>>&>; ++ + #if BUILDFLAG(IS_MAC) + const uint64_t kTestDeviceId = 123; + #elif BUILDFLAG(IS_WIN) +@@ -30,46 +41,37 @@ const char* kTestDeviceId = "123"; + // The report ID to use for reports sent to or received from the test device. + const uint8_t kTestReportId = 0x42; + +-// The max size of input and output reports for the test device. Feature reports +-// are not used in this test. ++// The max size of reports for the test device. + const uint64_t kMaxReportSizeBytes = 10; + +-// A fake HidConnection implementation that allows the test to simulate an +-// input report. +-class FakeHidConnection : public HidConnection { ++// A mock HidConnection implementation that allows the test to simulate reports. ++class MockHidConnection : public HidConnection { + public: +- explicit FakeHidConnection(scoped_refptr<HidDeviceInfo> device) ++ explicit MockHidConnection(scoped_refptr<HidDeviceInfo> device) + : HidConnection(device, + /*allow_protected_reports=*/false, + /*allow_fido_reports=*/false) {} +- FakeHidConnection(const FakeHidConnection&) = delete; +- FakeHidConnection& operator=(const FakeHidConnection&) = delete; ++ MockHidConnection(const MockHidConnection&) = delete; ++ MockHidConnection& operator=(const MockHidConnection&) = delete; + + // HidConnection implementation. + void PlatformClose() override {} +- void PlatformWrite(scoped_refptr<base::RefCountedBytes> buffer, +- WriteCallback callback) override { +- std::move(callback).Run(true); +- } +- void PlatformGetFeatureReport(uint8_t report_id, +- ReadCallback callback) override { +- NOTIMPLEMENTED(); +- } +- void PlatformSendFeatureReport(scoped_refptr<base::RefCountedBytes> buffer, +- WriteCallback callback) override { +- NOTIMPLEMENTED(); +- } ++ MOCK_METHOD2(PlatformWrite, ++ void(scoped_refptr<base::RefCountedBytes>, WriteCallback)); ++ MOCK_METHOD2(PlatformGetFeatureReport, void(uint8_t, ReadCallback)); ++ MOCK_METHOD2(PlatformSendFeatureReport, ++ void(scoped_refptr<base::RefCountedBytes>, WriteCallback)); + + void SimulateInputReport(scoped_refptr<base::RefCountedBytes> buffer) { + ProcessInputReport(buffer, buffer->size()); + } + + private: +- ~FakeHidConnection() override = default; ++ ~MockHidConnection() override = default; + }; + +-// A test implementation of HidConnectionClient that signals once an input +-// report has been received. The contents of the input report are saved. ++// An implementation of HidConnectionClient that enables the test to wait until ++// an input report is received. + class TestHidConnectionClient : public mojom::HidConnectionClient { + public: + TestHidConnectionClient() = default; +@@ -81,76 +83,18 @@ class TestHidConnectionClient : public mojom::HidConnectionClient { + receiver_.Bind(std::move(receiver)); + } + +- // mojom::HidConnectionClient implementation. + void OnInputReport(uint8_t report_id, + const std::vector<uint8_t>& buffer) override { +- report_id_ = report_id; +- buffer_ = buffer; +- run_loop_.Quit(); +- } +- +- void WaitForInputReport() { run_loop_.Run(); } +- +- uint8_t report_id() { return report_id_; } +- const std::vector<uint8_t>& buffer() { return buffer_; } +- +- private: +- base::RunLoop run_loop_; +- mojo::Receiver<mojom::HidConnectionClient> receiver_{this}; +- uint8_t report_id_ = 0; +- std::vector<uint8_t> buffer_; +-}; +- +-// A utility for capturing the state returned by mojom::HidConnection I/O +-// callbacks. +-class TestIoCallback { +- public: +- TestIoCallback() = default; +- TestIoCallback(const TestIoCallback&) = delete; +- TestIoCallback& operator=(const TestIoCallback&) = delete; +- ~TestIoCallback() = default; +- +- void SetReadResult(bool result, +- uint8_t report_id, +- const absl::optional<std::vector<uint8_t>>& buffer) { +- result_ = result; +- report_id_ = report_id; +- has_buffer_ = buffer.has_value(); +- if (has_buffer_) +- buffer_ = *buffer; +- run_loop_.Quit(); +- } +- +- void SetWriteResult(bool result) { +- result_ = result; +- run_loop_.Quit(); +- } +- +- bool WaitForResult() { +- run_loop_.Run(); +- return result_; +- } +- +- mojom::HidConnection::ReadCallback GetReadCallback() { +- return base::BindOnce(&TestIoCallback::SetReadResult, +- base::Unretained(this)); ++ future_.AddValue(report_id, buffer); + } + +- mojom::HidConnection::WriteCallback GetWriteCallback() { +- return base::BindOnce(&TestIoCallback::SetWriteResult, +- base::Unretained(this)); ++ std::pair<uint8_t, std::vector<uint8_t>> GetNextInputReport() { ++ return future_.Take(); + } + +- uint8_t report_id() { return report_id_; } +- bool has_buffer() { return has_buffer_; } +- const std::vector<uint8_t>& buffer() { return buffer_; } +- + private: +- base::RunLoop run_loop_; +- bool result_ = false; +- uint8_t report_id_ = 0; +- bool has_buffer_ = false; +- std::vector<uint8_t> buffer_; ++ mojo::Receiver<mojom::HidConnectionClient> receiver_{this}; ++ base::test::RepeatingTestFuture<uint8_t, std::vector<uint8_t>> future_; + }; + + } // namespace +@@ -158,8 +102,8 @@ class TestIoCallback { + class HidConnectionImplTest : public DeviceServiceTestBase { + public: + HidConnectionImplTest() = default; +- HidConnectionImplTest(HidConnectionImplTest&) = delete; +- HidConnectionImplTest& operator=(HidConnectionImplTest&) = delete; ++ HidConnectionImplTest(const HidConnectionImplTest&) = delete; ++ HidConnectionImplTest& operator=(const HidConnectionImplTest&) = delete; + + protected: + void SetUp() override { +@@ -167,18 +111,28 @@ class HidConnectionImplTest : public DeviceServiceTestBase { + base::RunLoop().RunUntilIdle(); + } + +- void CreateHidConnection(bool with_connection_client) { ++ void TearDown() override { ++ // HidConnectionImpl is self-owned and will self-destruct when its mojo pipe ++ // is disconnected. Allow disconnect handlers to run so HidConnectionImpl ++ // can self-destruct before the end of the test. ++ base::RunLoop().RunUntilIdle(); ++ } ++ ++ mojo::Remote<mojom::HidConnection> CreateHidConnection( ++ bool with_connection_client) { + mojo::PendingRemote<mojom::HidConnectionClient> hid_connection_client; + if (with_connection_client) { + connection_client_ = std::make_unique<TestHidConnectionClient>(); + connection_client_->Bind( + hid_connection_client.InitWithNewPipeAndPassReceiver()); + } +- fake_connection_ = new FakeHidConnection(CreateTestDevice()); +- hid_connection_impl_ = new HidConnectionImpl( +- fake_connection_, hid_connection_.InitWithNewPipeAndPassReceiver(), +- std::move(hid_connection_client), +- /*watcher=*/mojo::NullRemote()); ++ mock_connection_ = new MockHidConnection(CreateTestDevice()); ++ mojo::Remote<mojom::HidConnection> hid_connection; ++ HidConnectionImpl::Create(mock_connection_, ++ hid_connection.BindNewPipeAndPassReceiver(), ++ std::move(hid_connection_client), ++ /*watcher=*/mojo::NullRemote()); ++ return hid_connection; + } + + scoped_refptr<HidDeviceInfo> CreateTestDevice() { +@@ -190,7 +144,7 @@ class HidConnectionImplTest : public DeviceServiceTestBase { + /*vendor_id=*/0x1234, /*product_id=*/0xabcd, "product name", + "serial number", mojom::HidBusType::kHIDBusTypeUSB, + std::move(collection), kMaxReportSizeBytes, kMaxReportSizeBytes, +- /*max_feature_report_size=*/0); ++ kMaxReportSizeBytes); + } + + std::vector<uint8_t> CreateTestReportBuffer(uint8_t report_id, size_t size) { +@@ -201,37 +155,42 @@ class HidConnectionImplTest : public DeviceServiceTestBase { + return buffer; + } + +- mojo::PendingRemote<mojom::HidConnection> hid_connection_; +- raw_ptr<HidConnectionImpl> +- hid_connection_impl_; // Owned by |hid_connection_|. +- scoped_refptr<FakeHidConnection> fake_connection_; ++ MockHidConnection& mock_connection() { return *mock_connection_.get(); } ++ TestHidConnectionClient& connection_client() { return *connection_client_; } ++ ++ private: ++ scoped_refptr<MockHidConnection> mock_connection_; + std::unique_ptr<TestHidConnectionClient> connection_client_; + }; + + TEST_F(HidConnectionImplTest, ReadWrite) { +- CreateHidConnection(/*with_connection_client=*/false); ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); + const size_t kTestBufferSize = kMaxReportSizeBytes; + std::vector<uint8_t> buffer_vec = + CreateTestReportBuffer(kTestReportId, kTestBufferSize); + + // Simulate an output report (host to device). +- TestIoCallback write_callback; +- hid_connection_impl_->Write(kTestReportId, buffer_vec, +- write_callback.GetWriteCallback()); +- ASSERT_TRUE(write_callback.WaitForResult()); ++ EXPECT_CALL(mock_connection(), PlatformWrite) ++ .WillOnce([](scoped_refptr<base::RefCountedBytes> buffer, ++ HidConnectionImpl::WriteCallback callback) { ++ std::move(callback).Run(/*success=*/true); ++ }); ++ WriteFuture write_future; ++ hid_connection->Write(kTestReportId, buffer_vec, write_future.GetCallback()); ++ EXPECT_TRUE(write_future.Get()); + + // Simulate an input report (device to host). + auto buffer = base::MakeRefCounted<base::RefCountedBytes>(buffer_vec); + ASSERT_EQ(buffer->size(), kTestBufferSize); +- fake_connection_->SimulateInputReport(buffer); ++ mock_connection().SimulateInputReport(buffer); + + // Simulate reading the input report. +- TestIoCallback read_callback; +- hid_connection_impl_->Read(read_callback.GetReadCallback()); +- ASSERT_TRUE(read_callback.WaitForResult()); +- EXPECT_EQ(read_callback.report_id(), kTestReportId); +- ASSERT_TRUE(read_callback.has_buffer()); +- const auto& read_buffer = read_callback.buffer(); ++ ReadFuture read_future; ++ hid_connection->Read(read_future.GetCallback()); ++ EXPECT_TRUE(read_future.Get<0>()); ++ EXPECT_EQ(read_future.Get<1>(), kTestReportId); ++ ASSERT_TRUE(read_future.Get<2>().has_value()); ++ const auto& read_buffer = read_future.Get<2>().value(); + ASSERT_EQ(read_buffer.size(), kTestBufferSize - 1); + for (size_t i = 1; i < kTestBufferSize; ++i) { + EXPECT_EQ(read_buffer[i - 1], buffer_vec[i]) +@@ -240,26 +199,29 @@ TEST_F(HidConnectionImplTest, ReadWrite) { + } + + TEST_F(HidConnectionImplTest, ReadWriteWithConnectionClient) { +- CreateHidConnection(/*with_connection_client=*/true); ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/true); + const size_t kTestBufferSize = kMaxReportSizeBytes; + std::vector<uint8_t> buffer_vec = + CreateTestReportBuffer(kTestReportId, kTestBufferSize); + + // Simulate an output report (host to device). +- TestIoCallback write_callback; +- hid_connection_impl_->Write(kTestReportId, buffer_vec, +- write_callback.GetWriteCallback()); +- ASSERT_TRUE(write_callback.WaitForResult()); ++ EXPECT_CALL(mock_connection(), PlatformWrite) ++ .WillOnce([](scoped_refptr<base::RefCountedBytes> buffer, ++ HidConnectionImpl::WriteCallback callback) { ++ std::move(callback).Run(/*success=*/true); ++ }); ++ WriteFuture write_future; ++ hid_connection->Write(kTestReportId, buffer_vec, write_future.GetCallback()); ++ EXPECT_TRUE(write_future.Get()); + + // Simulate an input report (device to host). + auto buffer = base::MakeRefCounted<base::RefCountedBytes>(buffer_vec); + ASSERT_EQ(buffer->size(), kTestBufferSize); +- fake_connection_->SimulateInputReport(buffer); +- connection_client_->WaitForInputReport(); ++ mock_connection().SimulateInputReport(buffer); ++ auto [report_id, in_buffer] = connection_client().GetNextInputReport(); + + // The connection client should have been notified. +- EXPECT_EQ(connection_client_->report_id(), kTestReportId); +- const std::vector<uint8_t>& in_buffer = connection_client_->buffer(); ++ EXPECT_EQ(report_id, kTestReportId); + ASSERT_EQ(in_buffer.size(), kTestBufferSize - 1); + for (size_t i = 1; i < kTestBufferSize; ++i) { + EXPECT_EQ(in_buffer[i - 1], buffer_vec[i]) +@@ -268,7 +230,7 @@ TEST_F(HidConnectionImplTest, ReadWriteWithConnectionClient) { + } + + TEST_F(HidConnectionImplTest, DestroyWithPendingInputReport) { +- CreateHidConnection(/*with_connection_client=*/false); ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); + const size_t kTestBufferSize = kMaxReportSizeBytes; + std::vector<uint8_t> buffer_vec = + CreateTestReportBuffer(kTestReportId, kTestBufferSize); +@@ -276,21 +238,20 @@ TEST_F(HidConnectionImplTest, DestroyWithPendingInputReport) { + // Simulate an input report (device to host). + auto buffer = base::MakeRefCounted<base::RefCountedBytes>(buffer_vec); + ASSERT_EQ(buffer->size(), kTestBufferSize); +- fake_connection_->SimulateInputReport(buffer); ++ mock_connection().SimulateInputReport(buffer); + + // Destroy the connection without reading the report. +- hid_connection_.reset(); ++ hid_connection.reset(); + } + + TEST_F(HidConnectionImplTest, DestroyWithPendingRead) { +- CreateHidConnection(/*with_connection_client=*/false); ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); + + // Simulate reading an input report. +- TestIoCallback read_callback; +- hid_connection_impl_->Read(read_callback.GetReadCallback()); ++ hid_connection->Read(base::DoNothing()); + + // Destroy the connection without receiving an input report. +- hid_connection_.reset(); ++ hid_connection.reset(); + } + + TEST_F(HidConnectionImplTest, WatcherClosedWhenHidConnectionClosed) { +@@ -301,7 +262,7 @@ TEST_F(HidConnectionImplTest, WatcherClosedWhenHidConnectionClosed) { + + mojo::Remote<mojom::HidConnection> hid_connection; + HidConnectionImpl::Create( +- base::MakeRefCounted<FakeHidConnection>(CreateTestDevice()), ++ base::MakeRefCounted<MockHidConnection>(CreateTestDevice()), + hid_connection.BindNewPipeAndPassReceiver(), + /*connection_client=*/mojo::NullRemote(), std::move(watcher)); + +@@ -326,7 +287,7 @@ TEST_F(HidConnectionImplTest, HidConnectionClosedWhenWatcherClosed) { + + mojo::Remote<mojom::HidConnection> hid_connection; + HidConnectionImpl::Create( +- base::MakeRefCounted<FakeHidConnection>(CreateTestDevice()), ++ base::MakeRefCounted<MockHidConnection>(CreateTestDevice()), + hid_connection.BindNewPipeAndPassReceiver(), + /*connection_client=*/mojo::NullRemote(), std::move(watcher)); + +@@ -344,4 +305,74 @@ TEST_F(HidConnectionImplTest, HidConnectionClosedWhenWatcherClosed) { + EXPECT_FALSE(hid_connection.is_connected()); + } + ++TEST_F(HidConnectionImplTest, ReadZeroLengthInputReport) { ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); ++ mock_connection().SimulateInputReport( ++ base::MakeRefCounted<base::RefCountedBytes>( ++ CreateTestReportBuffer(kTestReportId, /*size=*/1u))); ++ ReadFuture read_future; ++ hid_connection->Read(read_future.GetCallback()); ++ EXPECT_TRUE(read_future.Get<0>()); ++ EXPECT_EQ(read_future.Get<1>(), kTestReportId); ++ ASSERT_TRUE(read_future.Get<2>().has_value()); ++ EXPECT_EQ(read_future.Get<2>().value().size(), 0u); ++} ++ ++TEST_F(HidConnectionImplTest, ReadZeroLengthInputReportWithClient) { ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/true); ++ mock_connection().SimulateInputReport( ++ base::MakeRefCounted<base::RefCountedBytes>( ++ CreateTestReportBuffer(kTestReportId, /*size=*/1u))); ++ auto [report_id, in_buffer] = connection_client().GetNextInputReport(); ++ EXPECT_EQ(report_id, kTestReportId); ++ EXPECT_EQ(in_buffer.size(), 0u); ++} ++ ++TEST_F(HidConnectionImplTest, WriteZeroLengthOutputReport) { ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); ++ EXPECT_CALL(mock_connection(), PlatformWrite) ++ .WillOnce([](scoped_refptr<base::RefCountedBytes> buffer, ++ HidConnectionImpl::WriteCallback callback) { ++ std::move(callback).Run(/*success=*/true); ++ }); ++ WriteFuture write_future; ++ hid_connection->Write(kTestReportId, /*buffer=*/{}, ++ write_future.GetCallback()); ++ EXPECT_TRUE(write_future.Get()); ++} ++ ++TEST_F(HidConnectionImplTest, ReadZeroLengthFeatureReport) { ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); ++ EXPECT_CALL(mock_connection(), PlatformGetFeatureReport) ++ .WillOnce([](uint8_t report_id, HidConnection::ReadCallback callback) { ++ std::move(callback).Run(/*success=*/true, ++ base::MakeRefCounted<base::RefCountedBytes>( ++ std::vector<uint8_t>{report_id}), ++ /*size=*/1u); ++ }); ++ GetFeatureFuture get_feature_future; ++ hid_connection->GetFeatureReport(kTestReportId, ++ get_feature_future.GetCallback()); ++ EXPECT_TRUE(get_feature_future.Get<0>()); ++ ASSERT_TRUE(get_feature_future.Get<1>().has_value()); ++ EXPECT_EQ(get_feature_future.Get<1>().value().size(), 1u); ++} ++ ++TEST_F(HidConnectionImplTest, WriteZeroLengthFeatureReport) { ++ auto hid_connection = CreateHidConnection(/*with_connection_client=*/false); ++ scoped_refptr<base::RefCountedBytes> feature_buffer; ++ EXPECT_CALL(mock_connection(), PlatformSendFeatureReport) ++ .WillOnce([&feature_buffer](scoped_refptr<base::RefCountedBytes> buffer, ++ HidConnectionImpl::WriteCallback callback) { ++ feature_buffer = buffer; ++ std::move(callback).Run(/*success=*/true); ++ }); ++ WriteFuture write_future; ++ hid_connection->SendFeatureReport(kTestReportId, /*buffer=*/{}, ++ write_future.GetCallback()); ++ EXPECT_TRUE(write_future.Get()); ++ ASSERT_TRUE(feature_buffer); ++ EXPECT_THAT(feature_buffer->data(), ElementsAre(kTestReportId)); ++} ++ + } // namespace device From 0b17a201195ae6445e11cee50e436a3511717600 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Wed, 29 Mar 2023 11:14:44 +0100 Subject: [PATCH 112/172] chore: cherry-pick b5c9e5efe5dd from chromium (#37693) * chore: [22-x-y] cherry-pick b5c9e5efe5dd from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-b5c9e5efe5dd.patch | 257 ++++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 patches/chromium/cherry-pick-b5c9e5efe5dd.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 82e5eb439af2d..7264f1ed36618 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -142,6 +142,7 @@ m108-lts_do_not_register_browser_watcher_activity_report_with.patch cherry-pick-38de42d2bbc3.patch cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch +cherry-pick-b5c9e5efe5dd.patch cherry-pick-56bd20b295b4.patch cherry-pick-1235110fce18.patch cherry-pick-b041159d06ad.patch diff --git a/patches/chromium/cherry-pick-b5c9e5efe5dd.patch b/patches/chromium/cherry-pick-b5c9e5efe5dd.patch new file mode 100644 index 0000000000000..c8923770919e6 --- /dev/null +++ b/patches/chromium/cherry-pick-b5c9e5efe5dd.patch @@ -0,0 +1,257 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dale Curtis <dalecurtis@chromium.org> +Date: Wed, 15 Mar 2023 22:55:57 +0000 +Subject: Merge M110: "Improve checks for VideoFrame layouts." + +Adds a `VideoFrameLayout::IsValidForSize(size)` method which clients can +use to verify a VideoFrameLayout for their purpose. Updates a few call +sites to use the new verifier and adds tests. + +(cherry picked from commit 17f73200c066158330542c19d521c517586533a2) + +Fixed: 1421268 +Change-Id: I51049ada6119eddb31cdd9b7edfe77ee65b1da7a +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4307674 +Auto-Submit: Dale Curtis <dalecurtis@chromium.org> +Reviewed-by: Hirokazu Honda <hiroh@chromium.org> +Reviewed-by: Dominick Ng <dominickn@chromium.org> +Commit-Queue: Dominick Ng <dominickn@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1116233} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4342492 +Cr-Commit-Position: refs/branch-heads/5481@{#1361} +Cr-Branched-From: 130f3e4d850f4bc7387cfb8d08aa993d288a67a9-refs/heads/main@{#1084008} + +diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc +index 4aa077a567840545b59645ee5ae84194517226b4..4ec81d5c1fc9b26559914b56f48f3eea1fca6bad 100644 +--- a/media/base/video_frame.cc ++++ b/media/base/video_frame.cc +@@ -427,20 +427,9 @@ scoped_refptr<VideoFrame> VideoFrame::WrapExternalDataWithLayout( + StorageType storage_type = STORAGE_UNOWNED_MEMORY; + + if (!IsValidConfig(layout.format(), storage_type, layout.coded_size(), +- visible_rect, natural_size)) { +- DLOG(ERROR) << __func__ << " Invalid config." +- << ConfigToString(layout.format(), storage_type, +- layout.coded_size(), visible_rect, +- natural_size); +- return nullptr; +- } +- +- const auto& last_plane = layout.planes()[layout.planes().size() - 1]; +- const size_t required_size = last_plane.offset + last_plane.size; +- if (data_size < required_size) { +- DLOG(ERROR) << __func__ << " Provided data size is too small. Provided " +- << data_size << " bytes, but " << required_size +- << " bytes are required." ++ visible_rect, natural_size) || ++ !layout.FitsInContiguousBufferOfSize(data_size)) { ++ DLOG(ERROR) << "Invalid config: " + << ConfigToString(layout.format(), storage_type, + layout.coded_size(), visible_rect, + natural_size); +diff --git a/media/base/video_frame_layout.cc b/media/base/video_frame_layout.cc +index b3307c302bfd678caf3c90c639d32659dd2cad21..1426adb193d92c4aeb658321a6d40cdaa34461ad 100644 +--- a/media/base/video_frame_layout.cc ++++ b/media/base/video_frame_layout.cc +@@ -9,6 +9,7 @@ + #include <sstream> + + #include "base/notreached.h" ++#include "base/numerics/checked_math.h" + + namespace media { + +@@ -173,6 +174,34 @@ bool VideoFrameLayout::operator!=(const VideoFrameLayout& rhs) const { + return !(*this == rhs); + } + ++bool VideoFrameLayout::FitsInContiguousBufferOfSize(size_t data_size) const { ++ if (is_multi_planar_) { ++ return false; ++ } ++ ++ base::CheckedNumeric<size_t> required_size = 0; ++ for (const auto& plane : planes_) { ++ if (plane.offset > data_size || plane.size > data_size) { ++ return false; ++ } ++ ++ // No individual plane should have a size + offset > data_size. ++ base::CheckedNumeric<size_t> plane_end = plane.size; ++ plane_end += plane.offset; ++ if (!plane_end.IsValid() || plane_end.ValueOrDie() > data_size) { ++ return false; ++ } ++ ++ required_size += plane.size; ++ } ++ ++ if (!required_size.IsValid() || required_size.ValueOrDie() > data_size) { ++ return false; ++ } ++ ++ return true; ++} ++ + std::ostream& operator<<(std::ostream& ostream, + const VideoFrameLayout& layout) { + ostream << "VideoFrameLayout(format: " << layout.format() +diff --git a/media/base/video_frame_layout.h b/media/base/video_frame_layout.h +index d899c15d2d3f31bfac022d2900b62a53eccc1665..ae68bcfe5ab3669932344a6489fce76d8d9ccefa 100644 +--- a/media/base/video_frame_layout.h ++++ b/media/base/video_frame_layout.h +@@ -112,6 +112,13 @@ class MEDIA_EXPORT VideoFrameLayout { + // Return the modifier of buffers. + uint64_t modifier() const { return modifier_; } + ++ // Any constructible layout is valid in and of itself, it can only be invalid ++ // if the backing memory is too small to contain it. ++ // ++ // Returns true if this VideoFrameLayout can fit in a contiguous buffer of ++ // size `data_size` -- always false for multi-planar layouts. ++ bool FitsInContiguousBufferOfSize(size_t data_size) const; ++ + private: + VideoFrameLayout(VideoPixelFormat format, + const gfx::Size& coded_size, +diff --git a/media/base/video_frame_layout_unittest.cc b/media/base/video_frame_layout_unittest.cc +index 71ef5d11d75de5693aa255b5d2400301ad3488c4..c11136eaee78b2cd35154d1a9cc10ec19835ac88 100644 +--- a/media/base/video_frame_layout_unittest.cc ++++ b/media/base/video_frame_layout_unittest.cc +@@ -308,4 +308,50 @@ TEST(VideoFrameLayout, EqualOperator) { + EXPECT_NE(*layout, *different_layout); + } + ++TEST(VideoFrameLayout, FitsInContiguousBufferOfSize) { ++ auto coded_size = gfx::Size(320, 180); ++ ++ std::vector<int32_t> strides = {384, 192, 192}; ++ std::vector<size_t> offsets = {0, 200, 300}; ++ std::vector<size_t> sizes = {200, 100, 100}; ++ std::vector<ColorPlaneLayout> planes(strides.size()); ++ for (size_t i = 0; i < strides.size(); i++) { ++ planes[i].stride = strides[i]; ++ planes[i].offset = offsets[i]; ++ planes[i].size = sizes[i]; ++ } ++ ++ auto layout = ++ VideoFrameLayout::CreateWithPlanes(PIXEL_FORMAT_I420, coded_size, planes); ++ ASSERT_TRUE(layout.has_value()); ++ ++ EXPECT_TRUE( ++ layout->FitsInContiguousBufferOfSize(sizes[0] + sizes[1] + sizes[2])); ++ ++ // Validate single plane size exceeds data size. ++ EXPECT_FALSE(layout->FitsInContiguousBufferOfSize(1)); ++ ++ // Validate sum of planes exceeds data size. ++ EXPECT_FALSE(layout->FitsInContiguousBufferOfSize(sizes[0] + sizes[1])); ++ ++ // Validate offset exceeds plane size. ++ planes[2].offset = 301; ++ layout = ++ VideoFrameLayout::CreateWithPlanes(PIXEL_FORMAT_I420, coded_size, planes); ++ ASSERT_TRUE(layout.has_value()); ++ EXPECT_TRUE( ++ layout->FitsInContiguousBufferOfSize(sizes[0] + sizes[1] + sizes[2] + 1)); ++ EXPECT_FALSE(layout->FitsInContiguousBufferOfSize(sizes[0])); ++ ++ // Validate overflow. ++ planes[0].offset = 0; ++ planes[0].size = planes[1].size = planes[2].size = ++ std::numeric_limits<size_t>::max() / 2; ++ layout = ++ VideoFrameLayout::CreateWithPlanes(PIXEL_FORMAT_I420, coded_size, planes); ++ ASSERT_TRUE(layout.has_value()); ++ EXPECT_FALSE( ++ layout->FitsInContiguousBufferOfSize(std::numeric_limits<size_t>::max())); ++} ++ + } // namespace media +diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc +index 2fb254e8315b57cad3ac743d7ecf4f7c11371823..9e2cd0878362ff4b6315338cc1a39816ffadf49c 100644 +--- a/media/base/video_frame_unittest.cc ++++ b/media/base/video_frame_unittest.cc +@@ -770,6 +770,46 @@ TEST(VideoFrame, AllocationSize_OddSize) { + } + } + ++TEST(VideoFrame, WrapExternalDataWithInvalidLayout) { ++ auto coded_size = gfx::Size(320, 180); ++ ++ std::vector<int32_t> strides = {384, 192, 192}; ++ std::vector<size_t> offsets = {0, 200, 300}; ++ std::vector<size_t> sizes = {200, 100, 100}; ++ std::vector<ColorPlaneLayout> planes(strides.size()); ++ for (size_t i = 0; i < strides.size(); i++) { ++ planes[i].stride = strides[i]; ++ planes[i].offset = offsets[i]; ++ planes[i].size = sizes[i]; ++ } ++ ++ auto layout = ++ VideoFrameLayout::CreateWithPlanes(PIXEL_FORMAT_I420, coded_size, planes); ++ ASSERT_TRUE(layout.has_value()); ++ ++ // Validate single plane size exceeds data size. ++ uint8_t data = 0; ++ auto frame = VideoFrame::WrapExternalDataWithLayout( ++ *layout, gfx::Rect(coded_size), coded_size, &data, sizeof(data), ++ base::TimeDelta()); ++ ASSERT_FALSE(frame); ++ ++ // Validate sum of planes exceeds data size. ++ frame = VideoFrame::WrapExternalDataWithLayout( ++ *layout, gfx::Rect(coded_size), coded_size, &data, sizes[0] + sizes[1], ++ base::TimeDelta()); ++ ASSERT_FALSE(frame); ++ ++ // Validate offset exceeds plane size. ++ planes[0].offset = 201; ++ layout = ++ VideoFrameLayout::CreateWithPlanes(PIXEL_FORMAT_I420, coded_size, planes); ++ frame = VideoFrame::WrapExternalDataWithLayout(*layout, gfx::Rect(coded_size), ++ coded_size, &data, sizes[0], ++ base::TimeDelta()); ++ ASSERT_FALSE(frame); ++} ++ + TEST(VideoFrameMetadata, MergeMetadata) { + VideoFrameMetadata reference_metadata = GetFullVideoFrameMetadata(); + VideoFrameMetadata full_metadata = reference_metadata; +diff --git a/media/mojo/mojom/video_frame_mojom_traits.cc b/media/mojo/mojom/video_frame_mojom_traits.cc +index cdc4498f52873a6ba68271e4b373c5ace27f43c9..3a07ab5e7e877c9230df7f1a3bcd0df51a8940b6 100644 +--- a/media/mojo/mojom/video_frame_mojom_traits.cc ++++ b/media/mojo/mojom/video_frame_mojom_traits.cc +@@ -231,14 +231,17 @@ bool StructTraits<media::mojom::VideoFrameDataView, + + auto layout = media::VideoFrameLayout::CreateWithPlanes(format, coded_size, + std::move(planes)); +- if (!layout) { ++ if (!layout || !layout->FitsInContiguousBufferOfSize(mapping.size())) { + DLOG(ERROR) << "Invalid layout"; + return false; + } ++ + frame = media::VideoFrame::WrapExternalYuvDataWithLayout( + *layout, visible_rect, natural_size, addr[0], addr[1], addr[2], + timestamp); +- frame->BackWithOwnedSharedMemory(std::move(region), std::move(mapping)); ++ if (frame) { ++ frame->BackWithOwnedSharedMemory(std::move(region), std::move(mapping)); ++ } + } else if (data.is_gpu_memory_buffer_data()) { + media::mojom::GpuMemoryBufferVideoFrameDataDataView gpu_memory_buffer_data; + data.GetGpuMemoryBufferDataDataView(&gpu_memory_buffer_data); +@@ -313,8 +316,9 @@ bool StructTraits<media::mojom::VideoFrameDataView, + return false; + } + +- if (!frame) ++ if (!frame) { + return false; ++ } + + media::VideoFrameMetadata metadata; + if (!input.ReadMetadata(&metadata)) From 62dddd12edb54b2fe73fd810b7a739f869f0b271 Mon Sep 17 00:00:00 2001 From: yehengxuan <21621210@zju.edu.cn> Date: Mon, 3 Apr 2023 19:20:45 +0800 Subject: [PATCH 113/172] chore: fix memory leak in v8.serialize() (#37774) --- .../fixup_for_wc_98-compat-extra-semi.patch | 2 +- .../node/support_v8_sandboxed_pointers.patch | 35 +++++++++++++------ script/node-disabled-tests.json | 1 - 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/patches/node/fixup_for_wc_98-compat-extra-semi.patch b/patches/node/fixup_for_wc_98-compat-extra-semi.patch index d0da196ba8948..686d0e7445aa2 100644 --- a/patches/node/fixup_for_wc_98-compat-extra-semi.patch +++ b/patches/node/fixup_for_wc_98-compat-extra-semi.patch @@ -7,7 +7,7 @@ Wc++98-compat-extra-semi is turned on for Electron so this patch fixes that error in node. diff --git a/src/node_serdes.cc b/src/node_serdes.cc -index 92d5020f293c98c81d3891a82f7320629bf9f926..2e815154ddbbd687e9c823cb7d42f11b7cb48000 100644 +index 573c185465407bbe34ef1c4ec5f58f6add596d42..b64333132d5c2322d29ad087fe60e0bbe24bebe2 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -32,7 +32,7 @@ namespace serdes { diff --git a/patches/node/support_v8_sandboxed_pointers.patch b/patches/node/support_v8_sandboxed_pointers.patch index 9c78499e61cd4..8e32a560281c5 100644 --- a/patches/node/support_v8_sandboxed_pointers.patch +++ b/patches/node/support_v8_sandboxed_pointers.patch @@ -155,7 +155,7 @@ index f7314c906e580664be445a8912030e17a3ac2fa4..99258ad0aa1e15ea1ba139fd0e83111e // Delegate to V8's allocator for compatibility with the V8 memory cage. diff --git a/src/node_serdes.cc b/src/node_serdes.cc -index f6f0034bc24d09e3ad65491c7d6be0b9c9db1581..92d5020f293c98c81d3891a82f7320629bf9f926 100644 +index f6f0034bc24d09e3ad65491c7d6be0b9c9db1581..573c185465407bbe34ef1c4ec5f58f6add596d42 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -29,6 +29,11 @@ using v8::ValueSerializer; @@ -219,17 +219,32 @@ index f6f0034bc24d09e3ad65491c7d6be0b9c9db1581..92d5020f293c98c81d3891a82f732062 Maybe<bool> SerializerContext::WriteHostObject(Isolate* isolate, Local<Object> input) { MaybeLocal<Value> ret; -@@ -211,7 +240,12 @@ void SerializerContext::ReleaseBuffer(const FunctionCallbackInfo<Value>& args) { +@@ -209,9 +238,14 @@ void SerializerContext::ReleaseBuffer(const FunctionCallbackInfo<Value>& args) { + // Note: Both ValueSerializer and this Buffer::New() variant use malloc() + // as the underlying allocator. std::pair<uint8_t*, size_t> ret = ctx->serializer_.Release(); - auto buf = Buffer::New(ctx->env(), - reinterpret_cast<char*>(ret.first), +- auto buf = Buffer::New(ctx->env(), +- reinterpret_cast<char*>(ret.first), - ret.second); -+ ret.second, -+ [](char* data, void* hint){ -+ if (data) -+ GetAllocator()->Free(data, reinterpret_cast<size_t>(hint)); -+ }, -+ reinterpret_cast<void*>(ctx->last_length_)); ++ std::unique_ptr<v8::BackingStore> bs = ++ v8::ArrayBuffer::NewBackingStore(reinterpret_cast<char*>(ret.first), ret.second, ++ [](void* data, size_t length, void* deleter_data) { ++ if (data) GetAllocator()->Free(reinterpret_cast<char*>(data), length); ++ }, nullptr); ++ Local<ArrayBuffer> ab = v8::ArrayBuffer::New(ctx->env()->isolate(), std::move(bs)); ++ ++ auto buf = Buffer::New(ctx->env(), ab, 0, ret.second); if (!buf.IsEmpty()) { args.GetReturnValue().Set(buf.ToLocalChecked()); +diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js +index a90c398adcdaf30491a0fecdcf00895038d62e69..f5b8a1430ad2033eae06ca0157af2fb51d3f36a5 100644 +--- a/test/parallel/test-v8-serialize-leak.js ++++ b/test/parallel/test-v8-serialize-leak.js +@@ -23,5 +23,5 @@ const after = process.memoryUsage.rss(); + if (process.config.variables.asan) { + assert(after < before * 10, `asan: before=${before} after=${after}`); + } else { +- assert(after < before * 2, `before=${before} after=${after}`); ++ assert(after < before * 3, `before=${before} after=${after}`); + } diff --git a/script/node-disabled-tests.json b/script/node-disabled-tests.json index 9aed5c7f0ebe2..fe65d965a34c3 100644 --- a/script/node-disabled-tests.json +++ b/script/node-disabled-tests.json @@ -117,7 +117,6 @@ "parallel/test-webcrypto-sign-verify-eddsa", "parallel/test-worker-debug", "parallel/test-worker-stdio", - "parallel/test-v8-serialize-leak", "parallel/test-zlib-unused-weak", "report/test-report-fatal-error", "report/test-report-getreport", From 7a4a94b18c7b8221994f4c0d7e796267d959b15a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:43:14 +0200 Subject: [PATCH 114/172] fix: record helper error messages in electron_main_mac (#37813) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> --- shell/app/electron_main_mac.cc | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/shell/app/electron_main_mac.cc b/shell/app/electron_main_mac.cc index c817df186e205..30c7e09c31fee 100644 --- a/shell/app/electron_main_mac.cc +++ b/shell/app/electron_main_mac.cc @@ -18,6 +18,14 @@ #include "sandbox/mac/seatbelt_exec.h" // nogncheck #endif +extern "C" { +// abort_report_np() records the message in a special section that both the +// system CrashReporter and Crashpad collect in crash reports. Using a Crashpad +// Annotation would be preferable, but this executable cannot depend on +// Crashpad directly. +void abort_report_np(const char* fmt, ...); +} + namespace { [[maybe_unused]] bool IsEnvSet(const char* name) { @@ -25,6 +33,20 @@ namespace { return indicator && indicator[0] != '\0'; } +#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD) +[[noreturn]] void FatalError(const char* format, ...) { + va_list valist; + va_start(valist, format); + char message[4096]; + if (vsnprintf(message, sizeof(message), format, valist) >= 0) { + fputs(message, stderr); + abort_report_np("%s", message); + } + va_end(valist); + abort(); +} +#endif + } // namespace int main(int argc, char* argv[]) { @@ -42,27 +64,23 @@ int main(int argc, char* argv[]) { uint32_t exec_path_size = 0; int rv = _NSGetExecutablePath(NULL, &exec_path_size); if (rv != -1) { - fprintf(stderr, "_NSGetExecutablePath: get length failed\n"); - abort(); + FatalError("_NSGetExecutablePath: get length failed."); } auto exec_path = std::make_unique<char[]>(exec_path_size); rv = _NSGetExecutablePath(exec_path.get(), &exec_path_size); if (rv != 0) { - fprintf(stderr, "_NSGetExecutablePath: get path failed\n"); - abort(); + FatalError("_NSGetExecutablePath: get path failed."); } sandbox::SeatbeltExecServer::CreateFromArgumentsResult seatbelt = sandbox::SeatbeltExecServer::CreateFromArguments(exec_path.get(), argc, argv); if (seatbelt.sandbox_required) { if (!seatbelt.server) { - fprintf(stderr, "Failed to create seatbelt sandbox server.\n"); - abort(); + FatalError("Failed to create seatbelt sandbox server."); } if (!seatbelt.server->InitializeSandbox()) { - fprintf(stderr, "Failed to initialize sandbox.\n"); - abort(); + FatalError("Failed to initialize sandbox."); } } #endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD) From ffff96e33f71364369fc39baf158639edc2e9082 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 6 Apr 2023 12:13:16 +0100 Subject: [PATCH 115/172] chore: cherry-pick d9081493c4b2 from chromium (#37850) * chore: [22-x-y] cherry-pick d9081493c4b2 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-d9081493c4b2.patch | 90 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 patches/chromium/cherry-pick-d9081493c4b2.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 7264f1ed36618..fe89c9bfb29a9 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -146,3 +146,4 @@ cherry-pick-b5c9e5efe5dd.patch cherry-pick-56bd20b295b4.patch cherry-pick-1235110fce18.patch cherry-pick-b041159d06ad.patch +cherry-pick-d9081493c4b2.patch diff --git a/patches/chromium/cherry-pick-d9081493c4b2.patch b/patches/chromium/cherry-pick-d9081493c4b2.patch new file mode 100644 index 0000000000000..f4e3de2d4b285 --- /dev/null +++ b/patches/chromium/cherry-pick-d9081493c4b2.patch @@ -0,0 +1,90 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: kylechar <kylechar@chromium.org> +Date: Tue, 28 Feb 2023 21:02:51 +0000 +Subject: Add CHECKs in HostFrameSinkManager + +It looks like it's possible for a compromised renderer to get multiple +things to register the same FrameSinkId with HostFrameSinkManager. This +violates assumptions around ownership so turn DCHECKs here into CHECKs. +Also convert DCHECKs into CHECKs for registering/unregistering frame +sink hierarchy just in case. + +(cherry picked from commit a707ac2d95e4726f4cf0267c9b0c038926c2a691) + +Bug: 1414018 +Change-Id: If948e758a8484024666f4066360620bc3a9cb493 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4283141 +Reviewed-by: Martin Kreichgauer <martinkr@google.com> +Reviewed-by: Jonathan Ross <jonross@chromium.org> +Commit-Queue: Kyle Charbonneau <kylechar@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1109533} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4298330 +Cr-Commit-Position: refs/branch-heads/5615@{#69} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/components/viz/host/host_frame_sink_manager.cc b/components/viz/host/host_frame_sink_manager.cc +index 8d724edf1624b83f896a9d2200542fc981e4005e..3ac8a9c13b6655591bf737578d7f9b5aa5874e57 100644 +--- a/components/viz/host/host_frame_sink_manager.cc ++++ b/components/viz/host/host_frame_sink_manager.cc +@@ -68,7 +68,7 @@ void HostFrameSinkManager::RegisterFrameSinkId( + DCHECK(client); + + FrameSinkData& data = frame_sink_data_map_[frame_sink_id]; +- DCHECK(!data.IsFrameSinkRegistered()); ++ CHECK(!data.IsFrameSinkRegistered()); + DCHECK(!data.has_created_compositor_frame_sink); + data.client = client; + data.report_activation = report_activation; +@@ -87,7 +87,7 @@ void HostFrameSinkManager::InvalidateFrameSinkId( + DCHECK(frame_sink_id.is_valid()); + + FrameSinkData& data = frame_sink_data_map_[frame_sink_id]; +- DCHECK(data.IsFrameSinkRegistered()); ++ CHECK(data.IsFrameSinkRegistered()); + + const bool destroy_synchronously = + data.has_created_compositor_frame_sink && data.wait_on_destruction; +@@ -227,14 +227,14 @@ bool HostFrameSinkManager::RegisterFrameSinkHierarchy( + return false; + } + ++ FrameSinkData& parent_data = iter->second; ++ CHECK(!base::Contains(parent_data.children, child_frame_sink_id)); ++ parent_data.children.push_back(child_frame_sink_id); ++ + // Register and store the parent. + frame_sink_manager_->RegisterFrameSinkHierarchy(parent_frame_sink_id, + child_frame_sink_id); + +- FrameSinkData& parent_data = iter->second; +- DCHECK(!base::Contains(parent_data.children, child_frame_sink_id)); +- parent_data.children.push_back(child_frame_sink_id); +- + return true; + } + +@@ -243,8 +243,9 @@ void HostFrameSinkManager::UnregisterFrameSinkHierarchy( + const FrameSinkId& child_frame_sink_id) { + // Unregister and clear the stored parent. + FrameSinkData& parent_data = frame_sink_data_map_[parent_frame_sink_id]; +- DCHECK(base::Contains(parent_data.children, child_frame_sink_id)); +- base::Erase(parent_data.children, child_frame_sink_id); ++ size_t num_erased = base::Erase(parent_data.children, child_frame_sink_id); ++ CHECK_EQ(num_erased, 1u); ++ + if (parent_data.IsEmpty()) + frame_sink_data_map_.erase(parent_frame_sink_id); + +diff --git a/components/viz/service/frame_sinks/frame_sink_manager_impl.cc b/components/viz/service/frame_sinks/frame_sink_manager_impl.cc +index 7c25edc433792408a7a285f9cc976289f6500398..20fa10b1e812b97337bfd57c2e4e18d03888c2f3 100644 +--- a/components/viz/service/frame_sinks/frame_sink_manager_impl.cc ++++ b/components/viz/service/frame_sinks/frame_sink_manager_impl.cc +@@ -284,7 +284,7 @@ void FrameSinkManagerImpl::UnregisterFrameSinkHierarchy( + } + + auto iter = frame_sink_source_map_.find(parent_frame_sink_id); +- DCHECK(iter != frame_sink_source_map_.end()); ++ CHECK(iter != frame_sink_source_map_.end()); + + // Remove |child_frame_sink_id| from parents list of children. + auto& mapping = iter->second; From ae7b2ae3cbd094f078872ab51f897d58fea45724 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:00:07 -0700 Subject: [PATCH 116/172] fix: exceptions in nested conversions live in the target world (#37899) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> --- .../api/electron_api_context_bridge.cc | 52 ++++++++++--------- .../api/electron_api_context_bridge.h | 5 +- shell/renderer/api/electron_api_web_frame.cc | 2 +- shell/renderer/renderer_client_base.cc | 3 +- spec/api-context-bridge-spec.ts | 14 ++++- 5 files changed, 46 insertions(+), 30 deletions(-) diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index 31b7b30eaea7e..ceeb731f3b76a 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -241,10 +241,10 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( global_destination_context.IsEmpty()) return; context_bridge::ObjectCache object_cache; - auto val = - PassValueToOtherContext(global_source_context.Get(isolate), - global_destination_context.Get(isolate), - result, &object_cache, false, 0); + auto val = PassValueToOtherContext( + global_source_context.Get(isolate), + global_destination_context.Get(isolate), result, &object_cache, + false, 0, BridgeErrorTarget::kSource); if (!val.IsEmpty()) proxied_promise->Resolve(val.ToLocalChecked()); }, @@ -268,10 +268,10 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( global_destination_context.IsEmpty()) return; context_bridge::ObjectCache object_cache; - auto val = - PassValueToOtherContext(global_source_context.Get(isolate), - global_destination_context.Get(isolate), - result, &object_cache, false, 0); + auto val = PassValueToOtherContext( + global_source_context.Get(isolate), + global_destination_context.Get(isolate), result, &object_cache, + false, 0, BridgeErrorTarget::kSource); if (!val.IsEmpty()) proxied_promise->Reject(val.ToLocalChecked()); }, @@ -324,7 +324,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( auto value_for_array = PassValueToOtherContext( source_context, destination_context, arr->Get(source_context, i).ToLocalChecked(), object_cache, - support_dynamic_properties, recursion_depth + 1); + support_dynamic_properties, recursion_depth + 1, error_target); if (value_for_array.IsEmpty()) return v8::MaybeLocal<v8::Value>(); @@ -358,7 +358,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( auto object_value = value.As<v8::Object>(); auto passed_value = CreateProxyForAPI( object_value, source_context, destination_context, object_cache, - support_dynamic_properties, recursion_depth + 1); + support_dynamic_properties, recursion_depth + 1, error_target); if (passed_value.IsEmpty()) return v8::MaybeLocal<v8::Value>(); return v8::MaybeLocal<v8::Value>(passed_value.ToLocalChecked()); @@ -372,8 +372,9 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( : destination_context; v8::Context::Scope error_scope(error_context); // V8 serializer will throw an error if required - if (!gin::ConvertFromV8(error_context->GetIsolate(), value, &ret)) + if (!gin::ConvertFromV8(error_context->GetIsolate(), value, &ret)) { return v8::MaybeLocal<v8::Value>(); + } } { @@ -420,9 +421,9 @@ void ProxyFunctionWrapper(const v8::FunctionCallbackInfo<v8::Value>& info) { args.GetRemaining(&original_args); for (auto value : original_args) { - auto arg = - PassValueToOtherContext(calling_context, func_owning_context, value, - &object_cache, support_dynamic_properties, 0); + auto arg = PassValueToOtherContext( + calling_context, func_owning_context, value, &object_cache, + support_dynamic_properties, 0, BridgeErrorTarget::kSource); if (arg.IsEmpty()) return; proxied_args.push_back(arg.ToLocalChecked()); @@ -485,7 +486,8 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI( const v8::Local<v8::Context>& destination_context, context_bridge::ObjectCache* object_cache, bool support_dynamic_properties, - int recursion_depth) { + int recursion_depth, + BridgeErrorTarget error_target) { gin_helper::Dictionary api(source_context->GetIsolate(), api_object); { @@ -526,14 +528,16 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI( if (!getter.IsEmpty()) { if (!PassValueToOtherContext(source_context, destination_context, getter, object_cache, - support_dynamic_properties, 1) + support_dynamic_properties, 1, + error_target) .ToLocal(&getter_proxy)) continue; } if (!setter.IsEmpty()) { if (!PassValueToOtherContext(source_context, destination_context, setter, object_cache, - support_dynamic_properties, 1) + support_dynamic_properties, 1, + error_target) .ToLocal(&setter_proxy)) continue; } @@ -551,7 +555,7 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI( auto passed_value = PassValueToOtherContext( source_context, destination_context, value, object_cache, - support_dynamic_properties, recursion_depth + 1); + support_dynamic_properties, recursion_depth + 1, error_target); if (passed_value.IsEmpty()) return v8::MaybeLocal<v8::Object>(); proxy.Set(key, passed_value.ToLocalChecked()); @@ -597,9 +601,9 @@ void ExposeAPIInWorld(v8::Isolate* isolate, context_bridge::ObjectCache object_cache; v8::Context::Scope target_context_scope(target_context); - v8::MaybeLocal<v8::Value> maybe_proxy = - PassValueToOtherContext(electron_isolated_context, target_context, api, - &object_cache, false, 0); + v8::MaybeLocal<v8::Value> maybe_proxy = PassValueToOtherContext( + electron_isolated_context, target_context, api, &object_cache, false, 0, + BridgeErrorTarget::kSource); if (maybe_proxy.IsEmpty()) return; auto proxy = maybe_proxy.ToLocalChecked(); @@ -649,7 +653,7 @@ void OverrideGlobalValueFromIsolatedWorld( context_bridge::ObjectCache object_cache; v8::MaybeLocal<v8::Value> maybe_proxy = PassValueToOtherContext( value->GetCreationContextChecked(), main_context, value, &object_cache, - support_dynamic_properties, 1); + support_dynamic_properties, 1, BridgeErrorTarget::kSource); DCHECK(!maybe_proxy.IsEmpty()); auto proxy = maybe_proxy.ToLocalChecked(); @@ -685,14 +689,14 @@ bool OverrideGlobalPropertyFromIsolatedWorld( if (!getter->IsNullOrUndefined()) { v8::MaybeLocal<v8::Value> maybe_getter_proxy = PassValueToOtherContext( getter->GetCreationContextChecked(), main_context, getter, - &object_cache, false, 1); + &object_cache, false, 1, BridgeErrorTarget::kSource); DCHECK(!maybe_getter_proxy.IsEmpty()); getter_proxy = maybe_getter_proxy.ToLocalChecked(); } if (!setter->IsNullOrUndefined() && setter->IsObject()) { v8::MaybeLocal<v8::Value> maybe_setter_proxy = PassValueToOtherContext( getter->GetCreationContextChecked(), main_context, setter, - &object_cache, false, 1); + &object_cache, false, 1, BridgeErrorTarget::kSource); DCHECK(!maybe_setter_proxy.IsEmpty()); setter_proxy = maybe_setter_proxy.ToLocalChecked(); } diff --git a/shell/renderer/api/electron_api_context_bridge.h b/shell/renderer/api/electron_api_context_bridge.h index bc60d2356a92c..dd2af4b7136d2 100644 --- a/shell/renderer/api/electron_api_context_bridge.h +++ b/shell/renderer/api/electron_api_context_bridge.h @@ -39,7 +39,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( context_bridge::ObjectCache* object_cache, bool support_dynamic_properties, int recursion_depth, - BridgeErrorTarget error_target = BridgeErrorTarget::kSource); + BridgeErrorTarget error_target); v8::MaybeLocal<v8::Object> CreateProxyForAPI( const v8::Local<v8::Object>& api_object, @@ -47,7 +47,8 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI( const v8::Local<v8::Context>& destination_context, context_bridge::ObjectCache* object_cache, bool support_dynamic_properties, - int recursion_depth); + int recursion_depth, + BridgeErrorTarget error_target); } // namespace electron::api diff --git a/shell/renderer/api/electron_api_web_frame.cc b/shell/renderer/api/electron_api_web_frame.cc index ba30e7c0e6dd3..eb4f9369f9690 100644 --- a/shell/renderer/api/electron_api_web_frame.cc +++ b/shell/renderer/api/electron_api_web_frame.cc @@ -142,7 +142,7 @@ class ScriptExecutionCallback { context_bridge::ObjectCache object_cache; maybe_result = PassValueToOtherContext( result->GetCreationContextChecked(), promise_.GetContext(), result, - &object_cache, false, 0); + &object_cache, false, 0, BridgeErrorTarget::kSource); if (maybe_result.IsEmpty() || try_catch.HasCaught()) { success = false; } diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index 8923708ab662b..e5309b3989796 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -608,7 +608,8 @@ void RendererClientBase::SetupMainWorldOverrides( if (global.GetHidden("guestViewInternal", &guest_view_internal)) { api::context_bridge::ObjectCache object_cache; auto result = api::PassValueToOtherContext( - source_context, context, guest_view_internal, &object_cache, false, 0); + source_context, context, guest_view_internal, &object_cache, false, 0, + api::BridgeErrorTarget::kSource); if (!result.IsEmpty()) { isolated_api.Set("guestViewInternal", result.ToLocalChecked()); } diff --git a/spec/api-context-bridge-spec.ts b/spec/api-context-bridge-spec.ts index 8a2041f264922..fb333317f09c7 100644 --- a/spec/api-context-bridge-spec.ts +++ b/spec/api-context-bridge-spec.ts @@ -802,6 +802,14 @@ describe('contextBridge', () => { throwNotClonable: () => { return Object(Symbol('foo')); }, + throwNotClonableNestedArray: () => { + return [Object(Symbol('foo'))]; + }, + throwNotClonableNestedObject: () => { + return { + bad: Object(Symbol('foo')) + }; + }, argumentConvert: () => {} }); }); @@ -817,10 +825,12 @@ describe('contextBridge', () => { const normalIsError = Object.getPrototypeOf(getError(root.example.throwNormal)) === Error.prototype; const weirdIsError = Object.getPrototypeOf(getError(root.example.throwWeird)) === Error.prototype; const notClonableIsError = Object.getPrototypeOf(getError(root.example.throwNotClonable)) === Error.prototype; + const notClonableNestedArrayIsError = Object.getPrototypeOf(getError(root.example.throwNotClonableNestedArray)) === Error.prototype; + const notClonableNestedObjectIsError = Object.getPrototypeOf(getError(root.example.throwNotClonableNestedObject)) === Error.prototype; const argumentConvertIsError = Object.getPrototypeOf(getError(() => root.example.argumentConvert(Object(Symbol('test'))))) === Error.prototype; - return [normalIsError, weirdIsError, notClonableIsError, argumentConvertIsError]; + return [normalIsError, weirdIsError, notClonableIsError, notClonableNestedArrayIsError, notClonableNestedObjectIsError, argumentConvertIsError]; }); - expect(result).to.deep.equal([true, true, true, true], 'should all be errors in the current context'); + expect(result).to.deep.equal([true, true, true, true, true, true], 'should all be errors in the current context'); }); it('should not leak prototypes', async () => { From 620bdcbb2a9eb4ffe0e5bb4520a141fa988b810b Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 16:20:49 +0900 Subject: [PATCH 117/172] test: support 'latest'/'latest@X' Electron version strings (#37869) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --- script/spec-runner.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/script/spec-runner.js b/script/spec-runner.js index a6f7083b7f07f..8edc5d44d2663 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -64,10 +64,24 @@ if (args.runners !== undefined) { async function main () { if (args.electronVersion) { const versions = await ElectronVersions.create(); - if (!versions.isVersion(args.electronVersion)) { + if (args.electronVersion === 'latest') { + args.electronVersion = versions.latest.version; + } else if (args.electronVersion.startsWith('latest@')) { + const majorVersion = parseInt(args.electronVersion.slice('latest@'.length)); + const ver = versions.inMajor(majorVersion).slice(-1)[0]; + if (ver) { + args.electronVersion = ver.version; + } else { + console.log(`${fail} '${majorVersion}' is not a recognized Electron major version`); + process.exit(1); + } + } else if (!versions.isVersion(args.electronVersion)) { console.log(`${fail} '${args.electronVersion}' is not a recognized Electron version`); process.exit(1); } + + const versionString = `v${args.electronVersion}`; + console.log(`Running against Electron ${versionString.green}`); } const [lastSpecHash, lastSpecInstallHash] = loadLastSpecHash(); From e2c4acd5052dc8dd1fdd019981f5838e7ea06bfb Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 16:23:01 +0900 Subject: [PATCH 118/172] fix: apply csp correctly when contextIsolation: false (#37843) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> --- shell/common/node_bindings.cc | 21 ++++++++- spec/chromium-spec.ts | 88 ++++++++++++++++++++++++++--------- 2 files changed, 86 insertions(+), 23 deletions(-) diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 015af73e0b924..8235eebd3de15 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -184,9 +184,10 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( v8::Local<v8::Context> context, v8::Local<v8::Value> source, bool is_code_like) { - // If we're running with contextIsolation enabled in the renderer process, - // fall back to Blink's logic. if (node::Environment::GetCurrent(context) == nullptr) { + // No node environment means we're in the renderer process, either in a + // sandboxed renderer or in an unsandboxed renderer with context isolation + // enabled. if (gin_helper::Locker::IsBrowserProcess()) { NOTREACHED(); return {false, {}}; @@ -195,6 +196,22 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( context, source, is_code_like); } + // If we get here then we have a node environment, so either a) we're in the + // main process, or b) we're in the renderer process in a context that has + // both node and blink, i.e. contextIsolation disabled. + + // If we're in the main process, delegate to node. + if (gin_helper::Locker::IsBrowserProcess()) { + return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); + } + + // If we're in the renderer with contextIsolation disabled, ask blink first + // (for CSP), and iff that allows codegen, delegate to node. + v8::ModifyCodeGenerationFromStringsResult result = + blink::V8Initializer::CodeGenerationCheckCallbackInMainThread( + context, source, is_code_like); + if (!result.codegen_allowed) + return result; return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); } diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 06f0519ff48c5..b84467ccbd2a9 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -355,28 +355,74 @@ describe('web security', () => { }); }); - describe('csp in sandbox: false', () => { - it('is correctly applied', async () => { - const w = new BrowserWindow({ - show: false, - webPreferences: { sandbox: false } + describe('csp', () => { + for (const sandbox of [true, false]) { + describe(`when sandbox: ${sandbox}`, () => { + for (const contextIsolation of [true, false]) { + describe(`when contextIsolation: ${contextIsolation}`, () => { + it('prevents eval from running in an inline script', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL(`data:text/html,<head> + <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'"> + </head> + <script> + try { + // We use console.log here because it is easier than making a + // preload script, and the behavior under test changes when + // contextIsolation: false + console.log(eval('true')) + } catch (e) { + console.log(e.message) + } + </script>`); + const [,, message] = await emittedOnce(w.webContents, 'console-message'); + expect(message).to.match(/Refused to evaluate a string/); + }); + + it('does not prevent eval from running in an inline script when there is no csp', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL(`data:text/html, + <script> + try { + // We use console.log here because it is easier than making a + // preload script, and the behavior under test changes when + // contextIsolation: false + console.log(eval('true')) + } catch (e) { + console.log(e.message) + } + </script>`); + const [,, message] = await emittedOnce(w.webContents, 'console-message'); + expect(message).to.equal('true'); + }); + + it('prevents eval from running in executeJavaScript', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL('data:text/html,<head><meta http-equiv="Content-Security-Policy" content="default-src \'self\'; script-src \'self\' \'unsafe-inline\'"></meta></head>'); + await expect(w.webContents.executeJavaScript('eval("true")')).to.be.rejected(); + }); + + it('does not prevent eval from running in executeJavaScript when there is no csp', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL('data:text/html,'); + expect(await w.webContents.executeJavaScript('eval("true")')).to.be.true(); + }); + }); + } }); - w.loadURL(`data:text/html,<head> - <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'"> - </head> - <script> - try { - // We use console.log here because it is easier than making a - // preload script, and the behavior under test changes when - // contextIsolation: false - console.log(eval('failure')) - } catch (e) { - console.log('success') - } - </script>`); - const [,, message] = await emittedOnce(w.webContents, 'console-message'); - expect(message).to.equal('success'); - }); + } }); it('does not crash when multiple WebContent are created with web security disabled', () => { From 3cd2f2ede91a7d17faf27177f9e675c892756bc8 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:24:24 +0200 Subject: [PATCH 119/172] docs: fix `app.getPreferredSystemLanguages()` return type (#37836) docs: fix app.getPreferredSystemLanguages() return type Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- docs/api/app.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index c4679c6939b35..23d9176f0802c 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -748,14 +748,21 @@ This API can be used for purposes such as deciding what language to present the Here are some examples of return values of the various language and locale APIs with different configurations: -* For Windows, where the application locale is German, the regional format is Finnish (Finland), and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese (China), Finnish, and Spanish (Latin America): - * `app.getLocale()` returns `'de'` - * `app.getSystemLocale()` returns `'fi-FI'` - * `app.getPreferredSystemLanguages()` returns `['fr-CA', 'en-US', 'zh-Hans-CN', 'fi', 'es-419']` -* On macOS, where the application locale is German, the region is Finland, and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese, and Spanish (Latin America): - * `app.getLocale()` returns `'de'` - * `app.getSystemLocale()` returns `'fr-FI'` - * `app.getPreferredSystemLanguages()` returns `['fr-CA', 'en-US', 'zh-Hans-FI', 'es-419']` +On Windows, given application locale is German, the regional format is Finnish (Finland), and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese (China), Finnish, and Spanish (Latin America): + +```js +app.getLocale() // 'de' +app.getSystemLocale() // 'fi-FI' +app.getPreferredSystemLanguages() // ['fr-CA', 'en-US', 'zh-Hans-CN', 'fi', 'es-419'] +``` + +On macOS, given the application locale is German, the region is Finland, and the preferred system languages from most to least preferred are French (Canada), English (US), Simplified Chinese, and Spanish (Latin America): + +```js +app.getLocale() // 'de' +app.getSystemLocale() // 'fr-FI' +app.getPreferredSystemLanguages() // ['fr-CA', 'en-US', 'zh-Hans-FI', 'es-419'] +``` Both the available languages and regions and the possible return values differ between the two operating systems. From c875adf7cf0496957e85aa44c0585a0f283bc761 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Tue, 11 Apr 2023 20:13:19 +0100 Subject: [PATCH 120/172] chore: cherry-pick d6946b70b431 from chromium (#37848) * chore: [22-x-y] cherry-pick d6946b70b431 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-d6946b70b431.patch | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 patches/chromium/cherry-pick-d6946b70b431.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index fe89c9bfb29a9..0a4ea51087d3c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -146,4 +146,5 @@ cherry-pick-b5c9e5efe5dd.patch cherry-pick-56bd20b295b4.patch cherry-pick-1235110fce18.patch cherry-pick-b041159d06ad.patch +cherry-pick-d6946b70b431.patch cherry-pick-d9081493c4b2.patch diff --git a/patches/chromium/cherry-pick-d6946b70b431.patch b/patches/chromium/cherry-pick-d6946b70b431.patch new file mode 100644 index 0000000000000..0d85cfd85b936 --- /dev/null +++ b/patches/chromium/cherry-pick-d6946b70b431.patch @@ -0,0 +1,47 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dave Tapuska <dtapuska@chromium.org> +Date: Fri, 24 Mar 2023 19:32:54 +0000 +Subject: Move the edit commands to an on stack variable + +DevTools uses nested event loops and the usage of the class member can +be problematic for iteration because the nested loop can change the +variable's storage causing a UAF. + +(cherry picked from commit d9b34f0f3a2d0dd73648eca3ef940fb66806227b) + +Bug: 1420510 +Change-Id: Ie08a71b60401fa4322cca0cc31062ba64672126a +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4355811 +Reviewed-by: David Bokan <bokan@chromium.org> +Commit-Queue: Dave Tapuska <dtapuska@chromium.org> +Reviewed-by: Daniel Cheng <dcheng@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1120123} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4369603 +Cr-Commit-Position: refs/branch-heads/5615@{#809} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +index 2779b0a23477d33e747cb0d97079b463b1060652..b4ca94c7b39a090b7d9700cd86f04a71ebdfcf1f 100644 +--- a/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc ++++ b/third_party/blink/renderer/core/frame/web_frame_widget_impl.cc +@@ -3182,11 +3182,18 @@ void WebFrameWidgetImpl::AddEditCommandForNextKeyEvent(const WebString& name, + } + + bool WebFrameWidgetImpl::HandleCurrentKeyboardEvent() { +- bool did_execute_command = false; ++ if (edit_commands_.empty()) { ++ return false; ++ } + WebLocalFrame* frame = FocusedWebLocalFrameInWidget(); + if (!frame) + frame = local_root_; +- for (const auto& command : edit_commands_) { ++ bool did_execute_command = false; ++ // Executing an edit command can run JS and we can end up reassigning ++ // `edit_commands_` so move it to a stack variable before iterating on it. ++ Vector<mojom::blink::EditCommandPtr> edit_commands = ++ std::move(edit_commands_); ++ for (const auto& command : edit_commands) { + // In gtk and cocoa, it's possible to bind multiple edit commands to one + // key (but it's the exception). Once one edit command is not executed, it + // seems safest to not execute the rest. From ee668f1472e8922fb247fb2ff5e3063bea808aa8 Mon Sep 17 00:00:00 2001 From: Darshan Sen <raisinten@gmail.com> Date: Wed, 12 Apr 2023 16:46:35 +0530 Subject: [PATCH 121/172] fix: recommended `node-gyp` version in `node.h` error (#37942) fix: recommended `node-gyp` version in `node.h` error (#37829) fix: recommended node-gyp version in node.h error In https://github.com/electron/electron/blob/main/docs/tutorial/using-native-node-modules.md#using-npm, we recommend setting the `npm_config_disturl` variable but doing that does not work on node-gyp v8.4.0 because after https://github.com/nodejs/node-gyp/pull/2497 landed, the dist URL was read only from `gyp.opts['dist-url']`. The fix for reading the value from `npm_config_disturl` by parsing `gyp.opts.disturl` was landed in https://github.com/nodejs/node-gyp/pull/2547 and that change was released in node-gyp v9.0.0, so this change updates the error macro to recommend node-gyp v9.0.0 as the minimum required version. Signed-off-by: Darshan Sen <raisinten@gmail.com> --- ...mbedder_to_control_codegenerationfromstringscallback.patch | 2 +- ...e_native_module_compilation_fails_if_not_using_a_new.patch | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch b/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch index edc2eebde5ad6..c3524a4e1d9e2 100644 --- a/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch +++ b/patches/node/allow_embedder_to_control_codegenerationfromstringscallback.patch @@ -30,7 +30,7 @@ index 93d85d46dc6b3b30795b88ffa8070253f62e51bd..05f8232c4b38f51e8059e8d01b0eb247 if ((s.flags & SHOULD_NOT_SET_PROMISE_REJECTION_CALLBACK) == 0) { auto* promise_reject_cb = s.promise_reject_callback ? diff --git a/src/node.h b/src/node.h -index 38bbb20968772a4ba6bceddb04a83589f8582fc8..a5ee97ae83149a1924e9d6198ad4b2a7fd8b876d 100644 +index b5e4d42035a23b49fd144d563f5716fcaed2b45c..f2e2acc98c1165430e46351fe07637315cc2c38e 100644 --- a/src/node.h +++ b/src/node.h @@ -374,6 +374,8 @@ struct IsolateSettings { diff --git a/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch b/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch index 2e23477369160..37ab79d5bdb3f 100644 --- a/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch +++ b/patches/node/build_ensure_native_module_compilation_fails_if_not_using_a_new.patch @@ -52,7 +52,7 @@ index 08894bf3908916d1cb639810c5e1b2afae74ff4d..19cbde58df38009258db145c5f7dbe73 o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0 o['variables']['v8_enable_gdbjit'] = 1 if options.gdb else 0 diff --git a/src/node.h b/src/node.h -index b6a26f8adf11959f94a00de0cbf9016fcc8707cb..38bbb20968772a4ba6bceddb04a83589f8582fc8 100644 +index b6a26f8adf11959f94a00de0cbf9016fcc8707cb..b5e4d42035a23b49fd144d563f5716fcaed2b45c 100644 --- a/src/node.h +++ b/src/node.h @@ -22,6 +22,12 @@ @@ -61,7 +61,7 @@ index b6a26f8adf11959f94a00de0cbf9016fcc8707cb..38bbb20968772a4ba6bceddb04a83589 +#ifdef ELECTRON_ENSURE_CONFIG_GYPI +#ifndef USING_ELECTRON_CONFIG_GYPI -+#error "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=8.4.0) if you're building modules directly." ++#error "It looks like you are building this native module without using the right config.gypi. This normally means that you need to update electron-rebuild (>=3.2.8) or node-gyp (>=9.0.0) if you're building modules directly." +#endif +#endif + From fcbd88f8aa27b1b603d267e5ebe0b7d748375c43 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 15:10:54 +0900 Subject: [PATCH 122/172] fix: exceptions during function/promise result conversions live in calling world (#37923) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> --- .../api/electron_api_context_bridge.cc | 101 +++++++++++++++--- spec/api-context-bridge-spec.ts | 30 +++++- 2 files changed, 115 insertions(+), 16 deletions(-) diff --git a/shell/renderer/api/electron_api_context_bridge.cc b/shell/renderer/api/electron_api_context_bridge.cc index ceeb731f3b76a..9dbc2093b7dc9 100644 --- a/shell/renderer/api/electron_api_context_bridge.cc +++ b/shell/renderer/api/electron_api_context_bridge.cc @@ -241,10 +241,29 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( global_destination_context.IsEmpty()) return; context_bridge::ObjectCache object_cache; - auto val = PassValueToOtherContext( - global_source_context.Get(isolate), - global_destination_context.Get(isolate), result, &object_cache, - false, 0, BridgeErrorTarget::kSource); + v8::MaybeLocal<v8::Value> val; + { + v8::TryCatch try_catch(isolate); + val = PassValueToOtherContext( + global_source_context.Get(isolate), + global_destination_context.Get(isolate), result, &object_cache, + false, 0, BridgeErrorTarget::kDestination); + if (try_catch.HasCaught()) { + if (try_catch.Message().IsEmpty()) { + proxied_promise->RejectWithErrorMessage( + "An error was thrown while sending a promise result over " + "the context bridge but it was not actually an Error " + "object. This normally means that a promise was resolved " + "with a value that is not supported by the Context " + "Bridge."); + } else { + proxied_promise->Reject( + v8::Exception::Error(try_catch.Message()->Get())); + } + return; + } + } + DCHECK(!val.IsEmpty()); if (!val.IsEmpty()) proxied_promise->Resolve(val.ToLocalChecked()); }, @@ -268,10 +287,28 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext( global_destination_context.IsEmpty()) return; context_bridge::ObjectCache object_cache; - auto val = PassValueToOtherContext( - global_source_context.Get(isolate), - global_destination_context.Get(isolate), result, &object_cache, - false, 0, BridgeErrorTarget::kSource); + v8::MaybeLocal<v8::Value> val; + { + v8::TryCatch try_catch(isolate); + val = PassValueToOtherContext( + global_source_context.Get(isolate), + global_destination_context.Get(isolate), result, &object_cache, + false, 0, BridgeErrorTarget::kDestination); + if (try_catch.HasCaught()) { + if (try_catch.Message().IsEmpty()) { + proxied_promise->RejectWithErrorMessage( + "An error was thrown while sending a promise rejection " + "over the context bridge but it was not actually an Error " + "object. This normally means that a promise was rejected " + "with a value that is not supported by the Context " + "Bridge."); + } else { + proxied_promise->Reject( + v8::Exception::Error(try_catch.Message()->Get())); + } + return; + } + } if (!val.IsEmpty()) proxied_promise->Reject(val.ToLocalChecked()); }, @@ -470,10 +507,50 @@ void ProxyFunctionWrapper(const v8::FunctionCallbackInfo<v8::Value>& info) { if (maybe_return_value.IsEmpty()) return; - auto ret = PassValueToOtherContext( - func_owning_context, calling_context, - maybe_return_value.ToLocalChecked(), &object_cache, - support_dynamic_properties, 0, BridgeErrorTarget::kDestination); + // In the case where we encounted an exception converting the return value + // of the function we need to ensure that the exception / thrown value is + // safely transferred from the function_owning_context (where it was thrown) + // into the calling_context (where it needs to be thrown) To do this we pull + // the message off the exception and later re-throw it in the right context. + // In some cases the caught thing is not an exception i.e. it's technically + // valid to `throw 123`. In these cases to avoid infinite + // PassValueToOtherContext recursion we bail early as being unable to send + // the value from one context to the other. + // TODO(MarshallOfSound): In this case and other cases where the error can't + // be sent _across_ worlds we should probably log it globally in some way to + // allow easier debugging. This is not trivial though so is left to a + // future change. + bool did_error_converting_result = false; + v8::MaybeLocal<v8::Value> ret; + v8::Local<v8::String> exception; + { + v8::TryCatch try_catch(args.isolate()); + ret = PassValueToOtherContext(func_owning_context, calling_context, + maybe_return_value.ToLocalChecked(), + &object_cache, support_dynamic_properties, + 0, BridgeErrorTarget::kDestination); + if (try_catch.HasCaught()) { + did_error_converting_result = true; + if (!try_catch.Message().IsEmpty()) { + exception = try_catch.Message()->Get(); + } + } + } + if (did_error_converting_result) { + v8::Context::Scope calling_context_scope(calling_context); + if (exception.IsEmpty()) { + const char err_msg[] = + "An unknown exception occurred while sending a function return " + "value over the context bridge, an error " + "occurred but a valid exception was not thrown."; + args.isolate()->ThrowException(v8::Exception::Error( + gin::StringToV8(args.isolate(), err_msg).As<v8::String>())); + } else { + args.isolate()->ThrowException(v8::Exception::Error(exception)); + } + return; + } + DCHECK(!ret.IsEmpty()); if (ret.IsEmpty()) return; info.GetReturnValue().Set(ret.ToLocalChecked()); diff --git a/spec/api-context-bridge-spec.ts b/spec/api-context-bridge-spec.ts index fb333317f09c7..b55e94e6c96f5 100644 --- a/spec/api-context-bridge-spec.ts +++ b/spec/api-context-bridge-spec.ts @@ -810,10 +810,21 @@ describe('contextBridge', () => { bad: Object(Symbol('foo')) }; }, - argumentConvert: () => {} + throwDynamic: () => { + return { + get bad () { + throw new Error('damm'); + } + }; + }, + argumentConvert: () => {}, + rejectNotClonable: async () => { + throw Object(Symbol('foo')); + }, + resolveNotClonable: async () => Object(Symbol('foo')) }); }); - const result = await callWithBindings((root: any) => { + const result = await callWithBindings(async (root: any) => { const getError = (fn: Function) => { try { fn(); @@ -822,15 +833,26 @@ describe('contextBridge', () => { } return null; }; + const getAsyncError = async (fn: Function) => { + try { + await fn(); + } catch (e) { + return e; + } + return null; + }; const normalIsError = Object.getPrototypeOf(getError(root.example.throwNormal)) === Error.prototype; const weirdIsError = Object.getPrototypeOf(getError(root.example.throwWeird)) === Error.prototype; const notClonableIsError = Object.getPrototypeOf(getError(root.example.throwNotClonable)) === Error.prototype; const notClonableNestedArrayIsError = Object.getPrototypeOf(getError(root.example.throwNotClonableNestedArray)) === Error.prototype; const notClonableNestedObjectIsError = Object.getPrototypeOf(getError(root.example.throwNotClonableNestedObject)) === Error.prototype; + const dynamicIsError = Object.getPrototypeOf(getError(root.example.throwDynamic)) === Error.prototype; const argumentConvertIsError = Object.getPrototypeOf(getError(() => root.example.argumentConvert(Object(Symbol('test'))))) === Error.prototype; - return [normalIsError, weirdIsError, notClonableIsError, notClonableNestedArrayIsError, notClonableNestedObjectIsError, argumentConvertIsError]; + const rejectNotClonableIsError = Object.getPrototypeOf(await getAsyncError(root.example.rejectNotClonable)) === Error.prototype; + const resolveNotClonableIsError = Object.getPrototypeOf(await getAsyncError(root.example.resolveNotClonable)) === Error.prototype; + return [normalIsError, weirdIsError, notClonableIsError, notClonableNestedArrayIsError, notClonableNestedObjectIsError, dynamicIsError, argumentConvertIsError, rejectNotClonableIsError, resolveNotClonableIsError]; }); - expect(result).to.deep.equal([true, true, true, true, true, true], 'should all be errors in the current context'); + expect(result).to.deep.equal([true, true, true, true, true, true, true, true, true], 'should all be errors in the current context'); }); it('should not leak prototypes', async () => { From f843f233630e8e8b205cac297e4fa2055eb9dad5 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 13 Apr 2023 21:08:40 -0400 Subject: [PATCH 123/172] fix: defaultFontFamily in webPreferences (#37970) * fix: defaultFontFamily in webPreferences Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * chore: check if default_font_family_ is empty Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --- shell/browser/web_contents_preferences.cc | 44 +++++++++++++---------- spec/api-browser-window-spec.ts | 16 +++++++++ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/shell/browser/web_contents_preferences.cc b/shell/browser/web_contents_preferences.cc index 14069bfdde30e..e5a793214e712 100644 --- a/shell/browser/web_contents_preferences.cc +++ b/shell/browser/web_contents_preferences.cc @@ -430,24 +430,32 @@ void WebContentsPreferences::OverrideWebkitPrefs( prefs->web_security_enabled = web_security_; prefs->allow_running_insecure_content = allow_running_insecure_content_; - if (auto font = - default_font_family_.find("standard") != default_font_family_.end()) - prefs->standard_font_family_map[blink::web_pref::kCommonScript] = font; - if (auto font = - default_font_family_.find("serif") != default_font_family_.end()) - prefs->serif_font_family_map[blink::web_pref::kCommonScript] = font; - if (auto font = - default_font_family_.find("sansSerif") != default_font_family_.end()) - prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] = font; - if (auto font = - default_font_family_.find("monospace") != default_font_family_.end()) - prefs->fixed_font_family_map[blink::web_pref::kCommonScript] = font; - if (auto font = - default_font_family_.find("cursive") != default_font_family_.end()) - prefs->cursive_font_family_map[blink::web_pref::kCommonScript] = font; - if (auto font = - default_font_family_.find("fantasy") != default_font_family_.end()) - prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = font; + if (!default_font_family_.empty()) { + if (auto iter = default_font_family_.find("standard"); + iter != default_font_family_.end()) + prefs->standard_font_family_map[blink::web_pref::kCommonScript] = + iter->second; + if (auto iter = default_font_family_.find("serif"); + iter != default_font_family_.end()) + prefs->serif_font_family_map[blink::web_pref::kCommonScript] = + iter->second; + if (auto iter = default_font_family_.find("sansSerif"); + iter != default_font_family_.end()) + prefs->sans_serif_font_family_map[blink::web_pref::kCommonScript] = + iter->second; + if (auto iter = default_font_family_.find("monospace"); + iter != default_font_family_.end()) + prefs->fixed_font_family_map[blink::web_pref::kCommonScript] = + iter->second; + if (auto iter = default_font_family_.find("cursive"); + iter != default_font_family_.end()) + prefs->cursive_font_family_map[blink::web_pref::kCommonScript] = + iter->second; + if (auto iter = default_font_family_.find("fantasy"); + iter != default_font_family_.end()) + prefs->fantasy_font_family_map[blink::web_pref::kCommonScript] = + iter->second; + } if (default_font_size_) prefs->default_font_size = *default_font_size_; diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 8cfc6dd9821f3..ddedf32c9ae25 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -3458,6 +3458,22 @@ describe('BrowserWindow module', () => { expect(w.getSize()).to.deep.equal(size); }); }); + + describe('"defaultFontFamily" option', () => { + it('can change the standard font family', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { + defaultFontFamily: { + standard: 'Impact' + } + } + }); + await w.loadFile(path.join(fixtures, 'pages', 'content.html')); + const fontFamily = await w.webContents.executeJavaScript("window.getComputedStyle(document.getElementsByTagName('p')[0])['font-family']", true); + expect(fontFamily).to.equal('Impact'); + }); + }); }); describe('beforeunload handler', function () { From 69d1434bcc96725d358b9db545bf8df3291a2156 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Sun, 16 Apr 2023 05:20:49 +0100 Subject: [PATCH 124/172] chore: cherry-pick f4b66ae451c2 from v8 (#37983) --- patches/v8/.patches | 1 + patches/v8/cherry-pick-f4b66ae451c2.patch | 33 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 patches/v8/cherry-pick-f4b66ae451c2.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 5dae5521ba989..60f7899c0d253 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -13,3 +13,4 @@ cherry-pick-e17eee4894be.patch cherry-pick-aeceeb2187a6.patch cherry-pick-546e00df97ac.patch cherry-pick-f6ddbf42b1ea.patch +cherry-pick-f4b66ae451c2.patch diff --git a/patches/v8/cherry-pick-f4b66ae451c2.patch b/patches/v8/cherry-pick-f4b66ae451c2.patch new file mode 100644 index 0000000000000..0896204ce3200 --- /dev/null +++ b/patches/v8/cherry-pick-f4b66ae451c2.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Darius M <dmercadier@chromium.org> +Date: Mon, 27 Mar 2023 13:39:50 +0200 +Subject: Merged: [compiler] Prevent constant folding of TypeGuard + +TypeGuard are used to prevent operations from floating before a +preceding check, and thus shouldn't be constant-folded. + +Bug: chromium:1427388 +(cherry picked from commit 867716437273c16dc6ef5bc85b9c18affa1fb242) + +Change-Id: Ia334d079707f13974235f8c04ccb468ac16ff794 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4386487 +Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Commit-Queue: Darius Mercadier <dmercadier@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.2@{#23} +Cr-Branched-From: 755511a138609ac5939449a8ac615c15603a4454-refs/heads/11.2.214@{#1} +Cr-Branched-From: e6b1ccefb0f0f1ff8d310578878130dc53d73749-refs/heads/main@{#86014} + +diff --git a/src/compiler/constant-folding-reducer.cc b/src/compiler/constant-folding-reducer.cc +index 5e74ba75352cc3e7bf29a83ee72273e45720907b..4059e47c2db00e0df82296fa63e09147095f7ba7 100644 +--- a/src/compiler/constant-folding-reducer.cc ++++ b/src/compiler/constant-folding-reducer.cc +@@ -66,7 +66,8 @@ ConstantFoldingReducer::~ConstantFoldingReducer() = default; + Reduction ConstantFoldingReducer::Reduce(Node* node) { + if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) && + node->op()->HasProperty(Operator::kEliminatable) && +- node->opcode() != IrOpcode::kFinishRegion) { ++ node->opcode() != IrOpcode::kFinishRegion && ++ node->opcode() != IrOpcode::kTypeGuard) { + Node* constant = TryGetConstant(jsgraph(), node); + if (constant != nullptr) { + DCHECK(NodeProperties::IsTyped(constant)); From c6b44676e63fdb62e52df30ece7b3c7357849adc Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 17 Apr 2023 16:18:21 +0100 Subject: [PATCH 125/172] chore: cherry-pick c605df24af3c from v8 (#37980) * chore: [22-x-y] cherry-pick c605df24af3c from v8 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: electron-patch-conflict-fixer[bot] <83340002+electron-patch-conflict-fixer[bot]@users.noreply.github.com> --- patches/v8/.patches | 1 + patches/v8/cherry-pick-c605df24af3c.patch | 36 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 patches/v8/cherry-pick-c605df24af3c.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 60f7899c0d253..97bd6ad2bfc9e 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -13,4 +13,5 @@ cherry-pick-e17eee4894be.patch cherry-pick-aeceeb2187a6.patch cherry-pick-546e00df97ac.patch cherry-pick-f6ddbf42b1ea.patch +cherry-pick-c605df24af3c.patch cherry-pick-f4b66ae451c2.patch diff --git a/patches/v8/cherry-pick-c605df24af3c.patch b/patches/v8/cherry-pick-c605df24af3c.patch new file mode 100644 index 0000000000000..fc4f4a54f7dc9 --- /dev/null +++ b/patches/v8/cherry-pick-c605df24af3c.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Sheludko <ishell@chromium.org> +Date: Wed, 12 Apr 2023 16:12:16 +0200 +Subject: Make Error.captureStackTrace() a no-op for global object + +(cherry picked from commit fa81078cca6964def7a3833704e0dba7b05065d8) + +Bug: chromium:1432210 +Change-Id: I8aa4c3f1d9ecbfffce503085c2879416ff916c69 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4417690 +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Reviewed-by: Tobias Tebbi <tebbi@chromium.org> +Commit-Queue: Tobias Tebbi <tebbi@chromium.org> +Auto-Submit: Igor Sheludko <ishell@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#87045} +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4419050 +Reviewed-by: Igor Sheludko <ishell@chromium.org> +Reviewed-by: Lutz Vahl <vahl@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.2@{#31} +Cr-Branched-From: 755511a138609ac5939449a8ac615c15603a4454-refs/heads/11.2.214@{#1} +Cr-Branched-From: e6b1ccefb0f0f1ff8d310578878130dc53d73749-refs/heads/main@{#86014} + +diff --git a/src/builtins/builtins-error.cc b/src/builtins/builtins-error.cc +index adb180fba89b61279895e0427caa71703769e28a..4a8dec419d3f483826467a7244b89ad03fa7ff1f 100644 +--- a/src/builtins/builtins-error.cc ++++ b/src/builtins/builtins-error.cc +@@ -35,6 +35,9 @@ BUILTIN(ErrorCaptureStackTrace) { + THROW_NEW_ERROR_RETURN_FAILURE( + isolate, NewTypeError(MessageTemplate::kInvalidArgument, object_obj)); + } ++ if (object_obj->IsJSGlobalProxy()) { ++ return ReadOnlyRoots(isolate).undefined_value(); ++ } + + Handle<JSObject> object = Handle<JSObject>::cast(object_obj); + Handle<Object> caller = args.atOrUndefined(isolate, 2); From 7fd1f3da64879537d47c637ac4b621dd59c92788 Mon Sep 17 00:00:00 2001 From: GhostlyDark <31742919+GhostlyDark@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:24:39 +0200 Subject: [PATCH 126/172] fix: set background color for menu bar on Windows (#37991) --- shell/browser/ui/views/menu_bar.cc | 15 ++++++++++++--- shell/browser/ui/views/menu_bar.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/shell/browser/ui/views/menu_bar.cc b/shell/browser/ui/views/menu_bar.cc index 7a0ba8139e1f0..0ec33726417b3 100644 --- a/shell/browser/ui/views/menu_bar.cc +++ b/shell/browser/ui/views/menu_bar.cc @@ -35,12 +35,11 @@ const char MenuBar::kViewClassName[] = "ElectronMenuBar"; MenuBar::MenuBar(NativeWindow* window, RootView* root_view) : background_color_(kDefaultColor), window_(window), root_view_(root_view) { const ui::NativeTheme* theme = root_view_->GetNativeTheme(); - RefreshColorCache(theme); - UpdateViewColors(); #if BUILDFLAG(IS_WIN) SetBackground(views::CreateThemedSolidBackground(ui::kColorMenuBackground)); - background_color_ = GetBackground()->get_color(); #endif + RefreshColorCache(theme); + UpdateViewColors(); SetFocusBehavior(FocusBehavior::ALWAYS); SetLayoutManager(std::make_unique<views::BoxLayout>( views::BoxLayout::Orientation::kHorizontal)); @@ -209,6 +208,14 @@ void MenuBar::ButtonPressed(size_t id, const ui::Event& event) { menu_delegate->AddObserver(this); } +void MenuBar::ViewHierarchyChanged( + const views::ViewHierarchyChangedDetails& details) { + views::AccessiblePaneView::ViewHierarchyChanged(details); +#if BUILDFLAG(IS_WIN) + background_color_ = GetBackground()->get_color(); +#endif +} + void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) { if (theme) { #if BUILDFLAG(IS_LINUX) @@ -217,6 +224,8 @@ void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) { gtk::GetFgColor("GtkMenuBar#menubar GtkMenuItem#menuitem GtkLabel"); disabled_color_ = gtk::GetFgColor( "GtkMenuBar#menubar GtkMenuItem#menuitem:disabled GtkLabel"); +#elif BUILDFLAG(IS_WIN) + background_color_ = GetBackground()->get_color(); #endif } } diff --git a/shell/browser/ui/views/menu_bar.h b/shell/browser/ui/views/menu_bar.h index 91546fb33cc55..b4beb95a723e9 100644 --- a/shell/browser/ui/views/menu_bar.h +++ b/shell/browser/ui/views/menu_bar.h @@ -50,6 +50,9 @@ class MenuBar : public views::AccessiblePaneView, ElectronMenuModel** menu_model, views::MenuButton** button); + void ViewHierarchyChanged( + const views::ViewHierarchyChangedDetails& details) override; + private: // MenuDelegate::Observer: void OnBeforeExecuteCommand() override; From f0685b60a724752e57d08c7c35761df46fec5bb6 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Tue, 18 Apr 2023 02:11:55 +0100 Subject: [PATCH 127/172] chore: cherry-pick 86fc0e9bedaf from chromium (#37665) --- patches/chromium/.patches | 3 +- ...revent_potential_integer_overflow_in.patch | 12 +++--- ...low_in_persistentmemoryallocator_1_2.patch | 37 +++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 patches/chromium/prevent_potential_integer_overflow_in_persistentmemoryallocator_1_2.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 0a4ea51087d3c..e962c0980bc04 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -137,8 +137,9 @@ cherry-pick-0407102d19b9.patch fix_crash_in_annotationagentimpl.patch cherry-pick-bfd926be8178.patch cherry-pick-9aa4c45f21b1.patch -m108-lts_prevent_potential_integer_overflow_in.patch m108-lts_do_not_register_browser_watcher_activity_report_with.patch +prevent_potential_integer_overflow_in_persistentmemoryallocator_1_2.patch +m108-lts_prevent_potential_integer_overflow_in.patch cherry-pick-38de42d2bbc3.patch cherry-pick-8731bd8a30f6.patch cherry-pick-26bfa5807606.patch diff --git a/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch b/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch index 38363c3fa6000..c9ca3c9365d25 100644 --- a/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch +++ b/patches/chromium/m108-lts_prevent_potential_integer_overflow_in.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Will Harris <wfh@chromium.org> Date: Thu, 2 Mar 2023 17:21:30 +0000 -Subject: Prevent potential integer overflow in PersistentMemoryAllocator +Subject: Prevent potential integer overflow in PersistentMemoryAllocator (2/2) https://crrev.com/c/4250177 added an extra check for potential integer overflow in GetAllocSize but forgot to add the same @@ -29,25 +29,25 @@ Cr-Commit-Position: refs/branch-heads/5359@{#1402} Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc -index bc4618bf30832d010570e8a490d3d893f064237b..d8146e96cf425adbf79a4ec484fcf72d151a888d 100644 +index b7edfc04c307662450f3a39c20142c3593fbacde..85b5290d8955240f8044054a280105e3f8362714 100644 --- a/base/metrics/persistent_memory_allocator.cc +++ b/base/metrics/persistent_memory_allocator.cc -@@ -881,8 +881,13 @@ PersistentMemoryAllocator::GetBlock(Reference ref, +@@ -884,8 +884,13 @@ PersistentMemoryAllocator::GetBlock(Reference ref, if (ref % kAllocAlignment != 0) return nullptr; size += sizeof(BlockHeader); - if (ref + size > mem_size_) + uint32_t total_size; + if (!base::CheckAdd(ref, size).AssignIfValid(&total_size)) { - return nullptr; ++ return nullptr; + } + if (total_size > mem_size_) { -+ return nullptr; + return nullptr; + } // Validation of referenced block-header. if (!free_ok) { -@@ -892,8 +897,13 @@ PersistentMemoryAllocator::GetBlock(Reference ref, +@@ -895,8 +900,13 @@ PersistentMemoryAllocator::GetBlock(Reference ref, return nullptr; if (block->size < size) return nullptr; diff --git a/patches/chromium/prevent_potential_integer_overflow_in_persistentmemoryallocator_1_2.patch b/patches/chromium/prevent_potential_integer_overflow_in_persistentmemoryallocator_1_2.patch new file mode 100644 index 0000000000000..3322ed148b88a --- /dev/null +++ b/patches/chromium/prevent_potential_integer_overflow_in_persistentmemoryallocator_1_2.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Will Harris <wfh@chromium.org> +Date: Thu, 2 Mar 2023 16:49:42 +0000 +Subject: Prevent potential integer overflow in PersistentMemoryAllocator (1/2) + +BUG=1415328 + +(cherry picked from commit 19de280a0c28065acf2a7e001af5c981698a461c) + +Change-Id: I66dcae6a1aacc1310ddd715033b3704c932b9800 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4250177 +Commit-Queue: Will Harris <wfh@chromium.org> +Commit-Queue: Alexei Svitkine <asvitkine@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1105177} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4279513 +Commit-Queue: Zakhar Voit <voit@google.com> +Owners-Override: Victor-Gabriel Savu <vsavu@google.com> +Reviewed-by: Victor-Gabriel Savu <vsavu@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1400} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc +index bc4618bf30832d010570e8a490d3d893f064237b..b7edfc04c307662450f3a39c20142c3593fbacde 100644 +--- a/base/metrics/persistent_memory_allocator.cc ++++ b/base/metrics/persistent_memory_allocator.cc +@@ -531,7 +531,10 @@ size_t PersistentMemoryAllocator::GetAllocSize(Reference ref) const { + uint32_t size = block->size; + // Header was verified by GetBlock() but a malicious actor could change + // the value between there and here. Check it again. +- if (size <= sizeof(BlockHeader) || ref + size > mem_size_) { ++ uint32_t total_size; ++ if (size <= sizeof(BlockHeader) || ++ !base::CheckAdd(ref, size).AssignIfValid(&total_size) || ++ total_size > mem_size_) { + SetCorrupt(); + return 0; + } From ea7e3c80ee59aa1d74a1b8b0d303856e19a2b97c Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Sun, 23 Apr 2023 21:14:29 +0100 Subject: [PATCH 128/172] chore: cherry-pick aed05b609629 from angle (#38064) * chore: cherry-pick aed05b609629 from angle * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/angle/.patches | 1 + patches/angle/cherry-pick-aed05b609629.patch | 108 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 patches/angle/cherry-pick-aed05b609629.patch diff --git a/patches/angle/.patches b/patches/angle/.patches index f6886ebbdb5fe..25c7c58b6b43a 100644 --- a/patches/angle/.patches +++ b/patches/angle/.patches @@ -1,3 +1,4 @@ fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch cherry-pick-55e2b6daba9d.patch cherry-pick-ce029c91a662.patch +cherry-pick-aed05b609629.patch diff --git a/patches/angle/cherry-pick-aed05b609629.patch b/patches/angle/cherry-pick-aed05b609629.patch new file mode 100644 index 0000000000000..11d55dd58756a --- /dev/null +++ b/patches/angle/cherry-pick-aed05b609629.patch @@ -0,0 +1,108 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Geoff Lang <geofflang@chromium.org> +Date: Fri, 31 Mar 2023 16:44:35 -0400 +Subject: M112: Mark RGBX and BGRX formats as having 8 unused bits. + +This makes sure that pixelBytes ends up being 4 and fixes potential +buffer size validation. + +Fix EGL configs using pixelBytes to compute EGL_BUFFER_SIZE which +is not supposed to include unused bits. This is covered by +dEQP-EGL.functional.query_config.constraints.color_buffer_size + +Bug: chromium:1404790 +Change-Id: Ie0480cbdc6229c4bb3a6c6242337eaed5a3ae3b7 +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4428752 +Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> + +diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp +index 76273f3be3406a1c4be11c8fe564e3f703aed4b9..4014953311976b0f1ae2d1842e8fced75ffecfc9 100644 +--- a/src/libANGLE/formatutils.cpp ++++ b/src/libANGLE/formatutils.cpp +@@ -549,6 +549,21 @@ bool InternalFormat::isDepthOrStencil() const + return depthBits != 0 || stencilBits != 0; + } + ++GLuint InternalFormat::getEGLConfigBufferSize() const ++{ ++ // EGL config's EGL_BUFFER_SIZE is measured in bits and is the sum of all the color channels for ++ // color formats or the luma channels for luma formats. It ignores unused bits so compute the ++ // bit count by summing instead of using pixelBytes. ++ if (isLUMA()) ++ { ++ return luminanceBits + alphaBits; ++ } ++ else ++ { ++ return redBits + greenBits + blueBits + alphaBits; ++ } ++} ++ + Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {} + + Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {} +@@ -1141,10 +1156,10 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() + AddRGBAFormat(&map, GL_BGR10_A2_ANGLEX, true, 10, 10, 10, 2, 0, GL_BGRA_EXT, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported, NeverSupported); + + // Special format to emulate RGB8 with RGBA8 within ANGLE. +- AddRGBAFormat(&map, GL_RGBX8_ANGLE, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported, AlwaysSupported, NeverSupported); ++ AddRGBAXFormat(&map, GL_RGBX8_ANGLE, true, FB< 8, 8, 8, 0, 8, 0>(), GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, AlwaysSupported, AlwaysSupported, NeverSupported); + + // Special format to emulate BGR8 with BGRA8 within ANGLE. +- AddRGBAFormat(&map, GL_BGRX8_ANGLEX, true, 8, 8, 8, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported); ++ AddRGBAXFormat(&map, GL_BGRX8_ANGLEX, true, FB< 8, 8, 8, 0, 8, 0>(), GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, NeverSupported, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported); + + // This format is supported on ES 2.0 with two extensions, so keep it out-of-line to not widen the table above even more. + // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer | Blend +diff --git a/src/libANGLE/formatutils.h b/src/libANGLE/formatutils.h +index 64cc42ec1f50ea017216063896ba2c07296cde37..e6154072365a8a253937a3f148ae12f7199c593c 100644 +--- a/src/libANGLE/formatutils.h ++++ b/src/libANGLE/formatutils.h +@@ -205,6 +205,8 @@ struct InternalFormat + bool isInt() const; + bool isDepthOrStencil() const; + ++ GLuint getEGLConfigBufferSize() const; ++ + bool operator==(const InternalFormat &other) const; + bool operator!=(const InternalFormat &other) const; + +diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +index cc56e9868248a192b6c22e650528986c88722503..040623866da9b78ca66efb7de4f8678dd98f5f1c 100644 +--- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp ++++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +@@ -1242,7 +1242,7 @@ egl::ConfigSet Renderer11::generateConfigs() + egl::Config config; + config.renderTargetFormat = colorBufferInternalFormat; + config.depthStencilFormat = depthStencilBufferInternalFormat; +- config.bufferSize = colorBufferFormatInfo.pixelBytes * 8; ++ config.bufferSize = colorBufferFormatInfo.getEGLConfigBufferSize(); + config.redSize = colorBufferFormatInfo.redBits; + config.greenSize = colorBufferFormatInfo.greenBits; + config.blueSize = colorBufferFormatInfo.blueBits; +diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +index d80997392d2d5d25cadc1381c84929401bce90a9..6979fe5445360e6703cdb35fd9a15a6e34d188c8 100644 +--- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp ++++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +@@ -523,7 +523,7 @@ egl::ConfigSet Renderer9::generateConfigs() + egl::Config config; + config.renderTargetFormat = colorBufferInternalFormat; + config.depthStencilFormat = depthStencilBufferInternalFormat; +- config.bufferSize = colorBufferFormatInfo.pixelBytes * 8; ++ config.bufferSize = colorBufferFormatInfo.getEGLConfigBufferSize(); + config.redSize = colorBufferFormatInfo.redBits; + config.greenSize = colorBufferFormatInfo.greenBits; + config.blueSize = colorBufferFormatInfo.blueBits; +diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp +index f49b24744682910ae5142f784c9e01ba1977c360..f601b516441fdb4db9e17db5ad22cb6198755e99 100644 +--- a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp ++++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp +@@ -1238,7 +1238,7 @@ egl::Config GenerateDefaultConfig(DisplayVk *display, + + config.renderTargetFormat = colorFormat.internalFormat; + config.depthStencilFormat = depthStencilFormat.internalFormat; +- config.bufferSize = colorFormat.pixelBytes * 8; ++ config.bufferSize = colorFormat.getEGLConfigBufferSize(); + config.redSize = colorFormat.redBits; + config.greenSize = colorFormat.greenBits; + config.blueSize = colorFormat.blueBits; From 85317c3109122da063eae9dc09ad69a816a73d78 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Sun, 23 Apr 2023 21:15:35 +0100 Subject: [PATCH 129/172] chore: cherry-pick 63686953dc22 from chromium (#38062) * chore: cherry-pick 63686953dc22 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-63686953dc22.patch | 124 ++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 patches/chromium/cherry-pick-63686953dc22.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index e962c0980bc04..0e11b0a56c16c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -149,3 +149,4 @@ cherry-pick-1235110fce18.patch cherry-pick-b041159d06ad.patch cherry-pick-d6946b70b431.patch cherry-pick-d9081493c4b2.patch +cherry-pick-63686953dc22.patch diff --git a/patches/chromium/cherry-pick-63686953dc22.patch b/patches/chromium/cherry-pick-63686953dc22.patch new file mode 100644 index 0000000000000..63662f72ccae0 --- /dev/null +++ b/patches/chromium/cherry-pick-63686953dc22.patch @@ -0,0 +1,124 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Florian Leimgruber <fleimgruber@google.com> +Date: Thu, 6 Apr 2023 09:21:41 +0000 +Subject: Add lock to AlternativeStateNameMap. + +To prevent the class from accessing its localized_state_names_map_ and +localized_state_names_reverse_lookup_map_ members, a lock is added. It +locks all reads/write from the aforementioned members. + +(cherry picked from commit dd848883aa0d7d88520846bbf6735eaae9f2b60e) + +Bug: 1360571, 1414241, 1425951 +Change-Id: Ic01b0cba3878748617863274deb04ec9e13645d4 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4352658 +Reviewed-by: Christoph Schwering <schwering@google.com> +Commit-Queue: Florian Leimgruber <fleimgruber@google.com> +Cr-Original-Commit-Position: refs/heads/main@{#1119411} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4402262 +Auto-Submit: Florian Leimgruber <fleimgruber@google.com> +Cr-Commit-Position: refs/branch-heads/5615@{#1147} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/components/autofill/core/browser/geo/alternative_state_name_map.cc b/components/autofill/core/browser/geo/alternative_state_name_map.cc +index d217082a0faf23d2fd74dce8eec1043d83b5e509..ed22752c50f15e1f45e48b9ef561b0cb7134fba8 100644 +--- a/components/autofill/core/browser/geo/alternative_state_name_map.cc ++++ b/components/autofill/core/browser/geo/alternative_state_name_map.cc +@@ -53,7 +53,6 @@ AlternativeStateNameMap::GetCanonicalStateName( + const CountryCode& country_code, + const StateName& state_name, + bool is_state_name_normalized) const { +- DCHECK_CALLED_ON_VALID_SEQUENCE(alternative_state_name_map_sequence_checker_); + // Example: + // Entries in |localized_state_names_map_| are: + // ("DE", "Bavaria") -> { +@@ -73,6 +72,7 @@ AlternativeStateNameMap::GetCanonicalStateName( + if (!is_state_name_normalized) + normalized_state_name = NormalizeStateName(state_name); + ++ base::AutoLock lock(lock_); + auto it = localized_state_names_reverse_lookup_map_.find( + {country_code, normalized_state_name}); + if (it != localized_state_names_reverse_lookup_map_.end()) +@@ -84,8 +84,6 @@ AlternativeStateNameMap::GetCanonicalStateName( + absl::optional<StateEntry> AlternativeStateNameMap::GetEntry( + const CountryCode& country_code, + const StateName& state_string_from_profile) const { +- DCHECK_CALLED_ON_VALID_SEQUENCE(alternative_state_name_map_sequence_checker_); +- + StateName normalized_state_string_from_profile = + NormalizeStateName(state_string_from_profile); + absl::optional<CanonicalStateName> canonical_state_name = +@@ -93,6 +91,7 @@ absl::optional<StateEntry> AlternativeStateNameMap::GetEntry( + /*is_state_name_normalized=*/true); + + if (canonical_state_name) { ++ base::AutoLock lock(lock_); + auto it = localized_state_names_map_.find( + {country_code, canonical_state_name.value()}); + if (it != localized_state_names_map_.end()) +@@ -108,8 +107,6 @@ void AlternativeStateNameMap::AddEntry( + const StateEntry& state_entry, + const std::vector<StateName>& normalized_alternative_state_names, + const CanonicalStateName& normalized_canonical_state_name) { +- DCHECK_CALLED_ON_VALID_SEQUENCE(alternative_state_name_map_sequence_checker_); +- + // Example: + // AddEntry("DE", "Bavaria", { + // "canonical_name": "Bayern", +@@ -126,12 +123,15 @@ void AlternativeStateNameMap::AddEntry( + // ("DE", "Bayern") -> "Bayern" + // ("DE", "BY") -> "Bayern" + // ("DE", "Bavaria") -> "Bayern" +- if (localized_state_names_map_.size() == kMaxMapSize || +- GetCanonicalStateName(country_code, normalized_state_value_from_profile, ++ if (GetCanonicalStateName(country_code, normalized_state_value_from_profile, + /*is_state_name_normalized=*/true)) { + return; + } + ++ base::AutoLock lock(lock_); ++ if (localized_state_names_map_.size() == kMaxMapSize) { ++ return; ++ } + localized_state_names_map_[{country_code, normalized_canonical_state_name}] = + state_entry; + for (const auto& alternative_name : normalized_alternative_state_names) { +@@ -141,12 +141,12 @@ void AlternativeStateNameMap::AddEntry( + } + + bool AlternativeStateNameMap::IsLocalisedStateNamesMapEmpty() const { +- DCHECK_CALLED_ON_VALID_SEQUENCE(alternative_state_name_map_sequence_checker_); ++ base::AutoLock lock(lock_); + return localized_state_names_map_.empty(); + } + + void AlternativeStateNameMap::ClearAlternativeStateNameMap() { +- DCHECK_CALLED_ON_VALID_SEQUENCE(alternative_state_name_map_sequence_checker_); ++ base::AutoLock lock(lock_); + localized_state_names_map_.clear(); + localized_state_names_reverse_lookup_map_.clear(); + } +diff --git a/components/autofill/core/browser/geo/alternative_state_name_map.h b/components/autofill/core/browser/geo/alternative_state_name_map.h +index d20cdf8a02fff5d3c3ea91ef3aa67c6522804692..58dd754bfbf39fd24c82e6d46ccb566008a4cd73 100644 +--- a/components/autofill/core/browser/geo/alternative_state_name_map.h ++++ b/components/autofill/core/browser/geo/alternative_state_name_map.h +@@ -9,7 +9,7 @@ + + #include "base/i18n/case_conversion.h" + #include "base/no_destructor.h" +-#include "base/sequence_checker.h" ++#include "base/synchronization/lock.h" + #include "base/types/strong_alias.h" + #include "components/autofill/core/browser/proto/states.pb.h" + #include "third_party/abseil-cpp/absl/types/optional.h" +@@ -177,7 +177,8 @@ class AlternativeStateNameMap { + CaseInsensitiveLessComparator> + localized_state_names_reverse_lookup_map_; + +- SEQUENCE_CHECKER(alternative_state_name_map_sequence_checker_); ++ // TODO(crbug.com/1425951): Remove lock. ++ mutable base::Lock lock_; + }; + + } // namespace autofill From 4c435b27e0a95f479d73154b77631649077a386d Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Sun, 23 Apr 2023 21:54:38 +0100 Subject: [PATCH 130/172] chore: cherry-pick 8421a9eebd8a and 4dc670a8c557 from skia (#38066) chore: cherry-pick 9e1af6fa14ff from skia --- patches/config.json | 4 +- patches/skia/.patches | 2 + ..._stack_limits_on_function_parameters.patch | 152 +++++++++ ...its_on_struct_and_array_declarations.patch | 291 ++++++++++++++++++ 4 files changed, 448 insertions(+), 1 deletion(-) create mode 100644 patches/skia/.patches create mode 100644 patches/skia/enforce_program_stack_limits_on_function_parameters.patch create mode 100644 patches/skia/enforce_size_limits_on_struct_and_array_declarations.patch diff --git a/patches/config.json b/patches/config.json index 32ae78a4fa1d3..14dd869b10a6b 100644 --- a/patches/config.json +++ b/patches/config.json @@ -23,5 +23,7 @@ "src/electron/patches/ReactiveObjC": "src/third_party/squirrel.mac/vendor/ReactiveObjC", - "src/electron/patches/pdfium": "src/third_party/pdfium" + "src/electron/patches/pdfium": "src/third_party/pdfium", + + "src/electron/patches/skia": "src/third_party/skia" } diff --git a/patches/skia/.patches b/patches/skia/.patches new file mode 100644 index 0000000000000..cad037071f416 --- /dev/null +++ b/patches/skia/.patches @@ -0,0 +1,2 @@ +enforce_program_stack_limits_on_function_parameters.patch +enforce_size_limits_on_struct_and_array_declarations.patch diff --git a/patches/skia/enforce_program_stack_limits_on_function_parameters.patch b/patches/skia/enforce_program_stack_limits_on_function_parameters.patch new file mode 100644 index 0000000000000..d07b980a42525 --- /dev/null +++ b/patches/skia/enforce_program_stack_limits_on_function_parameters.patch @@ -0,0 +1,152 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Stiles <johnstiles@google.com> +Date: Wed, 12 Apr 2023 14:56:54 -0400 +Subject: Enforce program stack limits on function parameters. + +M108 merge issues: + resources/sksl/BUILD.bazel: + File doesn't exist in M108, tests are added manually to gn/sksl_tests.gni. + + gn/sksl_tests.gni: + Conflicting rts entries + + src/sksl/ir/SkSLFunctionDefinition.cpp: + - Conflicting includes + - visitStatement(): + Conflicting declarations of const Variable* var (const Variable& var + on 108) + +Previously, a function's parameter list did not count against its +stack size limit. + +Bug: chromium:1432603 +Change-Id: If49dce98f3155f3144a766c26b5a3a39401ce1b2 +Reviewed-on: https://skia-review.googlesource.com/c/skia/+/670236 +Auto-Submit: John Stiles <johnstiles@google.com> +Commit-Queue: John Stiles <johnstiles@google.com> +(cherry picked from commit 4dc748f14c6650cb45c7086a39af1760bfda41d2) + +diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni +index 2f0100b8b617d3d101660a34c183bcf51a39c11c..6af1a84c6ef8a8853b259815eb17e02cb5027541 100644 +--- a/gn/sksl_tests.gni ++++ b/gn/sksl_tests.gni +@@ -283,6 +283,7 @@ sksl_error_tests = [ + "/sksl/errors/VoidInStruct.rts", + "/sksl/errors/VoidVariable.rts", + "/sksl/errors/WhileTypeMismatch.sksl", ++ "/sksl/errors/ProgramTooLarge_Parameters.rts", + ] + + sksl_glsl_tests = [ +diff --git a/resources/sksl/errors/ProgramTooLarge_Parameters.rts b/resources/sksl/errors/ProgramTooLarge_Parameters.rts +new file mode 100644 +index 0000000000000000000000000000000000000000..cced977be40620ffc3b145837bd5ffe16b40295b +--- /dev/null ++++ b/resources/sksl/errors/ProgramTooLarge_Parameters.rts +@@ -0,0 +1,14 @@ ++struct S { ++ half4 ah4[1]; ++ half ah[99999]; ++ half4 h4; ++ half h; ++}; ++ ++void func(int small, ++ S big_chungus, ++ S no_report /*we don't need to report overflows past the first*/) {} ++ ++/*%%* ++variable 'big_chungus' exceeds the stack size limit ++*%%*/ +diff --git a/src/sksl/ir/SkSLFunctionDefinition.cpp b/src/sksl/ir/SkSLFunctionDefinition.cpp +index 45695a1effe1f98d4185aa4c17d6add29281044c..adfe62dfd22e2810c316cd806aaef16a05aca4ad 100644 +--- a/src/sksl/ir/SkSLFunctionDefinition.cpp ++++ b/src/sksl/ir/SkSLFunctionDefinition.cpp +@@ -37,6 +37,7 @@ + #include <forward_list> + #include <string_view> + #include <type_traits> ++#include <vector> + + namespace SkSL { + +@@ -88,9 +89,29 @@ std::unique_ptr<FunctionDefinition> FunctionDefinition::Convert(const Context& c + bool builtin) { + class Finalizer : public ProgramWriter { + public: +- Finalizer(const Context& context, const FunctionDeclaration& function) ++ Finalizer(const Context& context, const FunctionDeclaration& function, Position pos) + : fContext(context) +- , fFunction(function) {} ++ , fFunction(function) { ++ // Function parameters count as local variables. ++ for (const Variable* var : function.parameters()) { ++ this->addLocalVariable(var, pos); ++ } ++ } ++ ++ void addLocalVariable(const Variable* var, Position pos) { ++ // We count the number of slots used, but don't consider the precision of the base type. ++ // In practice, this reflects what GPUs actually do pretty well. (i.e., RelaxedPrecision ++ // math doesn't mean your variable takes less space.) We also don't attempt to reclaim ++ // slots at the end of a Block. ++ size_t prevSlotsUsed = fSlotsUsed; ++ fSlotsUsed = SkSafeMath::Add(fSlotsUsed, var->type().slotCount()); ++ // To avoid overzealous error reporting, only trigger the error at the first ++ // place where the stack limit is exceeded. ++ if (prevSlotsUsed < kVariableSlotLimit && fSlotsUsed >= kVariableSlotLimit) { ++ fContext.fErrors->error(pos, "variable '" + std::string(var->name()) + ++ "' exceeds the stack size limit"); ++ } ++ } + + ~Finalizer() override { + SkASSERT(fBreakableLevel == 0); +@@ -109,24 +130,12 @@ std::unique_ptr<FunctionDefinition> FunctionDefinition::Convert(const Context& c + bool visitStatement(Statement& stmt) override { + switch (stmt.kind()) { + case Statement::Kind::kVarDeclaration: { +- // We count the number of slots used, but don't consider the precision of the +- // base type. In practice, this reflects what GPUs really do pretty well. +- // (i.e., RelaxedPrecision math doesn't mean your variable takes less space.) +- // We also don't attempt to reclaim slots at the end of a Block. +- size_t prevSlotsUsed = fSlotsUsed; + const Variable& var = stmt.as<VarDeclaration>().var(); + if (var.type().isOrContainsUnsizedArray()) { + fContext.fErrors->error(stmt.fPosition, + "unsized arrays are not permitted here"); +- break; +- } +- fSlotsUsed = SkSafeMath::Add(fSlotsUsed, var.type().slotCount()); +- // To avoid overzealous error reporting, only trigger the error at the first +- // place where the stack limit is exceeded. +- if (prevSlotsUsed < kVariableSlotLimit && fSlotsUsed >= kVariableSlotLimit) { +- fContext.fErrors->error(stmt.fPosition, +- "variable '" + std::string(var.name()) + +- "' exceeds the stack size limit"); ++ } else { ++ this->addLocalVariable(&var, stmt.fPosition); + } + break; + } +@@ -219,7 +228,7 @@ std::unique_ptr<FunctionDefinition> FunctionDefinition::Convert(const Context& c + using INHERITED = ProgramWriter; + }; + +- Finalizer(context, function).visitStatement(*body); ++ Finalizer(context, function, pos).visitStatement(*body); + if (function.isMain() && ProgramConfig::IsVertex(context.fConfig->fKind)) { + append_rtadjust_fixup_to_vertex_main(context, function, body->as<Block>()); + } +diff --git a/tests/sksl/errors/ProgramTooLarge_Parameters.glsl b/tests/sksl/errors/ProgramTooLarge_Parameters.glsl +new file mode 100644 +index 0000000000000000000000000000000000000000..d92c3256e82d52115621cf96d6dba99f62cdd945 +--- /dev/null ++++ b/tests/sksl/errors/ProgramTooLarge_Parameters.glsl +@@ -0,0 +1,6 @@ ++### Compilation failed: ++ ++error: 10: variable 'big_chungus' exceeds the stack size limit ++ S no_report /*we don't need to report overflows past the first*/) {} ++ ^^ ++1 error diff --git a/patches/skia/enforce_size_limits_on_struct_and_array_declarations.patch b/patches/skia/enforce_size_limits_on_struct_and_array_declarations.patch new file mode 100644 index 0000000000000..be388c56dc9cf --- /dev/null +++ b/patches/skia/enforce_size_limits_on_struct_and_array_declarations.patch @@ -0,0 +1,291 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Stiles <johnstiles@google.com> +Date: Thu, 13 Apr 2023 17:58:24 -0400 +Subject: Enforce size limits on struct and array declarations. + +M108 merge issues: + resources/sksl/BUILD.bazel: + File doesn't exist in M108, tests are added manually to gn/sksl_tests.gni. + + gn/sksl_tests.gni: + Conflicting rts entries + + tests/sksl/shared/Ossfuzz37900.* + Not present in 108, skipped. + + src/sksl/ir/SkSLType.cpp: + - Conflicting includes + - MakeStructType(): + - Conflicting function signature + - context isn't a parameter, used ThreadContext::Context() directly. + +This improves error reporting by more clearly attaching the error +message to the oversized type. + +Bug: chromium:1432603 +Change-Id: I26511f08aff22072cf4913abf7be2c49940a732c +Reviewed-on: https://skia-review.googlesource.com/c/skia/+/671377 +Commit-Queue: John Stiles <johnstiles@google.com> +(cherry picked from commit 1cbd33ecd73523f8d4bf88e9c5576303b39e5556) + +diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni +index 6af1a84c6ef8a8853b259815eb17e02cb5027541..20c2026322bf6f6ae6d19d4f649ddb0f5ed048ed 100644 +--- a/gn/sksl_tests.gni ++++ b/gn/sksl_tests.gni +@@ -284,6 +284,7 @@ sksl_error_tests = [ + "/sksl/errors/VoidVariable.rts", + "/sksl/errors/WhileTypeMismatch.sksl", + "/sksl/errors/ProgramTooLarge_Parameters.rts", ++ "/sksl/errors/ProgramTooLarge_Struct.rts", + ] + + sksl_glsl_tests = [ +diff --git a/resources/sksl/errors/ProgramTooLarge_Globals.rts b/resources/sksl/errors/ProgramTooLarge_Globals.rts +index af0ad17ce7a591d99a9cbb062278b99046bd2fe8..ee2556bb1a99404ebe53641064bceff3a553ea9a 100644 +--- a/resources/sksl/errors/ProgramTooLarge_Globals.rts ++++ b/resources/sksl/errors/ProgramTooLarge_Globals.rts +@@ -6,11 +6,10 @@ struct S { + }; + + int small; +-S medium; +-S large[10]; +-S extra_large[100]; +-S xxl[50000]; +- ++S medium[30]; ++S large[50]; ++S extra_large[70]; ++S xxl[90]; + + /*%%* + global variable 'extra_large' exceeds the size limit +diff --git a/resources/sksl/errors/ProgramTooLarge_Parameters.rts b/resources/sksl/errors/ProgramTooLarge_Parameters.rts +index cced977be40620ffc3b145837bd5ffe16b40295b..4e15ebd53e683f2078efed6771202e61d7b7bdc5 100644 +--- a/resources/sksl/errors/ProgramTooLarge_Parameters.rts ++++ b/resources/sksl/errors/ProgramTooLarge_Parameters.rts +@@ -1,11 +1,14 @@ + struct S { + half4 ah4[1]; +- half ah[99999]; ++ half ah[99990]; + half4 h4; + half h; + }; + + void func(int small, ++ int parameters, ++ int are, ++ int allowed, + S big_chungus, + S no_report /*we don't need to report overflows past the first*/) {} + +diff --git a/resources/sksl/errors/ProgramTooLarge_Stack.rts b/resources/sksl/errors/ProgramTooLarge_Stack.rts +index 4f004368a17b79d960e5cc142db35d82fb627cbd..a8f5217359ad9dab1fdcfcaac862938c1d205f0a 100644 +--- a/resources/sksl/errors/ProgramTooLarge_Stack.rts ++++ b/resources/sksl/errors/ProgramTooLarge_Stack.rts +@@ -1,12 +1,12 @@ + struct S { + half4 ah4[1]; +- half ah[99999]; ++ half ah[99990]; + half4 h4; + half h; + }; + + void func() { +- int small; ++ int small, variables, are, allowed; + S big_chungus; + S no_report; // we don't need to report overflows past the first + } +diff --git a/resources/sksl/errors/ProgramTooLarge_Struct.rts b/resources/sksl/errors/ProgramTooLarge_Struct.rts +new file mode 100644 +index 0000000000000000000000000000000000000000..690e1d37311b5d0745d20d71b48738a69c5c3ecb +--- /dev/null ++++ b/resources/sksl/errors/ProgramTooLarge_Struct.rts +@@ -0,0 +1,24 @@ ++struct A { ++ int4 big[25001]; // 100,004 slots ++}; ++ ++struct B { ++ int4 a[12500]; // 50,000 slots ++ int b[49999]; // 99,999 slots ++ int c; // 100,000 slots ++}; ++ ++struct C { ++ int a[99999]; // 99,999 slots (safe) ++}; ++ ++struct D { ++ C a; // 99,999 slots ++ int b; // 100,000 slots ++}; ++ ++/*%%* ++array size is too large ++struct is too large ++struct is too large ++*%%*/ +diff --git a/src/sksl/dsl/DSLType.cpp b/src/sksl/dsl/DSLType.cpp +index 5648c51c92b61430d31497f71cea73ff19ef8a97..aacdfb000527105ea4fff8b6dc3ba2c38d0e33f4 100644 +--- a/src/sksl/dsl/DSLType.cpp ++++ b/src/sksl/dsl/DSLType.cpp +@@ -266,7 +266,7 @@ DSLExpression DSLType::Construct(DSLType type, SkSpan<DSLExpression> argArray) { + + DSLType Array(const DSLType& base, int count, Position pos) { + count = base.skslType().convertArraySize(ThreadContext::Context(), pos, +- DSLExpression(count, pos).release()); ++ DSLExpression(count, pos).release()); + if (!count) { + return DSLType(kPoison_Type); + } +@@ -278,7 +278,7 @@ DSLType UnsizedArray(const DSLType& base, Position pos) { + return DSLType(kPoison_Type); + } + return ThreadContext::SymbolTable()->addArrayDimension(&base.skslType(), +- SkSL::Type::kUnsizedArray); ++ SkSL::Type::kUnsizedArray); + } + + DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos) { +diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp +index 04c1946509ee263ca1c591cab6353765a84a28d0..c474db149f5e4844cc873b1746a0b103f209390f 100644 +--- a/src/sksl/ir/SkSLType.cpp ++++ b/src/sksl/ir/SkSLType.cpp +@@ -12,10 +12,12 @@ + #include "include/private/SkTFitsIn.h" + #include "include/sksl/SkSLErrorReporter.h" + #include "src/core/SkMathPriv.h" ++#include "src/core/SkSafeMath.h" + #include "src/sksl/SkSLBuiltinTypes.h" + #include "src/sksl/SkSLConstantFolder.h" + #include "src/sksl/SkSLContext.h" + #include "src/sksl/SkSLProgramSettings.h" ++#include "src/sksl/SkSLThreadContext.h" + #include "src/sksl/ir/SkSLConstructorArrayCast.h" + #include "src/sksl/ir/SkSLConstructorCompoundCast.h" + #include "src/sksl/ir/SkSLConstructorScalarCast.h" +@@ -648,6 +650,17 @@ std::unique_ptr<Type> Type::MakeScalarType(std::string_view name, const char* ab + + std::unique_ptr<Type> Type::MakeStructType(Position pos, std::string_view name, + std::vector<Field> fields, bool interfaceBlock) { ++ size_t slots = 0; ++ for (const Field& field : fields) { ++ if (field.fType->isUnsizedArray()) { ++ continue; ++ } ++ slots = SkSafeMath::Add(slots, field.fType->slotCount()); ++ if (slots >= kVariableSlotLimit) { ++ ThreadContext::Context().fErrors->error(pos, "struct is too large"); ++ break; ++ } ++ } + return std::make_unique<StructType>(pos, name, std::move(fields), interfaceBlock); + } + +@@ -1120,8 +1133,9 @@ bool Type::checkIfUsableInArray(const Context& context, Position arrayPos) const + return true; + } + +-SKSL_INT Type::convertArraySize(const Context& context, Position arrayPos, +- std::unique_ptr<Expression> size) const { ++SKSL_INT Type::convertArraySize(const Context& context, ++ Position arrayPos, ++ std::unique_ptr<Expression> size) const { + size = context.fTypes.fInt->coerceExpression(std::move(size), context); + if (!size) { + return 0; +@@ -1138,7 +1152,7 @@ SKSL_INT Type::convertArraySize(const Context& context, Position arrayPos, + context.fErrors->error(size->fPosition, "array size must be positive"); + return 0; + } +- if (!SkTFitsIn<int32_t>(count)) { ++ if (SkSafeMath::Mul(this->slotCount(), count) > kVariableSlotLimit) { + context.fErrors->error(size->fPosition, "array size is too large"); + return 0; + } +diff --git a/tests/sksl/errors/ProgramTooLarge_Globals.glsl b/tests/sksl/errors/ProgramTooLarge_Globals.glsl +index 406949ad38ecb6ea80bbba505cdf5ad9346c9446..ccb7706c3a66a7b41fd5c6444ea1e9967f314282 100644 +--- a/tests/sksl/errors/ProgramTooLarge_Globals.glsl ++++ b/tests/sksl/errors/ProgramTooLarge_Globals.glsl +@@ -1,6 +1,6 @@ + ### Compilation failed: + + error: 11: global variable 'extra_large' exceeds the size limit +-S extra_large[100]; +-^^^^^^^^^^^^^^^^^^ ++S extra_large[70]; ++^^^^^^^^^^^^^^^^^ + 1 error +diff --git a/tests/sksl/errors/ProgramTooLarge_Parameters.glsl b/tests/sksl/errors/ProgramTooLarge_Parameters.glsl +index d92c3256e82d52115621cf96d6dba99f62cdd945..3ece6f379c8ab64dd846d856301217f95eb3e7ff 100644 +--- a/tests/sksl/errors/ProgramTooLarge_Parameters.glsl ++++ b/tests/sksl/errors/ProgramTooLarge_Parameters.glsl +@@ -1,6 +1,6 @@ + ### Compilation failed: + +-error: 10: variable 'big_chungus' exceeds the stack size limit ++error: 13: variable 'big_chungus' exceeds the stack size limit + S no_report /*we don't need to report overflows past the first*/) {} + ^^ + 1 error +diff --git a/tests/sksl/errors/ProgramTooLarge_Struct.glsl b/tests/sksl/errors/ProgramTooLarge_Struct.glsl +new file mode 100644 +index 0000000000000000000000000000000000000000..ebe47f700dfad807fbd7b774f5f2ce851ff28e64 +--- /dev/null ++++ b/tests/sksl/errors/ProgramTooLarge_Struct.glsl +@@ -0,0 +1,12 @@ ++### Compilation failed: ++ ++error: 2: array size is too large ++ int4 big[25001]; // 100,004 slots ++ ^^^^^^^^^^^^^^^ ++error: 5: struct is too large ++struct B { ++^^^^^^^^^^... ++error: 15: struct is too large ++struct D { ++^^^^^^^^^^... ++3 errors +diff --git a/tests/sksl/shared/Ossfuzz37900.asm.frag b/tests/sksl/shared/Ossfuzz37900.asm.frag +index 9751821fc01e704a2f2851c52d1e9489b204c4f7..5fb2b3c5fd467857b653f617976cc3b8af3a15fb 100644 +--- a/tests/sksl/shared/Ossfuzz37900.asm.frag ++++ b/tests/sksl/shared/Ossfuzz37900.asm.frag +@@ -1,6 +1,6 @@ + ### Compilation failed: + +-error: 2: variable 'a' exceeds the stack size limit ++error: 2: array size is too large + int[2147483646] a, b=a, c=a, d=a, e=a, f=a, g=a, h=a, i=a, j=a, k=a; +- ^^^^^^^^^^^^^^^^^ ++ ^^^^^^^^^^^^^^^ + 1 error +diff --git a/tests/sksl/shared/Ossfuzz37900.glsl b/tests/sksl/shared/Ossfuzz37900.glsl +index 9751821fc01e704a2f2851c52d1e9489b204c4f7..5fb2b3c5fd467857b653f617976cc3b8af3a15fb 100644 +--- a/tests/sksl/shared/Ossfuzz37900.glsl ++++ b/tests/sksl/shared/Ossfuzz37900.glsl +@@ -1,6 +1,6 @@ + ### Compilation failed: + +-error: 2: variable 'a' exceeds the stack size limit ++error: 2: array size is too large + int[2147483646] a, b=a, c=a, d=a, e=a, f=a, g=a, h=a, i=a, j=a, k=a; +- ^^^^^^^^^^^^^^^^^ ++ ^^^^^^^^^^^^^^^ + 1 error +diff --git a/tests/sksl/shared/Ossfuzz37900.metal b/tests/sksl/shared/Ossfuzz37900.metal +index 9751821fc01e704a2f2851c52d1e9489b204c4f7..5fb2b3c5fd467857b653f617976cc3b8af3a15fb 100644 +--- a/tests/sksl/shared/Ossfuzz37900.metal ++++ b/tests/sksl/shared/Ossfuzz37900.metal +@@ -1,6 +1,6 @@ + ### Compilation failed: + +-error: 2: variable 'a' exceeds the stack size limit ++error: 2: array size is too large + int[2147483646] a, b=a, c=a, d=a, e=a, f=a, g=a, h=a, i=a, j=a, k=a; +- ^^^^^^^^^^^^^^^^^ ++ ^^^^^^^^^^^^^^^ + 1 error From 29cdcb443aed63d949b6cf84d7fc632ca166b74a Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 24 Apr 2023 10:09:04 +0100 Subject: [PATCH 131/172] chore: cherry-pick 1d491fff578b, f7b87bea19d7 and 549d92d7ef35 from chromium (#38068) * chore: cherry-pick 1d491fff578b from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- patches/chromium/.patches | 3 + .../check_callback_availability_in.patch | 36 +++++++ ...oxyclientsocket_is_alive_after_write.patch | 41 ++++++++ ...emove_the_second_weakptrfactory_from.patch | 94 +++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 patches/chromium/check_callback_availability_in.patch create mode 100644 patches/chromium/merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch create mode 100644 patches/chromium/merge_m112_remove_the_second_weakptrfactory_from.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 0e11b0a56c16c..c92c971e32032 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -149,4 +149,7 @@ cherry-pick-1235110fce18.patch cherry-pick-b041159d06ad.patch cherry-pick-d6946b70b431.patch cherry-pick-d9081493c4b2.patch +merge_m112_remove_the_second_weakptrfactory_from.patch +merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch +check_callback_availability_in.patch cherry-pick-63686953dc22.patch diff --git a/patches/chromium/check_callback_availability_in.patch b/patches/chromium/check_callback_availability_in.patch new file mode 100644 index 0000000000000..6e1b16a275e61 --- /dev/null +++ b/patches/chromium/check_callback_availability_in.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kenichi Ishibashi <bashi@chromium.org> +Date: Tue, 18 Apr 2023 05:58:29 +0000 +Subject: Check callback availability in + SpdyProxyClientSocket::RunWriteCallback + +OnClose() could consume `write_callback_` so it may not be available +when RunWriteCallback() is invoked. + +Bug: 1428820 +Change-Id: I9a5ade62d67f5bf15e12d0915d1ad6098657ffd4 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4437791 +Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com> +Reviewed-by: Adam Rice <ricea@chromium.org> +Commit-Queue: Kenichi Ishibashi <bashi@chromium.org> +Cr-Commit-Position: refs/heads/main@{#1131689} + +diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc +index d9b67febc27cc99e5b3383a372451345cec6daaa..bdcf24a1cb65f5df291bd91784d68aa9c05e7b0d 100644 +--- a/net/spdy/spdy_proxy_client_socket.cc ++++ b/net/spdy/spdy_proxy_client_socket.cc +@@ -278,10 +278,11 @@ int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { + } + + void SpdyProxyClientSocket::RunWriteCallback(int result) { +- CHECK(write_callback_); +- + base::WeakPtr<SpdyProxyClientSocket> weak_ptr = weak_factory_.GetWeakPtr(); +- std::move(write_callback_).Run(result); ++ // `write_callback_` might be consumed by OnClose(). ++ if (write_callback_) { ++ std::move(write_callback_).Run(result); ++ } + if (!weak_ptr) { + // `this` was already destroyed while running `write_callback_`. Must + // return immediately without touching any field member. diff --git a/patches/chromium/merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch b/patches/chromium/merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch new file mode 100644 index 0000000000000..d7720cf384c2d --- /dev/null +++ b/patches/chromium/merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kenichi Ishibashi <bashi@chromium.org> +Date: Sat, 8 Apr 2023 04:16:50 +0000 +Subject: Check SpdyProxyClientSocket is alive after write callback + +To ensure that we don't use any member field. + +(cherry picked from commit b71541b22ca19d5c3a7c01fedffe521b26577b72) + +Bug: 1428820 +Change-Id: Icf6677c652a47dc2fd2d01675e94cda031a015f2 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4394863 +Reviewed-by: Adam Rice <ricea@chromium.org> +Commit-Queue: Kenichi Ishibashi <bashi@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1125634} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4410322 +Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Auto-Submit: Kenichi Ishibashi <bashi@chromium.org> +Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Cr-Commit-Position: refs/branch-heads/5615@{#1172} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc +index 173fc5cdbb67958cc9ca43284ff989196b287a8e..d9b67febc27cc99e5b3383a372451345cec6daaa 100644 +--- a/net/spdy/spdy_proxy_client_socket.cc ++++ b/net/spdy/spdy_proxy_client_socket.cc +@@ -279,7 +279,14 @@ int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { + + void SpdyProxyClientSocket::RunWriteCallback(int result) { + CHECK(write_callback_); ++ ++ base::WeakPtr<SpdyProxyClientSocket> weak_ptr = weak_factory_.GetWeakPtr(); + std::move(write_callback_).Run(result); ++ if (!weak_ptr) { ++ // `this` was already destroyed while running `write_callback_`. Must ++ // return immediately without touching any field member. ++ return; ++ } + + if (end_stream_state_ == EndStreamState::kEndStreamReceived) { + base::ThreadTaskRunnerHandle::Get()->PostTask( diff --git a/patches/chromium/merge_m112_remove_the_second_weakptrfactory_from.patch b/patches/chromium/merge_m112_remove_the_second_weakptrfactory_from.patch new file mode 100644 index 0000000000000..7dc50e08fa363 --- /dev/null +++ b/patches/chromium/merge_m112_remove_the_second_weakptrfactory_from.patch @@ -0,0 +1,94 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kenichi Ishibashi <bashi@chromium.org> +Date: Sat, 8 Apr 2023 01:56:25 +0000 +Subject: Remove the second WeakPtrFactory from SpdyProxyClientSocket + +It was introduced [1] to work around an old issue that wouldn't happen +any more since we store a write callback in the class. Instead of having +the second WeakPtrFactory and moving the callback, we can just keep it +until RunWriteCallback() is called. + +This is a speculative fix for the linked bug. + +[1] https://codereview.chromium.org/338583003/ + +(cherry picked from commit 01b25615896b911e21103dd381fafc1f85886d91) + +Bug: 1428820 +Change-Id: I0b5af2675b68188e208c2ecd42293251b2722b28 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4393905 +Reviewed-by: Adam Rice <ricea@chromium.org> +Commit-Queue: Kenichi Ishibashi <bashi@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1125216} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4410320 +Auto-Submit: Kenichi Ishibashi <bashi@chromium.org> +Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Cr-Commit-Position: refs/branch-heads/5615@{#1171} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc +index 5984ecedb3a14274bc33efe20b407dd33bc8a410..173fc5cdbb67958cc9ca43284ff989196b287a8e 100644 +--- a/net/spdy/spdy_proxy_client_socket.cc ++++ b/net/spdy/spdy_proxy_client_socket.cc +@@ -123,7 +123,6 @@ void SpdyProxyClientSocket::Disconnect() { + + write_buffer_len_ = 0; + write_callback_.Reset(); +- write_callback_weak_factory_.InvalidateWeakPtrs(); + + next_state_ = STATE_DISCONNECTED; + +@@ -278,9 +277,9 @@ int SpdyProxyClientSocket::GetLocalAddress(IPEndPoint* address) const { + return spdy_stream_->GetLocalAddress(address); + } + +-void SpdyProxyClientSocket::RunWriteCallback(CompletionOnceCallback callback, +- int result) const { +- std::move(callback).Run(result); ++void SpdyProxyClientSocket::RunWriteCallback(int result) { ++ CHECK(write_callback_); ++ std::move(write_callback_).Run(result); + + if (end_stream_state_ == EndStreamState::kEndStreamReceived) { + base::ThreadTaskRunnerHandle::Get()->PostTask( +@@ -517,8 +516,7 @@ void SpdyProxyClientSocket::OnDataSent() { + // stream's write callback chain to unwind (see crbug.com/355511). + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::BindOnce(&SpdyProxyClientSocket::RunWriteCallback, +- write_callback_weak_factory_.GetWeakPtr(), +- std::move(write_callback_), rv)); ++ weak_factory_.GetWeakPtr(), rv)); + } + + void SpdyProxyClientSocket::OnTrailers(const spdy::Http2HeaderBlock& trailers) { +diff --git a/net/spdy/spdy_proxy_client_socket.h b/net/spdy/spdy_proxy_client_socket.h +index cbb961a68c93b9485bd0bf1c5e31014bdc95a84e..98b9e74427f48399bbc53bfad5b45a8dc18ab84b 100644 +--- a/net/spdy/spdy_proxy_client_socket.h ++++ b/net/spdy/spdy_proxy_client_socket.h +@@ -121,9 +121,9 @@ class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket, + STATE_CLOSED + }; + +- // Calls |callback.Run(result)|. Used to run a callback posted to the ++ // Calls `write_callback_(result)`. Used to run a callback posted to the + // message loop. +- void RunWriteCallback(CompletionOnceCallback callback, int result) const; ++ void RunWriteCallback(int result); + + void OnIOComplete(int result); + +@@ -195,13 +195,7 @@ class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket, + }; + EndStreamState end_stream_state_ = EndStreamState::kNone; + +- // The default weak pointer factory. + base::WeakPtrFactory<SpdyProxyClientSocket> weak_factory_{this}; +- +- // Only used for posting write callbacks. Weak pointers created by this +- // factory are invalidated in Disconnect(). +- base::WeakPtrFactory<SpdyProxyClientSocket> write_callback_weak_factory_{ +- this}; + }; + + } // namespace net From 518d3e490d005fc5c40964a59a7dcf7764e82a7a Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Mon, 24 Apr 2023 13:25:32 +0100 Subject: [PATCH 132/172] chore: cherry-pick 2b30a50d0e62 from chromium (#38058) * chore: [22-x-y] cherry-pick 2b30a50d0e62 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-2b30a50d0e62.patch | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 patches/chromium/cherry-pick-2b30a50d0e62.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index c92c971e32032..98ecb7b09f9b1 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -149,6 +149,7 @@ cherry-pick-1235110fce18.patch cherry-pick-b041159d06ad.patch cherry-pick-d6946b70b431.patch cherry-pick-d9081493c4b2.patch +cherry-pick-2b30a50d0e62.patch merge_m112_remove_the_second_weakptrfactory_from.patch merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch check_callback_availability_in.patch diff --git a/patches/chromium/cherry-pick-2b30a50d0e62.patch b/patches/chromium/cherry-pick-2b30a50d0e62.patch new file mode 100644 index 0000000000000..a50f6b573a348 --- /dev/null +++ b/patches/chromium/cherry-pick-2b30a50d0e62.patch @@ -0,0 +1,91 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Yoshisato Yanagisawa <yyanagisawa@chromium.org> +Date: Mon, 10 Apr 2023 05:32:06 +0000 +Subject: Use ScriptState::Scope instead of setting HandleScope. + +Since `GetEffectiveFunction` may call `Get` if the given v8 listener is +an object, we need to prepare `v8::Context::Scope` before calling it. +Blink already have a helper class to prepare the environment for the +script execution, which has already been used used in other +ServiceWorkerGlobalScope member functions. It is `ScriptState::Scope` +This CL also use it instead. + +(cherry picked from commit 299385e09d41d5ce3abd434879b5f9b0a8880cd7) + +Bug: 1429197 +Change-Id: Idbcfdfa9c06160a18b57155a9540f72eed4ec0b8 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4387655 +Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org> +Commit-Queue: Kouhei Ueno <kouhei@chromium.org> +Reviewed-by: Leszek Swirski <leszeks@chromium.org> +Auto-Submit: Yoshisato Yanagisawa <yyanagisawa@chromium.org> +Reviewed-by: Kouhei Ueno <kouhei@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1125148} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4411454 +Reviewed-by: Shunya Shishido <sisidovski@chromium.org> +Cr-Commit-Position: refs/branch-heads/5615@{#1191} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/content/browser/service_worker/service_worker_version_browsertest.cc b/content/browser/service_worker/service_worker_version_browsertest.cc +index 5e1aeaa11cc99e9ac4c89be082e0b4254f6df000..0435c5a1850dd3ed16197bbc40c1e276e4613a60 100644 +--- a/content/browser/service_worker/service_worker_version_browsertest.cc ++++ b/content/browser/service_worker/service_worker_version_browsertest.cc +@@ -976,6 +976,18 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, + version_->fetch_handler_type()); + } + ++IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, ++ NonFunctionFetchHandlerWithHandleEventProperty) { ++ StartServerAndNavigateToSetup(); ++ ASSERT_EQ( ++ Install("/service_worker/fetch_event_with_handle_event_property.js"), ++ blink::ServiceWorkerStatusCode::kOk); ++ EXPECT_EQ(ServiceWorkerVersion::FetchHandlerExistence::EXISTS, ++ version_->fetch_handler_existence()); ++ EXPECT_EQ(ServiceWorkerVersion::FetchHandlerType::kNotSkippable, ++ version_->fetch_handler_type()); ++} ++ + // Check that fetch event handler added in the install event should result in a + // service worker that doesn't count as having a fetch event handler. + IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, +diff --git a/content/test/data/service_worker/fetch_event_with_handle_event_property.js b/content/test/data/service_worker/fetch_event_with_handle_event_property.js +new file mode 100644 +index 0000000000000000000000000000000000000000..2fe6153af242a10162f7ecb8eaab93c17d840211 +--- /dev/null ++++ b/content/test/data/service_worker/fetch_event_with_handle_event_property.js +@@ -0,0 +1,11 @@ ++// Copyright 2023 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++let obj = {}; ++Object.defineProperty(obj, "handleEvent", { ++ get: () => {}, ++ configurable: true, ++ enumerable: true, ++}); ++self.addEventListener('fetch', obj); +diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +index c66d232a65535bf1c66d47c6d51bc56418e57f26..b3a9f691a0fabf14bf6f319173f400c31c664c12 100644 +--- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc ++++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +@@ -2602,12 +2602,15 @@ ServiceWorkerGlobalScope::FetchHandlerType() { + if (!elv) { + return mojom::blink::ServiceWorkerFetchHandlerType::kNoHandler; + } +- v8::Isolate* isolate = v8::Isolate::GetCurrent(); +- v8::HandleScope handle_scope(isolate); ++ ++ ScriptState* script_state = ScriptController()->GetScriptState(); ++ // Do not remove this, |scope| is needed by `GetEffectiveFunction`. ++ ScriptState::Scope scope(script_state); ++ + // TODO(crbug.com/1349613): revisit the way to implement this. + // The following code returns kEmptyFetchHandler if all handlers are nop. + for (RegisteredEventListener& e : *elv) { +- EventTarget* et = EventTarget::Create(ScriptController()->GetScriptState()); ++ EventTarget* et = EventTarget::Create(script_state); + v8::Local<v8::Value> v = + To<JSBasedEventListener>(e.Callback())->GetEffectiveFunction(*et); + if (!v->IsFunction() || From 27575566c9309237bcef95975fe1886ca16bbff9 Mon Sep 17 00:00:00 2001 From: Milan Burda <milan.burda@gmail.com> Date: Mon, 24 Apr 2023 15:25:29 +0200 Subject: [PATCH 133/172] fix: defaults broken in shell.openExternal() options (#38092) fix: defaults broken in shell.openExternal() options (#38038) Co-authored-by: Milan Burda <miburda@microsoft.com> --- shell/common/api/electron_api_shell.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/shell/common/api/electron_api_shell.cc b/shell/common/api/electron_api_shell.cc index e279f3a73fe14..762473bdd4876 100644 --- a/shell/common/api/electron_api_shell.cc +++ b/shell/common/api/electron_api_shell.cc @@ -59,12 +59,10 @@ v8::Local<v8::Promise> OpenExternal(const GURL& url, gin::Arguments* args) { v8::Local<v8::Promise> handle = promise.GetHandle(); platform_util::OpenExternalOptions options; - if (args->Length() >= 2) { - gin::Dictionary obj(nullptr); - if (args->GetNext(&obj)) { - obj.Get("activate", &options.activate); - obj.Get("workingDirectory", &options.working_dir); - } + gin_helper::Dictionary obj; + if (args->GetNext(&obj)) { + obj.Get("activate", &options.activate); + obj.Get("workingDirectory", &options.working_dir); } platform_util::OpenExternal( From f907c18bac70f5174c4238fabd1f1c76dce9b73e Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Tue, 25 Apr 2023 10:45:26 +0100 Subject: [PATCH 134/172] chore: cherry-pick f58218891f8c from chromium (#38056) * chore: [22-x-y] cherry-pick f58218891f8c from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-f58218891f8c.patch | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 patches/chromium/cherry-pick-f58218891f8c.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 98ecb7b09f9b1..57af5efc52550 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -154,3 +154,4 @@ merge_m112_remove_the_second_weakptrfactory_from.patch merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch check_callback_availability_in.patch cherry-pick-63686953dc22.patch +cherry-pick-f58218891f8c.patch diff --git a/patches/chromium/cherry-pick-f58218891f8c.patch b/patches/chromium/cherry-pick-f58218891f8c.patch new file mode 100644 index 0000000000000..3d8b55d44d82a --- /dev/null +++ b/patches/chromium/cherry-pick-f58218891f8c.patch @@ -0,0 +1,98 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Yoshisato Yanagisawa <yyanagisawa@chromium.org> +Date: Tue, 11 Apr 2023 07:12:34 +0000 +Subject: Stop supporting { handleEvent }. + +Make the code aligned with the following specification update: +https://github.com/w3c/ServiceWorker/pull/1676 + +With the previous specification and code, event listener vector +can be modified during the GetEffectiveFunction execution, which may +bring unexpected vector state. + +(cherry picked from commit 5105ce37a6853d52ec97894bf6969b3c29a23afd) + +Change-Id: I732c4c9ab2caebc49a7f4ef52640df7b8476d838 +Bug: 1429201 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4394402 +Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org> +Reviewed-by: Kouhei Ueno <kouhei@chromium.org> +Reviewed-by: Domenic Denicola <domenic@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1126483} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4408837 +Reviewed-by: Shunya Shishido <sisidovski@chromium.org> +Reviewed-by: Minoru Chikamune <chikamune@chromium.org> +Cr-Commit-Position: refs/branch-heads/5615@{#1203} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/content/browser/service_worker/service_worker_version_browsertest.cc b/content/browser/service_worker/service_worker_version_browsertest.cc +index 0435c5a1850dd3ed16197bbc40c1e276e4613a60..a9ad30764c578d1e6cf15bd114ca46e169012039 100644 +--- a/content/browser/service_worker/service_worker_version_browsertest.cc ++++ b/content/browser/service_worker/service_worker_version_browsertest.cc +@@ -988,6 +988,17 @@ IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, + version_->fetch_handler_type()); + } + ++IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, ++ RemoveFetchEventListenersInGet) { ++ StartServerAndNavigateToSetup(); ++ ASSERT_EQ(Install("/service_worker/fetch_event_object_removing_itself.js"), ++ blink::ServiceWorkerStatusCode::kOk); ++ EXPECT_EQ(ServiceWorkerVersion::FetchHandlerExistence::EXISTS, ++ version_->fetch_handler_existence()); ++ EXPECT_EQ(ServiceWorkerVersion::FetchHandlerType::kNotSkippable, ++ version_->fetch_handler_type()); ++} ++ + // Check that fetch event handler added in the install event should result in a + // service worker that doesn't count as having a fetch event handler. + IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, +diff --git a/content/test/data/service_worker/fetch_event_object_removing_itself.js b/content/test/data/service_worker/fetch_event_object_removing_itself.js +new file mode 100644 +index 0000000000000000000000000000000000000000..110bc4821fae3a63a374d3dc6ca954d4bd744952 +--- /dev/null ++++ b/content/test/data/service_worker/fetch_event_object_removing_itself.js +@@ -0,0 +1,19 @@ ++// Copyright 2023 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++let obj = {}; ++function victim() {} ++ ++Object.defineProperty(obj, 'handleEvent', { ++ get: () => { ++ // Remove the victim function from the listener vector to break the loop. ++ self.removeEventListener('fetch', victim); ++ return () => {}; ++ }, ++ configurable: true, ++ enumerable: true, ++}); ++ ++self.addEventListener('fetch', obj); ++self.addEventListener('fetch', victim); +diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +index b3a9f691a0fabf14bf6f319173f400c31c664c12..9523aa1ee53aeabe03281a34b4a290a68f6a7dc4 100644 +--- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc ++++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +@@ -2604,7 +2604,7 @@ ServiceWorkerGlobalScope::FetchHandlerType() { + } + + ScriptState* script_state = ScriptController()->GetScriptState(); +- // Do not remove this, |scope| is needed by `GetEffectiveFunction`. ++ // Do not remove this, |scope| is needed by `GetListenerObject`. + ScriptState::Scope scope(script_state); + + // TODO(crbug.com/1349613): revisit the way to implement this. +@@ -2612,8 +2612,8 @@ ServiceWorkerGlobalScope::FetchHandlerType() { + for (RegisteredEventListener& e : *elv) { + EventTarget* et = EventTarget::Create(script_state); + v8::Local<v8::Value> v = +- To<JSBasedEventListener>(e.Callback())->GetEffectiveFunction(*et); +- if (!v->IsFunction() || ++ To<JSBasedEventListener>(e.Callback())->GetListenerObject(*et); ++ if (v.IsEmpty() || !v->IsFunction() || + !v.As<v8::Function>()->Experimental_IsNopFunction()) { + return mojom::blink::ServiceWorkerFetchHandlerType::kNotSkippable; + } From 6820094f8ef2e02a81f7bb53fecf2ebb75648517 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Wed, 26 Apr 2023 09:11:51 +0100 Subject: [PATCH 135/172] chore: cherry-pick f098ff0d1230 from chromium (#38060) chore: [22-x-y] cherry-pick f098ff0d1230 from chromium Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-f098ff0d1230.patch | 127 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 patches/chromium/cherry-pick-f098ff0d1230.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 57af5efc52550..cda8195cdf9e1 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -154,4 +154,5 @@ merge_m112_remove_the_second_weakptrfactory_from.patch merge_m112_check_spdyproxyclientsocket_is_alive_after_write.patch check_callback_availability_in.patch cherry-pick-63686953dc22.patch +cherry-pick-f098ff0d1230.patch cherry-pick-f58218891f8c.patch diff --git a/patches/chromium/cherry-pick-f098ff0d1230.patch b/patches/chromium/cherry-pick-f098ff0d1230.patch new file mode 100644 index 0000000000000..cd614a14b23ef --- /dev/null +++ b/patches/chromium/cherry-pick-f098ff0d1230.patch @@ -0,0 +1,127 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Andrey Kosyakov <caseq@chromium.org> +Date: Thu, 13 Apr 2023 03:55:24 +0000 +Subject: Retain DevToolsAgentHost after ForceDetachAllSessions() + +(cherry picked from commit 8c4aee2a90d08535cfb1bf0a59e00cae956b1762) + +Bug: 1424337 +Change-Id: Ie0ebe2a49ffbd2356b896c39446b93e09cd81f5a +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4378100 +Reviewed-by: Dmitry Gozman <dgozman@chromium.org> +Commit-Queue: Andrey Kosyakov <caseq@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1123772} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4420271 +Commit-Queue: Srinivas Sista <srinivassista@chromium.org> +Cr-Commit-Position: refs/branch-heads/5615@{#1244} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/content/browser/devtools/auction_worklet_devtools_agent_host.cc b/content/browser/devtools/auction_worklet_devtools_agent_host.cc +index 20a989999b6da5d269bca3d6c9bf181eea7180e7..34a13a884885926e3985098315fd9121902099e9 100644 +--- a/content/browser/devtools/auction_worklet_devtools_agent_host.cc ++++ b/content/browser/devtools/auction_worklet_devtools_agent_host.cc +@@ -96,7 +96,7 @@ AuctionWorkletDevToolsAgentHost::~AuctionWorkletDevToolsAgentHost() = default; + + void AuctionWorkletDevToolsAgentHost::WorkletDestroyed() { + worklet_ = nullptr; +- ForceDetachAllSessions(); ++ auto retain_this = ForceDetachAllSessionsImpl(); + associated_agent_remote_.reset(); + } + +diff --git a/content/browser/devtools/devtools_agent_host_impl.cc b/content/browser/devtools/devtools_agent_host_impl.cc +index 46314287ac23017f597c8f63d41cab7e46e2a53a..33f8676e811f3f5684bbd7dabae392668f34f20b 100644 +--- a/content/browser/devtools/devtools_agent_host_impl.cc ++++ b/content/browser/devtools/devtools_agent_host_impl.cc +@@ -350,12 +350,18 @@ bool DevToolsAgentHostImpl::Inspect() { + } + + void DevToolsAgentHostImpl::ForceDetachAllSessions() { +- scoped_refptr<DevToolsAgentHostImpl> protect(this); ++ std::ignore = ForceDetachAllSessionsImpl(); ++} ++ ++scoped_refptr<DevToolsAgentHost> ++DevToolsAgentHostImpl::ForceDetachAllSessionsImpl() { ++ scoped_refptr<DevToolsAgentHost> retain_this(this); + while (!sessions_.empty()) { + DevToolsAgentHostClient* client = (*sessions_.begin())->GetClient(); + DetachClient(client); + client->AgentHostClosed(this); + } ++ return retain_this; + } + + void DevToolsAgentHostImpl::ForceDetachRestrictedSessions( +diff --git a/content/browser/devtools/devtools_agent_host_impl.h b/content/browser/devtools/devtools_agent_host_impl.h +index 4c54b9100ef287d5ac5c45235d3a93187df2ca14..f29b5323c4555a96c069377df2b7f126abd029af 100644 +--- a/content/browser/devtools/devtools_agent_host_impl.h ++++ b/content/browser/devtools/devtools_agent_host_impl.h +@@ -119,15 +119,24 @@ class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { + void NotifyCreated(); + void NotifyNavigated(); + void NotifyCrashed(base::TerminationStatus status); +- void ForceDetachAllSessions(); + void ForceDetachRestrictedSessions( + const std::vector<DevToolsSession*>& restricted_sessions); + DevToolsIOContext* GetIOContext() { return &io_context_; } + DevToolsRendererChannel* GetRendererChannel() { return &renderer_channel_; } + + const std::vector<DevToolsSession*>& sessions() const { return sessions_; } ++ // Returns refptr retaining `this`. All other references may be removed ++ // at this point, so `this` will become invalid as soon as returned refptr ++ // gets destroyed. ++ [[nodiscard]] scoped_refptr<DevToolsAgentHost> ForceDetachAllSessionsImpl(); + + private: ++ // Note that calling this may result in the instance being deleted, ++ // as instance may be owned by client sessions. This should not be ++ // used by methods of derived classes, use `ForceDetachAllSessionsImpl()` ++ // above instead. ++ void ForceDetachAllSessions(); ++ + friend class DevToolsAgentHost; // for static methods + friend class DevToolsSession; + friend class DevToolsRendererChannel; +diff --git a/content/browser/devtools/render_frame_devtools_agent_host.cc b/content/browser/devtools/render_frame_devtools_agent_host.cc +index 2441cbcc429b9458af7743f1a2c5040b91163e4f..71607bffebc49b0a9b898e5ef1ac652190e8eb4f 100644 +--- a/content/browser/devtools/render_frame_devtools_agent_host.cc ++++ b/content/browser/devtools/render_frame_devtools_agent_host.cc +@@ -541,9 +541,9 @@ void RenderFrameDevToolsAgentHost::RenderFrameDeleted(RenderFrameHost* rfh) { + } + + void RenderFrameDevToolsAgentHost::DestroyOnRenderFrameGone() { +- scoped_refptr<RenderFrameDevToolsAgentHost> protect(this); ++ scoped_refptr<DevToolsAgentHost> retain_this; + if (IsAttached()) { +- ForceDetachAllSessions(); ++ retain_this = ForceDetachAllSessionsImpl(); + UpdateRawHeadersAccess(frame_host_); + } + ChangeFrameHostAndObservedProcess(nullptr); +diff --git a/content/browser/devtools/web_contents_devtools_agent_host.cc b/content/browser/devtools/web_contents_devtools_agent_host.cc +index 20976a4f189446f0cf3b0a0ab168ceb4a92eebe1..7d12f4f8b030200b49350d379f25d4b64b0d1a06 100644 +--- a/content/browser/devtools/web_contents_devtools_agent_host.cc ++++ b/content/browser/devtools/web_contents_devtools_agent_host.cc +@@ -299,7 +299,7 @@ DevToolsAgentHostImpl* WebContentsDevToolsAgentHost::GetPrimaryFrameAgent() { + + void WebContentsDevToolsAgentHost::WebContentsDestroyed() { + DCHECK_EQ(this, FindAgentHost(web_contents())); +- ForceDetachAllSessions(); ++ auto retain_this = ForceDetachAllSessionsImpl(); + auto_attacher_.reset(); + g_agent_host_instances.Get().erase(web_contents()); + Observe(nullptr); +diff --git a/content/browser/devtools/worker_devtools_agent_host.cc b/content/browser/devtools/worker_devtools_agent_host.cc +index db788e7298d6696ec5a354cb387dfdc4030d8ce0..0984b3ae35459d8676b903394577cc6a43601ac8 100644 +--- a/content/browser/devtools/worker_devtools_agent_host.cc ++++ b/content/browser/devtools/worker_devtools_agent_host.cc +@@ -87,7 +87,7 @@ void WorkerDevToolsAgentHost::ChildWorkerCreated( + } + + void WorkerDevToolsAgentHost::Disconnected() { +- ForceDetachAllSessions(); ++ auto retain_this = ForceDetachAllSessionsImpl(); + GetRendererChannel()->SetRenderer(mojo::NullRemote(), mojo::NullReceiver(), + ChildProcessHost::kInvalidUniqueID); + std::move(destroyed_callback_).Run(this); From 8c172f2e95d546d76486f4a808cf132106f86196 Mon Sep 17 00:00:00 2001 From: Robo <hop2deep@gmail.com> Date: Wed, 3 May 2023 16:56:25 +0900 Subject: [PATCH 136/172] fix: crash in utilityProcess when generating code from strings (#38156) fix: crash in utilityProcess when generating code from strings (#38040) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> --- shell/app/electron_main_delegate.cc | 14 +++-------- shell/common/api/electron_bindings.cc | 6 ++--- shell/common/gin_helper/callback.cc | 3 ++- shell/common/gin_helper/locker.cc | 10 +++----- shell/common/gin_helper/locker.h | 6 ----- shell/common/gin_helper/microtasks_scope.cc | 4 +-- shell/common/gin_helper/promise.cc | 2 +- shell/common/gin_helper/promise.h | 5 ++-- shell/common/gin_helper/trackable_object.cc | 4 +-- shell/common/node_bindings.cc | 27 ++++++++++----------- shell/common/process_util.cc | 16 ++++++++++++ shell/common/process_util.h | 3 +++ spec/api-utility-process-spec.ts | 14 +++++++++++ spec/fixtures/api/utility-process/eval.js | 6 +++++ 14 files changed, 72 insertions(+), 48 deletions(-) create mode 100644 spec/fixtures/api/utility-process/eval.js diff --git a/shell/app/electron_main_delegate.cc b/shell/app/electron_main_delegate.cc index 8aed325bd888b..5e0dff9440690 100644 --- a/shell/app/electron_main_delegate.cc +++ b/shell/app/electron_main_delegate.cc @@ -40,6 +40,7 @@ #include "shell/common/logging.h" #include "shell/common/options_switches.h" #include "shell/common/platform_util.h" +#include "shell/common/process_util.h" #include "shell/renderer/electron_renderer_client.h" #include "shell/renderer/electron_sandboxed_renderer_client.h" #include "shell/utility/electron_content_utility_client.h" @@ -82,11 +83,6 @@ constexpr base::StringPiece kElectronDisableSandbox("ELECTRON_DISABLE_SANDBOX"); constexpr base::StringPiece kElectronEnableStackDumping( "ELECTRON_ENABLE_STACK_DUMPING"); -bool IsBrowserProcess(base::CommandLine* cmd) { - std::string process_type = cmd->GetSwitchValueASCII(::switches::kProcessType); - return process_type.empty(); -} - // Returns true if this subprocess type needs the ResourceBundle initialized // and resources loaded. bool SubprocessNeedsResourceBundle(const std::string& process_type) { @@ -249,14 +245,12 @@ absl::optional<int> ElectronMainDelegate::BasicStartupComplete() { // On Windows the terminal returns immediately, so we add a new line to // prevent output in the same line as the prompt. - if (IsBrowserProcess(command_line)) + if (IsBrowserProcess()) std::wcout << std::endl; #endif // !BUILDFLAG(IS_WIN) auto env = base::Environment::Create(); - gin_helper::Locker::SetIsBrowserProcess(IsBrowserProcess(command_line)); - // Enable convenient stack printing. This is enabled by default in // non-official builds. if (env->HasVar(kElectronEnableStackDumping)) @@ -289,7 +283,7 @@ absl::optional<int> ElectronMainDelegate::BasicStartupComplete() { // bugs, but no use in Electron. base::win::DisableHandleVerifier(); - if (IsBrowserProcess(command_line)) + if (IsBrowserProcess()) base::win::PinUser32(); #endif @@ -385,7 +379,7 @@ void ElectronMainDelegate::PreSandboxStartup() { crash_keys::SetPlatformCrashKey(); #endif - if (IsBrowserProcess(command_line)) { + if (IsBrowserProcess()) { // Only append arguments for browser process. // Allow file:// URIs to read other file:// URIs by default. diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc index 5cd1930a8bcd2..32658c1a1e334 100644 --- a/shell/common/api/electron_bindings.cc +++ b/shell/common/api/electron_bindings.cc @@ -23,11 +23,11 @@ #include "shell/common/application_info.h" #include "shell/common/gin_converters/file_path_converter.h" #include "shell/common/gin_helper/dictionary.h" -#include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/microtasks_scope.h" #include "shell/common/gin_helper/promise.h" #include "shell/common/heap_snapshot.h" #include "shell/common/node_includes.h" +#include "shell/common/process_util.h" #include "third_party/blink/renderer/platform/heap/process_heap.h" // nogncheck namespace electron { @@ -50,7 +50,7 @@ void ElectronBindings::BindProcess(v8::Isolate* isolate, process->SetMethod("getCreationTime", &GetCreationTime); process->SetMethod("getHeapStatistics", &GetHeapStatistics); process->SetMethod("getBlinkMemoryInfo", &GetBlinkMemoryInfo); - if (gin_helper::Locker::IsBrowserProcess()) { + if (electron::IsBrowserProcess()) { process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); } process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); @@ -209,7 +209,7 @@ v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo( // static v8::Local<v8::Promise> ElectronBindings::GetProcessMemoryInfo( v8::Isolate* isolate) { - CHECK(gin_helper::Locker::IsBrowserProcess()); + CHECK(electron::IsBrowserProcess()); gin_helper::Promise<gin_helper::Dictionary> promise(isolate); v8::Local<v8::Promise> handle = promise.GetHandle(); diff --git a/shell/common/gin_helper/callback.cc b/shell/common/gin_helper/callback.cc index 4c68b5e14f4fc..0a82b901dc04c 100644 --- a/shell/common/gin_helper/callback.cc +++ b/shell/common/gin_helper/callback.cc @@ -7,6 +7,7 @@ #include "base/cxx17_backports.h" #include "content/public/browser/browser_thread.h" #include "gin/dictionary.h" +#include "shell/common/process_util.h" namespace gin_helper { @@ -70,7 +71,7 @@ void CallTranslater(v8::Local<v8::External> external, struct DeleteOnUIThread { template <typename T> static void Destruct(const T* x) { - if (gin_helper::Locker::IsBrowserProcess() && + if (electron::IsBrowserProcess() && !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE, x); diff --git a/shell/common/gin_helper/locker.cc b/shell/common/gin_helper/locker.cc index dbbaf7879fc46..84740204ebb2a 100644 --- a/shell/common/gin_helper/locker.cc +++ b/shell/common/gin_helper/locker.cc @@ -4,19 +4,15 @@ #include "shell/common/gin_helper/locker.h" +#include "shell/common/process_util.h" + namespace gin_helper { Locker::Locker(v8::Isolate* isolate) { - if (IsBrowserProcess()) + if (electron::IsBrowserProcess()) locker_ = std::make_unique<v8::Locker>(isolate); } Locker::~Locker() = default; -void Locker::SetIsBrowserProcess(bool is_browser_process) { - g_is_browser_process = is_browser_process; -} - -bool Locker::g_is_browser_process = false; - } // namespace gin_helper diff --git a/shell/common/gin_helper/locker.h b/shell/common/gin_helper/locker.h index 9fb11ad4b358d..b734d2f31cb5b 100644 --- a/shell/common/gin_helper/locker.h +++ b/shell/common/gin_helper/locker.h @@ -21,12 +21,6 @@ class Locker { Locker(const Locker&) = delete; Locker& operator=(const Locker&) = delete; - // Returns whether current process is browser process, currently we detect it - // by checking whether current has used V8 Lock, but it might be a bad idea. - static inline bool IsBrowserProcess() { return g_is_browser_process; } - - static void SetIsBrowserProcess(bool is_browser_process); - private: void* operator new(size_t size); void operator delete(void*, size_t); diff --git a/shell/common/gin_helper/microtasks_scope.cc b/shell/common/gin_helper/microtasks_scope.cc index a3f8c73d74930..f0201775023a6 100644 --- a/shell/common/gin_helper/microtasks_scope.cc +++ b/shell/common/gin_helper/microtasks_scope.cc @@ -4,14 +4,14 @@ #include "shell/common/gin_helper/microtasks_scope.h" -#include "shell/common/gin_helper/locker.h" +#include "shell/common/process_util.h" namespace gin_helper { MicrotasksScope::MicrotasksScope(v8::Isolate* isolate, bool ignore_browser_checkpoint, v8::MicrotasksScope::Type scope_type) { - if (Locker::IsBrowserProcess()) { + if (electron::IsBrowserProcess()) { if (!ignore_browser_checkpoint) v8::MicrotasksScope::PerformCheckpoint(isolate); } else { diff --git a/shell/common/gin_helper/promise.cc b/shell/common/gin_helper/promise.cc index bc34dfa6310b9..a1c69789252fa 100644 --- a/shell/common/gin_helper/promise.cc +++ b/shell/common/gin_helper/promise.cc @@ -63,7 +63,7 @@ v8::Local<v8::Promise::Resolver> PromiseBase::GetInner() const { // static void Promise<void>::ResolvePromise(Promise<void> promise) { - if (gin_helper::Locker::IsBrowserProcess() && + if (electron::IsBrowserProcess() && !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, diff --git a/shell/common/gin_helper/promise.h b/shell/common/gin_helper/promise.h index c720b588d7718..264f577c2525e 100644 --- a/shell/common/gin_helper/promise.h +++ b/shell/common/gin_helper/promise.h @@ -16,6 +16,7 @@ #include "shell/common/gin_converters/std_converter.h" #include "shell/common/gin_helper/locker.h" #include "shell/common/gin_helper/microtasks_scope.h" +#include "shell/common/process_util.h" namespace gin_helper { @@ -45,7 +46,7 @@ class PromiseBase { // Note: The parameter type is PromiseBase&& so it can take the instances of // Promise<T> type. static void RejectPromise(PromiseBase&& promise, base::StringPiece errmsg) { - if (gin_helper::Locker::IsBrowserProcess() && + if (electron::IsBrowserProcess() && !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, @@ -88,7 +89,7 @@ class Promise : public PromiseBase { // Helper for resolving the promise with |result|. static void ResolvePromise(Promise<RT> promise, RT result) { - if (gin_helper::Locker::IsBrowserProcess() && + if (electron::IsBrowserProcess() && !content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { content::GetUIThreadTaskRunner({})->PostTask( FROM_HERE, base::BindOnce([](Promise<RT> promise, diff --git a/shell/common/gin_helper/trackable_object.cc b/shell/common/gin_helper/trackable_object.cc index ae0feafa48cdf..73d87f5ba02c9 100644 --- a/shell/common/gin_helper/trackable_object.cc +++ b/shell/common/gin_helper/trackable_object.cc @@ -9,7 +9,7 @@ #include "base/bind.h" #include "base/supports_user_data.h" #include "shell/browser/electron_browser_main_parts.h" -#include "shell/common/gin_helper/locker.h" +#include "shell/common/process_util.h" namespace gin_helper { @@ -31,7 +31,7 @@ class IDUserData : public base::SupportsUserData::Data { TrackableObjectBase::TrackableObjectBase() { // TODO(zcbenz): Make TrackedObject work in renderer process. - DCHECK(gin_helper::Locker::IsBrowserProcess()) + DCHECK(electron::IsBrowserProcess()) << "This class only works for browser process"; } diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 8235eebd3de15..6cb2c3956ba3e 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -171,7 +171,7 @@ bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context, // If we're running with contextIsolation enabled in the renderer process, // fall back to Blink's logic. if (node::Environment::GetCurrent(context) == nullptr) { - if (gin_helper::Locker::IsBrowserProcess()) + if (!electron::IsRendererProcess()) return false; return blink::V8Initializer::WasmCodeGenerationCheckCallbackInMainThread( context, source); @@ -188,7 +188,7 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( // No node environment means we're in the renderer process, either in a // sandboxed renderer or in an unsandboxed renderer with context isolation // enabled. - if (gin_helper::Locker::IsBrowserProcess()) { + if (!electron::IsRendererProcess()) { NOTREACHED(); return {false, {}}; } @@ -197,21 +197,20 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( } // If we get here then we have a node environment, so either a) we're in the - // main process, or b) we're in the renderer process in a context that has - // both node and blink, i.e. contextIsolation disabled. - - // If we're in the main process, delegate to node. - if (gin_helper::Locker::IsBrowserProcess()) { - return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); - } + // non-rendrer process, or b) we're in the renderer process in a context that + // has both node and blink, i.e. contextIsolation disabled. // If we're in the renderer with contextIsolation disabled, ask blink first // (for CSP), and iff that allows codegen, delegate to node. - v8::ModifyCodeGenerationFromStringsResult result = - blink::V8Initializer::CodeGenerationCheckCallbackInMainThread( - context, source, is_code_like); - if (!result.codegen_allowed) - return result; + if (electron::IsRendererProcess()) { + v8::ModifyCodeGenerationFromStringsResult result = + blink::V8Initializer::CodeGenerationCheckCallbackInMainThread( + context, source, is_code_like); + if (!result.codegen_allowed) + return result; + } + + // If we're in the main process or utility process, delegate to node. return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); } diff --git a/shell/common/process_util.cc b/shell/common/process_util.cc index c253af58fc9dd..f54bdf6c3d366 100644 --- a/shell/common/process_util.cc +++ b/shell/common/process_util.cc @@ -4,6 +4,8 @@ #include "shell/common/process_util.h" +#include "base/command_line.h" +#include "content/public/common/content_switches.h" #include "gin/dictionary.h" #include "shell/common/gin_converters/callback_converter.h" #include "shell/common/node_includes.h" @@ -24,4 +26,18 @@ void EmitWarning(node::Environment* env, emit_warning.Run(warning_msg, warning_type, ""); } +bool IsBrowserProcess() { + auto* command_line = base::CommandLine::ForCurrentProcess(); + std::string process_type = + command_line->GetSwitchValueASCII(switches::kProcessType); + return process_type.empty(); +} + +bool IsRendererProcess() { + auto* command_line = base::CommandLine::ForCurrentProcess(); + std::string process_type = + command_line->GetSwitchValueASCII(switches::kProcessType); + return process_type == switches::kRendererProcess; +} + } // namespace electron diff --git a/shell/common/process_util.h b/shell/common/process_util.h index bd08b102662fa..8a93eb9488d40 100644 --- a/shell/common/process_util.h +++ b/shell/common/process_util.h @@ -17,6 +17,9 @@ void EmitWarning(node::Environment* env, const std::string& warning_msg, const std::string& warning_type); +bool IsBrowserProcess(); +bool IsRendererProcess(); + } // namespace electron #endif // ELECTRON_SHELL_COMMON_PROCESS_UTIL_H_ diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index bbdab8eea8cd9..57e28f781d780 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -360,5 +360,19 @@ describe('utilityProcess module', () => { await emittedOnce(child, 'exit'); expect(log).to.equal('hello\n'); }); + + it('does not crash when running eval', async () => { + const child = utilityProcess.fork('./eval.js', [], { + cwd: fixturesPath, + stdio: 'ignore' + }); + await emittedOnce(child, 'spawn'); + const [data] = await emittedOnce(child, 'message'); + expect(data).to.equal(42); + // Cleanup. + const exit = emittedOnce(child, 'exit'); + expect(child.kill()).to.be.true(); + await exit; + }); }); }); diff --git a/spec/fixtures/api/utility-process/eval.js b/spec/fixtures/api/utility-process/eval.js new file mode 100644 index 0000000000000..c521d90f1cc3f --- /dev/null +++ b/spec/fixtures/api/utility-process/eval.js @@ -0,0 +1,6 @@ +const vm = require('node:vm'); + +const contextObject = { result: 0 }; +vm.createContext(contextObject); +vm.runInContext('eval(\'result = 42\')', contextObject); +process.parentPort.postMessage(contextObject.result); From de3a8a538936f9977d817f6b1d4bba3226f86fc5 Mon Sep 17 00:00:00 2001 From: Alexey Kuzmin <alex.s.kuzmin@gmail.com> Date: Thu, 4 May 2023 10:48:07 +0200 Subject: [PATCH 137/172] test: use `await` to call "closeWindow" (#38172) --- spec/api-web-contents-view-spec.ts | 6 +++++- spec/extensions-spec.ts | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/api-web-contents-view-spec.ts b/spec/api-web-contents-view-spec.ts index b8b7b2603049e..44df0dc1243c7 100644 --- a/spec/api-web-contents-view-spec.ts +++ b/spec/api-web-contents-view-spec.ts @@ -4,7 +4,11 @@ import { BaseWindow, WebContentsView } from 'electron/main'; describe('WebContentsView', () => { let w: BaseWindow; - afterEach(() => closeWindow(w as any).then(() => { w = null as unknown as BaseWindow; })); + + afterEach(async () => { + await closeWindow(w as any); + w = null as unknown as BaseWindow; + }); it('can be used as content view', () => { w = new BaseWindow({ show: false }); diff --git a/spec/extensions-spec.ts b/spec/extensions-spec.ts index b2dc6d7f96c21..c3501fd8c7bde 100644 --- a/spec/extensions-spec.ts +++ b/spec/extensions-spec.ts @@ -562,9 +562,10 @@ describe('chrome extensions', () => { }); }); - afterEach(() => { + afterEach(async () => { removeAllExtensions(); - return closeWindow(w).then(() => { w = null as unknown as BrowserWindow; }); + await closeWindow(w); + w = null as unknown as BrowserWindow; }); it('should run content script at document_start', async () => { From 5af5b424221cc18824bed82c35c4148826a23611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20H=C4=83loiu?= <valentin.haloiu@gmail.com> Date: Tue, 9 May 2023 09:07:06 +0100 Subject: [PATCH 138/172] chore: cherry-pick d42c3e5fb7c3 from chromium (#38199) --- patches/chromium/.patches | 1 + ...d_buffer_size_is_a_multiple_of_scale.patch | 109 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 patches/chromium/wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index cda8195cdf9e1..b00df9d4d09bb 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -156,3 +156,4 @@ check_callback_availability_in.patch cherry-pick-63686953dc22.patch cherry-pick-f098ff0d1230.patch cherry-pick-f58218891f8c.patch +wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch diff --git a/patches/chromium/wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch b/patches/chromium/wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch new file mode 100644 index 0000000000000..ddd654e32e55a --- /dev/null +++ b/patches/chromium/wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch @@ -0,0 +1,109 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom Anderson <thomasanderson@chromium.org> +Date: Tue, 13 Dec 2022 22:49:47 +0000 +Subject: Ensure DND buffer size is a multiple of scale + +When using a scale factor of 2.0 on Sway ToT, this fixes a crash when +trying to DND an image or text that happens to have an odd width or +height. The issue is Wlroots will not allow attaching a buffer to a +surface when the buffer's size isn't a multiple of the surface's scale +factor. + +R=nickdiego + +Bug: 578890 +Change-Id: I283ed27a7d0051b895e0eed3b9a74d83feac3a37 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4099423 +Reviewed-by: Nick Yamane <nickdiego@igalia.com> +Commit-Queue: Thomas Anderson <thomasanderson@chromium.org> +Cr-Commit-Position: refs/heads/main@{#1082777} + +diff --git a/ui/ozone/platform/wayland/common/wayland_util.cc b/ui/ozone/platform/wayland/common/wayland_util.cc +index 4e8aa4b1e5530311338fbb43483e16d845707d2f..9b5806895a92cc92176644a0477d48bf79a35606 100644 +--- a/ui/ozone/platform/wayland/common/wayland_util.cc ++++ b/ui/ozone/platform/wayland/common/wayland_util.cc +@@ -115,7 +115,8 @@ uint32_t IdentifyDirection(const ui::WaylandConnection& connection, + bool DrawBitmap(const SkBitmap& bitmap, ui::WaylandShmBuffer* out_buffer) { + DCHECK(out_buffer); + DCHECK(out_buffer->GetMemory()); +- DCHECK_EQ(out_buffer->size(), gfx::Size(bitmap.width(), bitmap.height())); ++ DCHECK(gfx::Rect(out_buffer->size()) ++ .Contains(gfx::Rect(bitmap.width(), bitmap.height()))); + + auto* mapped_memory = out_buffer->GetMemory(); + auto size = out_buffer->size(); +diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc +index f2123ec8bac3f6afe9f46ba358cb9c829b2e9325..2bb7d0f4de6f8c50cc2bbaba6baaa0b684531115 100644 +--- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc ++++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc +@@ -140,7 +140,8 @@ bool WaylandDataDragController::StartSession(const OSExchangeData& data, + icon_surface_ = std::make_unique<WaylandSurface>(connection_, nullptr); + if (icon_surface_->Initialize()) { + // Corresponds to actual scale factor of the origin surface. +- icon_surface_->set_surface_buffer_scale(origin_window->window_scale()); ++ icon_surface_buffer_scale_ = origin_window->window_scale(); ++ icon_surface_->set_surface_buffer_scale(icon_surface_buffer_scale_); + // Icon surface do not need input. + const gfx::Rect empty_region_px; + icon_surface_->set_input_region(&empty_region_px); +@@ -153,6 +154,7 @@ bool WaylandDataDragController::StartSession(const OSExchangeData& data, + } else { + LOG(ERROR) << "Failed to create drag icon surface."; + icon_surface_.reset(); ++ icon_surface_buffer_scale_ = 1.0f; + } + } + +@@ -225,21 +227,28 @@ void WaylandDataDragController::DrawIconInternal() { + return; + + DCHECK(!icon_bitmap_->empty()); +- gfx::Size size(icon_bitmap_->width(), icon_bitmap_->height()); ++ // The protocol expects the attached buffer to have a pixel size that is a ++ // multiple of the surface's scale factor. Some compositors (eg. Wlroots) will ++ // refuse to attach the buffer if this condition is not met. ++ const gfx::Size size_dip = ++ gfx::ScaleToCeiledSize({icon_bitmap_->width(), icon_bitmap_->height()}, ++ 1.0f / icon_surface_buffer_scale_); ++ const gfx::Size size_px = ++ gfx::ScaleToCeiledSize(size_dip, icon_surface_buffer_scale_); + + icon_buffer_ = std::make_unique<WaylandShmBuffer>( +- connection_->wayland_buffer_factory(), size); ++ connection_->wayland_buffer_factory(), size_px); + if (!icon_buffer_->IsValid()) { + LOG(ERROR) << "Failed to create drag icon buffer."; + return; + } + +- DVLOG(3) << "Drawing drag icon. size=" << size.ToString(); ++ DVLOG(3) << "Drawing drag icon. size_px=" << size_px.ToString(); + wl::DrawBitmap(*icon_bitmap_, icon_buffer_.get()); + auto* const surface = icon_surface_->surface(); + wl_surface_attach(surface, icon_buffer_->get(), icon_offset_.x(), + icon_offset_.y()); +- wl_surface_damage(surface, 0, 0, size.width(), size.height()); ++ wl_surface_damage(surface, 0, 0, size_px.width(), size_px.height()); + wl_surface_commit(surface); + } + +@@ -370,6 +379,7 @@ void WaylandDataDragController::OnDataSourceFinish(bool completed) { + data_offer_.reset(); + icon_buffer_.reset(); + icon_surface_.reset(); ++ icon_surface_buffer_scale_ = 1.0f; + icon_bitmap_ = nullptr; + icon_frame_callback_.reset(); + offered_exchange_data_provider_.reset(); +diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.h b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.h +index 9912f1e0aebaf8289d2cdcdbff472a0baa91a981..39acda6bae9eb3a3f7837f6c93fafcee493bf78b 100644 +--- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.h ++++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.h +@@ -224,6 +224,7 @@ class WaylandDataDragController : public WaylandDataDevice::DragDelegate, + + // Drag icon related variables. + std::unique_ptr<WaylandSurface> icon_surface_; ++ float icon_surface_buffer_scale_ = 1.0f; + std::unique_ptr<WaylandShmBuffer> icon_buffer_; + raw_ptr<const SkBitmap> icon_bitmap_ = nullptr; + gfx::Point icon_offset_; From 900459e1b1c26304b701f93fcda5b798491de2e3 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <pepontes@microsoft.com> Date: Wed, 17 May 2023 09:36:43 +0100 Subject: [PATCH 139/172] chore: cherry-pick 81d7b3e613 from chromium (#38274) * chore: cherry-pick 81d7b3e613 from chromium * build: bump brew cache to v6 Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> (cherry picked from commit dbf986662b4c117252e73ec96193c9391f399160) --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> --- .circleci/config/base.yml | 4 +- patches/chromium/.patches | 1 + .../m112_cherry_pick_libxml_cve_fix.patch | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 patches/chromium/m112_cherry_pick_libxml_cve_fix.patch diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 9c4c8b0293653..935004662f0a9 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -355,14 +355,14 @@ step-restore-brew-cache: &step-restore-brew-cache - /usr/local/Cellar/gnu-tar - /usr/local/bin/gtar keys: - - v5-brew-cache-{{ arch }} + - v6-brew-cache-{{ arch }} step-save-brew-cache: &step-save-brew-cache save_cache: paths: - /usr/local/Cellar/gnu-tar - /usr/local/bin/gtar - key: v5-brew-cache-{{ arch }} + key: v6-brew-cache-{{ arch }} name: Persisting brew cache step-get-more-space-on-mac: &step-get-more-space-on-mac diff --git a/patches/chromium/.patches b/patches/chromium/.patches index b00df9d4d09bb..7d49d6afaab38 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -157,3 +157,4 @@ cherry-pick-63686953dc22.patch cherry-pick-f098ff0d1230.patch cherry-pick-f58218891f8c.patch wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch +m112_cherry_pick_libxml_cve_fix.patch diff --git a/patches/chromium/m112_cherry_pick_libxml_cve_fix.patch b/patches/chromium/m112_cherry_pick_libxml_cve_fix.patch new file mode 100644 index 0000000000000..80c0c83994620 --- /dev/null +++ b/patches/chromium/m112_cherry_pick_libxml_cve_fix.patch @@ -0,0 +1,47 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Joey Arhar <jarhar@chromium.org> +Date: Fri, 21 Apr 2023 20:53:40 +0000 +Subject: M112: Cherry pick libxml CVE fix + +This patch cherry-picks a fix for [CVE-2023-29469] from libxml: +https://gitlab.gnome.org/GNOME/libxml2/-/commit/547edbf1cbdccd46b2e8ff322a456eaa5931c5df + +I cherry-picked these by going into my libxml checkout, checking out the +commit that libxml is at for this M112 branch, cherry-picking the CVE +fixes, then running the roll script on all platforms. + +Bug: 1433328 +Change-Id: Iaee58b0890f7190386cca3e430286f39ccbbdb02 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4456592 +Commit-Queue: David Baron <dbaron@chromium.org> +Reviewed-by: David Baron <dbaron@chromium.org> +Commit-Queue: Joey Arhar <jarhar@chromium.org> +Auto-Submit: Joey Arhar <jarhar@chromium.org> +Cr-Commit-Position: refs/branch-heads/5615@{#1325} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/third_party/libxml/README.chromium b/third_party/libxml/README.chromium +index 9813d7cd51b62164cd9cad86b57a0b660d22a223..182f0a73439a5e549aed0fa01b22bdca94a8ccbc 100644 +--- a/third_party/libxml/README.chromium ++++ b/third_party/libxml/README.chromium +@@ -25,5 +25,6 @@ Modifications: + in chromium's copy of maldoca. See https://github.com/google/maldoca/issues/87 + - Add helper classes in the chromium/ subdirectory. + - Delete various unused files, see chromium/roll.py ++- Cherry picked fix for CVE-2023-29469 + + This import was generated by the chromium/roll.py script. +diff --git a/third_party/libxml/src/dict.c b/third_party/libxml/src/dict.c +index 5c9ca71940ceea9f4aec9f1e7dfb6c3ba6bd8c76..300df7a55638f4c6728a88c336b3c3197ab05676 100644 +--- a/third_party/libxml/src/dict.c ++++ b/third_party/libxml/src/dict.c +@@ -455,7 +455,8 @@ static unsigned long + xmlDictComputeFastKey(const xmlChar *name, int namelen, int seed) { + unsigned long value = seed; + +- if (name == NULL) return(0); ++ if ((name == NULL) || (namelen <= 0)) ++ return(value); + value += *name; + value <<= 5; + if (namelen > 10) { From df6f23bbd1675c7884d96faef134eb32e2cf8d6e Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 20:01:34 -0400 Subject: [PATCH 140/172] build: modify `gclient.py` with unified patch (#38370) * build: modify gclient.py with unified patch Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * ci: ensure depot_tools does not update Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * ci: move auto-update disable outside if Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --- .circleci/config/base.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 935004662f0a9..baa6d1e6e8882 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -243,14 +243,27 @@ step-depot-tools-get: &step-depot-tools-get sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja # Remove swift-format dep from cipd on macOS until we send a patch upstream. cd depot_tools - patch gclient.py -R \<<'EOF' - 676,677c676 - < packages = dep_value.get('packages', []) - < for package in (x for x in packages if "infra/3pp/tools/swift-format" not in x.get('package')): - --- - > for package in dep_value.get('packages', []): + cat > gclient.diff \<< 'EOF' + diff --git a/gclient.py b/gclient.py + index 3a9c5c6..f222043 100755 + --- a/gclient.py + +++ b/gclient.py + @@ -712,7 +712,8 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): + + if dep_type == 'cipd': + cipd_root = self.GetCipdRoot() + - for package in dep_value.get('packages', []): + + packages = dep_value.get('packages', []) + + for package in (x for x in packages if "infra/3pp/tools/swift-format" not in x.get('package')): + deps_to_add.append( + CipdDependency( + parent=self, EOF + git apply --3way gclient.diff fi + # Ensure depot_tools does not update. + test -d depot_tools && cd depot_tools + touch .disable_auto_update step-depot-tools-add-to-path: &step-depot-tools-add-to-path run: From b07f2f0f42a1483cd2e5ec8fa3c77ebaa0507069 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <pepontes@microsoft.com> Date: Thu, 18 May 2023 16:30:22 +0100 Subject: [PATCH 141/172] chore: cherry-pick cf90db14f2 from chromium (#38277) * chore: cherry-pick cf90db14f2 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../m112_fix_scopedobservation_uaf_in.patch | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 patches/chromium/m112_fix_scopedobservation_uaf_in.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 7d49d6afaab38..5aa1ecec37e4c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -158,3 +158,4 @@ cherry-pick-f098ff0d1230.patch cherry-pick-f58218891f8c.patch wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch m112_cherry_pick_libxml_cve_fix.patch +m112_fix_scopedobservation_uaf_in.patch diff --git a/patches/chromium/m112_fix_scopedobservation_uaf_in.patch b/patches/chromium/m112_fix_scopedobservation_uaf_in.patch new file mode 100644 index 0000000000000..82ca0647ccf18 --- /dev/null +++ b/patches/chromium/m112_fix_scopedobservation_uaf_in.patch @@ -0,0 +1,43 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Keren Zhu <kerenzhu@chromium.org> +Date: Mon, 24 Apr 2023 15:36:21 +0000 +Subject: Fix ScopedObservation UaF in + BubbleDialogDelegate::AnchorWidgetObserver + +A ScopedObservation can outlive the aura::Window it observes, leading to +a use-after-free error in ~ScopedObservation(). The problem occurs in +BubbleDialogDelegate::AnchorWidgetObserver. This fix listens for +OnWindowDestroying() and resets the observation to prevent the UaF. + +(cherry picked from commit 72bd6a1018548ee63a2ec06d6c7714d3a8cdf8a8) + +Bug: 1423360 +Change-Id: I742b4624b2664dea3fd97db7b399fcd15e45c8fe +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4455016 +Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com> +Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org> +Commit-Queue: Keren Zhu <kerenzhu@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1133511} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4466947 +Reviewed-by: Allen Bauer <kylixrd@chromium.org> +Cr-Commit-Position: refs/branch-heads/5615@{#1353} +Cr-Branched-From: 9c6408ef696e83a9936b82bbead3d41c93c82ee4-refs/heads/main@{#1109224} + +diff --git a/ui/views/bubble/bubble_dialog_delegate_view.cc b/ui/views/bubble/bubble_dialog_delegate_view.cc +index 2a84e8f5a7078e76dd40208c0265df3db06a7621..ad7f33ebcb5a09dc5ca97ddbcd5b8bc21a9fb529 100644 +--- a/ui/views/bubble/bubble_dialog_delegate_view.cc ++++ b/ui/views/bubble/bubble_dialog_delegate_view.cc +@@ -318,6 +318,13 @@ class BubbleDialogDelegate::AnchorWidgetObserver : public WidgetObserver, + owner_->OnAnchorBoundsChanged(); + } + } ++ ++ // If the native window is closed by the OS, OnWidgetDestroying() won't ++ // fire. Instead, OnWindowDestroying() will fire before aura::Window ++ // destruction. See //docs/ui/views/widget_destruction.md. ++ void OnWindowDestroying(aura::Window* window) override { ++ window_observation_.Reset(); ++ } + #endif + + private: From 2cdaab741dd355dccdd07c1a1b761ee3a512cf63 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 15:50:36 -0400 Subject: [PATCH 142/172] docs: add `<webview>` `new-window` event removal to breaking-changes.md (#38524) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <miburda@microsoft.com> --- docs/breaking-changes.md | 33 ++++++++++++ .../fiddles/ipc/webview-new-window/child.html | 3 ++ .../fiddles/ipc/webview-new-window/index.html | 4 ++ docs/fiddles/ipc/webview-new-window/main.js | 51 +++++++++++++++++++ .../fiddles/ipc/webview-new-window/preload.js | 6 +++ .../ipc/webview-new-window/renderer.js | 4 ++ 6 files changed, 101 insertions(+) create mode 100644 docs/fiddles/ipc/webview-new-window/child.html create mode 100644 docs/fiddles/ipc/webview-new-window/index.html create mode 100644 docs/fiddles/ipc/webview-new-window/main.js create mode 100644 docs/fiddles/ipc/webview-new-window/preload.js create mode 100644 docs/fiddles/ipc/webview-new-window/renderer.js diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 01aff3c085b22..61c8da4edea04 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -56,6 +56,39 @@ webContents.setWindowOpenHandler((details) => { }) ``` +### Removed: `<webview>` `new-window` event + +The `new-window` event of `<webview>` has been removed. There is no direct replacement. + +```js +// Removed in Electron 22 +webview.addEventListener('new-window', (event) => {}) +``` + +```javascript fiddle='docs/fiddles/ipc/webview-new-window' +// Replace with + +// main.js +mainWindow.webContents.on('did-attach-webview', (event, wc) => { + wc.setWindowOpenHandler((details) => { + mainWindow.webContents.send('webview-new-window', wc.id, details) + return { action: 'deny' } + }) +}) + +// preload.js +const { ipcRenderer } = require('electron') +ipcRenderer.on('webview-new-window', (e, webContentsId, details) => { + console.log('webview-new-window', webContentsId, details) + document.getElementById('webview').dispatchEvent(new Event('new-window')) +}) + +// renderer.js +document.getElementById('webview').addEventListener('new-window', () => { + console.log('got new-window event') +}) +``` + ### Deprecated: BrowserWindow `scroll-touch-*` events The `scroll-touch-begin`, `scroll-touch-end` and `scroll-touch-edge` events on diff --git a/docs/fiddles/ipc/webview-new-window/child.html b/docs/fiddles/ipc/webview-new-window/child.html new file mode 100644 index 0000000000000..90c94376c284b --- /dev/null +++ b/docs/fiddles/ipc/webview-new-window/child.html @@ -0,0 +1,3 @@ +<body> + <a href="child.html" target="_blank">new window</a> +</body> diff --git a/docs/fiddles/ipc/webview-new-window/index.html b/docs/fiddles/ipc/webview-new-window/index.html new file mode 100644 index 0000000000000..8b461bd15f83a --- /dev/null +++ b/docs/fiddles/ipc/webview-new-window/index.html @@ -0,0 +1,4 @@ +<body> + <webview id=webview src="child.html" allowpopups></webview> + <script src="renderer.js"></script> +</body> diff --git a/docs/fiddles/ipc/webview-new-window/main.js b/docs/fiddles/ipc/webview-new-window/main.js new file mode 100644 index 0000000000000..cab3b1ec1b656 --- /dev/null +++ b/docs/fiddles/ipc/webview-new-window/main.js @@ -0,0 +1,51 @@ +// Modules to control application life and create native browser window +const { app, BrowserWindow } = require('electron') +const path = require('path') + +function createWindow () { + // Create the browser window. + const mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + preload: path.join(__dirname, 'preload.js'), + webviewTag: true + } + }) + + mainWindow.webContents.on('did-attach-webview', (event, wc) => { + wc.setWindowOpenHandler((details) => { + mainWindow.webContents.send('webview-new-window', wc.id, details) + return { action: 'deny' } + }) + }) + + // and load the index.html of the app. + mainWindow.loadFile('index.html') + + // Open the DevTools. + // mainWindow.webContents.openDevTools() +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.whenReady().then(() => { + createWindow() + + app.on('activate', function () { + // On macOS it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) + +// Quit when all windows are closed, except on macOS. There, it's common +// for applications and their menu bar to stay active until the user quits +// explicitly with Cmd + Q. +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') app.quit() +}) + +// In this file you can include the rest of your app's specific main process +// code. You can also put them in separate files and require them here. diff --git a/docs/fiddles/ipc/webview-new-window/preload.js b/docs/fiddles/ipc/webview-new-window/preload.js new file mode 100644 index 0000000000000..5b5b6e70a6265 --- /dev/null +++ b/docs/fiddles/ipc/webview-new-window/preload.js @@ -0,0 +1,6 @@ +const { ipcRenderer } = require('electron') +const webview = document.getElementById('webview') +ipcRenderer.on('webview-new-window', (e, webContentsId, details) => { + console.log('webview-new-window', webContentsId, details) + webview.dispatchEvent(new Event('new-window')) +}) diff --git a/docs/fiddles/ipc/webview-new-window/renderer.js b/docs/fiddles/ipc/webview-new-window/renderer.js new file mode 100644 index 0000000000000..e62d0b4d17bc3 --- /dev/null +++ b/docs/fiddles/ipc/webview-new-window/renderer.js @@ -0,0 +1,4 @@ +const webview = document.getElementById('webview') +webview.addEventListener('new-window', () => { + console.log('got new-window event') +}) From a6ce1bc96d8028c976cf816f33e506d087aa1fb3 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt <jkleinsc@electronjs.org> Date: Thu, 1 Jun 2023 15:04:06 -0400 Subject: [PATCH 143/172] build: drop python2 from CI (#38554) build: drop python2 from CI (#38303) (cherry picked from commit a22e2a778e88361e683597c8c58c8bd3b6cbc4b6) (cherry picked from commit 9bdd4738ae46fc23223a18fbcd272f3ededbd952) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> --- .circleci/config/base.yml | 47 +++++++---------------------------- script/verify-chromedriver.py | 1 + 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index baa6d1e6e8882..533e7f1a0ea08 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -285,7 +285,7 @@ step-gclient-sync: &step-gclient-sync ELECTRON_USE_THREE_WAY_MERGE_FOR_PATCHES=1 gclient sync --with_branch_heads --with_tags if [ "$IS_RELEASE" != "true" ]; then # Re-export all the patches to check if there were changes. - python src/electron/script/export_all_patches.py src/electron/patches/config.json + python3 src/electron/script/export_all_patches.py src/electron/patches/config.json cd src/electron git update-index --refresh || true if ! git diff-index --quiet HEAD --; then @@ -339,8 +339,8 @@ step-setup-goma-for-build: &step-setup-goma-for-build mkdir third_party node -e "require('./src/utils/goma.js').downloadAndPrepare({ gomaOneForAll: true })" export GOMA_FALLBACK_ON_AUTH_FAILURE=true - third_party/goma/goma_ctl.py ensure_start - if [ ! -z "$RAW_GOMA_AUTH" ] && [ "`third_party/goma/goma_auth.py info`" != "Login as Fermi Planck" ]; then + python3 third_party/goma/goma_ctl.py ensure_start + if [ ! -z "$RAW_GOMA_AUTH" ] && [ "`python3 third_party/goma/goma_auth.py info`" != "Login as Fermi Planck" ]; then echo "WARNING!!!!!! Goma authentication is incorrect; please update Goma auth token." exit 1 fi @@ -368,14 +368,14 @@ step-restore-brew-cache: &step-restore-brew-cache - /usr/local/Cellar/gnu-tar - /usr/local/bin/gtar keys: - - v6-brew-cache-{{ arch }} + - v7-brew-cache-{{ arch }} step-save-brew-cache: &step-save-brew-cache save_cache: paths: - /usr/local/Cellar/gnu-tar - /usr/local/bin/gtar - key: v6-brew-cache-{{ arch }} + key: v7-brew-cache-{{ arch }} name: Persisting brew cache step-get-more-space-on-mac: &step-get-more-space-on-mac @@ -744,9 +744,9 @@ step-verify-mksnapshot: &step-verify-mksnapshot if [ "$IS_ASAN" != "1" ]; then cd src if [ "$TARGET_ARCH" == "arm" ] || [ "$TARGET_ARCH" == "arm64" ]; then - python electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default --snapshot-files-dir $PWD/cross-arch-snapshots + python3 electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default --snapshot-files-dir $PWD/cross-arch-snapshots else - python electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default + python3 electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default fi fi @@ -756,7 +756,7 @@ step-verify-chromedriver: &step-verify-chromedriver command: | if [ "$IS_ASAN" != "1" ]; then cd src - python electron/script/verify-chromedriver.py --source-root "$PWD" --build-dir out/Default + python3 electron/script/verify-chromedriver.py --source-root "$PWD" --build-dir out/Default fi step-setup-linux-for-headless-testing: &step-setup-linux-for-headless-testing @@ -872,7 +872,7 @@ step-maybe-cross-arch-snapshot: &step-maybe-cross-arch-snapshot elif [ "`uname`" == "Darwin" ]; then cp "out/Default/$MKSNAPSHOT_PATH/libffmpeg.dylib" out/Default fi - python electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default --create-snapshot-only + python3 electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default --create-snapshot-only mkdir cross-arch-snapshots cp out/Default-mksnapshot-test/*.bin cross-arch-snapshots fi @@ -1024,7 +1024,6 @@ step-ts-compile: &step-ts-compile # List of all steps. steps-electron-gn-check: &steps-electron-gn-check steps: - - install-python2-mac - *step-setup-goma-for-build - checkout-from-cache - *step-setup-env-for-build @@ -1052,7 +1051,6 @@ steps-tests: &steps-tests - *step-setup-linux-for-headless-testing - *step-restore-brew-cache - *step-fix-known-hosts-linux - - install-python2-mac - *step-install-signing-cert-on-mac - run: @@ -1136,31 +1134,6 @@ steps-test-node: &steps-test-node # Command Aliases commands: - install-python2-mac: - steps: - - restore_cache: - keys: - - v2.7.18-python-cache-{{ arch }} - name: Restore python cache - - run: - name: Install python2 on macos - command: | - if [ "`uname`" == "Darwin" ] && [ "$IS_ELECTRON_RUNNER" != "1" ]; then - if [ ! -f "python-downloads/python-2.7.18-macosx10.9.pkg" ]; then - mkdir python-downloads - echo 'Downloading Python 2.7.18' - curl -O https://dev-cdn.electronjs.org/python/python-2.7.18-macosx10.9.pkg - mv python-2.7.18-macosx10.9.pkg python-downloads - else - echo 'Using Python install from cache' - fi - sudo installer -pkg python-downloads/python-2.7.18-macosx10.9.pkg -target / - fi - - save_cache: - paths: - - python-downloads - key: v2.7.18-python-cache-{{ arch }} - name: Persisting python cache maybe-restore-portaled-src-cache: parameters: halt-if-successful: @@ -1324,7 +1297,6 @@ commands: - run: rm -rf src/electron - *step-restore-brew-cache - *step-install-gnutar-on-mac - - install-python2-mac - *step-save-brew-cache - when: condition: << parameters.build >> @@ -1496,7 +1468,6 @@ commands: - *step-depot-tools-get - *step-depot-tools-add-to-path - *step-restore-brew-cache - - install-python2-mac - *step-get-more-space-on-mac - when: condition: << parameters.checkout >> diff --git a/script/verify-chromedriver.py b/script/verify-chromedriver.py index 5244bb5c57b73..fba6869b0c8bf 100644 --- a/script/verify-chromedriver.py +++ b/script/verify-chromedriver.py @@ -17,6 +17,7 @@ def main(): chromedriver_name = { 'darwin': 'chromedriver', 'win32': 'chromedriver.exe', + 'linux': 'chromedriver', 'linux2': 'chromedriver' } From d654650f7b2aa54c4fef76c3682cb8edfcce3bea Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:18:05 -0700 Subject: [PATCH 144/172] build: improve error output in release.js (#38662) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --- script/release/release.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/script/release/release.js b/script/release/release.js index 0116113524e42..3f453ea7fa3fa 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -77,7 +77,7 @@ async function validateReleaseAssets (release, validatingRelease) { } else { await verifyShasumsForRemoteFiles(downloadUrls) .catch(err => { - console.log(`${fail} error verifyingShasums`, err); + console.error(`${fail} error verifyingShasums`, err); }); } const azRemoteFiles = azRemoteFilesForVersion(release.tag_name); @@ -90,7 +90,7 @@ function check (condition, statement, exitIfFail = false) { console.log(`${pass} ${statement}`); } else { failureCount++; - console.log(`${fail} ${statement}`); + console.error(`${fail} ${statement}`); if (exitIfFail) process.exit(1); } } @@ -212,7 +212,7 @@ function runScript (scriptName, scriptArgs, cwd) { try { return execSync(scriptCommand, scriptOptions); } catch (err) { - console.log(`${fail} Error running ${scriptName}`, err); + console.error(`${fail} Error running ${scriptName}`, err); process.exit(1); } } @@ -266,7 +266,8 @@ async function createReleaseShasums (release) { repo: targetRepo, asset_id: existingAssets[0].id }).catch(err => { - console.log(`${fail} Error deleting ${fileName} on GitHub:`, err); + console.error(`${fail} Error deleting ${fileName} on GitHub:`, err); + process.exit(1); }); } console.log(`Creating and uploading the release ${fileName}.`); @@ -292,7 +293,7 @@ async function uploadShasumFile (filePath, fileName, releaseId) { data: fs.createReadStream(filePath), name: fileName }).catch(err => { - console.log(`${fail} Error uploading ${filePath} to GitHub:`, err); + console.error(`${fail} Error uploading ${filePath} to GitHub:`, err); process.exit(1); }); } @@ -301,13 +302,13 @@ function saveShaSumFile (checksums, fileName) { return new Promise((resolve, reject) => { temp.open(fileName, (err, info) => { if (err) { - console.log(`${fail} Could not create ${fileName} file`); + console.error(`${fail} Could not create ${fileName} file`); process.exit(1); } else { fs.writeFileSync(info.fd, checksums); fs.close(info.fd, (err) => { if (err) { - console.log(`${fail} Could close ${fileName} file`); + console.error(`${fail} Could close ${fileName} file`); process.exit(1); } resolve(info.path); @@ -333,7 +334,7 @@ async function publishRelease (release) { draft: false, make_latest: makeLatest ? 'true' : 'false' }).catch(err => { - console.log(`${fail} Error publishing release:`, err); + console.error(`${fail} Error publishing release:`, err); process.exit(1); }); } @@ -403,7 +404,7 @@ async function verifyDraftGitHubReleaseAssets (release) { return { url: response.headers.location, file: asset.name }; })).catch(err => { - console.log(`${fail} Error downloading files from GitHub`, err); + console.error(`${fail} Error downloading files from GitHub`, err); process.exit(1); }); From 609855101cf1dbc3d5684ec0233131a72c612312 Mon Sep 17 00:00:00 2001 From: David Sanders <dsanders11@ucsbalum.com> Date: Thu, 8 Jun 2023 14:48:46 +0800 Subject: [PATCH 145/172] build: upgrade @electron/github-app-auth to 2.0.0 (#38665) build: upgrade @electron/github-app-auth to 2.0.0 (#38435) --- package.json | 2 +- yarn.lock | 337 ++++++++++++++++----------------------------------- 2 files changed, 104 insertions(+), 235 deletions(-) diff --git a/package.json b/package.json index fa5bbf3f39acc..a16654b917a6f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@azure/storage-blob": "^12.9.0", "@electron/docs-parser": "^1.0.0", "@electron/fiddle-core": "^1.0.4", - "@electron/github-app-auth": "^1.5.0", + "@electron/github-app-auth": "^2.0.0", "@electron/typescript-definitions": "^8.10.0", "@octokit/rest": "^19.0.7", "@primer/octicons": "^10.0.0", diff --git a/yarn.lock b/yarn.lock index b20dc8f88c51c..92dbea7125729 100644 --- a/yarn.lock +++ b/yarn.lock @@ -156,13 +156,13 @@ optionalDependencies: global-agent "^3.0.0" -"@electron/github-app-auth@^1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@electron/github-app-auth/-/github-app-auth-1.5.0.tgz#426e64ba50143417d9b68f2795a1b119cb62108b" - integrity sha512-t6Za+3E7jdIf1CX06nNV/avZhqSXNEkCLJ1xeAt5FKU9HdGbjzwSfirM+UlHO7lMGyuf13BGCZOCB1kODhDLWQ== +"@electron/github-app-auth@^2.0.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@electron/github-app-auth/-/github-app-auth-2.1.0.tgz#89b268fdc6a34106e64215c7fe00facd5060dc22" + integrity sha512-Y2p2ukLrbyZdon8wRsCsDaM0260MN9IC4x14lR9owa3hL9MqVfML6uZbLBFkkR3hEvN5RlAKpjUsh0yz+dwz8w== dependencies: - "@octokit/auth-app" "^3.6.1" - "@octokit/rest" "^18.12.0" + "@octokit/auth-app" "^4.0.13" + "@octokit/rest" "^19.0.11" "@electron/typescript-definitions@^8.10.0": version "8.10.0" @@ -253,45 +253,34 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" -"@octokit/auth-app@^3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-3.6.1.tgz#aa5b02cc211175cbc28ce6c03c73373c1206d632" - integrity sha512-6oa6CFphIYI7NxxHrdVOzhG7hkcKyGyYocg7lNDSJVauVOLtylg8hNJzoUyPAYKKK0yUeoZamE/lMs2tG+S+JA== - dependencies: - "@octokit/auth-oauth-app" "^4.3.0" - "@octokit/auth-oauth-user" "^1.2.3" - "@octokit/request" "^5.6.0" - "@octokit/request-error" "^2.1.0" - "@octokit/types" "^6.0.3" - "@types/lru-cache" "^5.1.0" +"@octokit/auth-app@^4.0.13": + version "4.0.13" + resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-4.0.13.tgz#53323bee6bfefbb73ea544dd8e6a0144550e13e3" + integrity sha512-NBQkmR/Zsc+8fWcVIFrwDgNXS7f4XDrkd9LHdi9DPQw1NdGHLviLzRO2ZBwTtepnwHXW5VTrVU9eFGijMUqllg== + dependencies: + "@octokit/auth-oauth-app" "^5.0.0" + "@octokit/auth-oauth-user" "^2.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" deprecation "^2.3.1" - lru-cache "^6.0.0" - universal-github-app-jwt "^1.0.1" + lru-cache "^9.0.0" + universal-github-app-jwt "^1.1.1" universal-user-agent "^6.0.0" -"@octokit/auth-oauth-app@^4.3.0": - version "4.3.4" - resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-4.3.4.tgz#7030955b1a59d4d977904775c606477d95fcfe8e" - integrity sha512-OYOTSSINeUAiLMk1uelaGB/dEkReBqHHr8+hBejzMG4z1vA4c7QSvDAS0RVZSr4oD4PEUPYFzEl34K7uNrXcWA== +"@octokit/auth-oauth-app@^5.0.0": + version "5.0.5" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-5.0.5.tgz#be2a93d72835133b4866ac4721aa628849475525" + integrity sha512-UPX1su6XpseaeLVCi78s9droxpGtBWIgz9XhXAx9VXabksoF0MyI5vaa1zo1njyYt6VaAjFisC2A2Wchcu2WmQ== dependencies: - "@octokit/auth-oauth-device" "^3.1.1" + "@octokit/auth-oauth-device" "^4.0.0" "@octokit/auth-oauth-user" "^2.0.0" - "@octokit/request" "^5.6.3" - "@octokit/types" "^6.0.3" + "@octokit/request" "^6.0.0" + "@octokit/types" "^9.0.0" "@types/btoa-lite" "^1.0.0" btoa-lite "^1.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-oauth-device@^3.1.1": - version "3.1.4" - resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-3.1.4.tgz#703c42f27a1e2eb23498a7001ad8e9ecf4a2f477" - integrity sha512-6sHE/++r+aEFZ/BKXOGPJcH/nbgbBjS1A4CHfq/PbPEwb0kZEt43ykW98GBO/rYBPAYaNpCPvXfGwzgR9yMCXg== - dependencies: - "@octokit/oauth-methods" "^2.0.0" - "@octokit/request" "^6.0.0" - "@octokit/types" "^6.10.0" - universal-user-agent "^6.0.0" - "@octokit/auth-oauth-device@^4.0.0": version "4.0.3" resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-4.0.3.tgz#00ce77233517e0d7d39e42a02652f64337d9df81" @@ -302,18 +291,6 @@ "@octokit/types" "^8.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-oauth-user@^1.2.3": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-1.3.0.tgz#da4e4529145181a6aa717ae858afb76ebd6e3360" - integrity sha512-3QC/TAdk7onnxfyZ24BnJRfZv8TRzQK7SEFUS9vLng4Vv6Hv6I64ujdk/CUkREec8lhrwU764SZ/d+yrjjqhaQ== - dependencies: - "@octokit/auth-oauth-device" "^3.1.1" - "@octokit/oauth-methods" "^1.1.0" - "@octokit/request" "^5.4.14" - "@octokit/types" "^6.12.2" - btoa-lite "^1.0.0" - universal-user-agent "^6.0.0" - "@octokit/auth-oauth-user@^2.0.0": version "2.0.4" resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-2.0.4.tgz#88f060ec678d7d493695af8d827e115dd064e212" @@ -326,13 +303,6 @@ btoa-lite "^1.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-token@^2.4.4": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" - integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g== - dependencies: - "@octokit/types" "^6.0.3" - "@octokit/auth-token@^3.0.0": version "3.0.3" resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-3.0.3.tgz#ce7e48a3166731f26068d7a7a7996b5da58cbe0c" @@ -340,19 +310,6 @@ dependencies: "@octokit/types" "^9.0.0" -"@octokit/core@^3.5.1": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" - integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== - dependencies: - "@octokit/auth-token" "^2.4.4" - "@octokit/graphql" "^4.5.8" - "@octokit/request" "^5.6.3" - "@octokit/request-error" "^2.0.5" - "@octokit/types" "^6.0.3" - before-after-hook "^2.2.0" - universal-user-agent "^6.0.0" - "@octokit/core@^4.1.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.0.tgz#8c253ba9605aca605bc46187c34fcccae6a96648" @@ -366,13 +323,17 @@ before-after-hook "^2.2.0" universal-user-agent "^6.0.0" -"@octokit/endpoint@^6.0.1": - version "6.0.5" - resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.5.tgz#43a6adee813c5ffd2f719e20cfd14a1fee7c193a" - integrity sha512-70K5u6zd45ItOny6aHQAsea8HHQjlQq85yqOMe+Aj8dkhN2qSJ9T+Q3YjUjEYfPRBcuUWNgMn62DQnP/4LAIiQ== +"@octokit/core@^4.2.1": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.1.tgz#fee6341ad0ce60c29cc455e056cd5b500410a588" + integrity sha512-tEDxFx8E38zF3gT7sSMDrT1tGumDgsw5yPG6BBh/X+5ClIQfMH/Yqocxz1PnHx6CHyF6pxmovUTOfZAUvQ0Lvw== dependencies: - "@octokit/types" "^5.0.0" - is-plain-object "^4.0.0" + "@octokit/auth-token" "^3.0.0" + "@octokit/graphql" "^5.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" + before-after-hook "^2.2.0" universal-user-agent "^6.0.0" "@octokit/endpoint@^7.0.0": @@ -384,15 +345,6 @@ is-plain-object "^5.0.0" universal-user-agent "^6.0.0" -"@octokit/graphql@^4.5.8": - version "4.8.0" - resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" - integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg== - dependencies: - "@octokit/request" "^5.6.0" - "@octokit/types" "^6.0.3" - universal-user-agent "^6.0.0" - "@octokit/graphql@^5.0.0": version "5.0.5" resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-5.0.5.tgz#a4cb3ea73f83b861893a6370ee82abb36e81afd2" @@ -402,27 +354,11 @@ "@octokit/types" "^9.0.0" universal-user-agent "^6.0.0" -"@octokit/oauth-authorization-url@^4.3.1": - version "4.3.3" - resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-4.3.3.tgz#6a6ef38f243086fec882b62744f39b517528dfb9" - integrity sha512-lhP/t0i8EwTmayHG4dqLXgU+uPVys4WD/qUNvC+HfB1S1dyqULm5Yx9uKc1x79aP66U1Cb4OZeW8QU/RA9A4XA== - "@octokit/oauth-authorization-url@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-5.0.0.tgz#029626ce87f3b31addb98cd0d2355c2381a1c5a1" integrity sha512-y1WhN+ERDZTh0qZ4SR+zotgsQUE1ysKnvBt1hvDRB2WRzYtVKQjn97HEPzoehh66Fj9LwNdlZh+p6TJatT0zzg== -"@octokit/oauth-methods@^1.1.0": - version "1.2.6" - resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-1.2.6.tgz#b9ac65e374b2cc55ee9dd8dcdd16558550438ea7" - integrity sha512-nImHQoOtKnSNn05uk2o76om1tJWiAo4lOu2xMAHYsNr0fwopP+Dv+2MlGvaMMlFjoqVd3fF3X5ZDTKCsqgmUaQ== - dependencies: - "@octokit/oauth-authorization-url" "^4.3.1" - "@octokit/request" "^5.4.14" - "@octokit/request-error" "^2.0.5" - "@octokit/types" "^6.12.2" - btoa-lite "^1.0.0" - "@octokit/oauth-methods@^2.0.0": version "2.0.4" resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-2.0.4.tgz#6abd9593ca7f91fe5068375a363bd70abd5516dc" @@ -434,11 +370,6 @@ "@octokit/types" "^8.0.0" btoa-lite "^1.0.0" -"@octokit/openapi-types@^12.11.0": - version "12.11.0" - resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.11.0.tgz#da5638d64f2b919bca89ce6602d059f1b52d3ef0" - integrity sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ== - "@octokit/openapi-types@^14.0.0": version "14.0.0" resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-14.0.0.tgz#949c5019028c93f189abbc2fb42f333290f7134a" @@ -449,12 +380,10 @@ resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-16.0.0.tgz#d92838a6cd9fb4639ca875ddb3437f1045cc625e" integrity sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA== -"@octokit/plugin-paginate-rest@^2.16.8": - version "2.21.3" - resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz#7f12532797775640dbb8224da577da7dc210c87e" - integrity sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw== - dependencies: - "@octokit/types" "^6.40.0" +"@octokit/openapi-types@^17.2.0": + version "17.2.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-17.2.0.tgz#f1800b5f9652b8e1b85cc6dfb1e0dc888810bdb5" + integrity sha512-MazrFNx4plbLsGl+LFesMo96eIXkFgEtaKbnNpdh4aQ0VM10aoylFsTYP1AEjkeoRNZiiPe3T6Gl2Hr8dJWdlQ== "@octokit/plugin-paginate-rest@^6.0.0": version "6.0.0" @@ -463,19 +392,19 @@ dependencies: "@octokit/types" "^9.0.0" +"@octokit/plugin-paginate-rest@^6.1.2": + version "6.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.1.2.tgz#f86456a7a1fe9e58fec6385a85cf1b34072341f8" + integrity sha512-qhrmtQeHU/IivxucOV1bbI/xZyC/iOBhclokv7Sut5vnejAIAEXVcGQeRpQlU39E0WwK9lNvJHphHri/DB6lbQ== + dependencies: + "@octokit/tsconfig" "^1.0.2" + "@octokit/types" "^9.2.3" + "@octokit/plugin-request-log@^1.0.4": version "1.0.4" resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== -"@octokit/plugin-rest-endpoint-methods@^5.12.0": - version "5.16.2" - resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz#7ee8bf586df97dd6868cf68f641354e908c25342" - integrity sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw== - dependencies: - "@octokit/types" "^6.39.0" - deprecation "^2.3.1" - "@octokit/plugin-rest-endpoint-methods@^7.0.0": version "7.0.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.0.1.tgz#f7ebe18144fd89460f98f35a587b056646e84502" @@ -484,14 +413,12 @@ "@octokit/types" "^9.0.0" deprecation "^2.3.1" -"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" - integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== +"@octokit/plugin-rest-endpoint-methods@^7.1.2": + version "7.1.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.1.3.tgz#b7ed1d9a58608b7ca30f47eea9c0f527bb6b67f2" + integrity sha512-0aoPd4f1k/KXPTGSX0NbxcBrShBHArgcW3pujEvLa6wUfcfA1BehxQ2Ifwa6CbJ4SfzaO79FvGgaUipoxDsgjA== dependencies: - "@octokit/types" "^6.0.3" - deprecation "^2.0.0" - once "^1.4.0" + "@octokit/types" "^9.2.3" "@octokit/request-error@^3.0.0": version "3.0.2" @@ -502,39 +429,27 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@^5.4.14", "@octokit/request@^5.6.0", "@octokit/request@^5.6.3": - version "5.6.3" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" - integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== - dependencies: - "@octokit/endpoint" "^6.0.1" - "@octokit/request-error" "^2.1.0" - "@octokit/types" "^6.16.1" - is-plain-object "^5.0.0" - node-fetch "^2.6.7" - universal-user-agent "^6.0.0" - "@octokit/request@^6.0.0": - version "6.2.2" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-6.2.2.tgz#a2ba5ac22bddd5dcb3f539b618faa05115c5a255" - integrity sha512-6VDqgj0HMc2FUX2awIs+sM6OwLgwHvAi4KCK3mT2H2IKRt6oH9d0fej5LluF5mck1lRR/rFWN0YIDSYXYSylbw== + version "6.2.5" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-6.2.5.tgz#7beef1065042998f7455973ef3f818e7b84d6ec2" + integrity sha512-z83E8UIlPNaJUsXpjD8E0V5o/5f+vJJNbNcBwVZsX3/vC650U41cOkTLjq4PKk9BYonQGOnx7N17gvLyNjgGcQ== dependencies: "@octokit/endpoint" "^7.0.0" "@octokit/request-error" "^3.0.0" - "@octokit/types" "^8.0.0" + "@octokit/types" "^9.0.0" is-plain-object "^5.0.0" node-fetch "^2.6.7" universal-user-agent "^6.0.0" -"@octokit/rest@^18.12.0": - version "18.12.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" - integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q== +"@octokit/rest@^19.0.11": + version "19.0.11" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-19.0.11.tgz#2ae01634fed4bd1fca5b642767205ed3fd36177c" + integrity sha512-m2a9VhaP5/tUw8FwfnW2ICXlXpLPIqxtg3XcAiGMLj/Xhw3RSBfZ8le/466ktO1Gcjr8oXudGnHhxV1TXJgFxw== dependencies: - "@octokit/core" "^3.5.1" - "@octokit/plugin-paginate-rest" "^2.16.8" + "@octokit/core" "^4.2.1" + "@octokit/plugin-paginate-rest" "^6.1.2" "@octokit/plugin-request-log" "^1.0.4" - "@octokit/plugin-rest-endpoint-methods" "^5.12.0" + "@octokit/plugin-rest-endpoint-methods" "^7.1.2" "@octokit/rest@^19.0.7": version "19.0.7" @@ -546,19 +461,10 @@ "@octokit/plugin-request-log" "^1.0.4" "@octokit/plugin-rest-endpoint-methods" "^7.0.0" -"@octokit/types@^5.0.0": - version "5.2.0" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.2.0.tgz#d075dc23bf293f540739250b6879e2c1be2fc20c" - integrity sha512-XjOk9y4m8xTLIKPe1NFxNWBdzA2/z3PFFA/bwf4EoH6oS8hM0Y46mEa4Cb+KCyj/tFDznJFahzQ0Aj3o1FYq4A== - dependencies: - "@types/node" ">= 8" - -"@octokit/types@^6.0.3", "@octokit/types@^6.10.0", "@octokit/types@^6.12.2", "@octokit/types@^6.16.1", "@octokit/types@^6.39.0", "@octokit/types@^6.40.0": - version "6.41.0" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04" - integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg== - dependencies: - "@octokit/openapi-types" "^12.11.0" +"@octokit/tsconfig@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@octokit/tsconfig/-/tsconfig-1.0.2.tgz#59b024d6f3c0ed82f00d08ead5b3750469125af7" + integrity sha512-I0vDR0rdtP8p2lGMzvsJzbhdOWy405HcGovrspJ8RRibHnyRgggUSNO5AIox5LmqiwmatHKYsvj6VGFHkqS7lA== "@octokit/types@^8.0.0": version "8.0.0" @@ -574,6 +480,13 @@ dependencies: "@octokit/openapi-types" "^16.0.0" +"@octokit/types@^9.2.3": + version "9.2.3" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-9.2.3.tgz#d0af522f394d74b585cefb7efd6197ca44d183a9" + integrity sha512-MMeLdHyFIALioycq+LFcA71v0S2xpQUX2cw6pPbHQjaibcHYwLnmK/kMZaWuGfGfjBJZ3wRUq+dOaWsvrPJVvA== + dependencies: + "@octokit/openapi-types" "^17.2.0" + "@opentelemetry/api@^1.0.1": version "1.0.4" resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.0.4.tgz#a167e46c10d05a07ab299fc518793b0cff8f6924" @@ -816,10 +729,10 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= -"@types/jsonwebtoken@^8.3.3": - version "8.5.0" - resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.0.tgz#2531d5e300803aa63279b232c014acf780c981c5" - integrity sha512-9bVao7LvyorRGZCw0VmH/dr7Og+NdjYSsKAxB43OQoComFbBgsEpoR9JW6+qSq/ogwVBg8GI2MfAlk4SYI4OLg== +"@types/jsonwebtoken@^9.0.0": + version "9.0.2" + resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz#9eeb56c76dd555039be2a3972218de5bd3b8d83e" + integrity sha512-drE6uz7QBKq1fYqqoFKTDRdFCPHd5TCub75BM+D+cMx7NU9hUz7SESLfC2fSCXVFMO5Yj8sOWHuGqPgjc+fz0Q== dependencies: "@types/node" "*" @@ -842,11 +755,6 @@ resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-2.1.0.tgz#ea3dd64c4805597311790b61e872cbd1ed2cd806" integrity sha512-Q7DYAOi9O/+cLLhdaSvKdaumWyHbm7HAk/bFwwyTuU0arR5yyCeW5GOoqt4tJTpDRxhpx9Q8kQL6vMpuw9hDSw== -"@types/lru-cache@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03" - integrity sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w== - "@types/markdown-it@^10.0.0": version "10.0.3" resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-10.0.3.tgz#a9800d14b112c17f1de76ec33eff864a4815eec7" @@ -912,11 +820,6 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.1.tgz#d5544f6de0aae03eefbb63d5120f6c8be0691946" integrity sha512-rp7La3m845mSESCgsJePNL/JQyhkOJA6G4vcwvVgkDAwHhGdq5GCumxmPjEk1MZf+8p5ZQAUE7tqgQRQTXN7uQ== -"@types/node@>= 8": - version "14.0.27" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.27.tgz#a151873af5a5e851b51b3b065c9e63390a9e0eb1" - integrity sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g== - "@types/node@^11.13.7": version "11.13.22" resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.22.tgz#91ee88ebfa25072433497f6f3150f84fa8c3a91b" @@ -3648,11 +3551,6 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-plain-object@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-4.1.1.tgz#1a14d6452cbd50790edc7fdaa0aed5a40a35ebb5" - integrity sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA== - is-plain-object@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" @@ -3828,21 +3726,15 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jsonwebtoken@^8.5.1: - version "8.5.1" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" - integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== +jsonwebtoken@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz#d0faf9ba1cc3a56255fe49c0961a67e520c1926d" + integrity sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw== dependencies: jws "^3.2.2" - lodash.includes "^4.3.0" - lodash.isboolean "^3.0.3" - lodash.isinteger "^4.0.4" - lodash.isnumber "^3.0.3" - lodash.isplainobject "^4.0.6" - lodash.isstring "^4.0.1" - lodash.once "^4.0.0" + lodash "^4.17.21" ms "^2.1.1" - semver "^5.6.0" + semver "^7.3.8" jsx-ast-utils@^2.1.0: version "2.4.1" @@ -4070,47 +3962,12 @@ lodash.flatten@^4.4.0, lodash.flatten@~4.4.0: resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= -lodash.includes@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" - integrity sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8= - -lodash.isboolean@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" - integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY= - -lodash.isinteger@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" - integrity sha1-YZwK89A/iwTDH1iChAt3sRzWg0M= - -lodash.isnumber@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" - integrity sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w= - -lodash.isplainobject@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" - integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= - -lodash.isstring@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" - integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= - -lodash.once@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" - integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= - lodash.range@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash.range/-/lodash.range-3.2.0.tgz#f461e588f66683f7eadeade513e38a69a565a15d" integrity sha1-9GHliPZmg/fq3q3lE+OKaaVloV0= -lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15: +lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -4175,6 +4032,11 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +lru-cache@^9.0.0: + version "9.1.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-9.1.2.tgz#255fdbc14b75589d6d0e73644ca167a8db506835" + integrity sha512-ERJq3FOzJTxBbFjZ7iDs+NiK4VI9Wz+RdrrAB8dio1oV+YvdPzUEE4QNiT2VD51DkIbCYRUUzCRkssXCHqSnKQ== + make-error@^1.1.1: version "1.3.5" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" @@ -6096,6 +5958,13 @@ semver@^7.3.5: dependencies: lru-cache "^6.0.0" +semver@^7.3.8: + version "7.5.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.1.tgz#c90c4d631cf74720e46b21c1d37ea07edfab91ec" + integrity sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw== + dependencies: + lru-cache "^6.0.0" + send@0.17.1: version "0.17.1" resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" @@ -6922,13 +6791,13 @@ unist-util-visit@^2.0.0: unist-util-is "^4.0.0" unist-util-visit-parents "^3.0.0" -universal-github-app-jwt@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-1.1.0.tgz#0abaa876101cdf1d3e4c546be2768841c0c1b514" - integrity sha512-3b+ocAjjz4JTyqaOT+NNBd5BtTuvJTxWElIoeHSVelUV9J3Jp7avmQTdLKCaoqi/5Ox2o/q+VK19TJ233rVXVQ== +universal-github-app-jwt@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-1.1.1.tgz#d57cee49020662a95ca750a057e758a1a7190e6e" + integrity sha512-G33RTLrIBMFmlDV4u4CBF7dh71eWwykck4XgaxaIVeZKOYZRAAxvcGMRFTUclVY6xoUPQvO4Ne5wKGxYm/Yy9w== dependencies: - "@types/jsonwebtoken" "^8.3.3" - jsonwebtoken "^8.5.1" + "@types/jsonwebtoken" "^9.0.0" + jsonwebtoken "^9.0.0" universal-user-agent@^6.0.0: version "6.0.0" From 1d60268033d555c8fc9000814f5d90d178202738 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 8 Jun 2023 11:34:57 +0100 Subject: [PATCH 146/172] chore: cherry-pick 2 changes from Release-1-M114 (#38653) * chore: [22-x-y] cherry-pick 2 changes from Release-1-M114 * 73af1a19a901 from v8 * 0035a4a8dac2 from v8 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/v8/.patches | 2 + patches/v8/cherry-pick-73af1a19a901.patch | 257 ++++++++++++++++++ ...dler_selection_for_arguments_objects.patch | 122 +++++++++ 3 files changed, 381 insertions(+) create mode 100644 patches/v8/cherry-pick-73af1a19a901.patch create mode 100644 patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 97bd6ad2bfc9e..703db8c93280a 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -15,3 +15,5 @@ cherry-pick-546e00df97ac.patch cherry-pick-f6ddbf42b1ea.patch cherry-pick-c605df24af3c.patch cherry-pick-f4b66ae451c2.patch +merged_ic_fix_store_handler_selection_for_arguments_objects.patch +cherry-pick-73af1a19a901.patch diff --git a/patches/v8/cherry-pick-73af1a19a901.patch b/patches/v8/cherry-pick-73af1a19a901.patch new file mode 100644 index 0000000000000..c45845ffdcdc6 --- /dev/null +++ b/patches/v8/cherry-pick-73af1a19a901.patch @@ -0,0 +1,257 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Sheludko <ishell@chromium.org> +Date: Thu, 1 Jun 2023 10:59:39 +0200 +Subject: Merged: [lookup] Robustify LookupIterator against own lookups + +... on non-JSReceiver objects. + +Bug: chromium:1447430 +(cherry picked from commit 515f187ba067ee4a99fdf5198cca2c97abd342fd) + +Change-Id: Ib9382d90ce19d6b55ee0b236dd299ded03ade04d +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4575069 +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#35} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/objects/lookup-inl.h b/src/objects/lookup-inl.h +index ff30fcc4f211f49d244e8431cfdb5cba29484329..579a195f06beec657271b8f84b5d92bc8c908d55 100644 +--- a/src/objects/lookup-inl.h ++++ b/src/objects/lookup-inl.h +@@ -167,7 +167,7 @@ Handle<Name> PropertyKey::GetName(Isolate* isolate) { + } + + Handle<Name> LookupIterator::name() const { +- DCHECK(!IsElement(*holder_)); ++ DCHECK_IMPLIES(!holder_.is_null(), !IsElement(*holder_)); + return name_; + } + +@@ -254,6 +254,7 @@ void LookupIterator::UpdateProtector() { + } + + InternalIndex LookupIterator::descriptor_number() const { ++ DCHECK(!holder_.is_null()); + DCHECK(!IsElement(*holder_)); + DCHECK(has_property_); + DCHECK(holder_->HasFastProperties(isolate_)); +@@ -261,6 +262,7 @@ InternalIndex LookupIterator::descriptor_number() const { + } + + InternalIndex LookupIterator::dictionary_entry() const { ++ DCHECK(!holder_.is_null()); + DCHECK(!IsElement(*holder_)); + DCHECK(has_property_); + DCHECK(!holder_->HasFastProperties(isolate_)); +@@ -275,13 +277,14 @@ LookupIterator::Configuration LookupIterator::ComputeConfiguration( + } + + // static +-Handle<JSReceiver> LookupIterator::GetRoot(Isolate* isolate, +- Handle<Object> lookup_start_object, +- size_t index) { ++MaybeHandle<JSReceiver> LookupIterator::GetRoot( ++ Isolate* isolate, Handle<Object> lookup_start_object, size_t index, ++ Configuration configuration) { + if (lookup_start_object->IsJSReceiver(isolate)) { + return Handle<JSReceiver>::cast(lookup_start_object); + } +- return GetRootForNonJSReceiver(isolate, lookup_start_object, index); ++ return GetRootForNonJSReceiver(isolate, lookup_start_object, index, ++ configuration); + } + + template <class T> +diff --git a/src/objects/lookup.cc b/src/objects/lookup.cc +index e08ebaff089f8ab0a1b347f9eb5befd85e3c115b..920d28ffa81798c2e5fe9e15db016501d72728c6 100644 +--- a/src/objects/lookup.cc ++++ b/src/objects/lookup.cc +@@ -42,27 +42,20 @@ PropertyKey::PropertyKey(Isolate* isolate, Handle<Object> key, bool* success) { + } + } + +-LookupIterator::LookupIterator(Isolate* isolate, Handle<Object> receiver, +- Handle<Name> name, Handle<Map> transition_map, +- PropertyDetails details, bool has_property) +- : configuration_(DEFAULT), +- state_(TRANSITION), +- has_property_(has_property), +- interceptor_state_(InterceptorState::kUninitialized), +- property_details_(details), +- isolate_(isolate), +- name_(name), +- transition_(transition_map), +- receiver_(receiver), +- lookup_start_object_(receiver), +- index_(kInvalidIndex) { +- holder_ = GetRoot(isolate, lookup_start_object_); +-} +- + template <bool is_element> + void LookupIterator::Start() { + // GetRoot might allocate if lookup_start_object_ is a string. +- holder_ = GetRoot(isolate_, lookup_start_object_, index_); ++ MaybeHandle<JSReceiver> maybe_holder = ++ GetRoot(isolate_, lookup_start_object_, index_, configuration_); ++ if (!maybe_holder.ToHandle(&holder_)) { ++ // This is an attempt to perform an own property lookup on a non-JSReceiver ++ // that doesn't have any properties. ++ DCHECK(!lookup_start_object_->IsJSReceiver()); ++ DCHECK(!check_prototype_chain()); ++ has_property_ = false; ++ state_ = NOT_FOUND; ++ return; ++ } + + { + DisallowGarbageCollection no_gc; +@@ -135,19 +128,27 @@ template void LookupIterator::RestartInternal<true>(InterceptorState); + template void LookupIterator::RestartInternal<false>(InterceptorState); + + // static +-Handle<JSReceiver> LookupIterator::GetRootForNonJSReceiver( +- Isolate* isolate, Handle<Object> lookup_start_object, size_t index) { +- // Strings are the only objects with properties (only elements) directly on +- // the wrapper. Hence we can skip generating the wrapper for all other cases. +- if (lookup_start_object->IsString(isolate) && +- index < +- static_cast<size_t>(String::cast(*lookup_start_object).length())) { +- // TODO(verwaest): Speed this up. Perhaps use a cached wrapper on the native +- // context, ensuring that we don't leak it into JS? +- Handle<JSFunction> constructor = isolate->string_function(); +- Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); +- Handle<JSPrimitiveWrapper>::cast(result)->set_value(*lookup_start_object); +- return result; ++MaybeHandle<JSReceiver> LookupIterator::GetRootForNonJSReceiver( ++ Isolate* isolate, Handle<Object> lookup_start_object, size_t index, ++ Configuration configuration) { ++ // Strings are the only non-JSReceiver objects with properties (only elements ++ // and 'length') directly on the wrapper. Hence we can skip generating ++ // the wrapper for all other cases. ++ bool own_property_lookup = (configuration & kPrototypeChain) == 0; ++ if (lookup_start_object->IsString(isolate)) { ++ if (own_property_lookup || ++ index < ++ static_cast<size_t>(String::cast(*lookup_start_object).length())) { ++ // TODO(verwaest): Speed this up. Perhaps use a cached wrapper on the ++ // native context, ensuring that we don't leak it into JS? ++ Handle<JSFunction> constructor = isolate->string_function(); ++ Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); ++ Handle<JSPrimitiveWrapper>::cast(result)->set_value(*lookup_start_object); ++ return result; ++ } ++ } else if (own_property_lookup) { ++ // Signal that the lookup will not find anything. ++ return {}; + } + Handle<HeapObject> root( + lookup_start_object->GetPrototypeChainRootMap(isolate).prototype(isolate), +@@ -903,6 +904,7 @@ Handle<Object> LookupIterator::FetchValue( + } + + bool LookupIterator::IsConstFieldValueEqualTo(Object value) const { ++ DCHECK(!holder_.is_null()); + DCHECK(!IsElement(*holder_)); + DCHECK(holder_->HasFastProperties(isolate_)); + DCHECK_EQ(PropertyLocation::kField, property_details_.location()); +@@ -944,6 +946,7 @@ bool LookupIterator::IsConstFieldValueEqualTo(Object value) const { + } + + bool LookupIterator::IsConstDictValueEqualTo(Object value) const { ++ DCHECK(!holder_.is_null()); + DCHECK(!IsElement(*holder_)); + DCHECK(!holder_->HasFastProperties(isolate_)); + DCHECK(!holder_->IsJSGlobalObject()); +@@ -994,6 +997,7 @@ int LookupIterator::GetAccessorIndex() const { + + FieldIndex LookupIterator::GetFieldIndex() const { + DCHECK(has_property_); ++ DCHECK(!holder_.is_null()); + DCHECK(holder_->HasFastProperties(isolate_)); + DCHECK_EQ(PropertyLocation::kField, property_details_.location()); + DCHECK(!IsElement(*holder_)); +@@ -1001,6 +1005,7 @@ FieldIndex LookupIterator::GetFieldIndex() const { + } + + Handle<PropertyCell> LookupIterator::GetPropertyCell() const { ++ DCHECK(!holder_.is_null()); + DCHECK(!IsElement(*holder_)); + Handle<JSGlobalObject> holder = GetHolder<JSGlobalObject>(); + return handle(holder->global_dictionary(isolate_, kAcquireLoad) +diff --git a/src/objects/lookup.h b/src/objects/lookup.h +index 782a09225c17a92ee8f08d20ede0902613158c27..15bcda75f2493bf4800d250e37f4273de36a6334 100644 +--- a/src/objects/lookup.h ++++ b/src/objects/lookup.h +@@ -214,11 +214,6 @@ class V8_EXPORT_PRIVATE LookupIterator final { + Handle<Object> lookup_start_object, + Configuration configuration); + +- // For |ForTransitionHandler|. +- LookupIterator(Isolate* isolate, Handle<Object> receiver, Handle<Name> name, +- Handle<Map> transition_map, PropertyDetails details, +- bool has_property); +- + static void InternalUpdateProtector(Isolate* isolate, Handle<Object> receiver, + Handle<Name> name); + +@@ -278,12 +273,12 @@ class V8_EXPORT_PRIVATE LookupIterator final { + Configuration configuration, + Handle<Name> name); + +- static Handle<JSReceiver> GetRootForNonJSReceiver( +- Isolate* isolate, Handle<Object> lookup_start_object, +- size_t index = kInvalidIndex); +- static inline Handle<JSReceiver> GetRoot(Isolate* isolate, +- Handle<Object> lookup_start_object, +- size_t index = kInvalidIndex); ++ static MaybeHandle<JSReceiver> GetRootForNonJSReceiver( ++ Isolate* isolate, Handle<Object> lookup_start_object, size_t index, ++ Configuration configuration); ++ static inline MaybeHandle<JSReceiver> GetRoot( ++ Isolate* isolate, Handle<Object> lookup_start_object, size_t index, ++ Configuration configuration); + + State NotFound(JSReceiver const holder) const; + +diff --git a/test/mjsunit/regress/regress-crbug-1447430.js b/test/mjsunit/regress/regress-crbug-1447430.js +new file mode 100644 +index 0000000000000000000000000000000000000000..c7bb3e72e3af1b9f8c2fa82faeeb2d813fe6ab3c +--- /dev/null ++++ b/test/mjsunit/regress/regress-crbug-1447430.js +@@ -0,0 +1,34 @@ ++// Copyright 2023 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Flags: --allow-natives-syntax ++ ++var s = %CreatePrivateSymbol('x'); ++ ++(function TestSmi() { ++ function f(o, p) { ++ o[p] = 153; ++ } ++ (1).__proto__[s] = 42; ++ %PrepareFunctionForOptimization(f); ++ assertEquals(f(42, s), undefined); ++}()); ++ ++(function TestString() { ++ function f(o, p) { ++ o[p] = 153; ++ } ++ ('xyz').__proto__[s] = 42; ++ %PrepareFunctionForOptimization(f); ++ assertEquals(f('abc', s), undefined); ++}()); ++ ++(function TestSymbol() { ++ function f(o, p) { ++ o[p] = 153; ++ } ++ Symbol('xyz').__proto__[s] = 42; ++ %PrepareFunctionForOptimization(f); ++ assertEquals(f(Symbol('abc'), s), undefined); ++}()); diff --git a/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch b/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch new file mode 100644 index 0000000000000..34e5f40486875 --- /dev/null +++ b/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch @@ -0,0 +1,122 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Sheludko <ishell@chromium.org> +Date: Fri, 2 Jun 2023 18:13:01 +0200 +Subject: Merged: [ic] Fix store handler selection for arguments objects + +Drive-by: fix printing of handlers in --trace-feedback-updates mode. + +(cherry picked from commit e144f3b71e64e01d6ffd247eb15ca1ff56f6287b) + +Bug: chromium:1450481 +Change-Id: Ifbb97d694b8520584df0610aad30805713b29c00 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4584889 +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Cr-Commit-Position: refs/branch-heads/10.9@{#32} +Cr-Branched-From: 8ade6bf1fa237ad30dd9a05cc6ffe548131699e8-refs/heads/10.9.194@{#1} +Cr-Branched-From: 9ff2515271f11cab783f0e82678ae0b925d77dd0-refs/heads/main@{#84164} + +diff --git a/src/diagnostics/objects-printer.cc b/src/diagnostics/objects-printer.cc +index 71604afa7a067e14a891057de4011416f45f4f19..3f94e8aa7701eef49d5a35fd552742279b5e8586 100644 +--- a/src/diagnostics/objects-printer.cc ++++ b/src/diagnostics/objects-printer.cc +@@ -1308,8 +1308,18 @@ void FeedbackNexus::Print(std::ostream& os) { + case FeedbackSlotKind::kSetKeyedStrict: { + os << InlineCacheState2String(ic_state()); + if (ic_state() == InlineCacheState::MONOMORPHIC) { +- os << "\n " << Brief(GetFeedback()) << ": "; +- StoreHandler::PrintHandler(GetFeedbackExtra().GetHeapObjectOrSmi(), os); ++ HeapObject feedback = GetFeedback().GetHeapObject(); ++ HeapObject feedback_extra = GetFeedbackExtra().GetHeapObject(); ++ if (feedback.IsName()) { ++ os << " with name " << Brief(feedback); ++ WeakFixedArray array = WeakFixedArray::cast(feedback_extra); ++ os << "\n " << Brief(array.Get(0)) << ": "; ++ Object handler = array.Get(1).GetHeapObjectOrSmi(); ++ StoreHandler::PrintHandler(handler, os); ++ } else { ++ os << "\n " << Brief(feedback) << ": "; ++ StoreHandler::PrintHandler(feedback_extra, os); ++ } + } else if (ic_state() == InlineCacheState::POLYMORPHIC) { + WeakFixedArray array = + WeakFixedArray::cast(GetFeedback().GetHeapObject()); +diff --git a/src/ic/handler-configuration.cc b/src/ic/handler-configuration.cc +index 43511407e0eb54e2ce22ee132d8a4d37c52b13a7..cd6d834d6b7ec84c1d46105449ca775cd970f4f2 100644 +--- a/src/ic/handler-configuration.cc ++++ b/src/ic/handler-configuration.cc +@@ -584,8 +584,11 @@ void StoreHandler::PrintHandler(Object handler, std::ostream& os) { + os << ", validity cell = "; + store_handler.validity_cell().ShortPrint(os); + os << ")" << std::endl; ++ } else if (handler.IsMap()) { ++ os << "StoreHandler(field transition to " << Brief(handler) << ")" ++ << std::endl; + } else { +- os << "StoreHandler(<unexpected>)(" << Brief(handler) << ")"; ++ os << "StoreHandler(<unexpected>)(" << Brief(handler) << ")" << std::endl; + } + } + +diff --git a/src/ic/ic.cc b/src/ic/ic.cc +index fff21e90bad3451e2d942ec327cb02f394fecc46..f86d9acf9073aba1662de103c5dd5d6056df19bf 100644 +--- a/src/ic/ic.cc ++++ b/src/ic/ic.cc +@@ -2296,10 +2296,18 @@ Handle<Object> KeyedStoreIC::StoreElementHandler( + receiver_map->has_sealed_elements() || + receiver_map->has_nonextensible_elements() || + receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) { ++ // TODO(jgruber): Update counter name. + TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreFastElementStub); +- code = StoreHandler::StoreFastElementBuiltin(isolate(), store_mode); +- if (receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) { +- return code; ++ if (receiver_map->IsJSArgumentsObjectMap() && ++ receiver_map->has_fast_packed_elements()) { ++ // Allow fast behaviour for in-bounds stores while making it miss and ++ // properly handle the out of bounds store case. ++ code = StoreHandler::StoreFastElementBuiltin(isolate(), STANDARD_STORE); ++ } else { ++ code = StoreHandler::StoreFastElementBuiltin(isolate(), store_mode); ++ if (receiver_map->has_typed_array_or_rab_gsab_typed_array_elements()) { ++ return code; ++ } + } + } else if (IsStoreInArrayLiteralIC()) { + // TODO(jgruber): Update counter name. +@@ -2310,7 +2318,7 @@ Handle<Object> KeyedStoreIC::StoreElementHandler( + TRACE_HANDLER_STATS(isolate(), KeyedStoreIC_StoreElementStub); + DCHECK(DICTIONARY_ELEMENTS == receiver_map->elements_kind() || + receiver_map->has_frozen_elements()); +- code = StoreHandler::StoreSlow(isolate(), store_mode); ++ return StoreHandler::StoreSlow(isolate(), store_mode); + } + + if (IsAnyDefineOwn() || IsStoreInArrayLiteralIC()) return code; +diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h +index 04cdb99e103c5ab51c22a91fd7ba0712b757556c..5f93c39b652946a5ad8f23235f958dde4b84cbb4 100644 +--- a/src/objects/map-inl.h ++++ b/src/objects/map-inl.h +@@ -589,6 +589,10 @@ bool Map::has_fast_elements() const { + return IsFastElementsKind(elements_kind()); + } + ++bool Map::has_fast_packed_elements() const { ++ return IsFastPackedElementsKind(elements_kind()); ++} ++ + bool Map::has_sloppy_arguments_elements() const { + return IsSloppyArgumentsElementsKind(elements_kind()); + } +diff --git a/src/objects/map.h b/src/objects/map.h +index 6914a51150f4235386f5dca7af0d8103bc64f9e2..8311850f82bc32b794873689789c510376f67233 100644 +--- a/src/objects/map.h ++++ b/src/objects/map.h +@@ -422,6 +422,7 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> { + inline bool has_fast_smi_or_object_elements() const; + inline bool has_fast_double_elements() const; + inline bool has_fast_elements() const; ++ inline bool has_fast_packed_elements() const; + inline bool has_sloppy_arguments_elements() const; + inline bool has_fast_sloppy_arguments_elements() const; + inline bool has_fast_string_wrapper_elements() const; From 399d2b2d2c52821452f2440f8df0d096c22dcaf8 Mon Sep 17 00:00:00 2001 From: Keeley Hammond <vertedinde@electronjs.org> Date: Thu, 8 Jun 2023 13:24:45 -0700 Subject: [PATCH 147/172] chore: cherry-pick 8 changes from Release-1-M113 (#38332) * chore: [22-x-y] cherry-pick 8 changes from Release-1-M113 * f4c70bc5e89b from v8 * 257a63512782 from v8 * 9964ff18eada from chromium * a1abaf29e189 from angle * fe45418c6592 from angle * d2ce640f16f2 from chromium * bae60787d3e9 from dawn * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/angle/.patches | 2 + ...f_private_variables_in_webgl_shaders.patch | 87 +++++ ...bgl_limit_total_size_of_private_data.patch | 207 ++++++++++ patches/chromium/.patches | 2 + .../chromium/cherry-pick-48785f698b1c.patch | 107 +++++ ...itnavigation_call_in_commiterrorpage.patch | 142 +++++++ patches/config.json | 4 +- patches/dawn/.patches | 1 + ..._to_invalidate_submitted_descriptors.patch | 42 ++ patches/v8/.patches | 2 + ...pi_fix_v8_object_setaccessorproperty.patch | 366 ++++++++++++++++++ ...d_register_in_global_unicode_special.patch | 304 +++++++++++++++ 12 files changed, 1265 insertions(+), 1 deletion(-) create mode 100644 patches/angle/translator_limit_the_size_of_private_variables_in_webgl_shaders.patch create mode 100644 patches/angle/webgl_limit_total_size_of_private_data.patch create mode 100644 patches/chromium/cherry-pick-48785f698b1c.patch create mode 100644 patches/chromium/m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch create mode 100644 patches/dawn/.patches create mode 100644 patches/dawn/change_d3d12_descriptor_allocator_to_invalidate_submitted_descriptors.patch create mode 100644 patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch create mode 100644 patches/v8/merged_regexp_fix_clobbered_register_in_global_unicode_special.patch diff --git a/patches/angle/.patches b/patches/angle/.patches index 25c7c58b6b43a..e2bdc1e72193e 100644 --- a/patches/angle/.patches +++ b/patches/angle/.patches @@ -2,3 +2,5 @@ fix_rename_webswapcgllayer_to_webswapcgllayerchromium.patch cherry-pick-55e2b6daba9d.patch cherry-pick-ce029c91a662.patch cherry-pick-aed05b609629.patch +translator_limit_the_size_of_private_variables_in_webgl_shaders.patch +webgl_limit_total_size_of_private_data.patch diff --git a/patches/angle/translator_limit_the_size_of_private_variables_in_webgl_shaders.patch b/patches/angle/translator_limit_the_size_of_private_variables_in_webgl_shaders.patch new file mode 100644 index 0000000000000..a5dd4b5dd62af --- /dev/null +++ b/patches/angle/translator_limit_the_size_of_private_variables_in_webgl_shaders.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shahbaz Youssefi <syoussefi@chromium.org> +Date: Tue, 28 Mar 2023 11:43:23 -0400 +Subject: Translator: Limit the size of private variables in WebGL shaders + +As a follow up to +https://chromium-review.googlesource.com/c/angle/angle/+/3023033, the +limit to shader-private variables (locals and globals) is further +reduced to 1MB. A variable that large will not fit in GPU registers and +will spill to memory, killing performance. + +Bug: chromium:1427865 +Change-Id: I77314d4b891c591cd9a83ad2aebb77d7256f3ada +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4377639 +Reviewed-by: Kenneth Russell <kbr@chromium.org> + +diff --git a/src/compiler/translator/ValidateTypeSizeLimitations.cpp b/src/compiler/translator/ValidateTypeSizeLimitations.cpp +index c9607db74b53487950d31f6a56d55f3e834556a0..6097b6d236b547710aeaf37a6fb45df97d621ca0 100644 +--- a/src/compiler/translator/ValidateTypeSizeLimitations.cpp ++++ b/src/compiler/translator/ValidateTypeSizeLimitations.cpp +@@ -20,9 +20,13 @@ namespace sh + namespace + { + +-// Arbitrarily enforce that types - even local variables' - declared +-// with a size in bytes of over 2 GB will cause compilation failure. +-constexpr size_t kMaxTypeSizeInBytes = static_cast<size_t>(2) * 1024 * 1024 * 1024; ++// Arbitrarily enforce that all types declared with a size in bytes of over 2 GB will cause ++// compilation failure. ++// ++// For local and global variables, the limit is much lower (1MB) as that much memory won't fit in ++// the GPU registers anyway. ++constexpr size_t kMaxVariableSizeInBytes = static_cast<size_t>(2) * 1024 * 1024 * 1024; ++constexpr size_t kMaxPrivateVariableSizeInBytes = static_cast<size_t>(1) * 1024 * 1024; + + // Traverses intermediate tree to ensure that the shader does not + // exceed certain implementation-defined limits on the sizes of types. +@@ -78,13 +82,24 @@ class ValidateTypeSizeLimitationsTraverser : public TIntermTraverser + // whether the row-major layout is correctly determined. + bool isRowMajorLayout = false; + TraverseShaderVariable(shaderVar, isRowMajorLayout, &visitor); +- if (layoutEncoder.getCurrentOffset() > kMaxTypeSizeInBytes) ++ if (layoutEncoder.getCurrentOffset() > kMaxVariableSizeInBytes) + { + error(asSymbol->getLine(), + "Size of declared variable exceeds implementation-defined limit", + asSymbol->getName()); + return false; + } ++ ++ const bool isPrivate = variableType.getQualifier() == EvqTemporary || ++ variableType.getQualifier() == EvqGlobal || ++ variableType.getQualifier() == EvqConst; ++ if (layoutEncoder.getCurrentOffset() > kMaxPrivateVariableSizeInBytes && isPrivate) ++ { ++ error(asSymbol->getLine(), ++ "Size of declared private variable exceeds implementation-defined limit", ++ asSymbol->getName()); ++ return false; ++ } + } + + return true; +diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp +index 7dc56cddbc63add1aca6fca3bfd031f3da8d04fc..f4bd19baf3582c0b4a840d73a57ea6fc385159a6 100644 +--- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp ++++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp +@@ -5283,8 +5283,8 @@ void main() + + constexpr char kVSArrayTooLarge[] = + R"(varying vec4 color; +-// 2 GB / 32 aligned bytes per mat2 = 67108864 +-const int array_size = 67108865; ++// 1 MB / 32 aligned bytes per mat2 = 32768 ++const int array_size = 32769; + void main() + { + mat2 array[array_size]; +@@ -5296,7 +5296,7 @@ void main() + + constexpr char kVSArrayMuchTooLarge[] = + R"(varying vec4 color; +-const int array_size = 556007917; ++const int array_size = 55600; + void main() + { + mat2 array[array_size]; diff --git a/patches/angle/webgl_limit_total_size_of_private_data.patch b/patches/angle/webgl_limit_total_size_of_private_data.patch new file mode 100644 index 0000000000000..91d01ec20c26a --- /dev/null +++ b/patches/angle/webgl_limit_total_size_of_private_data.patch @@ -0,0 +1,207 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shahbaz Youssefi <syoussefi@chromium.org> +Date: Wed, 3 May 2023 13:41:36 -0400 +Subject: WebGL: Limit total size of private data + +... not just individual arrays. + +Bug: chromium:1431761 +Change-Id: I721e29aeceeaf12c3f6a67b668abffb8dfbc89b0 +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4503753 +Reviewed-by: Kenneth Russell <kbr@chromium.org> +Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> + +diff --git a/src/compiler/translator/ValidateTypeSizeLimitations.cpp b/src/compiler/translator/ValidateTypeSizeLimitations.cpp +index 6097b6d236b547710aeaf37a6fb45df97d621ca0..2a033ad9d9422349865a9f2af7084bbf1c2c23d9 100644 +--- a/src/compiler/translator/ValidateTypeSizeLimitations.cpp ++++ b/src/compiler/translator/ValidateTypeSizeLimitations.cpp +@@ -35,7 +35,9 @@ class ValidateTypeSizeLimitationsTraverser : public TIntermTraverser + { + public: + ValidateTypeSizeLimitationsTraverser(TSymbolTable *symbolTable, TDiagnostics *diagnostics) +- : TIntermTraverser(true, false, false, symbolTable), mDiagnostics(diagnostics) ++ : TIntermTraverser(true, false, false, symbolTable), ++ mDiagnostics(diagnostics), ++ mTotalPrivateVariablesSize(0) + { + ASSERT(diagnostics); + } +@@ -93,18 +95,33 @@ class ValidateTypeSizeLimitationsTraverser : public TIntermTraverser + const bool isPrivate = variableType.getQualifier() == EvqTemporary || + variableType.getQualifier() == EvqGlobal || + variableType.getQualifier() == EvqConst; +- if (layoutEncoder.getCurrentOffset() > kMaxPrivateVariableSizeInBytes && isPrivate) ++ if (isPrivate) + { +- error(asSymbol->getLine(), +- "Size of declared private variable exceeds implementation-defined limit", +- asSymbol->getName()); +- return false; ++ if (layoutEncoder.getCurrentOffset() > kMaxPrivateVariableSizeInBytes) ++ { ++ error(asSymbol->getLine(), ++ "Size of declared private variable exceeds implementation-defined limit", ++ asSymbol->getName()); ++ return false; ++ } ++ mTotalPrivateVariablesSize += layoutEncoder.getCurrentOffset(); + } + } + + return true; + } + ++ void validateTotalPrivateVariableSize() ++ { ++ if (mTotalPrivateVariablesSize > kMaxPrivateVariableSizeInBytes) ++ { ++ mDiagnostics->error( ++ TSourceLoc{}, ++ "Total size of declared private variables exceeds implementation-defined limit", ++ ""); ++ } ++ } ++ + private: + void error(TSourceLoc loc, const char *reason, const ImmutableString &token) + { +@@ -213,6 +230,8 @@ class ValidateTypeSizeLimitationsTraverser : public TIntermTraverser + + TDiagnostics *mDiagnostics; + std::vector<int> mLoopSymbolIds; ++ ++ size_t mTotalPrivateVariablesSize; + }; + + } // namespace +@@ -223,6 +242,7 @@ bool ValidateTypeSizeLimitations(TIntermNode *root, + { + ValidateTypeSizeLimitationsTraverser validate(symbolTable, diagnostics); + root->traverse(&validate); ++ validate.validateTotalPrivateVariableSize(); + return diagnostics->numErrors() == 0; + } + +diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp +index f4bd19baf3582c0b4a840d73a57ea6fc385159a6..1b265568fc8a87280cc192fbd573a8b11dfb29ec 100644 +--- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp ++++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp +@@ -5271,11 +5271,12 @@ TEST_P(WebGLCompatibilityTest, ValidateArraySizes) + // fairly small array. + constexpr char kVSArrayOK[] = + R"(varying vec4 color; +-const int array_size = 1000; ++const int array_size = 500; + void main() + { + mat2 array[array_size]; +- if (array[0][0][0] == 2.0) ++ mat2 array2[array_size]; ++ if (array[0][0][0] + array2[0][0][0] == 2.0) + color = vec4(0.0, 1.0, 0.0, 1.0); + else + color = vec4(1.0, 0.0, 0.0, 1.0); +@@ -5353,6 +5354,103 @@ void main() + EXPECT_EQ(0u, program); + } + ++// Reject attempts to allocate too much private memory. ++// This is an implementation-defined limit - crbug.com/1431761. ++TEST_P(WebGLCompatibilityTest, ValidateTotalPrivateSize) ++{ ++ constexpr char kTooLargeGlobalMemory1[] = ++ R"(precision mediump float; ++ ++// 1 MB / 16 bytes per vec4 = 65536 ++vec4 array[32768]; ++vec4 array2[32769]; ++ ++void main() ++{ ++ if (array[0].x + array[1].x == 0.) ++ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); ++ else ++ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); ++})"; ++ ++ constexpr char kTooLargeGlobalMemory2[] = ++ R"(precision mediump float; ++ ++// 1 MB / 16 bytes per vec4 = 65536 ++vec4 array[32767]; ++vec4 array2[32767]; ++vec4 x, y, z; ++ ++void main() ++{ ++ if (array[0].x + array[1].x == x.w + y.w + z.w) ++ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); ++ else ++ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); ++})"; ++ ++ constexpr char kTooLargeGlobalAndLocalMemory1[] = ++ R"(precision mediump float; ++ ++// 1 MB / 16 bytes per vec4 = 65536 ++vec4 array[32768]; ++ ++void main() ++{ ++ vec4 array2[32769]; ++ if (array[0].x + array[1].x == 2.0) ++ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); ++ else ++ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); ++})"; ++ ++ // Note: The call stack is not taken into account for the purposes of total memory calculation. ++ constexpr char kTooLargeGlobalAndLocalMemory2[] = ++ R"(precision mediump float; ++ ++// 1 MB / 16 bytes per vec4 = 65536 ++vec4 array[32768]; ++ ++float f() ++{ ++ vec4 array2[16384]; ++ return array2[0].x; ++} ++ ++float g() ++{ ++ vec4 array3[16383]; ++ return array3[0].x; ++} ++ ++float h() ++{ ++ vec4 value; ++ float value2 ++ return value.x + value2; ++} ++ ++void main() ++{ ++ if (array[0].x + f() + g() + h() == 2.0) ++ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); ++ else ++ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); ++})"; ++ ++ GLuint program = CompileProgram(essl1_shaders::vs::Simple(), kTooLargeGlobalMemory1); ++ EXPECT_EQ(0u, program); ++ ++ program = CompileProgram(essl1_shaders::vs::Simple(), kTooLargeGlobalMemory2); ++ EXPECT_EQ(0u, program); ++ ++ program = CompileProgram(essl1_shaders::vs::Simple(), kTooLargeGlobalAndLocalMemory1); ++ EXPECT_EQ(0u, program); ++ ++ program = CompileProgram(essl1_shaders::vs::Simple(), kTooLargeGlobalAndLocalMemory2); ++ EXPECT_EQ(0u, program); ++} ++ + // Linking should fail when corresponding vertex/fragment uniform blocks have different precision + // qualifiers. + TEST_P(WebGL2CompatibilityTest, UniformBlockPrecisionMismatch) diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 5aa1ecec37e4c..a42ea7d1a2e16 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -159,3 +159,5 @@ cherry-pick-f58218891f8c.patch wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch m112_cherry_pick_libxml_cve_fix.patch m112_fix_scopedobservation_uaf_in.patch +cherry-pick-48785f698b1c.patch +m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch diff --git a/patches/chromium/cherry-pick-48785f698b1c.patch b/patches/chromium/cherry-pick-48785f698b1c.patch new file mode 100644 index 0000000000000..1e3ab437ac4ac --- /dev/null +++ b/patches/chromium/cherry-pick-48785f698b1c.patch @@ -0,0 +1,107 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Arthur Sonzogni <arthursonzogni@chromium.org> +Date: Tue, 2 May 2023 09:40:37 +0000 +Subject: Avoid buffer overflow read in HFSReadNextNonIgnorableCodePoint +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Unicode codepoints goes beyond 0xFFFF. + +It exists upper and lower case characters there: `𞤡 `vs `𞥃`. + +The buffer overflow occurred when using the lookup table: +``` +lower_case_table[codepoint >> 8] +``` + +Bug: 1425115 +Fixed: 1425115 +Change-Id: I679da02dbe570283a68176fbd3c0c620caa4f9ce +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4481260 +Reviewed-by: Alexander Timin <altimin@chromium.org> +Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> +Cr-Commit-Position: refs/heads/main@{#1138234} + +diff --git a/base/files/file_path.cc b/base/files/file_path.cc +index a43c09317da96332584286fdb67284b2bedd753f..3a7cca6fad051816d6d018857c8039594c51ec65 100644 +--- a/base/files/file_path.cc ++++ b/base/files/file_path.cc +@@ -775,7 +775,7 @@ int FilePath::CompareIgnoreCase(StringPieceType string1, + #elif BUILDFLAG(IS_APPLE) + // Mac OS X specific implementation of file string comparisons. + +-// cf. http://developer.apple.com/mac/library/technotes/tn/tn1150.html#UnicodeSubtleties ++// cf. https://developer.apple.com/library/archive/technotes/tn/tn1150.html#UnicodeSubtleties + // + // "When using CreateTextEncoding to create a text encoding, you should set + // the TextEncodingBase to kTextEncodingUnicodeV2_0, set the +@@ -801,11 +801,12 @@ int FilePath::CompareIgnoreCase(StringPieceType string1, + // Ignored characters are mapped to zero. + // + // cf. downloadable file linked in +-// http://developer.apple.com/mac/library/technotes/tn/tn1150.html#StringComparisonAlgorithm ++// https://developer.apple.com/library/archive/technotes/tn/tn1150.html#Downloads + + namespace { + +-const UInt16 lower_case_table[] = { ++// clang-format off ++const UInt16 lower_case_table[11 * 256] = { + // High-byte indices ( == 0 iff no case mapping and no ignorables ) + + /* 0 */ 0x0100, 0x0200, 0x0000, 0x0300, 0x0400, 0x0500, 0x0000, 0x0000, +@@ -1191,11 +1192,12 @@ const UInt16 lower_case_table[] = { + /* F */ 0xFFF0, 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0xFFF5, 0xFFF6, 0xFFF7, + 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF, + }; ++// clang-format on + +-// Returns the next non-ignorable codepoint within string starting from the +-// position indicated by index, or zero if there are no more. +-// The passed-in index is automatically advanced as the characters in the input +-// HFS-decomposed UTF-8 strings are read. ++// Returns the next non-ignorable codepoint within `string` starting from the ++// position indicated by `index`, or zero if there are no more. ++// The passed-in `index` is automatically advanced as the characters in the ++// input HFS-decomposed UTF-8 strings are read. + inline base_icu::UChar32 HFSReadNextNonIgnorableCodepoint(const char* string, + size_t length, + size_t* index) { +@@ -1206,12 +1208,16 @@ inline base_icu::UChar32 HFSReadNextNonIgnorableCodepoint(const char* string, + CBU8_NEXT(reinterpret_cast<const uint8_t*>(string), *index, length, + codepoint); + DCHECK_GT(codepoint, 0); +- if (codepoint > 0) { ++ ++ // Note: Here, there are no lower case conversion implemented in the ++ // Supplementary Multilingual Plane (codepoint > 0xFFFF). ++ ++ if (codepoint > 0 && codepoint <= 0xFFFF) { + // Check if there is a subtable for this upper byte. + int lookup_offset = lower_case_table[codepoint >> 8]; + if (lookup_offset != 0) + codepoint = lower_case_table[lookup_offset + (codepoint & 0x00FF)]; +- // Note: codepoint1 may be again 0 at this point if the character was ++ // Note: `codepoint` may be again 0 at this point if the character was + // an ignorable. + } + } +diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc +index b9b14c1ebb6a7046f6432531913fd72b045d6cb0..90457a001c2f0d5652ae1394c9d142bfd0003ca6 100644 +--- a/base/files/file_path_unittest.cc ++++ b/base/files/file_path_unittest.cc +@@ -1188,6 +1188,13 @@ TEST_F(FilePathTest, CompareIgnoreCase) { + {{FPL("K\u0301U\u032DO\u0304\u0301N"), FPL("\u1E31\u1E77\u1E53n")}, 0}, + {{FPL("k\u0301u\u032Do\u0304\u0301n"), FPL("\u1E30\u1E76\u1E52n")}, 0}, + {{FPL("k\u0301u\u032Do\u0304\u0302n"), FPL("\u1E30\u1E76\u1E52n")}, 1}, ++ ++ // Codepoints > 0xFFFF ++ // Here, we compare the `Adlam Letter Shu` in its capital and small version. ++ {{FPL("\U0001E921"), FPL("\U0001E943")}, -1}, ++ {{FPL("\U0001E943"), FPL("\U0001E921")}, 1}, ++ {{FPL("\U0001E921"), FPL("\U0001E921")}, 0}, ++ {{FPL("\U0001E943"), FPL("\U0001E943")}, 0}, + #endif + }; + diff --git a/patches/chromium/m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch b/patches/chromium/m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch new file mode 100644 index 0000000000000..3f86ceb49badd --- /dev/null +++ b/patches/chromium/m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch @@ -0,0 +1,142 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Rakina Zata Amni <rakina@chromium.org> +Date: Tue, 30 May 2023 16:24:26 +0000 +Subject: Return after ReadyCommitNavigation call in CommitErrorPage if it + deletes NavigationRequest + +M108 merge issue: + content/browser/renderer_host/navigation_request.cc: + topics_eligible_ isn't present in M108 + +NavigationRequest::ReadyToCommitNavigation() can cause deletion of the +NavigationRequest, so callers should check for that possibility after +calling the function. A caller in CommitErrorPage is missing that +check, which this CL adds, along with a regression test. + +(cherry picked from commit 42db806805ef2be64ee92803d3a784631b2a7df0) + +Bug: 1444360 +Change-Id: I3964da4909a6709b7730d25d6497b19c098f4f21 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4520493 +Commit-Queue: Charlie Reis <creis@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1143298} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4567848 +Reviewed-by: Rakina Zata Amni <rakina@chromium.org> +Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> +Cr-Commit-Position: refs/branch-heads/5359@{#1460} +Cr-Branched-From: 27d3765d341b09369006d030f83f582a29eb57ae-refs/heads/main@{#1058933} + +diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc +index f6f25544bd36fceb60ada013178cc8fb67e7b10a..ebc0a0c57fb78b3f0044979cca115c78f98f8c2d 100644 +--- a/content/browser/renderer_host/navigation_request.cc ++++ b/content/browser/renderer_host/navigation_request.cc +@@ -4913,7 +4913,13 @@ void NavigationRequest::CommitErrorPage( + } + } + ++ base::WeakPtr<NavigationRequest> weak_self(weak_factory_.GetWeakPtr()); + ReadyToCommitNavigation(true /* is_error */); ++ // The caller above might result in the deletion of `this`. Return immediately ++ // if so. ++ if (!weak_self) { ++ return; ++ } + + PopulateDocumentTokenForCrossDocumentNavigation(); + // Use a separate cache shard, and no cookies, for error pages. +diff --git a/content/browser/renderer_host/navigation_request_browsertest.cc b/content/browser/renderer_host/navigation_request_browsertest.cc +index 486a6871d9ff5256123c47accf9f714b67bc30fc..cc4f9acf9e5ec5f8c8dfa8a812a2cc6fb4505526 100644 +--- a/content/browser/renderer_host/navigation_request_browsertest.cc ++++ b/content/browser/renderer_host/navigation_request_browsertest.cc +@@ -43,6 +43,7 @@ + #include "content/public/test/prerender_test_util.h" + #include "content/public/test/test_frame_navigation_observer.h" + #include "content/public/test/test_navigation_observer.h" ++#include "content/public/test/test_service.mojom.h" + #include "content/public/test/test_utils.h" + #include "content/public/test/url_loader_interceptor.h" + #include "content/shell/browser/shell.h" +@@ -3850,4 +3851,83 @@ IN_PROC_BROWSER_TEST_P(NavigationRequestMPArchBrowserTest, + } + } + ++// Tests that when trying to commit an error page for a failed navigation, but ++// the renderer process of the, the navigation won't commit and won't crash. ++// Regression test for https://crbug.com/1444360. ++IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest, ++ RendererCrashedBeforeCommitErrorPage) { ++ // Navigate to `url_a` first. ++ GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html")); ++ ASSERT_TRUE(NavigateToURL(shell(), url_a)); ++ ++ // Set up an URLLoaderInterceptor which will cause future navigations to fail. ++ auto url_loader_interceptor = std::make_unique<URLLoaderInterceptor>( ++ base::BindRepeating([](URLLoaderInterceptor::RequestParams* params) { ++ network::URLLoaderCompletionStatus status; ++ status.error_code = net::ERR_NOT_IMPLEMENTED; ++ params->client->OnComplete(status); ++ return true; ++ })); ++ ++ // Do a navigation to `url_b1` that will fail and commit an error page. This ++ // is important so that the next error page navigation won't need to create a ++ // speculative RenderFrameHost (unless RenderDocument is enabled) and won't ++ // get cancelled earlier than commit time due to speculative RFH deletion. ++ GURL url_b1(embedded_test_server()->GetURL("b.com", "/title1.html")); ++ EXPECT_FALSE(NavigateToURL(shell(), url_b1)); ++ EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), url_b1); ++ EXPECT_TRUE( ++ shell()->web_contents()->GetPrimaryMainFrame()->IsErrorDocument()); ++ ++ // For the next navigation, set up a throttle that will be used to wait for ++ // WillFailRequest() and then defer the navigation, so that we can crash the ++ // error page process first. ++ TestNavigationThrottleInstaller installer( ++ shell()->web_contents(), ++ NavigationThrottle::PROCEED /* will_start_result */, ++ NavigationThrottle::PROCEED /* will_redirect_result */, ++ NavigationThrottle::DEFER /* will_fail_result */, ++ NavigationThrottle::PROCEED /* will_process_result */); ++ ++ // Start a navigation to `url_b2` that will also fail, but before it commits ++ // an error page, cause the error page process to crash. ++ GURL url_b2(embedded_test_server()->GetURL("b.com", "/title2.html")); ++ TestNavigationManager manager(shell()->web_contents(), url_b2); ++ shell()->LoadURL(url_b2); ++ EXPECT_TRUE(manager.WaitForRequestStart()); ++ ++ // Resume the navigation and wait for WillFailRequest(). After this point, we ++ // will have picked the final RenderFrameHost & RenderProcessHost for the ++ // failed navigation. ++ manager.ResumeNavigation(); ++ installer.WaitForThrottleWillFail(); ++ ++ // Kill the error page process. This will cause for the navigation to `url_b2` ++ // to return early in `NavigationRequest::ReadyToCommitNavigation()` and not ++ // commit a new error page. ++ RenderProcessHost* process_to_kill = ++ manager.GetNavigationHandle()->GetRenderFrameHost()->GetProcess(); ++ ASSERT_TRUE(process_to_kill->IsInitializedAndNotDead()); ++ { ++ // Trigger a renderer kill by calling DoSomething() which will cause a bad ++ // message to be reported. ++ RenderProcessHostBadIpcMessageWaiter kill_waiter(process_to_kill); ++ mojo::Remote<mojom::TestService> service; ++ process_to_kill->BindReceiver(service.BindNewPipeAndPassReceiver()); ++ service->DoSomething(base::DoNothing()); ++ EXPECT_EQ(bad_message::RPH_MOJO_PROCESS_ERROR, kill_waiter.Wait()); ++ } ++ ASSERT_FALSE(process_to_kill->IsInitializedAndNotDead()); ++ ++ // Resume the navigation, which won't commit. ++ if (!ShouldCreateNewHostForAllFrames()) { ++ installer.navigation_throttle()->ResumeNavigation(); ++ } ++ manager.WaitForNavigationFinished(); ++ EXPECT_FALSE(WaitForLoadStop(shell()->web_contents())); ++ ++ // The tab stayed at `url_b1` as the `url_b2` navigation didn't commit. ++ EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), url_b1); ++} ++ + } // namespace content diff --git a/patches/config.json b/patches/config.json index 14dd869b10a6b..6ab6da8595e4a 100644 --- a/patches/config.json +++ b/patches/config.json @@ -25,5 +25,7 @@ "src/electron/patches/pdfium": "src/third_party/pdfium", - "src/electron/patches/skia": "src/third_party/skia" + "src/electron/patches/skia": "src/third_party/skia", + + "src/electron/patches/dawn": "src/third_party/dawn" } diff --git a/patches/dawn/.patches b/patches/dawn/.patches new file mode 100644 index 0000000000000..59727faa97f94 --- /dev/null +++ b/patches/dawn/.patches @@ -0,0 +1 @@ +change_d3d12_descriptor_allocator_to_invalidate_submitted_descriptors.patch diff --git a/patches/dawn/change_d3d12_descriptor_allocator_to_invalidate_submitted_descriptors.patch b/patches/dawn/change_d3d12_descriptor_allocator_to_invalidate_submitted_descriptors.patch new file mode 100644 index 0000000000000..2fba963350313 --- /dev/null +++ b/patches/dawn/change_d3d12_descriptor_allocator_to_invalidate_submitted_descriptors.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Brandon Jones <brandon1.jones@intel.com> +Date: Fri, 5 May 2023 18:02:42 +0000 +Subject: Change D3D12 Descriptor Allocator To Invalidate Submitted Descriptors + +Changes D3D12 descriptor allocator to invalidate existing descriptors +after the descriptor heap was submitted for use. This fixes a +synchonization issue where stale descriptors were seen as valid because +command list execution ran long. + +Bug: dawn:1701 +Bug: chromium:1442263 +No-Try: true +Change-Id: Ibfd450b3be6cf91d66e8dce4ffd19ecf1a37f7f5 +Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129920 +Kokoro: Kokoro <noreply+kokoro@google.com> +Reviewed-by: Corentin Wallez <cwallez@chromium.org> +Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com> +(cherry picked from commit df6cb236493da101dad79fe50d4e6df0d5d1e915) +Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131508 +Kokoro: Austin Eng <enga@chromium.org> +Reviewed-by: Austin Eng <enga@chromium.org> + +diff --git a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp +index fe99a63ac9d2d082c2c23eb7940a733a9d13846a..aedb28ad58a0a972879f07a6037499f901fcf04a 100644 +--- a/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp ++++ b/src/dawn/native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp +@@ -237,9 +237,11 @@ bool ShaderVisibleDescriptorAllocator::IsLastShaderVisibleHeapInLRUForTesting() + + bool ShaderVisibleDescriptorAllocator::IsAllocationStillValid( + const GPUDescriptorHeapAllocation& allocation) const { +- // Consider valid if allocated for the pending submit and the shader visible heaps +- // have not switched over. +- return (allocation.GetLastUsageSerial() > mDevice->GetCompletedCommandSerial() && ++ // Descriptor allocations are only valid for the serial they were created for and are ++ // re-allocated every submit. For this reason, we view any descriptors allocated prior to the ++ // pending submit as invalid. We must also verify the descriptor heap has not switched (because ++ // a larger descriptor heap was needed). ++ return (allocation.GetLastUsageSerial() == mDevice->GetPendingCommandSerial() && + allocation.GetHeapSerial() == mHeapSerial); + } + diff --git a/patches/v8/.patches b/patches/v8/.patches index 703db8c93280a..dcb91e0f2c9f0 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -17,3 +17,5 @@ cherry-pick-c605df24af3c.patch cherry-pick-f4b66ae451c2.patch merged_ic_fix_store_handler_selection_for_arguments_objects.patch cherry-pick-73af1a19a901.patch +merged_regexp_fix_clobbered_register_in_global_unicode_special.patch +m108-lts_api_fix_v8_object_setaccessorproperty.patch diff --git a/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch b/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch new file mode 100644 index 0000000000000..d9ce9b4655a02 --- /dev/null +++ b/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch @@ -0,0 +1,366 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Sheludko <ishell@chromium.org> +Date: Thu, 27 Apr 2023 11:11:32 +0200 +Subject: Fix v8::Object::SetAccessorProperty + +... by using JavaScript spec compliant JSReceiver::DefineOwnProperty. + +Drive-by: +- cleanup comments in include/v8-object.h, insert links to +respective pages of https://tc39.es/ecma262/ when referencing spec, +- rename JSObject::DefineAccessor() to + JSObject::DefineOwnAccessorIgnoreAttributes(). + +(cherry picked from commit b8020e1973d7d3a50b17c076cd948f079e59f9e5) + +Bug: chromium:1433211 +Change-Id: Ia9edaadd68f1986f18581156ad8f79c438b77744 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4458947 +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#87302} +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4573392 +Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> +Reviewed-by: Michael Lippautz <mlippautz@chromium.org> +Reviewed-by: Igor Sheludko <ishell@chromium.org> +Cr-Commit-Position: refs/branch-heads/10.8@{#62} +Cr-Branched-From: f1bc03fd6b4c201abd9f0fd9d51fb989150f97b9-refs/heads/10.8.168@{#1} +Cr-Branched-From: 237de893e1c0a0628a57d0f5797483d3add7f005-refs/heads/main@{#83672} + +diff --git a/include/v8-object.h b/include/v8-object.h +index d7332ba0c88d12e8086f56117631dfb3e1e514b4..dfeda2d39431d481dbeab6698c3d3e7f02a1b19c 100644 +--- a/include/v8-object.h ++++ b/include/v8-object.h +@@ -247,13 +247,16 @@ class V8_EXPORT Object : public Value { + V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index, + Local<Value> value); + +- // Implements CreateDataProperty (ECMA-262, 7.3.4). +- // +- // Defines a configurable, writable, enumerable property with the given value +- // on the object unless the property already exists and is not configurable +- // or the object is not extensible. +- // +- // Returns true on success. ++ /** ++ * Implements CreateDataProperty(O, P, V), see ++ * https://tc39.es/ecma262/#sec-createdataproperty. ++ * ++ * Defines a configurable, writable, enumerable property with the given value ++ * on the object unless the property already exists and is not configurable ++ * or the object is not extensible. ++ * ++ * Returns true on success. ++ */ + V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context, + Local<Name> key, + Local<Value> value); +@@ -261,29 +264,35 @@ class V8_EXPORT Object : public Value { + uint32_t index, + Local<Value> value); + +- // Implements DefineOwnProperty. +- // +- // In general, CreateDataProperty will be faster, however, does not allow +- // for specifying attributes. +- // +- // Returns true on success. ++ /** ++ * Implements [[DefineOwnProperty]] for data property case, see ++ * https://tc39.es/ecma262/#table-essential-internal-methods. ++ * ++ * In general, CreateDataProperty will be faster, however, does not allow ++ * for specifying attributes. ++ * ++ * Returns true on success. ++ */ + V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty( + Local<Context> context, Local<Name> key, Local<Value> value, + PropertyAttribute attributes = None); + +- // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4. +- // +- // The defineProperty function is used to add an own property or +- // update the attributes of an existing own property of an object. +- // +- // Both data and accessor descriptors can be used. +- // +- // In general, CreateDataProperty is faster, however, does not allow +- // for specifying attributes or an accessor descriptor. +- // +- // The PropertyDescriptor can change when redefining a property. +- // +- // Returns true on success. ++ /** ++ * Implements Object.defineProperty(O, P, Attributes), see ++ * https://tc39.es/ecma262/#sec-object.defineproperty. ++ * ++ * The defineProperty function is used to add an own property or ++ * update the attributes of an existing own property of an object. ++ * ++ * Both data and accessor descriptors can be used. ++ * ++ * In general, CreateDataProperty is faster, however, does not allow ++ * for specifying attributes or an accessor descriptor. ++ * ++ * The PropertyDescriptor can change when redefining a property. ++ * ++ * Returns true on success. ++ */ + V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty( + Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor); + +@@ -302,14 +311,15 @@ class V8_EXPORT Object : public Value { + Local<Context> context, Local<Value> key); + + /** +- * Returns Object.getOwnPropertyDescriptor as per ES2016 section 19.1.2.6. ++ * Implements Object.getOwnPropertyDescriptor(O, P), see ++ * https://tc39.es/ecma262/#sec-object.getownpropertydescriptor. + */ + V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor( + Local<Context> context, Local<Name> key); + + /** +- * Object::Has() calls the abstract operation HasProperty(O, P) described +- * in ECMA-262, 7.3.10. Has() returns ++ * Object::Has() calls the abstract operation HasProperty(O, P), see ++ * https://tc39.es/ecma262/#sec-hasproperty. Has() returns + * true, if the object has the property, either own or on the prototype chain. + * Interceptors, i.e., PropertyQueryCallbacks, are called if present. + * +@@ -347,7 +357,7 @@ class V8_EXPORT Object : public Value { + + void SetAccessorProperty(Local<Name> name, Local<Function> getter, + Local<Function> setter = Local<Function>(), +- PropertyAttribute attribute = None, ++ PropertyAttribute attributes = None, + AccessControl settings = DEFAULT); + + /** +diff --git a/src/api/api-natives.cc b/src/api/api-natives.cc +index 8624c279d66e4fa54a7a20681e1398c453b6cdbd..742d3c17a3e7def43813f44b004c8dc41a27ed68 100644 +--- a/src/api/api-natives.cc ++++ b/src/api/api-natives.cc +@@ -92,10 +92,10 @@ MaybeHandle<Object> DefineAccessorProperty(Isolate* isolate, + Handle<FunctionTemplateInfo>::cast(setter)), + Object); + } +- RETURN_ON_EXCEPTION( +- isolate, +- JSObject::DefineAccessor(object, name, getter, setter, attributes), +- Object); ++ RETURN_ON_EXCEPTION(isolate, ++ JSObject::DefineOwnAccessorIgnoreAttributes( ++ object, name, getter, setter, attributes), ++ Object); + return object; + } + +diff --git a/src/api/api.cc b/src/api/api.cc +index 0bc26565403fa1a9827ced3bc6a49ca87bbf46c0..29e163c2e3073ae1f9a86e88f317e9fd44c6c112 100644 +--- a/src/api/api.cc ++++ b/src/api/api.cc +@@ -4932,7 +4932,7 @@ Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, + + void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, + Local<Function> setter, +- PropertyAttribute attribute, ++ PropertyAttribute attributes, + AccessControl settings) { + // TODO(verwaest): Remove |settings|. + DCHECK_EQ(v8::DEFAULT, settings); +@@ -4944,9 +4944,20 @@ void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, + i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); + i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); + if (setter_i.is_null()) setter_i = i_isolate->factory()->null_value(); +- i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), +- v8::Utils::OpenHandle(*name), getter_i, setter_i, +- static_cast<i::PropertyAttributes>(attribute)); ++ ++ i::PropertyDescriptor desc; ++ desc.set_enumerable(!(attributes & v8::DontEnum)); ++ desc.set_configurable(!(attributes & v8::DontDelete)); ++ desc.set_get(getter_i); ++ desc.set_set(setter_i); ++ ++ i::Handle<i::Name> name_i = v8::Utils::OpenHandle(*name); ++ // DefineOwnProperty might still throw if the receiver is a JSProxy and it ++ // might fail if the receiver is non-extensible or already has this property ++ // as non-configurable. ++ Maybe<bool> success = i::JSReceiver::DefineOwnProperty( ++ i_isolate, self, name_i, &desc, Just(i::kDontThrow)); ++ USE(success); + } + + Maybe<bool> Object::SetNativeDataProperty( +diff --git a/src/init/bootstrapper.cc b/src/init/bootstrapper.cc +index fc7b17d582e79b956362e0db46a7aefebd594ed0..8a81c4acda9a92b1d25491aa00278a0e929da695 100644 +--- a/src/init/bootstrapper.cc ++++ b/src/init/bootstrapper.cc +@@ -634,7 +634,9 @@ V8_NOINLINE void SimpleInstallGetterSetter(Isolate* isolate, + Handle<JSFunction> setter = + SimpleCreateFunction(isolate, setter_name, call_setter, 1, true); + +- JSObject::DefineAccessor(base, name, getter, setter, DONT_ENUM).Check(); ++ JSObject::DefineOwnAccessorIgnoreAttributes(base, name, getter, setter, ++ DONT_ENUM) ++ .Check(); + } + + void SimpleInstallGetterSetter(Isolate* isolate, Handle<JSObject> base, +@@ -658,7 +660,8 @@ V8_NOINLINE Handle<JSFunction> SimpleInstallGetter(Isolate* isolate, + + Handle<Object> setter = isolate->factory()->undefined_value(); + +- JSObject::DefineAccessor(base, property_name, getter, setter, DONT_ENUM) ++ JSObject::DefineOwnAccessorIgnoreAttributes(base, property_name, getter, ++ setter, DONT_ENUM) + .Check(); + + return getter; +diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc +index 15356b6c58d2f7355fa8b0dce4d3ea779a2884f9..834f83c0b0e68b9dcbe3fd0595dc2861cdd2c017 100644 +--- a/src/objects/js-objects.cc ++++ b/src/objects/js-objects.cc +@@ -1519,7 +1519,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( + ? desc->set() + : Handle<Object>::cast(isolate->factory()->null_value())); + MaybeHandle<Object> result = +- JSObject::DefineAccessor(it, getter, setter, desc->ToAttributes()); ++ JSObject::DefineOwnAccessorIgnoreAttributes(it, getter, setter, ++ desc->ToAttributes()); + if (result.is_null()) return Nothing<bool>(); + } + } +@@ -1700,8 +1701,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( + : current->has_set() + ? current->set() + : Handle<Object>::cast(isolate->factory()->null_value())); +- MaybeHandle<Object> result = +- JSObject::DefineAccessor(it, getter, setter, attrs); ++ MaybeHandle<Object> result = JSObject::DefineOwnAccessorIgnoreAttributes( ++ it, getter, setter, attrs); + if (result.is_null()) return Nothing<bool>(); + } + } +@@ -4635,22 +4636,19 @@ bool JSObject::HasEnumerableElements() { + UNREACHABLE(); + } + +-MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object, +- Handle<Name> name, +- Handle<Object> getter, +- Handle<Object> setter, +- PropertyAttributes attributes) { ++MaybeHandle<Object> JSObject::DefineOwnAccessorIgnoreAttributes( ++ Handle<JSObject> object, Handle<Name> name, Handle<Object> getter, ++ Handle<Object> setter, PropertyAttributes attributes) { + Isolate* isolate = object->GetIsolate(); + + PropertyKey key(isolate, name); + LookupIterator it(isolate, object, key, LookupIterator::OWN_SKIP_INTERCEPTOR); +- return DefineAccessor(&it, getter, setter, attributes); ++ return DefineOwnAccessorIgnoreAttributes(&it, getter, setter, attributes); + } + +-MaybeHandle<Object> JSObject::DefineAccessor(LookupIterator* it, +- Handle<Object> getter, +- Handle<Object> setter, +- PropertyAttributes attributes) { ++MaybeHandle<Object> JSObject::DefineOwnAccessorIgnoreAttributes( ++ LookupIterator* it, Handle<Object> getter, Handle<Object> setter, ++ PropertyAttributes attributes) { + Isolate* isolate = it->isolate(); + + it->UpdateProtector(); +diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h +index 06489c2b7bae61ecadbd8f020060e86ef50e11b6..ff96bd4be2ff8d2fe03f75b6bca35a744e2084af 100644 +--- a/src/objects/js-objects.h ++++ b/src/objects/js-objects.h +@@ -531,13 +531,14 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> { + GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); + + // Defines an AccessorPair property on the given object. +- V8_EXPORT_PRIVATE static MaybeHandle<Object> DefineAccessor( +- Handle<JSObject> object, Handle<Name> name, Handle<Object> getter, +- Handle<Object> setter, PropertyAttributes attributes); +- static MaybeHandle<Object> DefineAccessor(LookupIterator* it, +- Handle<Object> getter, +- Handle<Object> setter, +- PropertyAttributes attributes); ++ V8_EXPORT_PRIVATE static MaybeHandle<Object> ++ DefineOwnAccessorIgnoreAttributes(Handle<JSObject> object, Handle<Name> name, ++ Handle<Object> getter, ++ Handle<Object> setter, ++ PropertyAttributes attributes); ++ static MaybeHandle<Object> DefineOwnAccessorIgnoreAttributes( ++ LookupIterator* it, Handle<Object> getter, Handle<Object> setter, ++ PropertyAttributes attributes); + + // Defines an AccessorInfo property on the given object. + V8_WARN_UNUSED_RESULT static MaybeHandle<Object> SetAccessor( +diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc +index 56e58bea3e1c7add75729e590b628d9a78558ce6..01111be8d6ea28ed1e1e81255b29da5a77ab1e39 100644 +--- a/src/runtime/runtime-object.cc ++++ b/src/runtime/runtime-object.cc +@@ -1109,7 +1109,8 @@ RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { + auto attrs = PropertyAttributesFromInt(args.smi_value_at(4)); + + RETURN_FAILURE_ON_EXCEPTION( +- isolate, JSObject::DefineAccessor(obj, name, getter, setter, attrs)); ++ isolate, JSObject::DefineOwnAccessorIgnoreAttributes(obj, name, getter, ++ setter, attrs)); + return ReadOnlyRoots(isolate).undefined_value(); + } + +@@ -1215,8 +1216,8 @@ RUNTIME_FUNCTION(Runtime_DefineGetterPropertyUnchecked) { + + RETURN_FAILURE_ON_EXCEPTION( + isolate, +- JSObject::DefineAccessor(object, name, getter, +- isolate->factory()->null_value(), attrs)); ++ JSObject::DefineOwnAccessorIgnoreAttributes( ++ object, name, getter, isolate->factory()->null_value(), attrs)); + return ReadOnlyRoots(isolate).undefined_value(); + } + +@@ -1360,8 +1361,8 @@ RUNTIME_FUNCTION(Runtime_DefineSetterPropertyUnchecked) { + + RETURN_FAILURE_ON_EXCEPTION( + isolate, +- JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), +- setter, attrs)); ++ JSObject::DefineOwnAccessorIgnoreAttributes( ++ object, name, isolate->factory()->null_value(), setter, attrs)); + return ReadOnlyRoots(isolate).undefined_value(); + } + +diff --git a/src/sandbox/testing.cc b/src/sandbox/testing.cc +index fead4aa222ceb81d76f6dfec7e7797e337e7ba94..aab72a18015bf7ac1d0949e9497e85d9d089b4b8 100644 +--- a/src/sandbox/testing.cc ++++ b/src/sandbox/testing.cc +@@ -156,7 +156,8 @@ void InstallGetter(Isolate* isolate, Handle<JSObject> object, + Handle<String> property_name = factory->NewStringFromAsciiChecked(name); + Handle<JSFunction> getter = CreateFunc(isolate, func, property_name, false); + Handle<Object> setter = factory->null_value(); +- JSObject::DefineAccessor(object, property_name, getter, setter, FROZEN); ++ JSObject::DefineOwnAccessorIgnoreAttributes(object, property_name, getter, ++ setter, FROZEN); + } + + void InstallFunction(Isolate* isolate, Handle<JSObject> holder, +diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc +index 53ad0a95e2e63f32610a77ee7195d15f7037898d..4152456d1a7962da4a0d88e15bc68107da585613 100644 +--- a/test/cctest/test-code-stub-assembler.cc ++++ b/test/cctest/test-code-stub-assembler.cc +@@ -1179,7 +1179,9 @@ void AddProperties(Handle<JSObject> object, Handle<Name> names[], + Handle<AccessorPair> pair = Handle<AccessorPair>::cast(value); + Handle<Object> getter(pair->getter(), isolate); + Handle<Object> setter(pair->setter(), isolate); +- JSObject::DefineAccessor(object, names[i], getter, setter, NONE).Check(); ++ JSObject::DefineOwnAccessorIgnoreAttributes(object, names[i], getter, ++ setter, NONE) ++ .Check(); + } else { + JSObject::AddProperty(isolate, object, names[i], value, NONE); + } diff --git a/patches/v8/merged_regexp_fix_clobbered_register_in_global_unicode_special.patch b/patches/v8/merged_regexp_fix_clobbered_register_in_global_unicode_special.patch new file mode 100644 index 0000000000000..b987af2148e23 --- /dev/null +++ b/patches/v8/merged_regexp_fix_clobbered_register_in_global_unicode_special.patch @@ -0,0 +1,304 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shu-yu Guo <syg@chromium.org> +Date: Wed, 26 Apr 2023 10:56:03 -0700 +Subject: Merged: [regexp] Fix clobbered register in global Unicode special + case + +Bug: chromium:1439691 +(cherry picked from commit 2c8a019f39d29b403f881d9b5932e3219fdcc832) + +Change-Id: Ia418ae04bf4352e3618700c55ecd37447023e6eb +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4503810 +Reviewed-by: Jakob Linke <jgruber@chromium.org> +Commit-Queue: Shu-yu Guo <syg@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.2@{#43} +Cr-Branched-From: 755511a138609ac5939449a8ac615c15603a4454-refs/heads/11.2.214@{#1} +Cr-Branched-From: e6b1ccefb0f0f1ff8d310578878130dc53d73749-refs/heads/main@{#86014} + +diff --git a/src/regexp/arm/regexp-macro-assembler-arm.cc b/src/regexp/arm/regexp-macro-assembler-arm.cc +index 2658068b6f94b97f024b1400c8c0b20eefdc5143..5de110c8495ef5bd261df92ca8f459c5f0cc7e5b 100644 +--- a/src/regexp/arm/regexp-macro-assembler-arm.cc ++++ b/src/regexp/arm/regexp-macro-assembler-arm.cc +@@ -877,19 +877,18 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) { + __ add(r2, r2, Operand(num_saved_registers_ * kPointerSize)); + __ str(r2, MemOperand(frame_pointer(), kRegisterOutput)); + +- // Prepare r0 to initialize registers with its value in the next run. +- __ ldr(r0, MemOperand(frame_pointer(), kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), r2); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // r4: capture start index + __ cmp(current_input_offset(), r4); + // Not a zero-length match, restart. +- __ b(ne, &load_char_start_regexp); ++ __ b(ne, &reload_string_start_minus_one); + // Offset from the end is zero if we already reached the end. + __ cmp(current_input_offset(), Operand::Zero()); + __ b(eq, &exit_label_); +@@ -901,6 +900,11 @@ Handle<HeapObject> RegExpMacroAssemblerARM::GetCode(Handle<String> source) { + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } + ++ __ bind(&reload_string_start_minus_one); ++ // Prepare r0 to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ ldr(r0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ + __ b(&load_char_start_regexp); + } else { + __ mov(r0, Operand(SUCCESS)); +diff --git a/src/regexp/ia32/regexp-macro-assembler-ia32.cc b/src/regexp/ia32/regexp-macro-assembler-ia32.cc +index 600234542042ce9a06ceb3b415fece83f6f271bf..6c3df5da7d6c28619902b20419c9cf437325c1d1 100644 +--- a/src/regexp/ia32/regexp-macro-assembler-ia32.cc ++++ b/src/regexp/ia32/regexp-macro-assembler-ia32.cc +@@ -915,19 +915,18 @@ Handle<HeapObject> RegExpMacroAssemblerIA32::GetCode(Handle<String> source) { + __ add(Operand(ebp, kRegisterOutput), + Immediate(num_saved_registers_ * kSystemPointerSize)); + +- // Prepare eax to initialize registers with its value in the next run. +- __ mov(eax, Operand(ebp, kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), ebx); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // edx: capture start index + __ cmp(edi, edx); + // Not a zero-length match, restart. +- __ j(not_equal, &load_char_start_regexp); ++ __ j(not_equal, &reload_string_start_minus_one); + // edi (offset from the end) is zero if we already reached the end. + __ test(edi, edi); + __ j(zero, &exit_label_, Label::kNear); +@@ -941,6 +940,12 @@ Handle<HeapObject> RegExpMacroAssemblerIA32::GetCode(Handle<String> source) { + } + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } ++ ++ __ bind(&reload_string_start_minus_one); ++ // Prepare eax to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ mov(eax, Operand(ebp, kStringStartMinusOne)); ++ + __ jmp(&load_char_start_regexp); + } else { + __ mov(eax, Immediate(SUCCESS)); +diff --git a/src/regexp/loong64/regexp-macro-assembler-loong64.cc b/src/regexp/loong64/regexp-macro-assembler-loong64.cc +index 35fd95bd0f2d210419b4057ced6e16ffd5aec051..d5c52b4134ccbfecef85328e181dae1bbda7bf63 100644 +--- a/src/regexp/loong64/regexp-macro-assembler-loong64.cc ++++ b/src/regexp/loong64/regexp-macro-assembler-loong64.cc +@@ -850,18 +850,17 @@ Handle<HeapObject> RegExpMacroAssemblerLOONG64::GetCode(Handle<String> source) { + __ Add_d(a2, a2, num_saved_registers_ * kIntSize); + __ St_d(a2, MemOperand(frame_pointer(), kRegisterOutput)); + +- // Prepare a0 to initialize registers with its value in the next run. +- __ Ld_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), a2); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // t3: capture start index + // Not a zero-length match, restart. +- __ Branch(&load_char_start_regexp, ne, current_input_offset(), ++ __ Branch(&reload_string_start_minus_one, ne, current_input_offset(), + Operand(t3)); + // Offset from the end is zero if we already reached the end. + __ Branch(&exit_label_, eq, current_input_offset(), +@@ -874,6 +873,11 @@ Handle<HeapObject> RegExpMacroAssemblerLOONG64::GetCode(Handle<String> source) { + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } + ++ __ bind(&reload_string_start_minus_one); ++ // Prepare a0 to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ Ld_d(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ + __ Branch(&load_char_start_regexp); + } else { + __ li(a0, Operand(SUCCESS)); +diff --git a/src/regexp/mips64/regexp-macro-assembler-mips64.cc b/src/regexp/mips64/regexp-macro-assembler-mips64.cc +index 456e166adefc72b7bcaa9245798f3885c2a4c2e7..6ee4c709cf96f68a32a0b3c1ebdc42817293bf29 100644 +--- a/src/regexp/mips64/regexp-macro-assembler-mips64.cc ++++ b/src/regexp/mips64/regexp-macro-assembler-mips64.cc +@@ -898,19 +898,18 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) { + __ Daddu(a2, a2, num_saved_registers_ * kIntSize); + __ Sd(a2, MemOperand(frame_pointer(), kRegisterOutput)); + +- // Prepare a0 to initialize registers with its value in the next run. +- __ Ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), a2); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // t3: capture start index + // Not a zero-length match, restart. +- __ Branch( +- &load_char_start_regexp, ne, current_input_offset(), Operand(t3)); ++ __ Branch(&reload_string_start_minus_one, ne, current_input_offset(), ++ Operand(t3)); + // Offset from the end is zero if we already reached the end. + __ Branch(&exit_label_, eq, current_input_offset(), + Operand(zero_reg)); +@@ -922,6 +921,11 @@ Handle<HeapObject> RegExpMacroAssemblerMIPS::GetCode(Handle<String> source) { + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } + ++ __ bind(&reload_string_start_minus_one); ++ // Prepare a0 to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ Ld(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ + __ Branch(&load_char_start_regexp); + } else { + __ li(v0, Operand(SUCCESS)); +diff --git a/src/regexp/riscv/regexp-macro-assembler-riscv.cc b/src/regexp/riscv/regexp-macro-assembler-riscv.cc +index c8f3eb551e05805003d30a1786acdd9aab96d906..c03be100849c50f471d6839d4cd960e5a78d67d3 100644 +--- a/src/regexp/riscv/regexp-macro-assembler-riscv.cc ++++ b/src/regexp/riscv/regexp-macro-assembler-riscv.cc +@@ -869,18 +869,17 @@ Handle<HeapObject> RegExpMacroAssemblerRISCV::GetCode(Handle<String> source) { + __ AddWord(a2, a2, num_saved_registers_ * kIntSize); + __ StoreWord(a2, MemOperand(frame_pointer(), kRegisterOutput)); + +- // Prepare a0 to initialize registers with its value in the next run. +- __ LoadWord(a0, MemOperand(frame_pointer(), kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), a2); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // s3: capture start index + // Not a zero-length match, restart. +- __ Branch(&load_char_start_regexp, ne, current_input_offset(), ++ __ Branch(&reload_string_start_minus_one, ne, current_input_offset(), + Operand(s3)); + // Offset from the end is zero if we already reached the end. + __ Branch(&exit_label_, eq, current_input_offset(), +@@ -893,6 +892,12 @@ Handle<HeapObject> RegExpMacroAssemblerRISCV::GetCode(Handle<String> source) { + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } + ++ __ bind(&reload_string_start_minus_one); ++ // Prepare a0 to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ LoadWord(a0, ++ MemOperand(frame_pointer(), kStringStartMinusOne)); ++ + __ Branch(&load_char_start_regexp); + } else { + __ li(a0, Operand(SUCCESS)); +diff --git a/src/regexp/s390/regexp-macro-assembler-s390.cc b/src/regexp/s390/regexp-macro-assembler-s390.cc +index a61bc379ba6c265ecb0c5cd7aa8d7a2e35ca6c1e..de184b95862e7f2e64d69cff6b60d866eb212f36 100644 +--- a/src/regexp/s390/regexp-macro-assembler-s390.cc ++++ b/src/regexp/s390/regexp-macro-assembler-s390.cc +@@ -947,19 +947,18 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) { + __ AddS64(r4, Operand(num_saved_registers_ * kIntSize)); + __ StoreU64(r4, MemOperand(frame_pointer(), kRegisterOutput)); + +- // Prepare r2 to initialize registers with its value in the next run. +- __ LoadU64(r2, MemOperand(frame_pointer(), kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), r4); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // r6: capture start index + __ CmpS64(current_input_offset(), r6); + // Not a zero-length match, restart. +- __ bne(&load_char_start_regexp); ++ __ bne(&reload_string_start_minus_one); + // Offset from the end is zero if we already reached the end. + __ CmpS64(current_input_offset(), Operand::Zero()); + __ beq(&exit_label_); +@@ -970,6 +969,11 @@ Handle<HeapObject> RegExpMacroAssemblerS390::GetCode(Handle<String> source) { + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } + ++ __ bind(&reload_string_start_minus_one); ++ // Prepare r2 to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ LoadU64(r2, MemOperand(frame_pointer(), kStringStartMinusOne)); ++ + __ b(&load_char_start_regexp); + } else { + __ mov(r2, Operand(SUCCESS)); +diff --git a/src/regexp/x64/regexp-macro-assembler-x64.cc b/src/regexp/x64/regexp-macro-assembler-x64.cc +index 89fd2e34f1296113c43f16896d8f35d741782709..7c59534aa46c4c1c6fed151d7dad13070d133f47 100644 +--- a/src/regexp/x64/regexp-macro-assembler-x64.cc ++++ b/src/regexp/x64/regexp-macro-assembler-x64.cc +@@ -951,19 +951,18 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) { + __ addq(Operand(rbp, kRegisterOutput), + Immediate(num_saved_registers_ * kIntSize)); + +- // Prepare rax to initialize registers with its value in the next run. +- __ movq(rax, Operand(rbp, kStringStartMinusOne)); +- + // Restore the original regexp stack pointer value (effectively, pop the + // stored base pointer). + PopRegExpBasePointer(backtrack_stackpointer(), kScratchRegister); + ++ Label reload_string_start_minus_one; ++ + if (global_with_zero_length_check()) { + // Special case for zero-length matches. + // rdx: capture start index + __ cmpq(rdi, rdx); + // Not a zero-length match, restart. +- __ j(not_equal, &load_char_start_regexp); ++ __ j(not_equal, &reload_string_start_minus_one); + // rdi (offset from the end) is zero if we already reached the end. + __ testq(rdi, rdi); + __ j(zero, &exit_label_, Label::kNear); +@@ -978,6 +977,11 @@ Handle<HeapObject> RegExpMacroAssemblerX64::GetCode(Handle<String> source) { + if (global_unicode()) CheckNotInSurrogatePair(0, &advance); + } + ++ __ bind(&reload_string_start_minus_one); ++ // Prepare rax to initialize registers with its value in the next run. ++ // Must be immediately before the jump to avoid clobbering. ++ __ movq(rax, Operand(rbp, kStringStartMinusOne)); ++ + __ jmp(&load_char_start_regexp); + } else { + __ Move(rax, SUCCESS); +diff --git a/test/mjsunit/regress/regress-crbug-1439691.js b/test/mjsunit/regress/regress-crbug-1439691.js +new file mode 100644 +index 0000000000000000000000000000000000000000..6c55835535ab4f42ef0446abf863986962df9e9b +--- /dev/null ++++ b/test/mjsunit/regress/regress-crbug-1439691.js +@@ -0,0 +1,7 @@ ++// Copyright 2023 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++function f0() { ++} ++/(?!(a))\1/gudyi[Symbol.replace]("f\uD83D\uDCA9ba\u2603", f0); From c676c0aaca7914d77b7353dc7e3be4baff37662b Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 15:31:02 -0700 Subject: [PATCH 148/172] build: move uploadIndexJson to just before publishRelease (#38702) * build: move uploadIndexJson to just before publishRelease Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * chore: move uploadNodeShasums as well Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --- script/release/release.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script/release/release.js b/script/release/release.js index 3f453ea7fa3fa..0b2ffc4e4a59d 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -351,14 +351,18 @@ async function makeRelease (releaseToValidate) { await validateReleaseAssets(release, true); } else { let draftRelease = await getDraftRelease(); - uploadNodeShasums(); - uploadIndexJson(); - await createReleaseShasums(draftRelease); // Fetch latest version of release before verifying draftRelease = await getDraftRelease(pkgVersion, true); await validateReleaseAssets(draftRelease); + // index.json goes live once uploaded so do these uploads as + // late as possible to reduce the chances it contains a release + // which fails to publish. It has to be done before the final + // publish to ensure there aren't published releases not contained + // in index.json, which causes other problems in downstream projects + uploadNodeShasums(); + uploadIndexJson(); await publishRelease(draftRelease); console.log(`${pass} SUCCESS!!! Release has been published. Please run ` + '"npm run publish-to-npm" to publish release to npm.'); From 81bc1ea8760d9148d08225367f5c6892e6ea81af Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 9 Jun 2023 12:19:23 -0700 Subject: [PATCH 149/172] build: upload node checksums before validating them (#38719) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> --- script/release/release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release/release.js b/script/release/release.js index 0b2ffc4e4a59d..309e46a2b70e1 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -351,6 +351,7 @@ async function makeRelease (releaseToValidate) { await validateReleaseAssets(release, true); } else { let draftRelease = await getDraftRelease(); + uploadNodeShasums(); await createReleaseShasums(draftRelease); // Fetch latest version of release before verifying @@ -361,7 +362,6 @@ async function makeRelease (releaseToValidate) { // which fails to publish. It has to be done before the final // publish to ensure there aren't published releases not contained // in index.json, which causes other problems in downstream projects - uploadNodeShasums(); uploadIndexJson(); await publishRelease(draftRelease); console.log(`${pass} SUCCESS!!! Release has been published. Please run ` + From 047f474eabcbffc85cca8bb0fdbe8650afa5bf33 Mon Sep 17 00:00:00 2001 From: Keeley Hammond <vertedinde@electronjs.org> Date: Fri, 9 Jun 2023 12:24:31 -0700 Subject: [PATCH 150/172] chore: cherry-pick 7 changes from Release-0-M114 (#38534) * chore: [22-x-y] cherry-pick 6 changes from Release-0-M114 * c6ec59dcae7d from angle * 93c6be3a42e7 from chromium * e6b75a8b4900 from chromium * 3b0607d14060 from v8 * 9c6dfc733fce from v8 * ea1cd76358e0 from chromium * chore: remove 2 invalid patches, fix 2 others * chore: remove unnecessary patch. * chore: add missing backports. * chore: further fix a backport * chore: update patches --------- Co-authored-by: Pedro Pontes <pepontes@microsoft.com> Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 2 + .../chromium/cherry-pick-ea1cd76358e0.patch | 200 +++++++++++++++ ..._crash_caused_by_calling_trace_event.patch | 38 +++ patches/pdfium/.patches | 3 + ...urn_code_from_cpwl_combobox_setpopup.patch | 236 ++++++++++++++++++ ..._cpwl_combobox_across_all_on_methods.patch | 213 ++++++++++++++++ ...dget_across_setoptionselection_calls.patch | 40 +++ patches/v8/.patches | 2 + patches/v8/cherry-pick-3b0607d14060.patch | 186 ++++++++++++++ patches/v8/cherry-pick-73af1a19a901.patch | 16 +- patches/v8/cherry-pick-9c6dfc733fce.patch | 150 +++++++++++ ...pi_fix_v8_object_setaccessorproperty.patch | 12 +- ...dler_selection_for_arguments_objects.patch | 2 +- 13 files changed, 1085 insertions(+), 15 deletions(-) create mode 100644 patches/chromium/cherry-pick-ea1cd76358e0.patch create mode 100644 patches/chromium/m114_merge_fix_a_crash_caused_by_calling_trace_event.patch create mode 100644 patches/pdfium/m114_always_check_return_code_from_cpwl_combobox_setpopup.patch create mode 100644 patches/pdfium/m114_observe_cpwl_combobox_across_all_on_methods.patch create mode 100644 patches/pdfium/m114_observe_widget_across_setoptionselection_calls.patch create mode 100644 patches/v8/cherry-pick-3b0607d14060.patch create mode 100644 patches/v8/cherry-pick-9c6dfc733fce.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index a42ea7d1a2e16..51718c5fe8189 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -159,5 +159,7 @@ cherry-pick-f58218891f8c.patch wayland_ensure_dnd_buffer_size_is_a_multiple_of_scale.patch m112_cherry_pick_libxml_cve_fix.patch m112_fix_scopedobservation_uaf_in.patch +cherry-pick-ea1cd76358e0.patch cherry-pick-48785f698b1c.patch m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch +m114_merge_fix_a_crash_caused_by_calling_trace_event.patch diff --git a/patches/chromium/cherry-pick-ea1cd76358e0.patch b/patches/chromium/cherry-pick-ea1cd76358e0.patch new file mode 100644 index 0000000000000..74c04ad26d508 --- /dev/null +++ b/patches/chromium/cherry-pick-ea1cd76358e0.patch @@ -0,0 +1,200 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kevin McNee <mcnee@chromium.org> +Date: Tue, 23 May 2023 15:46:16 +0000 +Subject: M114: Compute all webview find options before cloning them + +Compute all webview find options before cloning them + +In WebViewFindHelper::Find, we're cloning the find options before we've +set the value for `new_session`. For requests that are part of the same +session, in WebViewFindHelper::FindReply, we're using the incorrect +value for `new_session` and we're destroying the FindInfo for what we +think is a previous session but is actually for the request we're +currently processing. + +We now fully compute the options before cloning them. + +(cherry picked from commit bb8e17b942b8b1de0a58b2dce34197e00a3b6525) + +Bug: 1443401 +Change-Id: Ife6747aedabaf74f9a4855a173349ffe612b6f95 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4533923 +Reviewed-by: James Maclean <wjmaclean@chromium.org> +Commit-Queue: James Maclean <wjmaclean@chromium.org> +Auto-Submit: Kevin McNee <mcnee@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1145265} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4556646 +Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Cr-Commit-Position: refs/branch-heads/5735@{#941} +Cr-Branched-From: 2f562e4ddbaf79a3f3cb338b4d1bd4398d49eb67-refs/heads/main@{#1135570} + +diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc +index 4e6212397a183fdf494f271a255eaf2d536587e6..7159cf6af5cfd0ad5b9e5ba526043a4407a5399d 100644 +--- a/chrome/browser/apps/guest_view/web_view_browsertest.cc ++++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc +@@ -3851,6 +3851,11 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_testFindInMultipleWebViews) { + TestHelper("testFindInMultipleWebViews", "web_view/shim", NO_TEST_SERVER); + } + ++IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestFindAfterTerminate) { ++ content::ScopedAllowRendererCrashes scoped_allow_renderer_crashes; ++ TestHelper("testFindAfterTerminate", "web_view/shim", NO_TEST_SERVER); ++} ++ + IN_PROC_BROWSER_TEST_P(WebViewTest, Shim_TestLoadDataAPI) { + TestHelper("testLoadDataAPI", "web_view/shim", NEEDS_TEST_SERVER); + +diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js +index 5ed4f0223346b01d83cc04c8cda6c0e92e1a72e3..4a1543d1751cc817a511594d0123deacc0e61ebb 100644 +--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js ++++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js +@@ -2859,6 +2859,20 @@ function testFindInMultipleWebViews() { + }); + } + ++function testFindAfterTerminate() { ++ let webview = new WebView(); ++ webview.src = 'data:text/html,<body><iframe></iframe></body>'; ++ webview.addEventListener('loadstop', () => { ++ webview.find('A'); ++ webview.terminate(); ++ webview.find('B', {'backward': true}); ++ webview.find('B', {'backward': true}, (results) => { ++ embedder.test.succeed(); ++ }); ++ }); ++ document.body.appendChild(webview); ++} ++ + function testLoadDataAPI() { + var webview = new WebView(); + webview.src = 'about:blank'; +@@ -3600,6 +3614,7 @@ embedder.test.testList = { + 'testFindAPI': testFindAPI, + 'testFindAPI_findupdate': testFindAPI_findupdate, + 'testFindInMultipleWebViews': testFindInMultipleWebViews, ++ 'testFindAfterTerminate': testFindAfterTerminate, + 'testLoadDataAPI': testLoadDataAPI, + 'testLoadDataAPIAccessibleResources': testLoadDataAPIAccessibleResources, + 'testResizeEvents': testResizeEvents, +diff --git a/extensions/browser/guest_view/web_view/web_view_find_helper.cc b/extensions/browser/guest_view/web_view/web_view_find_helper.cc +index 07b8a6975907190741267e3f92c2e9bde5d9c5d6..f7e5c7c6ece05fa59374735cb1757d1918d1597c 100644 +--- a/extensions/browser/guest_view/web_view/web_view_find_helper.cc ++++ b/extensions/browser/guest_view/web_view/web_view_find_helper.cc +@@ -36,12 +36,12 @@ void WebViewFindHelper::CancelAllFindSessions() { + + void WebViewFindHelper::DispatchFindUpdateEvent(bool canceled, + bool final_update) { +- DCHECK(find_update_event_.get()); ++ CHECK(find_update_event_); + std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); + find_update_event_->PrepareResults(args.get()); + args->SetBoolKey(webview::kFindCanceled, canceled); + args->SetBoolKey(webview::kFindFinalUpdate, final_update); +- DCHECK(webview_guest_); ++ CHECK(webview_guest_); + webview_guest_->DispatchEventToView(std::make_unique<GuestViewEvent>( + webview::kEventFindReply, std::move(args))); + } +@@ -94,6 +94,17 @@ void WebViewFindHelper::Find( + // Need a new request_id for each new find request. + ++current_find_request_id_; + ++ if (current_find_session_) { ++ const std::u16string& current_search_text = ++ current_find_session_->search_text(); ++ bool current_match_case = current_find_session_->options()->match_case; ++ options->new_session = current_search_text.empty() || ++ current_search_text != search_text || ++ current_match_case != options->match_case; ++ } else { ++ options->new_session = true; ++ } ++ + // Stores the find request information by request_id so that its callback + // function can be called when the find results are available. + std::pair<FindInfoMap::iterator, bool> insert_result = +@@ -102,32 +113,19 @@ void WebViewFindHelper::Find( + base::MakeRefCounted<FindInfo>(current_find_request_id_, search_text, + options.Clone(), find_function))); + // No duplicate insertions. +- DCHECK(insert_result.second); +- +- blink::mojom::FindOptionsPtr full_options = +- insert_result.first->second->options().Clone(); +- +- if (current_find_session_) { +- const std::u16string& current_search_text = +- current_find_session_->search_text(); +- bool current_match_case = current_find_session_->options()->match_case; +- full_options->new_session = current_search_text.empty() || +- current_search_text != search_text || +- current_match_case != options->match_case; +- } else { +- full_options->new_session = true; +- } ++ CHECK(insert_result.second); + + // Link find requests that are a part of the same find session. +- if (!full_options->new_session && current_find_session_) { +- DCHECK(current_find_request_id_ != current_find_session_->request_id()); ++ if (!options->new_session && current_find_session_) { ++ CHECK(current_find_request_id_ != current_find_session_->request_id()); + current_find_session_->AddFindNextRequest( + insert_result.first->second->AsWeakPtr()); + } + + // Update the current find session, if necessary. +- if (full_options->new_session) ++ if (options->new_session) { + current_find_session_ = insert_result.first->second; ++ } + + // Handle the empty |search_text| case internally. + if (search_text.empty()) { +@@ -137,7 +135,7 @@ void WebViewFindHelper::Find( + } + + guest_web_contents->Find(current_find_request_id_, search_text, +- std::move(full_options), /*skip_delay=*/true); ++ std::move(options), /*skip_delay=*/true); + } + + void WebViewFindHelper::FindReply(int request_id, +@@ -152,14 +150,14 @@ void WebViewFindHelper::FindReply(int request_id, + return; + + // This find request must be a part of an existing find session. +- DCHECK(current_find_session_); ++ CHECK(current_find_session_); + + WebViewFindHelper::FindInfo* find_info = find_iterator->second.get(); + // Handle canceled find requests. + if (find_info->options()->new_session && + find_info_map_.begin()->first < request_id) { +- DCHECK_NE(current_find_session_->request_id(), +- find_info_map_.begin()->first); ++ CHECK_NE(current_find_session_->request_id(), ++ find_info_map_.begin()->first); + if (find_update_event_) + DispatchFindUpdateEvent(true /* canceled */, true /* final_update */); + EndFindSession(find_info_map_.begin()->first, true /* canceled */); +@@ -174,11 +172,12 @@ void WebViewFindHelper::FindReply(int request_id, + // Aggregate the find results. + find_info->AggregateResults(number_of_matches, selection_rect, + active_match_ordinal, final_update); +- find_update_event_->AggregateResults(number_of_matches, selection_rect, +- active_match_ordinal, final_update); +- +- // Propagate incremental results to the |findupdate| event. +- DispatchFindUpdateEvent(false /* canceled */, final_update); ++ if (find_update_event_) { ++ find_update_event_->AggregateResults(number_of_matches, selection_rect, ++ active_match_ordinal, final_update); ++ // Propagate incremental results to the |findupdate| event. ++ DispatchFindUpdateEvent(false /* canceled */, final_update); ++ } + + // Call the callback functions of completed find requests. + if (final_update) diff --git a/patches/chromium/m114_merge_fix_a_crash_caused_by_calling_trace_event.patch b/patches/chromium/m114_merge_fix_a_crash_caused_by_calling_trace_event.patch new file mode 100644 index 0000000000000..75d6549adc1ca --- /dev/null +++ b/patches/chromium/m114_merge_fix_a_crash_caused_by_calling_trace_event.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Maggie Chen <magchen@chromium.org> +Date: Thu, 18 May 2023 00:20:34 +0000 +Subject: Fix a crash caused by calling TRACE_EVENT + +Now use literal constant for TRACE_EVENT. Passing a pointer instead of +string content to TRACE_EVENT causes a crash in ScopedTracer. + +(cherry picked from commit 6f2e587807aff2306309025db1c15fc59290eb6f) + +Bug: 1444195 +Change-Id: I02aa1148d61e7596e9293ffc866135e99991e42e +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4522164 +Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org> +Commit-Queue: Maggie Chen <magchen@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1144352} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4544885 +Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Cr-Commit-Position: refs/branch-heads/5735@{#749} +Cr-Branched-From: 2f562e4ddbaf79a3f3cb338b4d1bd4398d49eb67-refs/heads/main@{#1135570} + +diff --git a/ui/gl/swap_chain_presenter.cc b/ui/gl/swap_chain_presenter.cc +index 31deec1168cd438c0a37edc9230484ba2181b525..5cf91faf97a2a6f4f130d9e62678d972f55756ec 100644 +--- a/ui/gl/swap_chain_presenter.cc ++++ b/ui/gl/swap_chain_presenter.cc +@@ -1635,10 +1635,8 @@ bool SwapChainPresenter::ReallocateSwapChain( + } + } + if (!use_yuv_swap_chain) { +- std::ostringstream trace_event_stream; +- trace_event_stream << "SwapChainPresenter::ReallocateSwapChain::" +- << DxgiFormatToString(swap_chain_format); +- TRACE_EVENT0("gpu", trace_event_stream.str().c_str()); ++ TRACE_EVENT1("gpu", "SwapChainPresenter::ReallocateSwapChain::BGRA", ++ "format", DxgiFormatToString(swap_chain_format)); + + desc.Format = swap_chain_format; + desc.Flags = DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO; diff --git a/patches/pdfium/.patches b/patches/pdfium/.patches index 3dc9951c0b7c4..e0e3deea83720 100644 --- a/patches/pdfium/.patches +++ b/patches/pdfium/.patches @@ -1 +1,4 @@ cherry-pick-a0d16d18d072.patch +m114_observe_cpwl_combobox_across_all_on_methods.patch +m114_observe_widget_across_setoptionselection_calls.patch +m114_always_check_return_code_from_cpwl_combobox_setpopup.patch diff --git a/patches/pdfium/m114_always_check_return_code_from_cpwl_combobox_setpopup.patch b/patches/pdfium/m114_always_check_return_code_from_cpwl_combobox_setpopup.patch new file mode 100644 index 0000000000000..f81deb71931bf --- /dev/null +++ b/patches/pdfium/m114_always_check_return_code_from_cpwl_combobox_setpopup.patch @@ -0,0 +1,236 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom Sepez <tsepez@chromium.org> +Date: Fri, 19 May 2023 18:41:31 +0000 +Subject: Always check return code from CPWL_ComboBox::SetPopup(). + +Operation must not continue when false is returned. + +Bug: chromium:1444238 +Change-Id: Ic8c29653ac185ac80b6248203649ce05d0e10f06 +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107390 +Commit-Queue: Tom Sepez <tsepez@chromium.org> +Reviewed-by: Lei Zhang <thestig@chromium.org> +(cherry picked from commit 3eb3c4d77d4f9372f77aa4895b85a1d4e4755c89) +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107812 + +diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp +index 4d834e698ee1b08bcc81d20e062e029620438b7e..fdcc2ef1b2fba4257aab3835f58c5ec0913663cf 100644 +--- a/fpdfsdk/pwl/cpwl_combo_box.cpp ++++ b/fpdfsdk/pwl/cpwl_combo_box.cpp +@@ -400,7 +400,9 @@ bool CPWL_ComboBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) { + // options. + switch (nChar) { + case pdfium::ascii::kReturn: +- SetPopup(!IsPopup()); ++ if (!SetPopup(!IsPopup())) { ++ return false; ++ } + SetSelectText(); + return true; + case pdfium::ascii::kSpace: +@@ -408,7 +410,9 @@ bool CPWL_ComboBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) { + // editable + if (!HasFlag(PCBS_ALLOWCUSTOMTEXT)) { + if (!IsPopup()) { +- SetPopup(/*bPopUp=*/true); ++ if (!SetPopup(/*bPopUp=*/true)) { ++ return false; ++ } + SetSelectText(); + } + return true; +@@ -438,7 +442,7 @@ bool CPWL_ComboBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) { + + void CPWL_ComboBox::NotifyLButtonDown(CPWL_Wnd* child, const CFX_PointF& pos) { + if (child == m_pButton) { +- SetPopup(!m_bPopup); ++ (void)SetPopup(!m_bPopup); + // Note, |this| may no longer be viable at this point. If more work needs to + // be done, check the return value of SetPopup(). + } +@@ -451,7 +455,7 @@ void CPWL_ComboBox::NotifyLButtonUp(CPWL_Wnd* child, const CFX_PointF& pos) { + SetSelectText(); + SelectAllText(); + m_pEdit->SetFocus(); +- SetPopup(false); ++ (void)SetPopup(false); + // Note, |this| may no longer be viable at this point. If more work needs to + // be done, check the return value of SetPopup(). + } +diff --git a/fpdfsdk/pwl/cpwl_combo_box.h b/fpdfsdk/pwl/cpwl_combo_box.h +index 0d13b40b7a1fa1410070a14a3f9f4ef5ad625181..4b97394996d0fb1212e8f7e54f3513e1e93b6b80 100644 +--- a/fpdfsdk/pwl/cpwl_combo_box.h ++++ b/fpdfsdk/pwl/cpwl_combo_box.h +@@ -64,7 +64,7 @@ class CPWL_ComboBox final : public CPWL_Wnd { + void CreateListBox(const CreateParams& cp); + + // Returns |true| iff this instance is still allocated. +- bool SetPopup(bool bPopup); ++ [[nodiscard]] bool SetPopup(bool bPopup); + + UnownedPtr<CPWL_Edit> m_pEdit; + UnownedPtr<CPWL_CBButton> m_pButton; +diff --git a/testing/resources/javascript/xfa_specific/bug_1444238.evt b/testing/resources/javascript/xfa_specific/bug_1444238.evt +new file mode 100644 +index 0000000000000000000000000000000000000000..adca35aa0d756e76eb395c5d60ba41b86c3d0090 +--- /dev/null ++++ b/testing/resources/javascript/xfa_specific/bug_1444238.evt +@@ -0,0 +1,3 @@ ++mousedown,left,91,539 ++mouseup,left,91,539 ++charcode,32 +diff --git a/testing/resources/javascript/xfa_specific/bug_1444238.in b/testing/resources/javascript/xfa_specific/bug_1444238.in +new file mode 100644 +index 0000000000000000000000000000000000000000..675178c9446b0181c3633a4b5c9bc664bb4c127d +--- /dev/null ++++ b/testing/resources/javascript/xfa_specific/bug_1444238.in +@@ -0,0 +1,149 @@ ++{{header}} ++{{object 1 0}} << ++ /Type /Catalog ++ /Pages 2 0 R ++ /AcroForm 4 0 R ++ /OpenAction 40 0 R ++>> ++endobj ++{{object 2 0}} << ++ /Type /Pages ++ /Count 2 ++ /Kids [ ++ 32 0 R ++ 34 0 R ++ ] ++>> ++endobj ++% Forms ++{{object 4 0}} << ++ /XFA 43 0 R ++ /Fields [ ++ 10 0 R ++ 11 0 R ++ ] ++>> ++endobj ++% Fields ++{{object 10 0}} << ++ /Type /Annot ++ /Subtype /Widget ++ /FT /Tx ++ /T (MyField5) ++ /V (myfield_5) ++ /Rect [0 500 600 600] ++>> ++% Fields ++{{object 11 0}} << ++ /T (MyField3) ++ /Parent 4 0 R ++ /Kids [12 0 R] ++ /Opt [(a) (b) (c) (d)] ++ /V [(a) (b) (c)] ++>> ++endobj ++% Fields ++{{object 12 0}} << ++ /Type /Annot ++ /Subtype /Widget ++ /FT /Ch ++ /Ff 131072 ++ /Parent 11 0 R ++ /Kids [13 0 R] ++>> ++endobj ++% Fields ++{{object 13 0}} << ++ /Type /Annot ++ /Subtype /Widget ++ /Parent 12 0 R ++ /Rect [0 400 600 600] ++>> ++endobj ++% Fields ++{{object 14 0}} << ++ /Type /Annot ++ /Subtype /Widget ++ /Parent 12 0 R ++ /Rect [100 400 500 500] ++>> ++endobj ++% Page number 2. ++{{object 32 0}} << ++ /Type /Page ++ /Parent 2 0 R ++ /MediaBox [0 0 612 792] ++ /Annots [13 0 R] ++ ++>> ++endobj ++{{object 34 0}} << ++ /Type /Page ++ /Parent 2 0 R ++ /MediaBox [0 0 612 792] ++ /Annots [10 0 R] ++>> ++endobj ++% Document JS Action ++{{object 40 0}} << ++ /Type /Action ++ /S /JavaScript ++ /JS 41 0 R ++>> ++endobj ++% JS program to exexute ++{{object 41 0}} << ++>> ++stream ++var f5 = this.getField("MyField5"); ++var f3 = this.getField("MyField3"); ++f3.setFocus(); ++this.__defineGetter__("pageNum",function o(){f5.setFocus(); f3.borderStyle="dashed"; f3.setFocus();}); ++endstream ++endobj ++{{object 43 0}} << ++ {{streamlen}} ++>> ++stream ++<?xml version="1.0" encoding="UTF-8"?> ++<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"> ++<config></config> ++<template xmlns="http://www.xfa.org/schema/xfa-template/2.8/"> ++ <subform layout="tb" locale="en_US"> ++ <pageSet> ++ <pageArea id="Page1" name="Page1"> ++ <contentArea h="268.939mm" w="203.2mm" x="6.35mm" y="6.35mm"/> ++ <medium long="792pt" short="612pt" stock="default"/> ++ </pageArea> ++ </pageSet> ++ <field h="9.0001mm" name="MyField3" w="47.625mm" x="120mm" y="120mm"> ++ <ui> ++ <choiceList open="onEntry"> ++ <border> ++ <edge/> ++ </border> ++ </choiceList> ++ </ui> ++ <items save="1"> ++ <text>apples</text> ++ <text>bananas</text> ++ <text>pears</text> ++ </items> ++ <value> ++ <text>apples</text> ++ </value> ++ <event activity="preOpen"> ++ <script contentType="application/x-javascript"> ++ var aa = this.pageNum; ++ </script> ++ </event> ++ </field> ++ </subform> ++</template> ++</xdp:xdp> ++endstream ++endobj ++{{xref}} ++{{trailer}} ++{{startxref}} ++%%EOF diff --git a/patches/pdfium/m114_observe_cpwl_combobox_across_all_on_methods.patch b/patches/pdfium/m114_observe_cpwl_combobox_across_all_on_methods.patch new file mode 100644 index 0000000000000..4c45f41b0c7ed --- /dev/null +++ b/patches/pdfium/m114_observe_cpwl_combobox_across_all_on_methods.patch @@ -0,0 +1,213 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom Sepez <tsepez@chromium.org> +Date: Fri, 19 May 2023 20:05:10 +0000 +Subject: Observe CPWL_ComboBox across all On* methods + +Bug: chromium:1445426 +Change-Id: I1d7ebf66fe170ca016c27a0df3ac4574e75c763c +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107650 +Reviewed-by: Lei Zhang <thestig@chromium.org> +Commit-Queue: Tom Sepez <tsepez@chromium.org> +(cherry picked from commit 29c665ea4c61b089746c3f502c30fcb5f4b11486) +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107811 + +diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp +index 6f89e7df41ea6691e805a4dd3942d5cb89787db3..4d834e698ee1b08bcc81d20e062e029620438b7e 100644 +--- a/fpdfsdk/pwl/cpwl_combo_box.cpp ++++ b/fpdfsdk/pwl/cpwl_combo_box.cpp +@@ -339,31 +339,42 @@ bool CPWL_ComboBox::OnKeyDown(FWL_VKEYCODE nKeyCode, + if (!m_pEdit) + return false; + ++ ObservedPtr<CPWL_Wnd> thisObserved(this); + m_nSelectItem = -1; + + switch (nKeyCode) { + case FWL_VKEY_Up: + if (m_pList->GetCurSel() > 0) { +- if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag)) ++ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag) || ++ !thisObserved) { + return false; +- if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag)) ++ } ++ if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag) || ++ !thisObserved) { + return false; ++ } + if (m_pList->IsMovementKey(nKeyCode)) { +- if (m_pList->OnMovementKeyDown(nKeyCode, nFlag)) ++ if (m_pList->OnMovementKeyDown(nKeyCode, nFlag) || !thisObserved) { + return false; ++ } + SetSelectText(); + } + } + return true; + case FWL_VKEY_Down: + if (m_pList->GetCurSel() < m_pList->GetCount() - 1) { +- if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag)) ++ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag) || ++ !thisObserved) { + return false; +- if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag)) ++ } ++ if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag) || ++ !thisObserved) { + return false; ++ } + if (m_pList->IsMovementKey(nKeyCode)) { +- if (m_pList->OnMovementKeyDown(nKeyCode, nFlag)) ++ if (m_pList->OnMovementKeyDown(nKeyCode, nFlag) || !thisObserved) { + return false; ++ } + SetSelectText(); + } + } +@@ -411,10 +422,15 @@ bool CPWL_ComboBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) { + if (HasFlag(PCBS_ALLOWCUSTOMTEXT)) + return m_pEdit->OnChar(nChar, nFlag); + +- if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag)) ++ ObservedPtr<CPWL_Wnd> thisObserved(this); ++ if (GetFillerNotify()->OnPopupPreOpen(GetAttachedData(), nFlag) || ++ !thisObserved) { + return false; +- if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag)) ++ } ++ if (GetFillerNotify()->OnPopupPostOpen(GetAttachedData(), nFlag) || ++ !thisObserved) { + return false; ++ } + if (!m_pList->IsChar(nChar, nFlag)) + return false; + return m_pList->OnCharNotify(nChar, nFlag); +diff --git a/testing/resources/javascript/bug_1445426.evt b/testing/resources/javascript/bug_1445426.evt +new file mode 100644 +index 0000000000000000000000000000000000000000..265e85b0471b33509568238ccae30d2395b4b4ab +--- /dev/null ++++ b/testing/resources/javascript/bug_1445426.evt +@@ -0,0 +1,3 @@ ++mousedown,left,202,697 ++mouseup,left,202,697 ++keycode,40 +diff --git a/testing/resources/javascript/bug_1445426.in b/testing/resources/javascript/bug_1445426.in +new file mode 100644 +index 0000000000000000000000000000000000000000..1483da72f5759e9f2c8fdb538d5c6fa0cd1611c5 +--- /dev/null ++++ b/testing/resources/javascript/bug_1445426.in +@@ -0,0 +1,114 @@ ++{{header}} ++{{object 1 0}} << ++ /Type /Catalog ++ /Pages 2 0 R ++ /AcroForm 4 0 R ++ /OpenAction 40 0 R ++>> ++endobj ++{{object 2 0}} << ++ /Type /Pages ++ /Count 2 ++ /Kids [ ++ 32 0 R ++ 34 0 R ++ ] ++>> ++endobj ++% Forms ++{{object 4 0}} << ++ /Fields [ ++ 10 0 R ++ 11 0 R ++ ] ++>> ++endobj ++% Fields ++{{object 10 0}} << ++ /Type /Annot ++ /Subtype /Widget ++ /FT /Tx ++ /T (Field_TextEdit) ++ /Rect [0 0 612 792] ++>> ++{{object 11 0}} << ++ /T (Field_ComboBox) ++ /Parent 4 0 R ++ /Kids [12 0 R] ++ /Opt [(a) (b) (c) (d)] ++ /V [(a)] ++>> ++endobj ++{{object 12 0}} << ++ /Type /Annot ++ /Subtype /Widget ++ /FT /Ch ++ /Ff 131072 ++ /Parent 11 0 R ++ /Kids [13 0 R] ++>> ++endobj ++{{object 13 0}} << ++ /Parent 12 0 R ++ /Type /Annot ++ /Subtype /Widget ++ /Rect [0 0 612 792] ++ /AA << /K 20 0 R >> ++>> ++endobj ++% Pages ++{{object 32 0}} << ++ /Type /Page ++ /Parent 2 0 R ++ /MediaBox [0 0 612 792] ++ /Annots [13 0 R] ++ ++>> ++endobj ++{{object 34 0}} << ++ /Type /Page ++ /Parent 2 0 R ++ /MediaBox [0 0 612 792] ++ /Annots [10 0 R] ++>> ++endobj ++% Document JS Action ++{{object 40 0}} << ++ /Type /Action ++ /S /JavaScript ++ /JS 41 0 R ++>> ++endobj ++% JS program to exexute ++{{object 41 0}} << ++ {{streamlen}} ++>> ++stream ++var field_text = this.getField("Field_TextEdit"); ++var field_combobox = this.getField("Field_ComboBox"); ++field_combobox.setFocus(); ++this.__defineGetter__("filesize", function new_getter(){ ++ field_text.setFocus(); ++ field_combobox.borderStyle="dashed"; ++ field_combobox.setFocus(); ++ }); ++endstream ++endobj ++% OpenAction action ++{{object 20 0}} << ++ /S /JavaScript ++ /JS 21 0 R ++>> ++endobj ++% JS program to exexute ++{{object 21 0}} << ++ {{streamlen}} ++>> ++stream ++var t = this.filesize; ++endstream ++endobj ++{{xref}} ++{{trailer}} ++{{startxref}} ++%%EOF diff --git a/patches/pdfium/m114_observe_widget_across_setoptionselection_calls.patch b/patches/pdfium/m114_observe_widget_across_setoptionselection_calls.patch new file mode 100644 index 0000000000000..62a877881ca54 --- /dev/null +++ b/patches/pdfium/m114_observe_widget_across_setoptionselection_calls.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tom Sepez <tsepez@chromium.org> +Date: Thu, 18 May 2023 18:37:17 +0000 +Subject: Observe widget across SetOptionSelection() calls. + +Call may re-enter JavaScript. + +Bug: chromium:1444581 +Change-Id: Id7a2f17b3b81f822ca8f4496ac08c19b7794c48a +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107394 +Commit-Queue: Tom Sepez <tsepez@chromium.org> +Reviewed-by: Lei Zhang <thestig@chromium.org> +(cherry picked from commit a9ff918a86d700c3bdf9b5820faed35490c0cd25) +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107735 +Auto-Submit: Tom Sepez <tsepez@chromium.org> + +diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp +index 4bb100014c804adcfc7f1f2023cd1870f81c85e8..6fe5d91a2472a7aaadf13399b4e6075c2a9617c7 100644 +--- a/fpdfsdk/formfiller/cffl_listbox.cpp ++++ b/fpdfsdk/formfiller/cffl_listbox.cpp +@@ -116,11 +116,18 @@ void CFFL_ListBox::SaveData(const CPDFSDK_PageView* pPageView) { + } + if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) { + for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) { +- if (pListBox->IsItemSelected(i)) ++ if (pListBox->IsItemSelected(i)) { + m_pWidget->SetOptionSelection(i); ++ if (!observed_box) { ++ return; ++ } ++ } + } + } else { + m_pWidget->SetOptionSelection(pListBox->GetCurSel()); ++ if (!observed_box) { ++ return; ++ } + } + ObservedPtr<CPDFSDK_Widget> observed_widget(m_pWidget.Get()); + ObservedPtr<CFFL_ListBox> observed_this(this); diff --git a/patches/v8/.patches b/patches/v8/.patches index dcb91e0f2c9f0..784ae8f372af8 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -15,6 +15,8 @@ cherry-pick-546e00df97ac.patch cherry-pick-f6ddbf42b1ea.patch cherry-pick-c605df24af3c.patch cherry-pick-f4b66ae451c2.patch +cherry-pick-3b0607d14060.patch +cherry-pick-9c6dfc733fce.patch merged_ic_fix_store_handler_selection_for_arguments_objects.patch cherry-pick-73af1a19a901.patch merged_regexp_fix_clobbered_register_in_global_unicode_special.patch diff --git a/patches/v8/cherry-pick-3b0607d14060.patch b/patches/v8/cherry-pick-3b0607d14060.patch new file mode 100644 index 0000000000000..83ae8b8455207 --- /dev/null +++ b/patches/v8/cherry-pick-3b0607d14060.patch @@ -0,0 +1,186 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Sheludko <ishell@chromium.org> +Date: Wed, 17 May 2023 13:47:36 +0200 +Subject: Merged: [runtime] Remove redundant calls to GetPropertyAttributes + +... when defining properties in favour of CheckIfCanDefine. + +Drive-by: move JSReceiver::CheckIfCanDefine to +JSObject::CheckIfCanDefineAsConfigurable and fix handling of +absent properties. + +Bug: chromium:1443452 +(cherry picked from commit e98baa3526426c0219bb0474028ca301b8bd0677) + +Change-Id: Ia1fd617778be608accee99dcee37f7d1ce3460b8 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4545762 +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#22} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/ic/ic.cc b/src/ic/ic.cc +index fff21e90bad3451e2d942ec327cb02f394fecc46..32039f9888d3cb54699c6aefd0bcc3573044995e 100644 +--- a/src/ic/ic.cc ++++ b/src/ic/ic.cc +@@ -1812,14 +1812,14 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name, + // been thrown if the private field already exists in the object. + if (IsAnyDefineOwn() && !name->IsPrivateName() && !object->IsJSProxy() && + !Handle<JSObject>::cast(object)->HasNamedInterceptor()) { +- Maybe<bool> can_define = JSReceiver::CheckIfCanDefine( ++ Maybe<bool> can_define = JSObject::CheckIfCanDefineAsConfigurable( + isolate(), &it, value, Nothing<ShouldThrow>()); + MAYBE_RETURN_NULL(can_define); + if (!can_define.FromJust()) { + return isolate()->factory()->undefined_value(); + } +- // Restart the lookup iterator updated by CheckIfCanDefine() for +- // UpdateCaches() to handle access checks. ++ // Restart the lookup iterator updated by CheckIfCanDefineAsConfigurable() ++ // for UpdateCaches() to handle access checks. + if (use_ic && object->IsAccessCheckNeeded()) { + it.Restart(); + } +diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc +index 15356b6c58d2f7355fa8b0dce4d3ea779a2884f9..e86fdec6a57e08bbcd229b7866f22ba3441f608c 100644 +--- a/src/objects/js-objects.cc ++++ b/src/objects/js-objects.cc +@@ -243,27 +243,6 @@ Maybe<bool> JSReceiver::CheckPrivateNameStore(LookupIterator* it, + return Just(true); + } + +-// static +-Maybe<bool> JSReceiver::CheckIfCanDefine(Isolate* isolate, LookupIterator* it, +- Handle<Object> value, +- Maybe<ShouldThrow> should_throw) { +- if (it->IsFound()) { +- Maybe<PropertyAttributes> attributes = GetPropertyAttributes(it); +- MAYBE_RETURN(attributes, Nothing<bool>()); +- if ((attributes.FromJust() & DONT_DELETE) != 0) { +- RETURN_FAILURE( +- isolate, GetShouldThrow(isolate, should_throw), +- NewTypeError(MessageTemplate::kRedefineDisallowed, it->GetName())); +- } +- } else if (!JSObject::IsExtensible( +- Handle<JSObject>::cast(it->GetReceiver()))) { +- RETURN_FAILURE( +- isolate, GetShouldThrow(isolate, should_throw), +- NewTypeError(MessageTemplate::kDefineDisallowed, it->GetName())); +- } +- return Just(true); +-} +- + namespace { + + bool HasExcludedProperty( +@@ -3639,7 +3618,7 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes( + + if (semantics == EnforceDefineSemantics::kDefine) { + it->Restart(); +- Maybe<bool> can_define = JSReceiver::CheckIfCanDefine( ++ Maybe<bool> can_define = JSObject::CheckIfCanDefineAsConfigurable( + it->isolate(), it, value, should_throw); + if (can_define.IsNothing() || !can_define.FromJust()) { + return can_define; +@@ -4068,17 +4047,16 @@ Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it, + Handle<Object> value, + Maybe<ShouldThrow> should_throw) { + DCHECK(it->GetReceiver()->IsJSObject()); +- MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>()); + Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(it->GetReceiver()); + Isolate* isolate = receiver->GetIsolate(); + +- Maybe<bool> can_define = +- JSReceiver::CheckIfCanDefine(isolate, it, value, should_throw); ++ Maybe<bool> can_define = JSObject::CheckIfCanDefineAsConfigurable( ++ isolate, it, value, should_throw); + if (can_define.IsNothing() || !can_define.FromJust()) { + return can_define; + } + +- RETURN_ON_EXCEPTION_VALUE(it->isolate(), ++ RETURN_ON_EXCEPTION_VALUE(isolate, + DefineOwnPropertyIgnoreAttributes(it, value, NONE), + Nothing<bool>()); + +@@ -4707,19 +4685,42 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, + return it.factory()->undefined_value(); + } + +- CHECK(GetPropertyAttributes(&it).IsJust()); +- +- // ES5 forbids turning a property into an accessor if it's not +- // configurable. See 8.6.1 (Table 5). +- if (it.IsFound() && !it.IsConfigurable()) { +- return it.factory()->undefined_value(); +- } ++ Maybe<bool> can_define = JSObject::CheckIfCanDefineAsConfigurable( ++ isolate, &it, info, Nothing<ShouldThrow>()); ++ MAYBE_RETURN_NULL(can_define); ++ if (!can_define.FromJust()) return it.factory()->undefined_value(); + + it.TransitionToAccessorPair(info, attributes); + + return object; + } + ++// static ++Maybe<bool> JSObject::CheckIfCanDefineAsConfigurable( ++ Isolate* isolate, LookupIterator* it, Handle<Object> value, ++ Maybe<ShouldThrow> should_throw) { ++ DCHECK(it->GetReceiver()->IsJSObject()); ++ if (it->IsFound()) { ++ Maybe<PropertyAttributes> attributes = GetPropertyAttributes(it); ++ MAYBE_RETURN(attributes, Nothing<bool>()); ++ if (attributes.FromJust() != ABSENT) { ++ if ((attributes.FromJust() & DONT_DELETE) != 0) { ++ RETURN_FAILURE( ++ isolate, GetShouldThrow(isolate, should_throw), ++ NewTypeError(MessageTemplate::kRedefineDisallowed, it->GetName())); ++ } ++ return Just(true); ++ } ++ // Property does not exist, check object extensibility. ++ } ++ if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) { ++ RETURN_FAILURE( ++ isolate, GetShouldThrow(isolate, should_throw), ++ NewTypeError(MessageTemplate::kDefineDisallowed, it->GetName())); ++ } ++ return Just(true); ++} ++ + Object JSObject::SlowReverseLookup(Object value) { + if (HasFastProperties()) { + DescriptorArray descs = map().instance_descriptors(); +diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h +index 06489c2b7bae61ecadbd8f020060e86ef50e11b6..f663af6ed8a445f8ef30a67bac176a1abe6c85f8 100644 +--- a/src/objects/js-objects.h ++++ b/src/objects/js-objects.h +@@ -167,12 +167,6 @@ class JSReceiver : public TorqueGeneratedJSReceiver<JSReceiver, HeapObject> { + V8_WARN_UNUSED_RESULT static Maybe<bool> CheckPrivateNameStore( + LookupIterator* it, bool is_define); + +- // Check if a data property can be created on the object. It will fail with +- // an error when it cannot. +- V8_WARN_UNUSED_RESULT static Maybe<bool> CheckIfCanDefine( +- Isolate* isolate, LookupIterator* it, Handle<Object> value, +- Maybe<ShouldThrow> should_throw); +- + // ES6 7.3.4 (when passed kDontThrow) + V8_WARN_UNUSED_RESULT static Maybe<bool> CreateDataProperty( + Isolate* isolate, Handle<JSReceiver> object, Handle<Name> key, +@@ -544,6 +538,12 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> { + Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> info, + PropertyAttributes attributes); + ++ // Check if a data property can be created on the object. It will fail with ++ // an error when it cannot. ++ V8_WARN_UNUSED_RESULT static Maybe<bool> CheckIfCanDefineAsConfigurable( ++ Isolate* isolate, LookupIterator* it, Handle<Object> value, ++ Maybe<ShouldThrow> should_throw); ++ + // The result must be checked first for exceptions. If there's no exception, + // the output parameter |done| indicates whether the interceptor has a result + // or not. diff --git a/patches/v8/cherry-pick-73af1a19a901.patch b/patches/v8/cherry-pick-73af1a19a901.patch index c45845ffdcdc6..f54398447130c 100644 --- a/patches/v8/cherry-pick-73af1a19a901.patch +++ b/patches/v8/cherry-pick-73af1a19a901.patch @@ -17,10 +17,10 @@ Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{ Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} diff --git a/src/objects/lookup-inl.h b/src/objects/lookup-inl.h -index ff30fcc4f211f49d244e8431cfdb5cba29484329..579a195f06beec657271b8f84b5d92bc8c908d55 100644 +index 642d83ff070d6b631a755af78627989878f685a2..22960729c64062b9e8a4abaf6b5ed8d44ccaa2de 100644 --- a/src/objects/lookup-inl.h +++ b/src/objects/lookup-inl.h -@@ -167,7 +167,7 @@ Handle<Name> PropertyKey::GetName(Isolate* isolate) { +@@ -190,7 +190,7 @@ Handle<Name> PropertyKey::GetName(Isolate* isolate) { } Handle<Name> LookupIterator::name() const { @@ -29,7 +29,7 @@ index ff30fcc4f211f49d244e8431cfdb5cba29484329..579a195f06beec657271b8f84b5d92bc return name_; } -@@ -254,6 +254,7 @@ void LookupIterator::UpdateProtector() { +@@ -281,6 +281,7 @@ void LookupIterator::UpdateProtector() { } InternalIndex LookupIterator::descriptor_number() const { @@ -37,7 +37,7 @@ index ff30fcc4f211f49d244e8431cfdb5cba29484329..579a195f06beec657271b8f84b5d92bc DCHECK(!IsElement(*holder_)); DCHECK(has_property_); DCHECK(holder_->HasFastProperties(isolate_)); -@@ -261,6 +262,7 @@ InternalIndex LookupIterator::descriptor_number() const { +@@ -288,6 +289,7 @@ InternalIndex LookupIterator::descriptor_number() const { } InternalIndex LookupIterator::dictionary_entry() const { @@ -45,7 +45,7 @@ index ff30fcc4f211f49d244e8431cfdb5cba29484329..579a195f06beec657271b8f84b5d92bc DCHECK(!IsElement(*holder_)); DCHECK(has_property_); DCHECK(!holder_->HasFastProperties(isolate_)); -@@ -275,13 +277,14 @@ LookupIterator::Configuration LookupIterator::ComputeConfiguration( +@@ -302,13 +304,14 @@ LookupIterator::Configuration LookupIterator::ComputeConfiguration( } // static @@ -181,10 +181,10 @@ index e08ebaff089f8ab0a1b347f9eb5befd85e3c115b..920d28ffa81798c2e5fe9e15db016501 Handle<JSGlobalObject> holder = GetHolder<JSGlobalObject>(); return handle(holder->global_dictionary(isolate_, kAcquireLoad) diff --git a/src/objects/lookup.h b/src/objects/lookup.h -index 782a09225c17a92ee8f08d20ede0902613158c27..15bcda75f2493bf4800d250e37f4273de36a6334 100644 +index 67a8bac22e6e29df2d7df36937565e4cc0acde45..78a00d7ca0fab1ab8b2b1e49e3ffb92473b21cc9 100644 --- a/src/objects/lookup.h +++ b/src/objects/lookup.h -@@ -214,11 +214,6 @@ class V8_EXPORT_PRIVATE LookupIterator final { +@@ -222,11 +222,6 @@ class V8_EXPORT_PRIVATE LookupIterator final { Handle<Object> lookup_start_object, Configuration configuration); @@ -196,7 +196,7 @@ index 782a09225c17a92ee8f08d20ede0902613158c27..15bcda75f2493bf4800d250e37f4273d static void InternalUpdateProtector(Isolate* isolate, Handle<Object> receiver, Handle<Name> name); -@@ -278,12 +273,12 @@ class V8_EXPORT_PRIVATE LookupIterator final { +@@ -286,12 +281,12 @@ class V8_EXPORT_PRIVATE LookupIterator final { Configuration configuration, Handle<Name> name); diff --git a/patches/v8/cherry-pick-9c6dfc733fce.patch b/patches/v8/cherry-pick-9c6dfc733fce.patch new file mode 100644 index 0000000000000..0b04709b28d6a --- /dev/null +++ b/patches/v8/cherry-pick-9c6dfc733fce.patch @@ -0,0 +1,150 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Igor Sheludko <ishell@chromium.org> +Date: Tue, 16 May 2023 16:01:49 +0200 +Subject: Merged: [runtime] Fix handling of interceptors + +Drive-by: simplify creation of LookupIterator copies. + +Bug: chromium:1440695 +(cherry picked from commit d125c7329f6e22af4523de3c55de3a22f168acc9) + +Change-Id: I58416531b9af3456f53264566ec1eb7457328f94 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4545763 +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#23} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc +index e86fdec6a57e08bbcd229b7866f22ba3441f608c..b938d82667498d4ff3505d455a7ed3a299cd5247 100644 +--- a/src/objects/js-objects.cc ++++ b/src/objects/js-objects.cc +@@ -3629,10 +3629,8 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes( + // own property without the interceptor. + Isolate* isolate = it->isolate(); + Handle<Object> receiver = it->GetReceiver(); +- LookupIterator::Configuration c = LookupIterator::OWN_SKIP_INTERCEPTOR; +- LookupIterator own_lookup = +- it->IsElement() ? LookupIterator(isolate, receiver, it->index(), c) +- : LookupIterator(isolate, receiver, it->name(), c); ++ LookupIterator own_lookup(isolate, receiver, it->GetKey(), ++ LookupIterator::OWN_SKIP_INTERCEPTOR); + return JSObject::DefineOwnPropertyIgnoreAttributes( + &own_lookup, value, attributes, should_throw, handling, semantics, + store_origin); +diff --git a/src/objects/lookup-inl.h b/src/objects/lookup-inl.h +index ff30fcc4f211f49d244e8431cfdb5cba29484329..642d83ff070d6b631a755af78627989878f685a2 100644 +--- a/src/objects/lookup-inl.h ++++ b/src/objects/lookup-inl.h +@@ -130,6 +130,29 @@ PropertyKey::PropertyKey(Isolate* isolate, double index) { + #endif + } + ++PropertyKey::PropertyKey(Isolate* isolate, Handle<Name> name, size_t index) ++ : name_(name), index_(index) { ++ DCHECK_IMPLIES(index_ == LookupIterator::kInvalidIndex, !name_.is_null()); ++#if V8_TARGET_ARCH_32_BIT ++ DCHECK_IMPLIES(index_ != LookupIterator::kInvalidIndex, ++ index_ <= JSObject::kMaxElementIndex); ++#endif ++#if DEBUG ++ if (index_ != LookupIterator::kInvalidIndex && !name_.is_null()) { ++ // If both valid index and name are given then the name is a string ++ // representation of the same index. ++ size_t integer_index; ++ CHECK(name_->AsIntegerIndex(&integer_index)); ++ CHECK_EQ(index_, integer_index); ++ } else if (index_ == LookupIterator::kInvalidIndex) { ++ // If only name is given it must not be a string representing an integer ++ // index. ++ size_t integer_index; ++ CHECK(!name_->AsIntegerIndex(&integer_index)); ++ } ++#endif ++} ++ + PropertyKey::PropertyKey(Isolate* isolate, Handle<Name> name) { + if (name->AsIntegerIndex(&index_)) { + name_ = name; +@@ -179,6 +202,10 @@ Handle<Name> LookupIterator::GetName() { + return name_; + } + ++PropertyKey LookupIterator::GetKey() const { ++ return PropertyKey(isolate_, name_, index_); ++} ++ + bool LookupIterator::IsElement(JSReceiver object) const { + return index_ <= JSObject::kMaxElementIndex || + (index_ != kInvalidIndex && +diff --git a/src/objects/lookup.h b/src/objects/lookup.h +index 782a09225c17a92ee8f08d20ede0902613158c27..67a8bac22e6e29df2d7df36937565e4cc0acde45 100644 +--- a/src/objects/lookup.h ++++ b/src/objects/lookup.h +@@ -36,6 +36,11 @@ class PropertyKey { + inline Handle<Name> GetName(Isolate* isolate); + + private: ++ friend LookupIterator; ++ ++ // Shortcut for constructing PropertyKey from an active LookupIterator. ++ inline PropertyKey(Isolate* isolate, Handle<Name> name, size_t index); ++ + Handle<Name> name_; + size_t index_; + }; +@@ -108,6 +113,9 @@ class V8_EXPORT_PRIVATE LookupIterator final { + return static_cast<uint32_t>(index_); + } + ++ // Helper method for creating a copy of of the iterator. ++ inline PropertyKey GetKey() const; ++ + // Returns true if this LookupIterator has an index in the range + // [0, size_t::max). + bool IsElement() const { return index_ != kInvalidIndex; } +diff --git a/src/objects/objects.cc b/src/objects/objects.cc +index c15ac8656adeaf92773a0c4049f7e903ecd2e07f..a7e1833f730e6e5869cd4925cca6dc908859000c 100644 +--- a/src/objects/objects.cc ++++ b/src/objects/objects.cc +@@ -2668,11 +2668,8 @@ Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value, + + // Note, the callers rely on the fact that this code is redoing the full own + // lookup from scratch. +- LookupIterator::Configuration c = LookupIterator::OWN; +- LookupIterator own_lookup = +- it->IsElement() ? LookupIterator(isolate, receiver, it->index(), c) +- : LookupIterator(isolate, receiver, it->name(), c); +- ++ LookupIterator own_lookup(isolate, receiver, it->GetKey(), ++ LookupIterator::OWN); + for (; own_lookup.IsFound(); own_lookup.Next()) { + switch (own_lookup.state()) { + case LookupIterator::ACCESS_CHECK: +@@ -2709,6 +2706,8 @@ Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value, + JSReceiver::GetOwnPropertyDescriptor(&own_lookup, &desc); + MAYBE_RETURN(owned, Nothing<bool>()); + if (!owned.FromJust()) { ++ // |own_lookup| might become outdated at this point anyway. ++ own_lookup.Restart(); + if (!CheckContextualStoreToJSGlobalObject(&own_lookup, + should_throw)) { + return Nothing<bool>(); +diff --git a/test/unittests/api/interceptor-unittest.cc b/test/unittests/api/interceptor-unittest.cc +index 635bf6a0b72f8d49591be333b1314846c9c47269..416f9bd1eb4c59160eb03031e6011ae02dcf021e 100644 +--- a/test/unittests/api/interceptor-unittest.cc ++++ b/test/unittests/api/interceptor-unittest.cc +@@ -174,8 +174,10 @@ TEST_F(InterceptorLoggingTest, DispatchTest) { + EXPECT_EQ(Run("obj.foo"), "named getter"); + EXPECT_EQ(Run("obj[42]"), "indexed getter"); + +- EXPECT_EQ(Run("obj.foo = null"), "named setter, named descriptor"); +- EXPECT_EQ(Run("obj[42] = null"), "indexed setter, indexed descriptor"); ++ EXPECT_EQ(Run("obj.foo = null"), ++ "named setter, named descriptor, named query"); ++ EXPECT_EQ(Run("obj[42] = null"), ++ "indexed setter, indexed descriptor, indexed query"); + + EXPECT_EQ(Run("Object.getOwnPropertyDescriptor(obj, 'foo')"), + "named descriptor"); diff --git a/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch b/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch index d9ce9b4655a02..70fa9149fe7a0 100644 --- a/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch +++ b/patches/v8/m108-lts_api_fix_v8_object_setaccessorproperty.patch @@ -219,10 +219,10 @@ index fc7b17d582e79b956362e0db46a7aefebd594ed0..8a81c4acda9a92b1d25491aa00278a0e return getter; diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc -index 15356b6c58d2f7355fa8b0dce4d3ea779a2884f9..834f83c0b0e68b9dcbe3fd0595dc2861cdd2c017 100644 +index b938d82667498d4ff3505d455a7ed3a299cd5247..e51264eef22c9fc91c89ef6fe0d223c97ccf7fa9 100644 --- a/src/objects/js-objects.cc +++ b/src/objects/js-objects.cc -@@ -1519,7 +1519,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( +@@ -1498,7 +1498,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( ? desc->set() : Handle<Object>::cast(isolate->factory()->null_value())); MaybeHandle<Object> result = @@ -232,7 +232,7 @@ index 15356b6c58d2f7355fa8b0dce4d3ea779a2884f9..834f83c0b0e68b9dcbe3fd0595dc2861 if (result.is_null()) return Nothing<bool>(); } } -@@ -1700,8 +1701,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( +@@ -1679,8 +1680,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor( : current->has_set() ? current->set() : Handle<Object>::cast(isolate->factory()->null_value())); @@ -243,7 +243,7 @@ index 15356b6c58d2f7355fa8b0dce4d3ea779a2884f9..834f83c0b0e68b9dcbe3fd0595dc2861 if (result.is_null()) return Nothing<bool>(); } } -@@ -4635,22 +4636,19 @@ bool JSObject::HasEnumerableElements() { +@@ -4611,22 +4612,19 @@ bool JSObject::HasEnumerableElements() { UNREACHABLE(); } @@ -274,10 +274,10 @@ index 15356b6c58d2f7355fa8b0dce4d3ea779a2884f9..834f83c0b0e68b9dcbe3fd0595dc2861 it->UpdateProtector(); diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h -index 06489c2b7bae61ecadbd8f020060e86ef50e11b6..ff96bd4be2ff8d2fe03f75b6bca35a744e2084af 100644 +index f663af6ed8a445f8ef30a67bac176a1abe6c85f8..5e7326eb1c99115829c358cd4069e1f6835f972b 100644 --- a/src/objects/js-objects.h +++ b/src/objects/js-objects.h -@@ -531,13 +531,14 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> { +@@ -525,13 +525,14 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> { GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); // Defines an AccessorPair property on the given object. diff --git a/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch b/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch index 34e5f40486875..005a08490910f 100644 --- a/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch +++ b/patches/v8/merged_ic_fix_store_handler_selection_for_arguments_objects.patch @@ -59,7 +59,7 @@ index 43511407e0eb54e2ce22ee132d8a4d37c52b13a7..cd6d834d6b7ec84c1d46105449ca775c } diff --git a/src/ic/ic.cc b/src/ic/ic.cc -index fff21e90bad3451e2d942ec327cb02f394fecc46..f86d9acf9073aba1662de103c5dd5d6056df19bf 100644 +index 32039f9888d3cb54699c6aefd0bcc3573044995e..0a7794de93dc6ba2a20f106ccf2d5f4b30319167 100644 --- a/src/ic/ic.cc +++ b/src/ic/ic.cc @@ -2296,10 +2296,18 @@ Handle<Object> KeyedStoreIC::StoreElementHandler( From a68e328e53ebfd93648f5bbef66796ceb975c83a Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Wed, 14 Jun 2023 22:19:04 +0100 Subject: [PATCH 151/172] chore: cherry-pick 5 changes from Release-2-M114, Release-1-M110 and Release-0-M110 (#38789) * chore: [22-x-y] cherry-pick 1 changes from Release-2-M114 * 2e76270cf65e from v8 * chore: update patches * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + ...do_not_use_va_args_twice_in_asprintf.patch | 96 +++++++++++++ patches/config.json | 4 +- patches/v8/.patches | 1 + patches/v8/cherry-pick-2e76270cf65e.patch | 45 +++++++ patches/webrtc/.patches | 1 + patches/webrtc/cherry-pick-218b56e51638.patch | 11 +- patches/webrtc/cherry-pick-e0efbd45ea74.patch | 15 ++- ...on_loop_over_to_the_signaling_thread.patch | 126 ++++++++++++++++++ 9 files changed, 287 insertions(+), 13 deletions(-) create mode 100644 patches/chromium/base_do_not_use_va_args_twice_in_asprintf.patch create mode 100644 patches/v8/cherry-pick-2e76270cf65e.patch create mode 100644 patches/webrtc/m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 51718c5fe8189..3c84459096235 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -163,3 +163,4 @@ cherry-pick-ea1cd76358e0.patch cherry-pick-48785f698b1c.patch m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch m114_merge_fix_a_crash_caused_by_calling_trace_event.patch +base_do_not_use_va_args_twice_in_asprintf.patch diff --git a/patches/chromium/base_do_not_use_va_args_twice_in_asprintf.patch b/patches/chromium/base_do_not_use_va_args_twice_in_asprintf.patch new file mode 100644 index 0000000000000..dae347a8f8400 --- /dev/null +++ b/patches/chromium/base_do_not_use_va_args_twice_in_asprintf.patch @@ -0,0 +1,96 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benoit Lize <lizeb@chromium.org> +Date: Fri, 9 Jun 2023 17:59:08 +0000 +Subject: Do not use va_args twice in asprintf() + +(cherry picked from commit 3cff0cb19a6d01cbdd9932f43dabaaeda9c0330a) + +Bug: 1450536 +Change-Id: Ib34d96935278869a63897f9a1c66afc98865d90f +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4579347 +Reviewed-by: Egor Pasko <pasko@chromium.org> +Commit-Queue: Benoit Lize <lizeb@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1151796} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4604070 +Reviewed-by: Michael Thiessen <mthiesse@chromium.org> +Cr-Commit-Position: refs/branch-heads/5735@{#1224} +Cr-Branched-From: 2f562e4ddbaf79a3f3cb338b4d1bd4398d49eb67-refs/heads/main@{#1135570} + +diff --git a/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h b/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h +index 621873126602463a09efca1bf1548ed10910d323..de2af6d7d54e254b9e7b8264b53d30a338fb13e8 100644 +--- a/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h ++++ b/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h +@@ -123,13 +123,21 @@ SHIM_ALWAYS_EXPORT char* __wrap_getcwd(char* buffer, size_t size) { + SHIM_ALWAYS_EXPORT int __wrap_vasprintf(char** strp, + const char* fmt, + va_list va_args) { ++ // There are cases where we need to use the list of arguments twice, namely ++ // when the original buffer is too small. It is not allowed to walk the list ++ // twice, so make a copy for the second invocation of vsnprintf(). ++ va_list va_args_copy; ++ va_copy(va_args_copy, va_args); ++ + constexpr int kInitialSize = 128; + *strp = static_cast<char*>( + malloc(kInitialSize)); // Our malloc() doesn't return nullptr. + + int actual_size = vsnprintf(*strp, kInitialSize, fmt, va_args); +- if (actual_size < 0) ++ if (actual_size < 0) { ++ va_end(va_args_copy); + return actual_size; ++ } + *strp = + static_cast<char*>(realloc(*strp, static_cast<size_t>(actual_size + 1))); + +@@ -139,9 +147,14 @@ SHIM_ALWAYS_EXPORT int __wrap_vasprintf(char** strp, + // + // This is very lightly used in Chromium in practice, see crbug.com/116558 for + // details. +- if (actual_size >= kInitialSize) +- return vsnprintf(*strp, static_cast<size_t>(actual_size + 1), fmt, va_args); +- ++ if (actual_size >= kInitialSize) { ++ int ret = vsnprintf(*strp, static_cast<size_t>(actual_size + 1), fmt, ++ va_args_copy); ++ va_end(va_args_copy); ++ return ret; ++ } ++ ++ va_end(va_args_copy); + return actual_size; + } + +diff --git a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc +index 6caf9d6ffe0db92602ac1e448f45da422e077c2c..57d36f722e1aa747cda3a808104cc108147552c1 100644 +--- a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc ++++ b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc +@@ -706,6 +706,28 @@ TEST_F(AllocatorShimTest, InterceptVasprintf) { + // Should not crash. + } + ++TEST_F(AllocatorShimTest, InterceptLongVasprintf) { ++ char* str = nullptr; ++ const char* lorem_ipsum = ++ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. " ++ "Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, " ++ "ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula " ++ "massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci " ++ "nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit " ++ "amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat " ++ "in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero " ++ "pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo " ++ "in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue " ++ "blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus " ++ "et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed " ++ "pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales " ++ "hendrerit."; ++ int err = asprintf(&str, "%s", lorem_ipsum); ++ EXPECT_EQ(err, static_cast<int>(strlen(lorem_ipsum))); ++ EXPECT_TRUE(str); ++ free(str); ++} ++ + #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + + #endif // BUILDFLAG(IS_ANDROID) diff --git a/patches/config.json b/patches/config.json index 6ab6da8595e4a..e991ec3fea008 100644 --- a/patches/config.json +++ b/patches/config.json @@ -27,5 +27,7 @@ "src/electron/patches/skia": "src/third_party/skia", - "src/electron/patches/dawn": "src/third_party/dawn" + "src/electron/patches/dawn": "src/third_party/dawn", + + "src/electron/patches/webrtc": "src/third_party/webrtc" } diff --git a/patches/v8/.patches b/patches/v8/.patches index 784ae8f372af8..c157518d3adda 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -21,3 +21,4 @@ merged_ic_fix_store_handler_selection_for_arguments_objects.patch cherry-pick-73af1a19a901.patch merged_regexp_fix_clobbered_register_in_global_unicode_special.patch m108-lts_api_fix_v8_object_setaccessorproperty.patch +cherry-pick-2e76270cf65e.patch diff --git a/patches/v8/cherry-pick-2e76270cf65e.patch b/patches/v8/cherry-pick-2e76270cf65e.patch new file mode 100644 index 0000000000000..a1db13a0ae984 --- /dev/null +++ b/patches/v8/cherry-pick-2e76270cf65e.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shu-yu Guo <syg@chromium.org> +Date: Mon, 5 Jun 2023 16:05:52 -0700 +Subject: Merged: Check for encoding when appending in string builder + +Fixed: chromium:1450114 +(cherry picked from commit a7e2bef27b72f187a7dcdf95714df686f56d9e0b) + +Change-Id: I5838383b6b12d137e84c8a36863ef88000e85c76 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4604652 +Reviewed-by: Igor Sheludko <ishell@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#41} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/strings/string-builder.cc b/src/strings/string-builder.cc +index 9d1e3a95746b47b99c15f18ec593549d79e10b8c..c7e98e55763aba2d64f4070e25759489f850f589 100644 +--- a/src/strings/string-builder.cc ++++ b/src/strings/string-builder.cc +@@ -306,12 +306,21 @@ bool IncrementalStringBuilder::CanAppendByCopy(Handle<String> string) { + void IncrementalStringBuilder::AppendStringByCopy(Handle<String> string) { + DCHECK(CanAppendByCopy(string)); + +- Handle<SeqOneByteString> part = +- Handle<SeqOneByteString>::cast(current_part()); + { + DisallowGarbageCollection no_gc; +- String::WriteToFlat(*string, part->GetChars(no_gc) + current_index_, 0, +- string->length()); ++ if (encoding_ == String::ONE_BYTE_ENCODING) { ++ String::WriteToFlat( ++ *string, ++ Handle<SeqOneByteString>::cast(current_part())->GetChars(no_gc) + ++ current_index_, ++ 0, string->length()); ++ } else { ++ String::WriteToFlat( ++ *string, ++ Handle<SeqTwoByteString>::cast(current_part())->GetChars(no_gc) + ++ current_index_, ++ 0, string->length()); ++ } + } + current_index_ += string->length(); + DCHECK(current_index_ <= part_length_); diff --git a/patches/webrtc/.patches b/patches/webrtc/.patches index ff43ad9385c19..97afee4d801b6 100644 --- a/patches/webrtc/.patches +++ b/patches/webrtc/.patches @@ -1,2 +1,3 @@ cherry-pick-e0efbd45ea74.patch cherry-pick-218b56e51638.patch +m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch diff --git a/patches/webrtc/cherry-pick-218b56e51638.patch b/patches/webrtc/cherry-pick-218b56e51638.patch index 3d24052a2a2e2..430e1898d6c53 100644 --- a/patches/webrtc/cherry-pick-218b56e51638.patch +++ b/patches/webrtc/cherry-pick-218b56e51638.patch @@ -1,7 +1,7 @@ -From 218b56e516386cd57c7513197528c3124bcd7ef3 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Alexander Cooper <alcooper@chromium.org> -Date: Wed, 08 Feb 2023 14:16:01 -0800 -Subject: [PATCH] Fix Destruction inside WGC Callback +Date: Wed, 8 Feb 2023 14:16:01 -0800 +Subject: Fix Destruction inside WGC Callback If we are notified of the destruction of the window before a CaptureFrame call can fail, then we may end up attempting to destroy the @@ -29,13 +29,12 @@ Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/293246 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/branch-heads/5481@{#5} Cr-Branched-From: 2e1a9a4ae0234d4b1ea7a6fd4188afa1fb20379d-refs/heads/main@{#38901} ---- diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc -index e165291..ea5565c 100644 +index 831257b4d476d674303f835f6002b22bf809a772..20045b6d1d1250fc9b634e51fe3875b484d6c397 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc -@@ -397,17 +397,14 @@ +@@ -388,17 +388,14 @@ HRESULT WgcCaptureSession::OnItemClosed(WGC::IGraphicsCaptureItem* sender, RTC_LOG(LS_INFO) << "Capture target has been closed."; item_closed_ = true; diff --git a/patches/webrtc/cherry-pick-e0efbd45ea74.patch b/patches/webrtc/cherry-pick-e0efbd45ea74.patch index 7e62974f93689..9a535541ccd4f 100644 --- a/patches/webrtc/cherry-pick-e0efbd45ea74.patch +++ b/patches/webrtc/cherry-pick-e0efbd45ea74.patch @@ -1,7 +1,11 @@ -From e0efbd45ea7421fb944c7343254ac5dc22bee541 Mon Sep 17 00:00:00 2001 -From: Henrik Boström <hbos@webrtc.org> +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= <hbos@webrtc.org> Date: Fri, 20 Jan 2023 10:48:31 +0100 -Subject: [PATCH] [Merge-110] [Stats] Handle the case of missing certificates. +Subject: =?UTF-8?q?=C2=A0[Stats]=20Handle=20the=20case=20of=20missing=20ce?= + =?UTF-8?q?rtificates.?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit Certificates being missing is a sign of a bug (e.g. webrtc:14844, to be fixed separately) which is why we have a DCHECK. But this DCHECK does @@ -22,13 +26,12 @@ Cr-Original-Commit-Position: refs/heads/main@{#39159} Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291380 Cr-Commit-Position: refs/branch-heads/5481@{#2} Cr-Branched-From: 2e1a9a4ae0234d4b1ea7a6fd4188afa1fb20379d-refs/heads/main@{#38901} ---- diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc -index d500a7b..1d88566 100644 +index ff7e334169da41c400d94387527734362d5dbeaa..c16e9ac7eaade4785f16afa46b2051f338095ca3 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc -@@ -2192,16 +2192,17 @@ +@@ -2197,16 +2197,17 @@ void RTCStatsCollector::ProduceTransportStats_n( // exist. const auto& certificate_stats_it = transport_cert_stats.find(transport_name); diff --git a/patches/webrtc/m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch b/patches/webrtc/m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch new file mode 100644 index 0000000000000..f0d29a7748c0e --- /dev/null +++ b/patches/webrtc/m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch @@ -0,0 +1,126 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tommi <tommi@webrtc.org> +Date: Thu, 1 Jun 2023 16:08:52 +0200 +Subject: Move transceiver iteration loop over to the signaling thread. + +This is required for ReportTransportStats since iterating over the +transceiver list from the network thread is not safe. + +(cherry picked from commit dba22d31909298161318e00d43a80cdb0abc940f) + +No-Try: true +Bug: chromium:1446274, webrtc:12692 +Change-Id: I7c514df9f029112c4b1da85826af91217850fb26 +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307340 +Reviewed-by: Harald Alvestrand <hta@webrtc.org> +Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> +Cr-Original-Commit-Position: refs/heads/main@{#40197} +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/308001 +Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> +Cr-Commit-Position: refs/branch-heads/5735@{#3} +Cr-Branched-From: df7df199abd619e75b9f1d9a7e12fc3f3f748775-refs/heads/main@{#39949} + +diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc +index 4615ce5a2c413dba798c3f9f8f7d4c1ae78bf9af..62179cd44c57dc6d808579353b398412db5e1ed6 100644 +--- a/pc/peer_connection.cc ++++ b/pc/peer_connection.cc +@@ -716,9 +716,6 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( + transport_controller_->SubscribeIceConnectionState( + [this](cricket::IceConnectionState s) { + RTC_DCHECK_RUN_ON(network_thread()); +- if (s == cricket::kIceConnectionConnected) { +- ReportTransportStats(); +- } + signaling_thread()->PostTask( + SafeTask(signaling_thread_safety_.flag(), [this, s]() { + RTC_DCHECK_RUN_ON(signaling_thread()); +@@ -2372,6 +2369,20 @@ void PeerConnection::OnTransportControllerConnectionState( + case cricket::kIceConnectionConnected: + RTC_LOG(LS_INFO) << "Changing to ICE connected state because " + "all transports are writable."; ++ { ++ std::vector<RtpTransceiverProxyRefPtr> transceivers; ++ if (ConfiguredForMedia()) { ++ transceivers = rtp_manager()->transceivers()->List(); ++ } ++ ++ network_thread()->PostTask( ++ SafeTask(network_thread_safety_, ++ [this, transceivers = std::move(transceivers)] { ++ RTC_DCHECK_RUN_ON(network_thread()); ++ ReportTransportStats(std::move(transceivers)); ++ })); ++ } ++ + SetIceConnectionState(PeerConnectionInterface::kIceConnectionConnected); + NoteUsageEvent(UsageEvent::ICE_STATE_CONNECTED); + break; +@@ -2701,20 +2712,18 @@ void PeerConnection::OnTransportControllerGatheringState( + } + + // Runs on network_thread(). +-void PeerConnection::ReportTransportStats() { ++void PeerConnection::ReportTransportStats( ++ std::vector<RtpTransceiverProxyRefPtr> transceivers) { + TRACE_EVENT0("webrtc", "PeerConnection::ReportTransportStats"); + rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; + std::map<std::string, std::set<cricket::MediaType>> + media_types_by_transport_name; +- if (ConfiguredForMedia()) { +- for (const auto& transceiver : +- rtp_manager()->transceivers()->UnsafeList()) { +- if (transceiver->internal()->channel()) { +- std::string transport_name( +- transceiver->internal()->channel()->transport_name()); +- media_types_by_transport_name[transport_name].insert( +- transceiver->media_type()); +- } ++ for (const auto& transceiver : transceivers) { ++ if (transceiver->internal()->channel()) { ++ std::string transport_name( ++ transceiver->internal()->channel()->transport_name()); ++ media_types_by_transport_name[transport_name].insert( ++ transceiver->media_type()); + } + } + +diff --git a/pc/peer_connection.h b/pc/peer_connection.h +index 36a9d2ac743a81e2c4ac8b4abd73d2fd40c3dd40..ea221e697322bd8b8c161edada7a448a68fa7f68 100644 +--- a/pc/peer_connection.h ++++ b/pc/peer_connection.h +@@ -563,7 +563,8 @@ class PeerConnection : public PeerConnectionInternal, + + // Invoked when TransportController connection completion is signaled. + // Reports stats for all transports in use. +- void ReportTransportStats() RTC_RUN_ON(network_thread()); ++ void ReportTransportStats(std::vector<RtpTransceiverProxyRefPtr> transceivers) ++ RTC_RUN_ON(network_thread()); + + // Gather the usage of IPv4/IPv6 as best connection. + static void ReportBestConnectionState(const cricket::TransportStats& stats); +diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc +index 19cc6ce3cfc8b8b38d45f5df9c28fe6dd01572f5..da8a53ef5d91c9c14dc6f42a10d176c7f6089ada 100644 +--- a/pc/peer_connection_integrationtest.cc ++++ b/pc/peer_connection_integrationtest.cc +@@ -1831,6 +1831,10 @@ TEST_P(PeerConnectionIntegrationTest, + EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected, + callee()->ice_connection_state(), kDefaultTimeout); + ++ // Part of reporting the stats will occur on the network thread, so flush it ++ // before checking NumEvents. ++ SendTask(network_thread(), [] {}); ++ + EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents( + "WebRTC.PeerConnection.CandidatePairType_UDP", + webrtc::kIceCandidatePairHostNameHostName)); +@@ -1959,6 +1963,10 @@ TEST_P(PeerConnectionIntegrationIceStatesTest, MAYBE_VerifyBestConnection) { + EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected, + callee()->ice_connection_state(), kDefaultTimeout); + ++ // Part of reporting the stats will occur on the network thread, so flush it ++ // before checking NumEvents. ++ SendTask(network_thread(), [] {}); ++ + // TODO(bugs.webrtc.org/9456): Fix it. + const int num_best_ipv4 = webrtc::metrics::NumEvents( + "WebRTC.PeerConnection.IPMetrics", webrtc::kBestConnections_IPv4); From 4ade2a6fb65e4b723feb7c09a5df765e5006b378 Mon Sep 17 00:00:00 2001 From: David Sanders <dsanders11@ucsbalum.com> Date: Mon, 19 Jun 2023 03:43:50 +0800 Subject: [PATCH 152/172] build: use Xcode 13.4.1 (#38822) --- .circleci/config/base.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 533e7f1a0ea08..a8f844352ad99 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -54,7 +54,7 @@ executors: type: enum enum: ["macos.x86.medium.gen2", "large"] macos: - xcode: 13.3.0 + xcode: 13.4.1 resource_class: << parameters.size >> # Electron Runners @@ -2185,4 +2185,4 @@ workflows: jobs: - lint -# VS Code Extension Version: 1.4.0 \ No newline at end of file +# VS Code Extension Version: 1.4.0 From 1f91895d22d90e44db98ec16d5e94f5891443ddc Mon Sep 17 00:00:00 2001 From: Pedro Pontes <ppontes@gmail.com> Date: Thu, 6 Jul 2023 02:19:53 +0100 Subject: [PATCH 153/172] chore: cherry-pick 4 changes from Release-3-M114 (#38949) * chore: [22-x-y] cherry-pick 4 changes from Release-3-M114 * 85beff6fd302 from chromium * 60b93798c991 from chromium * a1efa5343880 from v8 * d20849d07107 from webrtc * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 2 + .../chromium/cherry-pick-85beff6fd302.patch | 215 ++++++++++++++++++ ...changing_temporal_layer_count_in_av1.patch | 99 ++++++++ patches/v8/.patches | 3 + ...ler_stackcheck_can_have_side_effects.patch | 31 +++ ...instance_prototypes_directly_on_maps.patch | 44 ++++ ...0fix_20using_20shared_20objects_20as.patch | 78 +++++++ patches/webrtc/.patches | 1 + ...eject_duplicate_ssrcs_in_ssrc-groups.patch | 79 +++++++ 9 files changed, 552 insertions(+) create mode 100644 patches/chromium/cherry-pick-85beff6fd302.patch create mode 100644 patches/chromium/m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch create mode 100644 patches/v8/merged_compiler_stackcheck_can_have_side_effects.patch create mode 100644 patches/v8/merged_runtime_set_instance_prototypes_directly_on_maps.patch create mode 100644 patches/v8/utf-8_q_shared-struct_20fix_20using_20shared_20objects_20as.patch create mode 100644 patches/webrtc/m114_sdp_reject_duplicate_ssrcs_in_ssrc-groups.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 3c84459096235..c788fd1d33cf9 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -164,3 +164,5 @@ cherry-pick-48785f698b1c.patch m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch m114_merge_fix_a_crash_caused_by_calling_trace_event.patch base_do_not_use_va_args_twice_in_asprintf.patch +cherry-pick-85beff6fd302.patch +m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch diff --git a/patches/chromium/cherry-pick-85beff6fd302.patch b/patches/chromium/cherry-pick-85beff6fd302.patch new file mode 100644 index 0000000000000..3b4d5802ef9ab --- /dev/null +++ b/patches/chromium/cherry-pick-85beff6fd302.patch @@ -0,0 +1,215 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Kevin McNee <mcnee@chromium.org> +Date: Wed, 14 Jun 2023 01:10:19 +0000 +Subject: M114: Don't recursively destroy guests when clearing unattached + guests + +Don't recursively destroy guests when clearing unattached guests + +When an embedder process is destroyed, we also destroy any unattached +guests associated with that process. This is currently done with a +single call to `owned_guests_.erase`. However, it's possible that two +unattached guests could have an opener relationship, which causes the +destruction of the opener guest to also destroy the other guest, during +the call to `erase`, which is unsafe. + +We now separate the steps of erasing `owned_guests_` and destroying the +guests, to avoid this recursive guest destruction. + +This also fixes the WaitForNumGuestsCreated test method to not +return prematurely. + +(cherry picked from commit 6345e7871e8197af92f9c6158b06c6e197f87945) + +Bug: 1450397 +Change-Id: Ifef5ec9ff3a1e6952ff56ec279e29e8522625ac0 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4589949 +Commit-Queue: Kevin McNee <mcnee@chromium.org> +Auto-Submit: Kevin McNee <mcnee@chromium.org> +Reviewed-by: James Maclean <wjmaclean@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1153396} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4611152 +Commit-Queue: James Maclean <wjmaclean@chromium.org> +Cr-Commit-Position: refs/branch-heads/5735@{#1292} +Cr-Branched-From: 2f562e4ddbaf79a3f3cb338b4d1bd4398d49eb67-refs/heads/main@{#1135570} + +diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc +index 7159cf6af5cfd0ad5b9e5ba526043a4407a5399d..e43966f43f7ae551b3ea335a3f4222887071a75e 100644 +--- a/chrome/browser/apps/guest_view/web_view_browsertest.cc ++++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc +@@ -2731,6 +2731,22 @@ IN_PROC_BROWSER_TEST_P(WebViewNewWindowTest, + EXPECT_TRUE(content::NavigateToURLFromRenderer(guest2, coop_url)); + } + ++// This test creates a situation where we have two unattached webviews which ++// have an opener relationship, and ensures that we can shutdown safely. See ++// https://crbug.com/1450397. ++IN_PROC_BROWSER_TEST_P(WebViewNewWindowTest, DestroyOpenerBeforeAttachment) { ++ TestHelper("testDestroyOpenerBeforeAttachment", "web_view/newwindow", ++ NEEDS_TEST_SERVER); ++ GetGuestViewManager()->WaitForNumGuestsCreated(2); ++ ++ content::RenderProcessHost* embedder_rph = ++ GetEmbedderWebContents()->GetPrimaryMainFrame()->GetProcess(); ++ content::RenderProcessHostWatcher kill_observer( ++ embedder_rph, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); ++ EXPECT_TRUE(embedder_rph->Shutdown(content::RESULT_CODE_KILLED)); ++ kill_observer.Wait(); ++} ++ + IN_PROC_BROWSER_TEST_P(WebViewTest, ContextMenuInspectElement) { + LoadAppWithGuest("web_view/context_menus/basic"); + content::RenderFrameHost* guest_rfh = GetGuestRenderFrameHost(); +diff --git a/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js +index 900911f4963d23d74225868dce01326ba533f63a..4dd25d8849b0b13957ab7fa2912c0a158d3cd244 100644 +--- a/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js ++++ b/chrome/test/data/extensions/platform_apps/web_view/newwindow/embedder.js +@@ -34,6 +34,9 @@ embedder.setUp_ = function(config) { + embedder.guestWithLinkURL = embedder.baseGuestURL + + '/extensions/platform_apps/web_view/newwindow' + + '/guest_with_link.html'; ++ embedder.guestOpenOnLoadURL = embedder.baseGuestURL + ++ '/extensions/platform_apps/web_view/newwindow' + ++ '/guest_opener_open_on_load.html'; + }; + + /** @private */ +@@ -652,6 +655,24 @@ function testNewWindowDeferredAttachmentIndefinitely() { + embedder.setUpNewWindowRequest_(webview, 'guest.html', '', testName); + } + ++// This is not a test in and of itself, but a means of creating a webview that ++// is left in an unattached state while its opener webview is also in an ++// unattached state, so that the C++ side can test it in that state. ++function testDestroyOpenerBeforeAttachment() { ++ embedder.test.succeed(); ++ ++ let webview = new WebView(); ++ webview.src = embedder.guestOpenOnLoadURL; ++ document.body.appendChild(webview); ++ ++ // By spinning forever here, we prevent `webview` from completing the ++ // attachment process. But since the guest is still created and it calls ++ // window.open, we have a situation where two unattached webviews have an ++ // opener relationship. The C++ side will test that we can shutdown safely in ++ // this case. ++ while (true) {} ++} ++ + embedder.test.testList = { + 'testNewWindowAttachAfterOpenerDestroyed': + testNewWindowAttachAfterOpenerDestroyed, +@@ -675,7 +696,9 @@ embedder.test.testList = { + testNewWindowWebViewNameTakesPrecedence, + 'testNewWindowAndUpdateOpener': testNewWindowAndUpdateOpener, + 'testNewWindowDeferredAttachmentIndefinitely': +- testNewWindowDeferredAttachmentIndefinitely ++ testNewWindowDeferredAttachmentIndefinitely, ++ 'testDestroyOpenerBeforeAttachment': ++ testDestroyOpenerBeforeAttachment + }; + + onload = function() { +diff --git a/chrome/test/data/extensions/platform_apps/web_view/newwindow/guest_opener_open_on_load.html b/chrome/test/data/extensions/platform_apps/web_view/newwindow/guest_opener_open_on_load.html +new file mode 100644 +index 0000000000000000000000000000000000000000..e961feb3c6487066801adf414bf4a2746c50a3f6 +--- /dev/null ++++ b/chrome/test/data/extensions/platform_apps/web_view/newwindow/guest_opener_open_on_load.html +@@ -0,0 +1,13 @@ ++<!-- ++Copyright 2023 The Chromium Authors ++Use of this source code is governed by a BSD-style license that can be ++found in the LICENSE file. ++--> ++<html> ++<body> ++<script> ++ // A guest that opens a new window on load. ++ window.open('guest.html'); ++</script> ++</body> ++</html> +diff --git a/components/guest_view/browser/guest_view_manager.cc b/components/guest_view/browser/guest_view_manager.cc +index 38f0f12e65009c660a6dba262617d48c10ff72ea..129443365f474b840e2ddc61868e89af2851a892 100644 +--- a/components/guest_view/browser/guest_view_manager.cc ++++ b/components/guest_view/browser/guest_view_manager.cc +@@ -324,7 +324,20 @@ void GuestViewManager::RemoveGuest(int guest_instance_id) { + + void GuestViewManager::EmbedderProcessDestroyed(int embedder_process_id) { + embedders_observed_.erase(embedder_process_id); ++ ++ // We can't just call std::multimap::erase here because destroying a guest ++ // could trigger the destruction of another guest which is also owned by ++ // `owned_guests_`. Recursively calling std::multimap::erase is unsafe (see ++ // https://crbug.com/1450397). So we take ownership of all of the guests that ++ // will be destroyed before erasing the entries from the map. ++ std::vector<std::unique_ptr<GuestViewBase>> guests_to_destroy; ++ const auto destroy_range = owned_guests_.equal_range(embedder_process_id); ++ for (auto it = destroy_range.first; it != destroy_range.second; ++it) { ++ guests_to_destroy.push_back(std::move(it->second)); ++ } + owned_guests_.erase(embedder_process_id); ++ guests_to_destroy.clear(); ++ + CallViewDestructionCallbacks(embedder_process_id); + } + +diff --git a/components/guest_view/browser/test_guest_view_manager.cc b/components/guest_view/browser/test_guest_view_manager.cc +index ab703db51b5ecd33e5fabd831ba121a2b5047d93..877f3eea7b440ed0a860253f85108c2442afee2e 100644 +--- a/components/guest_view/browser/test_guest_view_manager.cc ++++ b/components/guest_view/browser/test_guest_view_manager.cc +@@ -36,7 +36,6 @@ TestGuestViewManager::TestGuestViewManager( + num_guests_created_(0), + expected_num_guests_created_(0), + num_views_garbage_collected_(0), +- waiting_for_guests_created_(false), + waiting_for_attach_(nullptr) {} + + TestGuestViewManager::~TestGuestViewManager() = default; +@@ -127,14 +126,15 @@ GuestViewBase* TestGuestViewManager::WaitForNextGuestViewCreated() { + } + + void TestGuestViewManager::WaitForNumGuestsCreated(size_t count) { +- if (count == num_guests_created_) ++ if (count == num_guests_created_) { + return; ++ } + +- waiting_for_guests_created_ = true; + expected_num_guests_created_ = count; + + num_created_run_loop_ = std::make_unique<base::RunLoop>(); + num_created_run_loop_->Run(); ++ num_created_run_loop_ = nullptr; + } + + void TestGuestViewManager::WaitUntilAttached(GuestViewBase* guest_view) { +@@ -179,13 +179,11 @@ void TestGuestViewManager::AddGuest(int guest_instance_id, + created_run_loop_->Quit(); + + ++num_guests_created_; +- if (!waiting_for_guests_created_ && +- num_guests_created_ != expected_num_guests_created_) { +- return; +- } + +- if (num_created_run_loop_) ++ if (num_created_run_loop_ && ++ num_guests_created_ == expected_num_guests_created_) { + num_created_run_loop_->Quit(); ++ } + } + + void TestGuestViewManager::AttachGuest(int embedder_process_id, +diff --git a/components/guest_view/browser/test_guest_view_manager.h b/components/guest_view/browser/test_guest_view_manager.h +index 75015f30cfaf8f4bb427b360951f01c729f37308..557afdbdcde44062f13dd981aacd56b8c17d35d6 100644 +--- a/components/guest_view/browser/test_guest_view_manager.h ++++ b/components/guest_view/browser/test_guest_view_manager.h +@@ -121,7 +121,6 @@ class TestGuestViewManager : public GuestViewManager { + size_t num_guests_created_; + size_t expected_num_guests_created_; + int num_views_garbage_collected_; +- bool waiting_for_guests_created_; + + // Tracks the life time of the GuestView's main FrameTreeNode. The main FTN + // has the same lifesspan as the GuestView. diff --git a/patches/chromium/m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch b/patches/chromium/m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch new file mode 100644 index 0000000000000..e083287f8b003 --- /dev/null +++ b/patches/chromium/m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch @@ -0,0 +1,99 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eugene Zemtsov <eugene@chromium.org> +Date: Wed, 21 Jun 2023 17:57:52 +0000 +Subject: webcodecs: Fix crash when changing temporal layer count in AV1 + encoder + +(cherry picked from commit f312efac1b90117729e8961b58c643fc0eae1fbd) + +Bug: 1447568 +Change-Id: I4ecb02ed956707571573a65ade17fdffe676b502 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4554300 +Auto-Submit: Eugene Zemtsov <eugene@chromium.org> +Commit-Queue: Dale Curtis <dalecurtis@chromium.org> +Reviewed-by: Dale Curtis <dalecurtis@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1148041} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4610718 +Cr-Commit-Position: refs/branch-heads/5735@{#1360} +Cr-Branched-From: 2f562e4ddbaf79a3f3cb338b4d1bd4398d49eb67-refs/heads/main@{#1135570} + +diff --git a/media/video/av1_video_encoder.cc b/media/video/av1_video_encoder.cc +index 71e4fa09a650183c3cd2ef84520d9493f2655bba..266170a524bc8f4317bec941714fe0be9333de37 100644 +--- a/media/video/av1_video_encoder.cc ++++ b/media/video/av1_video_encoder.cc +@@ -118,6 +118,7 @@ EncoderStatus SetUpAomConfig(const VideoEncoder::Options& opts, + svc_params = {}; + svc_params.framerate_factor[0] = 1; + svc_params.number_spatial_layers = 1; ++ svc_params.number_temporal_layers = 1; + if (opts.scalability_mode.has_value()) { + switch (opts.scalability_mode.value()) { + case SVCScalabilityMode::kL1T2: +diff --git a/media/video/software_video_encoder_test.cc b/media/video/software_video_encoder_test.cc +index 318c743bddcf9bec3a994f125ea329d45f8c4376..7a27b9326a5df556b1a6bacdad71081d46bcc781 100644 +--- a/media/video/software_video_encoder_test.cc ++++ b/media/video/software_video_encoder_test.cc +@@ -602,6 +602,63 @@ TEST_P(SVCVideoEncoderTest, EncodeClipTemporalSvc) { + } + } + ++TEST_P(SVCVideoEncoderTest, ChangeLayers) { ++ VideoEncoder::Options options; ++ options.frame_size = gfx::Size(640, 480); ++ options.bitrate = Bitrate::ConstantBitrate(1000000u); // 1Mbps ++ options.framerate = 25; ++ options.scalability_mode = GetParam().scalability_mode; ++ std::vector<scoped_refptr<VideoFrame>> frames_to_encode; ++ ++ std::vector<VideoEncoderOutput> chunks; ++ size_t total_frames_count = 80; ++ ++ // Encoder all frames with 3 temporal layers and put all outputs in |chunks| ++ auto frame_duration = base::Seconds(1.0 / options.framerate.value()); ++ ++ VideoEncoder::OutputCB encoder_output_cb = base::BindLambdaForTesting( ++ [&](VideoEncoderOutput output, ++ absl::optional<VideoEncoder::CodecDescription> desc) { ++ chunks.push_back(std::move(output)); ++ }); ++ ++ encoder_->Initialize(profile_, options, /*info_cb=*/base::DoNothing(), ++ std::move(encoder_output_cb), ++ ValidatingStatusCB(/* quit_run_loop_on_call */ true)); ++ RunUntilQuit(); ++ ++ uint32_t color = 0x964050; ++ for (auto frame_index = 0u; frame_index < total_frames_count; frame_index++) { ++ auto timestamp = frame_index * frame_duration; ++ ++ const bool reconfigure = (frame_index == total_frames_count / 2); ++ if (reconfigure) { ++ encoder_->Flush(ValidatingStatusCB(/* quit_run_loop_on_call */ true)); ++ RunUntilQuit(); ++ ++ // Ask encoder to change SVC mode, empty output callback ++ // means the encoder should keep the old one. ++ options.scalability_mode = SVCScalabilityMode::kL1T1; ++ encoder_->ChangeOptions( ++ options, VideoEncoder::OutputCB(), ++ ValidatingStatusCB(/* quit_run_loop_on_call */ true)); ++ RunUntilQuit(); ++ } ++ ++ auto frame = ++ CreateFrame(options.frame_size, pixel_format_, timestamp, color); ++ color = (color << 1) + frame_index; ++ frames_to_encode.push_back(frame); ++ encoder_->Encode(frame, VideoEncoder::EncodeOptions(false), ++ ValidatingStatusCB(/* quit_run_loop_on_call */ true)); ++ RunUntilQuit(); ++ } ++ ++ encoder_->Flush(ValidatingStatusCB(/* quit_run_loop_on_call */ true)); ++ RunUntilQuit(); ++ EXPECT_EQ(chunks.size(), total_frames_count); ++} ++ + TEST_P(H264VideoEncoderTest, ReconfigureWithResize) { + VideoEncoder::Options options; + gfx::Size size1(320, 200), size2(400, 240); diff --git a/patches/v8/.patches b/patches/v8/.patches index c157518d3adda..cf2d669daee39 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -22,3 +22,6 @@ cherry-pick-73af1a19a901.patch merged_regexp_fix_clobbered_register_in_global_unicode_special.patch m108-lts_api_fix_v8_object_setaccessorproperty.patch cherry-pick-2e76270cf65e.patch +utf-8_q_shared-struct_20fix_20using_20shared_20objects_20as.patch +merged_runtime_set_instance_prototypes_directly_on_maps.patch +merged_compiler_stackcheck_can_have_side_effects.patch diff --git a/patches/v8/merged_compiler_stackcheck_can_have_side_effects.patch b/patches/v8/merged_compiler_stackcheck_can_have_side_effects.patch new file mode 100644 index 0000000000000..cae4f4d5c41b2 --- /dev/null +++ b/patches/v8/merged_compiler_stackcheck_can_have_side_effects.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tobias Tebbi <tebbi@chromium.org> +Date: Tue, 13 Jun 2023 17:08:59 +0200 +Subject: Merged: [compiler] StackCheck can have side effects + +Bug: chromium:1452137 +(cherry picked from commit e548943e473b020fdc1de6e5543ca31b24d8b7f9) + +Change-Id: Ibd7c9b02efd12341b452e4c34a635a58a817649f +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4637129 +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Commit-Queue: Tobias Tebbi <tebbi@chromium.org> +Auto-Submit: Tobias Tebbi <tebbi@chromium.org> +Commit-Queue: Toon Verwaest <verwaest@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#49} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/compiler/js-operator.cc b/src/compiler/js-operator.cc +index 8af8e7d32fb68fdcaedaf08427103c893d23098d..e60c8a2c78970c89c4f52a6dc34a97d56e602e26 100644 +--- a/src/compiler/js-operator.cc ++++ b/src/compiler/js-operator.cc +@@ -1396,7 +1396,7 @@ const Operator* JSOperatorBuilder::CloneObject(FeedbackSource const& feedback, + const Operator* JSOperatorBuilder::StackCheck(StackCheckKind kind) { + return zone()->New<Operator1<StackCheckKind>>( // -- + IrOpcode::kJSStackCheck, // opcode +- Operator::kNoWrite, // properties ++ Operator::kNoProperties, // properties + "JSStackCheck", // name + 0, 1, 1, 0, 1, 2, // counts + kind); // parameter diff --git a/patches/v8/merged_runtime_set_instance_prototypes_directly_on_maps.patch b/patches/v8/merged_runtime_set_instance_prototypes_directly_on_maps.patch new file mode 100644 index 0000000000000..cbdf2b00f259f --- /dev/null +++ b/patches/v8/merged_runtime_set_instance_prototypes_directly_on_maps.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Toon Verwaest <verwaest@chromium.org> +Date: Fri, 16 Jun 2023 17:13:52 +0200 +Subject: Merged: [runtime] Set instance prototypes directly on maps + +Bug: chromium:1452137 +(cherry picked from commit c7c447735f762f6d6d0878e229371797845ef4ab) + +Change-Id: I611c41f942e2e51f3c4b4f1d119c18410617188e +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4637888 +Commit-Queue: Igor Sheludko <ishell@chromium.org> +Auto-Submit: Igor Sheludko <ishell@chromium.org> +Commit-Queue: Toon Verwaest <verwaest@chromium.org> +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#47} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/objects/js-function.cc b/src/objects/js-function.cc +index 62fe309a471b323c1cb2a9a872380563bbdc369f..878ef8fd6b49debcd46f8d4f3693630fb02fef17 100644 +--- a/src/objects/js-function.cc ++++ b/src/objects/js-function.cc +@@ -672,6 +672,10 @@ void SetInstancePrototype(Isolate* isolate, Handle<JSFunction> function, + // At that point, a new initial map is created and the prototype is put + // into the initial map where it belongs. + function->set_prototype_or_initial_map(*value, kReleaseStore); ++ if (value->IsJSObjectThatCanBeTrackedAsPrototype()) { ++ // Optimize as prototype to detach it from its transition tree. ++ JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value)); ++ } + } else { + Handle<Map> new_map = + Map::Copy(isolate, initial_map, "SetInstancePrototype"); +@@ -796,8 +800,10 @@ void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) { + Handle<HeapObject> prototype; + if (function->has_instance_prototype()) { + prototype = handle(function->instance_prototype(), isolate); ++ map->set_prototype(*prototype); + } else { + prototype = isolate->factory()->NewFunctionPrototype(function); ++ Map::SetPrototype(isolate, map, prototype); + } + DCHECK(map->has_fast_object_elements()); + diff --git a/patches/v8/utf-8_q_shared-struct_20fix_20using_20shared_20objects_20as.patch b/patches/v8/utf-8_q_shared-struct_20fix_20using_20shared_20objects_20as.patch new file mode 100644 index 0000000000000..c712b05b71639 --- /dev/null +++ b/patches/v8/utf-8_q_shared-struct_20fix_20using_20shared_20objects_20as.patch @@ -0,0 +1,78 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Pedro Pontes <pepontes@microsoft.com> +Date: Thu, 29 Jun 2023 01:16:50 -0700 +Subject: Fix using shared objects as prototypes more (Partial backport) + +The previous fix from +https://chromium-review.googlesource.com/c/v8/v8/+/4086127 was +insufficient. It prevented shared objects from being optimized as +prototypes, but callers of OptimizeAsPrototype also assume that all +JSObjects can track prototype users via prototype_info on the map. + +This CL attempts a broader fix where shared objects are not considered +optimizable as prototypes at all. When used as a prototype, shared +objects are treated like non-JSObjects (e.g. JSProxy, WasmObject). + +Bug: chromium:1401295, v8:12547 +Change-Id: I9886e9ccac9e597e7dd34a09083a096ff4e3bf16 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4112150 +Reviewed-by: Toon Verwaest <verwaest@chromium.org> +Commit-Queue: Shu-yu Guo <syg@chromium.org> +Cr-Commit-Position: refs/heads/main@{#84916} + +diff --git a/src/objects/heap-object.h b/src/objects/heap-object.h +index 806b34b969eeaccc7f16cfd0ac734d667b165943..b2d401ba823231f939b8d1ae4f44660360276053 100644 +--- a/src/objects/heap-object.h ++++ b/src/objects/heap-object.h +@@ -113,6 +113,8 @@ class HeapObject : public Object { + STRUCT_LIST(DECL_STRUCT_PREDICATE) + #undef DECL_STRUCT_PREDICATE + ++ V8_INLINE bool IsJSObjectThatCanBeTrackedAsPrototype() const; ++ + // Converts an address to a HeapObject pointer. + static inline HeapObject FromAddress(Address address) { + DCHECK_TAG_ALIGNED(address); +diff --git a/src/objects/objects-inl.h b/src/objects/objects-inl.h +index 025c87dbf313cc4b3adb884b4b2d96940c4ce389..baa1167a123b4c161d06b9869938d3cbd4f15fb2 100644 +--- a/src/objects/objects-inl.h ++++ b/src/objects/objects-inl.h +@@ -83,6 +83,11 @@ bool Object::InSharedWritableHeap() const { + return IsHeapObject() && HeapObject::cast(*this).InSharedWritableHeap(); + } + ++bool Object::IsJSObjectThatCanBeTrackedAsPrototype() const { ++ return IsHeapObject() && ++ HeapObject::cast(*this).IsJSObjectThatCanBeTrackedAsPrototype(); ++} ++ + #define IS_TYPE_FUNCTION_DEF(type_) \ + bool Object::Is##type_() const { \ + return IsHeapObject() && HeapObject::cast(*this).Is##type_(); \ +@@ -189,6 +194,13 @@ bool HeapObject::InSharedWritableHeap() const { + return BasicMemoryChunk::FromHeapObject(*this)->InSharedHeap(); + } + ++bool HeapObject::IsJSObjectThatCanBeTrackedAsPrototype() const { ++ // Do not optimize objects in the shared heap because it is not ++ // threadsafe. Objects in the shared heap have fixed layouts and their maps ++ // never change. ++ return IsJSObject() && !InSharedWritableHeap(); ++} ++ + bool HeapObject::IsNullOrUndefined(Isolate* isolate) const { + return IsNullOrUndefined(ReadOnlyRoots(isolate)); + } +diff --git a/src/objects/objects.h b/src/objects/objects.h +index c3a0cbf15a329d0e4e68aa5fd379352a1cc061ba..8814ddadc4bfaac6e243a94c4890147b6ea5b4b9 100644 +--- a/src/objects/objects.h ++++ b/src/objects/objects.h +@@ -341,6 +341,8 @@ class Object : public TaggedImpl<HeapObjectReferenceType::STRONG, Address> { + bool IsWasmObject(Isolate* = nullptr) const { return false; } + #endif + ++ V8_INLINE bool IsJSObjectThatCanBeTrackedAsPrototype() const; ++ + enum class Conversion { kToNumber, kToNumeric }; + + #define DECL_STRUCT_PREDICATE(NAME, Name, name) \ diff --git a/patches/webrtc/.patches b/patches/webrtc/.patches index 97afee4d801b6..7ebf08e48a574 100644 --- a/patches/webrtc/.patches +++ b/patches/webrtc/.patches @@ -1,3 +1,4 @@ cherry-pick-e0efbd45ea74.patch cherry-pick-218b56e51638.patch m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch +m114_sdp_reject_duplicate_ssrcs_in_ssrc-groups.patch diff --git a/patches/webrtc/m114_sdp_reject_duplicate_ssrcs_in_ssrc-groups.patch b/patches/webrtc/m114_sdp_reject_duplicate_ssrcs_in_ssrc-groups.patch new file mode 100644 index 0000000000000..af247b3120a37 --- /dev/null +++ b/patches/webrtc/m114_sdp_reject_duplicate_ssrcs_in_ssrc-groups.patch @@ -0,0 +1,79 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Philipp Hancke <phancke@microsoft.com> +Date: Thu, 15 Jun 2023 07:21:56 +0200 +Subject: sdp: reject duplicate ssrcs in ssrc-groups + +while not really covered by + https://www.rfc-editor.org/rfc/rfc5576.html#section-4.2 +and using the same SSRC for RTX and primary payload may work +since payload type demuxing *could* be used is not a good idea. +This also applies to flexfec's FEC-FR. + +For the nonstandard SIM ssrc-group duplicates make no sense. +This rejects duplicates for unknown ssrc-groups as well. + +BUG=chromium:1454860 + +(cherry picked from commit 6a38a3eb38f732b89ca0d8e36c43a434670c4ef5) + +No-Try: true +Change-Id: I3e86101dbd5d6c4099f2fdb7b4a52d5cd0809c5f +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/308820 +Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> +Reviewed-by: Harald Alvestrand <hta@webrtc.org> +Commit-Queue: Philipp Hancke <phancke@microsoft.com> +Cr-Original-Commit-Position: refs/heads/main@{#40292} +Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309601 +Cr-Commit-Position: refs/branch-heads/5735@{#4} +Cr-Branched-From: df7df199abd619e75b9f1d9a7e12fc3f3f748775-refs/heads/main@{#39949} + +diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc +index 39b16901a1c8951aa102ea1cdbdbfcf06b9b4b87..02375ad60dcef89b303faa42d3ea0faea6d22a0b 100644 +--- a/pc/webrtc_sdp.cc ++++ b/pc/webrtc_sdp.cc +@@ -3485,6 +3485,11 @@ bool ParseSsrcGroupAttribute(absl::string_view line, + if (!GetValueFromString(line, fields[i], &ssrc, error)) { + return false; + } ++ // Reject duplicates. While not forbidden by RFC 5576, ++ // they don't make sense. ++ if (absl::c_linear_search(ssrcs, ssrc)) { ++ return ParseFailed(line, "Duplicate SSRC in ssrc-group", error); ++ } + ssrcs.push_back(ssrc); + } + ssrc_groups->push_back(SsrcGroup(semantics, ssrcs)); +diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc +index 7880af069380a514730466112364e4529bef112f..1e5b669ccaef2f6696383c6da1864f9a5e5dc8a8 100644 +--- a/pc/webrtc_sdp_unittest.cc ++++ b/pc/webrtc_sdp_unittest.cc +@@ -4722,3 +4722,29 @@ TEST_F(WebRtcSdpTest, ParseIgnoreUnknownSsrcSpecificAttribute) { + SdpParseError error; + ASSERT_TRUE(webrtc::SdpDeserialize(sdp, &output, &error)); + } ++ ++TEST_F(WebRtcSdpTest, RejectDuplicateSsrcInSsrcGroup) { ++ std::string sdp = ++ "v=0\r\n" ++ "o=- 0 3 IN IP4 127.0.0.1\r\n" ++ "s=-\r\n" ++ "t=0 0\r\n" ++ "a=group:BUNDLE 0\r\n" ++ "a=fingerprint:sha-1 " ++ "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n" ++ "a=setup:actpass\r\n" ++ "a=ice-ufrag:ETEn\r\n" ++ "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n" ++ "m=video 9 UDP/TLS/RTP/SAVPF 96 97\r\n" ++ "c=IN IP4 0.0.0.0\r\n" ++ "a=rtcp-mux\r\n" ++ "a=sendonly\r\n" ++ "a=mid:0\r\n" ++ "a=rtpmap:96 VP8/90000\r\n" ++ "a=rtpmap:97 rtx/90000\r\n" ++ "a=fmtp:97 apt=96\r\n" ++ "a=ssrc-group:FID 1234 1234\r\n" ++ "a=ssrc:1234 cname:test\r\n"; ++ JsepSessionDescription jdesc(kDummyType); ++ EXPECT_FALSE(SdpDeserialize(sdp, &jdesc)); ++} From 047fdbf3ca1958e4e489f0e777bf4022540f5ec2 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:43:51 +0200 Subject: [PATCH 154/172] build: disable unneeded depot_tools update on Windows CI (#39017) build: disable unneeded depot_tools update Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- appveyor-woa.yml | 2 ++ appveyor.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 0116cd64dc89b..ba09915b5b979 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -83,6 +83,8 @@ for: Remove-Item -Recurse -Force $pwd\build-tools } - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File + - depot_tools\bootstrap\win_tools.bat - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { diff --git a/appveyor.yml b/appveyor.yml index 5f7f59cd32b28..7a0abe46c17b5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -81,6 +81,8 @@ for: Remove-Item -Recurse -Force $pwd\build-tools } - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File + - depot_tools\bootstrap\win_tools.bat - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { From bbe9d8b8c9340f6842c74827a48522cb0f136ebe Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 11:57:03 +0200 Subject: [PATCH 155/172] ci: fail appveyor build if artifacts are missing (#39218) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- appveyor-woa.yml | 39 +++++++++++++++++++++++++++------------ appveyor.yml | 35 +++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/appveyor-woa.yml b/appveyor-woa.yml index ba09915b5b979..e36590d359ab6 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -194,16 +194,28 @@ for: on_finish: # Uncomment this lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - - cd C:\projects\src - - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) - - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) - - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) - - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) - - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) - - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) - - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) - - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) - - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) + - ps: | + cd C:\projects\src + $missing_artifacts = $false + $artifacts_to_upload = @('dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip') + foreach($artifact_name in $artifacts_to_upload) { + if ($artifact_name -eq 'ffmpeg.zip') { + $artifact_file = "out\ffmpeg\ffmpeg.zip" + } elseif ($artifact_name -eq 'node_headers.zip') { + $artifact_file = $artifact_name + } else { + $artifact_file = "out\Default\$artifact_name" + } + if (Test-Path $artifact_file) { + appveyor-retry appveyor PushArtifact $artifact_file + } else { + Write-warning "$artifact_name is missing and cannot be added to artifacts" + $missing_artifacts = $true + } + } + if ($missing_artifacts) { + throw "Build failed due to missing artifacts" + } - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip @@ -234,7 +246,7 @@ for: # Download build artifacts $apiUrl = 'https://ci.appveyor.com/api' $build_info = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/builds/$env:APPVEYOR_BUILD_ID" - $artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','pdb.zip','electron.lib') + $artifacts_to_download = @('dist.zip','ffmpeg.zip','node_headers.zip','electron.lib') foreach ($job in $build_info.build.jobs) { if ($job.name -eq "Build Arm on X64 Windows") { $jobId = $job.jobId @@ -246,10 +258,13 @@ for: } Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile } + # Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing + # Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip + # 7z x -y -osrc pdb.zip } } - ps: | - $out_default_zips = @('dist.zip','pdb.zip') + $out_default_zips = @('dist.zip') foreach($zip_name in $out_default_zips) { 7z x -y -osrc\out\Default $zip_name } diff --git a/appveyor.yml b/appveyor.yml index 7a0abe46c17b5..fc972607f6da4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -192,16 +192,28 @@ for: on_finish: # Uncomment this lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - - cd C:\projects\src - - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) - - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) - - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) - - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) - - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) - - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) - - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) - - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) - - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) + - ps: | + cd C:\projects\src + $missing_artifacts = $false + $artifacts_to_upload = @('dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip') + foreach($artifact_name in $artifacts_to_upload) { + if ($artifact_name -eq 'ffmpeg.zip') { + $artifact_file = "out\ffmpeg\ffmpeg.zip" + } elseif ($artifact_name -eq 'node_headers.zip') { + $artifact_file = $artifact_name + } else { + $artifact_file = "out\Default\$artifact_name" + } + if (Test-Path $artifact_file) { + appveyor-retry appveyor PushArtifact $artifact_file + } else { + Write-warning "$artifact_name is missing and cannot be added to artifacts" + $missing_artifacts = $true + } + } + if ($missing_artifacts) { + throw "Build failed due to missing artifacts" + } - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip @@ -242,6 +254,9 @@ for: } Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/$artifact_name" -OutFile $outfile } + # Uncomment the following lines to download the pdb.zip to show real stacktraces when crashes happen during testing + # Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/pdb.zip" -OutFile pdb.zip + # 7z x -y -osrc pdb.zip } } - ps: | From 878f18474e920b152d7afdbeb56ac1d31f7ba37a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 27 Jul 2023 12:57:21 -0700 Subject: [PATCH 156/172] fix: do not resolve electron entrypoints on disk (#39248) * fix: do not resolve electron entrypoints on disk Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * chore: fixup .patches file after trop --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> --- patches/node/.patches | 1 + ..._do_not_resolve_electron_entrypoints.patch | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 patches/node/fix_do_not_resolve_electron_entrypoints.patch diff --git a/patches/node/.patches b/patches/node/.patches index 0495363a662e2..9b8477e0d2552 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -55,3 +55,4 @@ chore_enable_c_17_for_native_modules.patch enable_crashpad_linux_node_processes.patch cherry-pick-09ae62b.patch allow_embedder_to_control_codegenerationfromstringscallback.patch +fix_do_not_resolve_electron_entrypoints.patch diff --git a/patches/node/fix_do_not_resolve_electron_entrypoints.patch b/patches/node/fix_do_not_resolve_electron_entrypoints.patch new file mode 100644 index 0000000000000..8d700b8fab6b3 --- /dev/null +++ b/patches/node/fix_do_not_resolve_electron_entrypoints.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard <marshallofsound@electronjs.org> +Date: Wed, 26 Jul 2023 17:03:15 -0700 +Subject: fix: do not resolve electron entrypoints + +This wastes fs cycles and can result in strange behavior if this path actually exists on disk + +diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js +index 5a50d5d6afab6e6648f72a1c0efa1df4cd80bcd9..0be45309028b00a6957ee473322a9452a7fa7d67 100644 +--- a/lib/internal/modules/run_main.js ++++ b/lib/internal/modules/run_main.js +@@ -13,6 +13,12 @@ const { + } = require('internal/modules/esm/handle_process_exit'); + + function resolveMainPath(main) { ++ // For built-in modules used as the main entry point we _never_ ++ // want to waste cycles resolving them to file paths on disk ++ // that actually might exist ++ if (typeof main === 'string' && main.startsWith('electron/js2c')) { ++ return main; ++ } + // Note extension resolution for the main entry point can be deprecated in a + // future major. + // Module._findPath is monkey-patchable here. From 7a4948bd80a023360ad04ebd7b0202219fc1ea12 Mon Sep 17 00:00:00 2001 From: Keeley Hammond <vertedinde@electronjs.org> Date: Wed, 2 Aug 2023 08:51:43 -0700 Subject: [PATCH 157/172] chore: cherry-pick 4 changes from Release-0-M115 (#39269) --- patches/chromium/.patches | 3 + .../chromium/cherry-pick-933b9fad3a53.patch | 404 ++++++++++++++++++ .../chromium/cherry-pick-b03973561862.patch | 119 ++++++ .../chromium/cherry-pick-c60a1ab717c7.patch | 187 ++++++++ 4 files changed, 713 insertions(+) create mode 100644 patches/chromium/cherry-pick-933b9fad3a53.patch create mode 100644 patches/chromium/cherry-pick-b03973561862.patch create mode 100644 patches/chromium/cherry-pick-c60a1ab717c7.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index c788fd1d33cf9..8846084992e62 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -166,3 +166,6 @@ m114_merge_fix_a_crash_caused_by_calling_trace_event.patch base_do_not_use_va_args_twice_in_asprintf.patch cherry-pick-85beff6fd302.patch m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch +cherry-pick-933b9fad3a53.patch +cherry-pick-b03973561862.patch +cherry-pick-c60a1ab717c7.patch diff --git a/patches/chromium/cherry-pick-933b9fad3a53.patch b/patches/chromium/cherry-pick-933b9fad3a53.patch new file mode 100644 index 0000000000000..9561862d19343 --- /dev/null +++ b/patches/chromium/cherry-pick-933b9fad3a53.patch @@ -0,0 +1,404 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ken Rockot <rockot@google.com> +Date: Fri, 9 Jun 2023 07:49:02 +0000 +Subject: Reland "ipcz: Refactor FragmentDescriptor decode" + +This is a reland of commit 17dd18d1f2194089b8433e0ca334c81343b591e2 + +Original change's description: +> ipcz: Refactor FragmentDescriptor decode +> +> Funnels untrusted FragmentDescriptor mapping through a new +> Fragment::MappedFromDescriptor helper. See the linked bug +> for more details. +> +> Fixed: 1450899 +> Change-Id: I4c7751b9f4299da4a13c0becc1b889160a0c6e66 +> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4599218 +> Reviewed-by: Daniel Cheng <dcheng@chromium.org> +> Commit-Queue: Ken Rockot <rockot@google.com> +> Cr-Commit-Position: refs/heads/main@{#1155133} + +Change-Id: I86ee9118a30dea59d837c377a1f751b20a85a3c3 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4602794 +Reviewed-by: Daniel Cheng <dcheng@chromium.org> +Commit-Queue: Ken Rockot <rockot@google.com> +Cr-Commit-Position: refs/heads/main@{#1155397} + +diff --git a/third_party/ipcz/src/BUILD.gn b/third_party/ipcz/src/BUILD.gn +index 8b98d75aaa8f6d4df22c872cb9261381647256eb..7dabb9e9d4f3b0c00ce0acbcb2b7ff0e6085fc58 100644 +--- a/third_party/ipcz/src/BUILD.gn ++++ b/third_party/ipcz/src/BUILD.gn +@@ -210,6 +210,7 @@ ipcz_source_set("impl") { + "ipcz/api_object.h", + "ipcz/block_allocator.h", + "ipcz/box.h", ++ "ipcz/buffer_id.h", + "ipcz/buffer_pool.h", + "ipcz/driver_memory.h", + "ipcz/driver_memory_mapping.h", +@@ -253,7 +254,6 @@ ipcz_source_set("impl") { + "ipcz/block_allocator_pool.cc", + "ipcz/block_allocator_pool.h", + "ipcz/box.cc", +- "ipcz/buffer_id.h", + "ipcz/buffer_pool.cc", + "ipcz/driver_memory.cc", + "ipcz/driver_memory_mapping.cc", +@@ -376,6 +376,7 @@ ipcz_source_set("ipcz_tests_sources") { + "ipcz/driver_memory_test.cc", + "ipcz/driver_object_test.cc", + "ipcz/driver_transport_test.cc", ++ "ipcz/fragment_test.cc", + "ipcz/message_test.cc", + "ipcz/node_connector_test.cc", + "ipcz/node_link_memory_test.cc", +diff --git a/third_party/ipcz/src/ipcz/block_allocator_pool.cc b/third_party/ipcz/src/ipcz/block_allocator_pool.cc +index bd464f897d1fcbde03941ee334d0e1706bf59868..1b9d50b2c77c046d815a94d7760328c8b379ecab 100644 +--- a/third_party/ipcz/src/ipcz/block_allocator_pool.cc ++++ b/third_party/ipcz/src/ipcz/block_allocator_pool.cc +@@ -86,7 +86,7 @@ Fragment BlockAllocatorPool::Allocate() { + FragmentDescriptor descriptor( + entry->buffer_id, checked_cast<uint32_t>(offset), + checked_cast<uint32_t>(allocator.block_size())); +- return Fragment(descriptor, block); ++ return Fragment::FromDescriptorUnsafe(descriptor, block); + } + + // Allocation from the active allocator failed. Try another if available. +diff --git a/third_party/ipcz/src/ipcz/buffer_pool.cc b/third_party/ipcz/src/ipcz/buffer_pool.cc +index 6881346d8f8532f070e5121da16f064ae4a9bdaf..27b23049848967f29f81b10ba4f8fa4ead14d2e2 100644 +--- a/third_party/ipcz/src/ipcz/buffer_pool.cc ++++ b/third_party/ipcz/src/ipcz/buffer_pool.cc +@@ -26,15 +26,11 @@ Fragment BufferPool::GetFragment(const FragmentDescriptor& descriptor) { + absl::MutexLock lock(&mutex_); + auto it = mappings_.find(descriptor.buffer_id()); + if (it == mappings_.end()) { +- return Fragment(descriptor, nullptr); ++ return Fragment::PendingFromDescriptor(descriptor); + } + + auto& [id, mapping] = *it; +- if (descriptor.end() > mapping.bytes().size()) { +- return {}; +- } +- +- return Fragment(descriptor, mapping.address_at(descriptor.offset())); ++ return Fragment::MappedFromDescriptor(descriptor, mapping); + } + + bool BufferPool::AddBlockBuffer( +diff --git a/third_party/ipcz/src/ipcz/buffer_pool_test.cc b/third_party/ipcz/src/ipcz/buffer_pool_test.cc +index a009ffe1c20ade013a19b51eceee4faf334eb591..bff66c452a3e2c38b0f208cca1fa1a082f1ee871 100644 +--- a/third_party/ipcz/src/ipcz/buffer_pool_test.cc ++++ b/third_party/ipcz/src/ipcz/buffer_pool_test.cc +@@ -194,9 +194,11 @@ TEST_F(BufferPoolTest, BasicBlockAllocation) { + pool.GetTotalBlockCapacity(kBlockSize)); + + // We can't free something that isn't a valid allocation. +- EXPECT_FALSE(pool.FreeBlock(Fragment{{}, nullptr})); +- EXPECT_FALSE(pool.FreeBlock(Fragment{{BufferId{1000}, 0, 1}, nullptr})); +- EXPECT_FALSE(pool.FreeBlock(Fragment{{BufferId{0}, 0, 1}, bytes0.data()})); ++ EXPECT_FALSE(pool.FreeBlock(Fragment::FromDescriptorUnsafe({}, nullptr))); ++ EXPECT_FALSE(pool.FreeBlock( ++ Fragment::FromDescriptorUnsafe({BufferId{1000}, 0, 1}, nullptr))); ++ EXPECT_FALSE(pool.FreeBlock( ++ Fragment::FromDescriptorUnsafe({BufferId{0}, 0, 1}, bytes0.data()))); + + // Allocate all available capacity. + std::vector<Fragment> fragments; +diff --git a/third_party/ipcz/src/ipcz/fragment.cc b/third_party/ipcz/src/ipcz/fragment.cc +index 651d1c2fca5fe4fb69cdf61c6062bd8804ebf704..2ef4ed8dcfa0a56a73975a0b7dcc3f86bf5a83a0 100644 +--- a/third_party/ipcz/src/ipcz/fragment.cc ++++ b/third_party/ipcz/src/ipcz/fragment.cc +@@ -6,10 +6,38 @@ + + #include <cstdint> + ++#include "ipcz/driver_memory_mapping.h" ++#include "ipcz/fragment_descriptor.h" + #include "third_party/abseil-cpp/absl/base/macros.h" ++#include "util/safe_math.h" + + namespace ipcz { + ++// static ++Fragment Fragment::MappedFromDescriptor(const FragmentDescriptor& descriptor, ++ DriverMemoryMapping& mapping) { ++ if (descriptor.is_null()) { ++ return {}; ++ } ++ ++ const uint32_t end = SaturatedAdd(descriptor.offset(), descriptor.size()); ++ if (end > mapping.bytes().size()) { ++ return {}; ++ } ++ return Fragment{descriptor, mapping.address_at(descriptor.offset())}; ++} ++ ++// static ++Fragment Fragment::PendingFromDescriptor(const FragmentDescriptor& descriptor) { ++ return Fragment{descriptor, nullptr}; ++} ++ ++// static ++Fragment Fragment::FromDescriptorUnsafe(const FragmentDescriptor& descriptor, ++ void* base_address) { ++ return Fragment{descriptor, base_address}; ++} ++ + Fragment::Fragment(const FragmentDescriptor& descriptor, void* address) + : descriptor_(descriptor), address_(address) { + // If `address` is non-null, the descriptor must also be. Note that the +diff --git a/third_party/ipcz/src/ipcz/fragment.h b/third_party/ipcz/src/ipcz/fragment.h +index c0151fdcf4b418680172a29d1c0d28b58a5807cd..de65f087b0bc27fd59ab88e23130d5ce0d345a8a 100644 +--- a/third_party/ipcz/src/ipcz/fragment.h ++++ b/third_party/ipcz/src/ipcz/fragment.h +@@ -14,21 +14,32 @@ + + namespace ipcz { + ++class DriverMemoryMapping; ++ + // Represents a span of memory located within the shared memory regions owned by + // a NodeLinkMemory, via BufferPool. This is essentially a FragmentDescriptor + // plus the actual mapped address of the given buffer and offset. + struct Fragment { + constexpr Fragment() = default; + +- // Constructs a new Fragment over `descriptor`, mapped to `address`. If +- // `address` is null, the Fragment is considered "pending" -- it has a +- // potentially valid descriptor, but could not be resolved to a mapped address +- // yet (e.g. because the relevant BufferPool doesn't have the identified +- // buffer mapped yet.) +- Fragment(const FragmentDescriptor& descriptor, void* address); + Fragment(const Fragment&); + Fragment& operator=(const Fragment&); + ++ // Returns a new concrete Fragment corresponding to `descriptor` within the ++ // context of `mapping`. This validates that the fragment's bounds fall within ++ // the bounds of `mapping`. If `descriptor` was null or validation fails, this ++ // returns a null Fragment. ++ static Fragment MappedFromDescriptor(const FragmentDescriptor& descriptor, ++ DriverMemoryMapping& mapping); ++ ++ // Returns a pending Fragment corresponding to `descriptor`. ++ static Fragment PendingFromDescriptor(const FragmentDescriptor& descriptor); ++ ++ // Returns a Fragment corresponding to `descriptor`, with the starting address ++ // already mapped to `address`. ++ static Fragment FromDescriptorUnsafe(const FragmentDescriptor& descriptor, ++ void* address); ++ + // A null fragment is a fragment with a null descriptor, meaning it does not + // reference a valid buffer ID. + bool is_null() const { return descriptor_.is_null(); } +@@ -66,6 +77,13 @@ struct Fragment { + } + + private: ++ // Constructs a new Fragment over `descriptor`, mapped to `address`. If ++ // `address` is null, the Fragment is considered "pending" -- it has a ++ // potentially valid descriptor, but could not be resolved to a mapped address ++ // yet (e.g. because the relevant BufferPool doesn't have the identified ++ // buffer mapped yet.) ++ Fragment(const FragmentDescriptor& descriptor, void* address); ++ + FragmentDescriptor descriptor_; + + // The actual mapped address corresponding to `descriptor_`. +diff --git a/third_party/ipcz/src/ipcz/fragment_descriptor.h b/third_party/ipcz/src/ipcz/fragment_descriptor.h +index b247215fd5e5f7c69e521416614465b0321f5d83..aeaa7da9c82761854948d009e7f245c9c9d042c7 100644 +--- a/third_party/ipcz/src/ipcz/fragment_descriptor.h ++++ b/third_party/ipcz/src/ipcz/fragment_descriptor.h +@@ -39,7 +39,6 @@ struct IPCZ_ALIGN(8) FragmentDescriptor { + BufferId buffer_id() const { return buffer_id_; } + uint32_t offset() const { return offset_; } + uint32_t size() const { return size_; } +- uint32_t end() const { return offset_ + size_; } + + private: + // Identifies the shared memory buffer in which the memory resides. This ID is +diff --git a/third_party/ipcz/src/ipcz/fragment_test.cc b/third_party/ipcz/src/ipcz/fragment_test.cc +new file mode 100644 +index 0000000000000000000000000000000000000000..e6b6baa6cb2f1fbdfb89d87d644f63681c797c01 +--- /dev/null ++++ b/third_party/ipcz/src/ipcz/fragment_test.cc +@@ -0,0 +1,102 @@ ++// Copyright 2023 The Chromium Authors ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++#include "ipcz/fragment.h" ++ ++#include <algorithm> ++#include <cstring> ++#include <limits> ++#include <string> ++#include <utility> ++ ++#include "ipcz/buffer_id.h" ++#include "ipcz/driver_memory.h" ++#include "ipcz/driver_memory_mapping.h" ++#include "reference_drivers/sync_reference_driver.h" ++#include "testing/gtest/include/gtest/gtest.h" ++ ++namespace ipcz { ++namespace { ++ ++const IpczDriver& kTestDriver = reference_drivers::kSyncReferenceDriver; ++ ++using FragmentTest = testing::Test; ++ ++TEST_F(FragmentTest, FromDescriptorUnsafe) { ++ char kBuffer[] = "Hello, world!"; ++ ++ Fragment f = Fragment::FromDescriptorUnsafe({BufferId{0}, 1, 4}, kBuffer + 1); ++ EXPECT_FALSE(f.is_null()); ++ EXPECT_FALSE(f.is_pending()); ++ EXPECT_EQ(1u, f.offset()); ++ EXPECT_EQ(4u, f.size()); ++ EXPECT_EQ("ello", std::string(f.bytes().begin(), f.bytes().end())); ++ ++ f = Fragment::FromDescriptorUnsafe({BufferId{0}, 7, 6}, kBuffer + 7); ++ EXPECT_FALSE(f.is_null()); ++ EXPECT_FALSE(f.is_pending()); ++ EXPECT_EQ(7u, f.offset()); ++ EXPECT_EQ(6u, f.size()); ++ EXPECT_EQ("world!", std::string(f.bytes().begin(), f.bytes().end())); ++} ++ ++TEST_F(FragmentTest, PendingFromDescriptor) { ++ Fragment f = Fragment::PendingFromDescriptor({BufferId{0}, 5, 42}); ++ EXPECT_TRUE(f.is_pending()); ++ EXPECT_FALSE(f.is_null()); ++ EXPECT_EQ(5u, f.offset()); ++ EXPECT_EQ(42u, f.size()); ++ ++ f = Fragment::PendingFromDescriptor({kInvalidBufferId, 0, 0}); ++ EXPECT_TRUE(f.is_null()); ++ EXPECT_FALSE(f.is_pending()); ++} ++ ++TEST_F(FragmentTest, NullMappedFromDescriptor) { ++ constexpr size_t kDataSize = 32; ++ DriverMemory memory(kTestDriver, kDataSize); ++ auto mapping = memory.Map(); ++ ++ Fragment f = ++ Fragment::MappedFromDescriptor({kInvalidBufferId, 0, 0}, mapping); ++ EXPECT_TRUE(f.is_null()); ++} ++ ++TEST_F(FragmentTest, InvalidMappedFromDescriptor) { ++ constexpr size_t kDataSize = 32; ++ DriverMemory memory(kTestDriver, kDataSize); ++ auto mapping = memory.Map(); ++ ++ Fragment f; ++ ++ // Offset out of bounds ++ f = Fragment::MappedFromDescriptor({BufferId{0}, kDataSize, 1}, mapping); ++ EXPECT_TRUE(f.is_null()); ++ ++ // Tail out of bounds ++ f = Fragment::MappedFromDescriptor({BufferId{0}, 0, kDataSize + 5}, mapping); ++ EXPECT_TRUE(f.is_null()); ++ ++ // Tail overflow ++ f = Fragment::MappedFromDescriptor( ++ {BufferId{0}, std::numeric_limits<uint32_t>::max(), 2}, mapping); ++ EXPECT_TRUE(f.is_null()); ++} ++ ++TEST_F(FragmentTest, ValidMappedFromDescriptor) { ++ const char kData[] = "0123456789abcdef"; ++ DriverMemory memory(kTestDriver, std::size(kData)); ++ auto mapping = memory.Map(); ++ memcpy(mapping.bytes().data(), kData, std::size(kData)); ++ ++ Fragment f = Fragment::MappedFromDescriptor({BufferId{0}, 2, 11}, mapping); ++ EXPECT_FALSE(f.is_null()); ++ EXPECT_FALSE(f.is_pending()); ++ EXPECT_EQ(2u, f.offset()); ++ EXPECT_EQ(11u, f.size()); ++ EXPECT_EQ("23456789abc", std::string(f.bytes().begin(), f.bytes().end())); ++} ++ ++} // namespace ++} // namespace ipcz +diff --git a/third_party/ipcz/src/ipcz/node_link_memory.cc b/third_party/ipcz/src/ipcz/node_link_memory.cc +index 0cfadfa02aa4b7058e04c3b0255412a0d11aed87..9f920faf31748a6c4213045e31331af2a865bb4f 100644 +--- a/third_party/ipcz/src/ipcz/node_link_memory.cc ++++ b/third_party/ipcz/src/ipcz/node_link_memory.cc +@@ -278,8 +278,9 @@ FragmentRef<RouterLinkState> NodeLinkMemory::GetInitialRouterLinkState( + FragmentDescriptor descriptor(kPrimaryBufferId, + ToOffset(state, primary_buffer_memory_.data()), + sizeof(RouterLinkState)); +- return FragmentRef<RouterLinkState>(RefCountedFragment::kUnmanagedRef, +- Fragment(descriptor, state)); ++ return FragmentRef<RouterLinkState>( ++ RefCountedFragment::kUnmanagedRef, ++ Fragment::FromDescriptorUnsafe(descriptor, state)); + } + + Fragment NodeLinkMemory::GetFragment(const FragmentDescriptor& descriptor) { +diff --git a/third_party/ipcz/src/ipcz/ref_counted_fragment_test.cc b/third_party/ipcz/src/ipcz/ref_counted_fragment_test.cc +index d5a2243a693597e43f87f116f80599fde383cb59..220c3556a261c5caab7194114af4cf375d9af683 100644 +--- a/third_party/ipcz/src/ipcz/ref_counted_fragment_test.cc ++++ b/third_party/ipcz/src/ipcz/ref_counted_fragment_test.cc +@@ -64,7 +64,8 @@ TEST_F(RefCountedFragmentTest, SimpleRef) { + + FragmentRef<TestObject> ref( + RefCountedFragment::kUnmanagedRef, +- Fragment(FragmentDescriptor(BufferId(0), 0, sizeof(object)), &object)); ++ Fragment::FromDescriptorUnsafe( ++ FragmentDescriptor(BufferId(0), 0, sizeof(object)), &object)); + EXPECT_EQ(1, object.ref_count_for_testing()); + ref.reset(); + EXPECT_EQ(0, object.ref_count_for_testing()); +@@ -75,7 +76,8 @@ TEST_F(RefCountedFragmentTest, Copy) { + + FragmentRef<TestObject> ref1( + RefCountedFragment::kUnmanagedRef, +- Fragment(FragmentDescriptor(BufferId(0), 0, sizeof(object1)), &object1)); ++ Fragment::FromDescriptorUnsafe( ++ FragmentDescriptor(BufferId(0), 0, sizeof(object1)), &object1)); + EXPECT_EQ(1, object1.ref_count_for_testing()); + + FragmentRef<TestObject> other1 = ref1; +@@ -88,7 +90,8 @@ TEST_F(RefCountedFragmentTest, Copy) { + TestObject object2; + auto ref2 = FragmentRef<TestObject>( + RefCountedFragment::kUnmanagedRef, +- Fragment(FragmentDescriptor(BufferId(0), 0, sizeof(object2)), &object2)); ++ Fragment::FromDescriptorUnsafe( ++ FragmentDescriptor(BufferId(0), 0, sizeof(object2)), &object2)); + EXPECT_EQ(1, object1.ref_count_for_testing()); + EXPECT_EQ(1, object2.ref_count_for_testing()); + ref2 = ref1; +@@ -115,7 +118,8 @@ TEST_F(RefCountedFragmentTest, Move) { + + FragmentRef<TestObject> ref1( + RefCountedFragment::kUnmanagedRef, +- Fragment(FragmentDescriptor(BufferId(0), 0, sizeof(object1)), &object1)); ++ Fragment::FromDescriptorUnsafe( ++ FragmentDescriptor(BufferId(0), 0, sizeof(object1)), &object1)); + EXPECT_EQ(1, ref1.ref_count_for_testing()); + + FragmentRef<TestObject> other1 = std::move(ref1); +@@ -133,10 +137,12 @@ TEST_F(RefCountedFragmentTest, Move) { + TestObject object3; + FragmentRef<TestObject> ref2( + RefCountedFragment::kUnmanagedRef, +- Fragment(FragmentDescriptor(BufferId(0), 0, sizeof(object2)), &object2)); ++ Fragment::FromDescriptorUnsafe( ++ FragmentDescriptor(BufferId(0), 0, sizeof(object2)), &object2)); + FragmentRef<TestObject> ref3( + RefCountedFragment::kUnmanagedRef, +- Fragment(FragmentDescriptor(BufferId(0), 0, sizeof(object3)), &object3)); ++ Fragment::FromDescriptorUnsafe( ++ FragmentDescriptor(BufferId(0), 0, sizeof(object3)), &object3)); + + EXPECT_FALSE(ref2.is_null()); + EXPECT_TRUE(ref2.is_addressable()); diff --git a/patches/chromium/cherry-pick-b03973561862.patch b/patches/chromium/cherry-pick-b03973561862.patch new file mode 100644 index 0000000000000..87b92b8ea574d --- /dev/null +++ b/patches/chromium/cherry-pick-b03973561862.patch @@ -0,0 +1,119 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tommi <tommi@chromium.org> +Date: Wed, 5 Jul 2023 10:55:53 +0000 +Subject: Make RTCDataChannel's channel and observer pointers const. + +This allows channel properties to be queried while the RTCDataChannel +instance exists and avoids potential null deref after entering the +kClosed state. + +(cherry picked from commit 08d5ad011f53a1995bfccef6728bfa62541f7608) + +Bug: 1456567, 1457421 +Change-Id: I4747f9c00804b35711667d7320ec6188f20910c4 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4663082 +Commit-Queue: Tomas Gunnarsson <tommi@chromium.org> +Reviewed-by: Elad Alon <eladalon@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1165406} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4665530 +Cr-Commit-Position: refs/branch-heads/5845@{#300} +Cr-Branched-From: 5a5dff63a4a4c63b9b18589819bebb2566c85443-refs/heads/main@{#1160321} + +diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc b/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc +index 78d28d60822f4ce206d869846235352224378076..91c20cbcc5042373964d57545177ff06074db564 100644 +--- a/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc ++++ b/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc +@@ -228,11 +228,12 @@ RTCDataChannel::Observer::Observer( + scoped_refptr<webrtc::DataChannelInterface> channel) + : main_thread_(main_thread), + blink_channel_(blink_channel), +- webrtc_channel_(channel) {} ++ webrtc_channel_(std::move(channel)) { ++ CHECK(webrtc_channel_.get()); ++} + + RTCDataChannel::Observer::~Observer() { + DCHECK(!blink_channel_) << "Reference to blink channel hasn't been released."; +- DCHECK(!webrtc_channel_.get()) << "Unregister hasn't been called."; + } + + const scoped_refptr<webrtc::DataChannelInterface>& +@@ -242,13 +243,8 @@ RTCDataChannel::Observer::channel() const { + + void RTCDataChannel::Observer::Unregister() { + DCHECK(main_thread_->BelongsToCurrentThread()); ++ webrtc_channel_->UnregisterObserver(); + blink_channel_ = nullptr; +- if (webrtc_channel_.get()) { +- webrtc_channel_->UnregisterObserver(); +- // Now that we're guaranteed to not get further OnStateChange callbacks, +- // it's safe to release our reference to the channel. +- webrtc_channel_ = nullptr; +- } + } + + void RTCDataChannel::Observer::OnStateChange() { +@@ -302,7 +298,7 @@ void RTCDataChannel::Observer::OnMessageImpl( + + RTCDataChannel::RTCDataChannel( + ExecutionContext* context, +- scoped_refptr<webrtc::DataChannelInterface> channel, ++ scoped_refptr<webrtc::DataChannelInterface> data_channel, + RTCPeerConnectionHandler* peer_connection_handler) + : ExecutionContextLifecycleObserver(context), + state_(webrtc::DataChannelInterface::kConnecting), +@@ -317,7 +313,7 @@ RTCDataChannel::RTCDataChannel( + observer_(base::MakeRefCounted<Observer>( + context->GetTaskRunner(TaskType::kNetworking), + this, +- channel)), ++ std::move(data_channel))), + signaling_thread_(peer_connection_handler->signaling_thread()) { + DCHECK(peer_connection_handler); + +@@ -340,7 +336,7 @@ RTCDataChannel::RTCDataChannel( + observer_, state_), + "RegisterObserverAndGetStateUpdate"); + +- IncrementCounters(*channel.get()); ++ IncrementCounters(*(observer_->channel()).get()); + } + + RTCDataChannel::~RTCDataChannel() = default; +@@ -689,9 +685,8 @@ void RTCDataChannel::Dispose() { + if (stopped_) + return; + +- // Clears the weak persistent reference to this on-heap object. ++ // Clear the weak persistent reference to this on-heap object. + observer_->Unregister(); +- observer_ = nullptr; + } + + void RTCDataChannel::ScheduleDispatchEvent(Event* event) { +diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.h b/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.h +index 21bb39382ac0c6acbf984ffbda5f6a4e6c863432..6959b8b1e3a0b586be68cb4a8d0389b7926b98fe 100644 +--- a/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.h ++++ b/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.h +@@ -152,7 +152,7 @@ class MODULES_EXPORT RTCDataChannel final + + const scoped_refptr<base::SingleThreadTaskRunner> main_thread_; + WeakPersistent<RTCDataChannel> blink_channel_; +- scoped_refptr<webrtc::DataChannelInterface> webrtc_channel_; ++ const scoped_refptr<webrtc::DataChannelInterface> webrtc_channel_; + }; + + void OnStateChange(webrtc::DataChannelInterface::DataState state); +@@ -195,7 +195,11 @@ class MODULES_EXPORT RTCDataChannel final + unsigned buffered_amount_; + bool stopped_; + bool closed_from_owner_; +- scoped_refptr<Observer> observer_; ++ // Keep the `observer_` reference const to make it clear that we don't want ++ // to free the underlying channel (or callback observer) until the ++ // `RTCDataChannel` instance goes away. This allows properties to be queried ++ // after the state reaches `kClosed`. ++ const scoped_refptr<Observer> observer_; + scoped_refptr<base::SingleThreadTaskRunner> signaling_thread_; + THREAD_CHECKER(thread_checker_); + }; diff --git a/patches/chromium/cherry-pick-c60a1ab717c7.patch b/patches/chromium/cherry-pick-c60a1ab717c7.patch new file mode 100644 index 0000000000000..7d9ca84b3356c --- /dev/null +++ b/patches/chromium/cherry-pick-c60a1ab717c7.patch @@ -0,0 +1,187 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taylor Bergquist <tbergquist@chromium.org> +Date: Tue, 11 Jul 2023 01:32:22 +0000 +Subject: Fix UAF when exiting a nested run loop in + TabDragContextImpl::OnGestureEvent. + +OnGestureEvent may call ContinueDrag, which may run a nested run loop. After the nested run loop returns, multiple seconds of time may have passed, and the world may be in a very different state; in particular, the window that contains this TabDragContext may have closed. + +This CL checks if this has happened, and returns early in that case. + +(cherry picked from commit 63d6b8ba8126b16215d33670df8c67dcbc6c9bef) + +Bug: 1453465 +Change-Id: I6095c0afeb5aa5f422717f1bbd93b96175e52afa +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4657527 +Reviewed-by: Darryl James <dljames@chromium.org> +Commit-Queue: Taylor Bergquist <tbergquist@chromium.org> +Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com> +Cr-Original-Commit-Position: refs/heads/main@{#1164449} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4676126 +Reviewed-by: Shibalik Mohapatra <shibalik@chromium.org> +Cr-Commit-Position: refs/branch-heads/5845@{#410} +Cr-Branched-From: 5a5dff63a4a4c63b9b18589819bebb2566c85443-refs/heads/main@{#1160321} + +diff --git a/chrome/browser/ui/views/tabs/fake_tab_slot_controller.cc b/chrome/browser/ui/views/tabs/fake_tab_slot_controller.cc +index 94d27ec3ab22f7afb5e265fdcee662e48f36c00e..81348ceb4a415f789dd384988a54662ec3c3d0e0 100644 +--- a/chrome/browser/ui/views/tabs/fake_tab_slot_controller.cc ++++ b/chrome/browser/ui/views/tabs/fake_tab_slot_controller.cc +@@ -45,6 +45,12 @@ bool FakeTabSlotController::IsFocusInTabs() const { + return false; + } + ++TabSlotController::Liveness FakeTabSlotController::ContinueDrag( ++ views::View* view, ++ const ui::LocatedEvent& event) { ++ return Liveness::kAlive; ++} ++ + bool FakeTabSlotController::EndDrag(EndDragReason reason) { + return false; + } +diff --git a/chrome/browser/ui/views/tabs/fake_tab_slot_controller.h b/chrome/browser/ui/views/tabs/fake_tab_slot_controller.h +index ebbae9b19a8f9534e3a86d2bf28875418a7be80d..4795c222651af3a7146a8bf12e824a1480cdbfae 100644 +--- a/chrome/browser/ui/views/tabs/fake_tab_slot_controller.h ++++ b/chrome/browser/ui/views/tabs/fake_tab_slot_controller.h +@@ -60,8 +60,8 @@ class FakeTabSlotController : public TabSlotController { + TabSlotView* source, + const ui::LocatedEvent& event, + const ui::ListSelectionModel& original_selection) override {} +- void ContinueDrag(views::View* view, const ui::LocatedEvent& event) override { +- } ++ Liveness ContinueDrag(views::View* view, ++ const ui::LocatedEvent& event) override; + bool EndDrag(EndDragReason reason) override; + Tab* GetTabAt(const gfx::Point& point) override; + const Tab* GetAdjacentTab(const Tab* tab, int offset) override; +diff --git a/chrome/browser/ui/views/tabs/tab_slot_controller.h b/chrome/browser/ui/views/tabs/tab_slot_controller.h +index 6a43f963a22917b9e9b861d3619d9804851dfb5b..d412ad6d5d9a95aa5d635fae5232eddfa87132ae 100644 +--- a/chrome/browser/ui/views/tabs/tab_slot_controller.h ++++ b/chrome/browser/ui/views/tabs/tab_slot_controller.h +@@ -49,6 +49,8 @@ class TabSlotController { + kEvent + }; + ++ enum class Liveness { kAlive, kDeleted }; ++ + virtual const ui::ListSelectionModel& GetSelectionModel() const = 0; + + // Returns the tab at |index|. +@@ -126,9 +128,10 @@ class TabSlotController { + const ui::LocatedEvent& event, + const ui::ListSelectionModel& original_selection) = 0; + +- // Continues dragging a Tab. +- virtual void ContinueDrag(views::View* view, +- const ui::LocatedEvent& event) = 0; ++ // Continues dragging a Tab. May enter a nested event loop - returns ++ // Liveness::kDeleted if `this` was destroyed during this nested event loop, ++ // and Liveness::kAlive if `this` is still alive. ++ virtual Liveness ContinueDrag(views::View* view, const ui::LocatedEvent& event) = 0; + + // Ends dragging a Tab. Returns whether the tab has been destroyed. + virtual bool EndDrag(EndDragReason reason) = 0; +diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc +index f2f18c7f21bc249b95dece091716fcb6872b0c12..22a4b6b761058f44cbea029bbc52dd4071e111e9 100644 +--- a/chrome/browser/ui/views/tabs/tab_strip.cc ++++ b/chrome/browser/ui/views/tabs/tab_strip.cc +@@ -174,7 +174,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext, + } + + bool OnMouseDragged(const ui::MouseEvent& event) override { +- ContinueDrag(this, event); ++ (void)ContinueDrag(this, event); + return true; + } + +@@ -185,6 +185,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext, + void OnMouseCaptureLost() override { EndDrag(END_DRAG_CAPTURE_LOST); } + + void OnGestureEvent(ui::GestureEvent* event) override { ++ Liveness tabstrip_alive = Liveness::kAlive; + switch (event->type()) { + case ui::ET_GESTURE_SCROLL_END: + case ui::ET_SCROLL_FLING_START: +@@ -198,7 +199,8 @@ class TabStrip::TabDragContextImpl : public TabDragContext, + } + + case ui::ET_GESTURE_SCROLL_UPDATE: +- ContinueDrag(this, *event); ++ // N.B. !! ContinueDrag may enter a nested run loop !! ++ tabstrip_alive = ContinueDrag(this, *event); + break; + + case ui::ET_GESTURE_TAP_DOWN: +@@ -210,6 +212,12 @@ class TabStrip::TabDragContextImpl : public TabDragContext, + } + event->SetHandled(); + ++ // If tabstrip was destroyed (during ContinueDrag above), return early to ++ // avoid UAF below. ++ if (tabstrip_alive == Liveness::kDeleted) { ++ return; ++ } ++ + // TabDragContext gets event capture as soon as a drag session begins, which + // precludes TabStrip from ever getting events like tap or long tap. Forward + // this on to TabStrip so it can respond to those events. +@@ -295,20 +303,20 @@ class TabStrip::TabDragContextImpl : public TabDragContext, + std::move(drag_controller_set_callback_).Run(drag_controller_.get()); + } + +- void ContinueDrag(views::View* view, const ui::LocatedEvent& event) { +- if (drag_controller_.get() && +- drag_controller_->event_source() == EventSourceFromEvent(event)) { +- gfx::Point screen_location(event.location()); +- views::View::ConvertPointToScreen(view, &screen_location); ++ Liveness ContinueDrag(views::View* view, const ui::LocatedEvent& event) { ++ if (!drag_controller_.get() || ++ drag_controller_->event_source() != EventSourceFromEvent(event)) { ++ return Liveness::kAlive; ++ } + +- // Note: |tab_strip_| can be destroyed during drag, also destroying +- // |this|. +- base::WeakPtr<TabDragContext> weak_ptr(weak_factory_.GetWeakPtr()); +- drag_controller_->Drag(screen_location); ++ gfx::Point screen_location(event.location()); ++ views::View::ConvertPointToScreen(view, &screen_location); + +- if (!weak_ptr) +- return; +- } ++ // Note: `tab_strip_` can be destroyed during drag, also destroying `this`. ++ base::WeakPtr<TabDragContext> weak_ptr(weak_factory_.GetWeakPtr()); ++ drag_controller_->Drag(screen_location); ++ ++ return weak_ptr ? Liveness::kAlive : Liveness::kDeleted; + } + + bool EndDrag(EndDragReason reason) { +@@ -1573,8 +1581,10 @@ void TabStrip::MaybeStartDrag( + drag_context_->MaybeStartDrag(source, event, original_selection); + } + +-void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) { +- drag_context_->ContinueDrag(view, event); ++TabSlotController::Liveness TabStrip::ContinueDrag( ++ views::View* view, ++ const ui::LocatedEvent& event) { ++ return drag_context_->ContinueDrag(view, event); + } + + bool TabStrip::EndDrag(EndDragReason reason) { +diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h +index fce93e7d993434ce1e99c7cbca71c1391798c1a4..de6f20bb978c32d635b4f8b75841c148996df2c6 100644 +--- a/chrome/browser/ui/views/tabs/tab_strip.h ++++ b/chrome/browser/ui/views/tabs/tab_strip.h +@@ -278,7 +278,8 @@ class TabStrip : public views::View, + TabSlotView* source, + const ui::LocatedEvent& event, + const ui::ListSelectionModel& original_selection) override; +- void ContinueDrag(views::View* view, const ui::LocatedEvent& event) override; ++ Liveness ContinueDrag(views::View* view, ++ const ui::LocatedEvent& event) override; + bool EndDrag(EndDragReason reason) override; + Tab* GetTabAt(const gfx::Point& point) override; + const Tab* GetAdjacentTab(const Tab* tab, int offset) override; From b026a66172a794e9b2eaf0d370c2d66879c29edf Mon Sep 17 00:00:00 2001 From: John Kleinschmidt <jkleinsc@electronjs.org> Date: Mon, 7 Aug 2023 16:56:16 -0400 Subject: [PATCH 158/172] ci: fix hang when validating AppVeyor artifacts (#39398) ci: fix hang when validating AppVeyor artifacts (#39362) (cherry picked from commit 1eb6e45a365fd7b73b23302662f29e465a698719) (cherry picked from commit dc7b42edbbc175e587fe14cc10179e40aef71817) --- appveyor-woa.yml | 56 +++++++++++++++++++++++++++++------------------- appveyor.yml | 56 +++++++++++++++++++++++++++++------------------- 2 files changed, 68 insertions(+), 44 deletions(-) diff --git a/appveyor-woa.yml b/appveyor-woa.yml index e36590d359ab6..57e0cd3cbbded 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -178,6 +178,30 @@ for: 7z a pdb.zip out\Default\*.pdb } - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + - ps: | + cd C:\projects\src + $missing_artifacts = $false + if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') { + Write-warning "Skipping artifact validation for doc-only PR" + } else { + $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip' + foreach($artifact_name in $artifacts_to_validate) { + if ($artifact_name -eq 'ffmpeg.zip') { + $artifact_file = "out\ffmpeg\ffmpeg.zip" + } elseif ($artifact_name -eq 'node_headers.zip') { + $artifact_file = $artifact_name + } else { + $artifact_file = "out\Default\$artifact_name" + } + if (-not(Test-Path $artifact_file)) { + Write-warning "$artifact_name is missing and cannot be added to artifacts" + $missing_artifacts = $true + } + } + } + if ($missing_artifacts) { + throw "Build failed due to missing artifacts" + } deploy_script: - cd electron @@ -194,28 +218,16 @@ for: on_finish: # Uncomment this lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - - ps: | - cd C:\projects\src - $missing_artifacts = $false - $artifacts_to_upload = @('dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip') - foreach($artifact_name in $artifacts_to_upload) { - if ($artifact_name -eq 'ffmpeg.zip') { - $artifact_file = "out\ffmpeg\ffmpeg.zip" - } elseif ($artifact_name -eq 'node_headers.zip') { - $artifact_file = $artifact_name - } else { - $artifact_file = "out\Default\$artifact_name" - } - if (Test-Path $artifact_file) { - appveyor-retry appveyor PushArtifact $artifact_file - } else { - Write-warning "$artifact_name is missing and cannot be added to artifacts" - $missing_artifacts = $true - } - } - if ($missing_artifacts) { - throw "Build failed due to missing artifacts" - } + - cd C:\projects\src + - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) + - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) + - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) + - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) + - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) + - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) + - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) + - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) + - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip diff --git a/appveyor.yml b/appveyor.yml index fc972607f6da4..0314cbb59c589 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -176,6 +176,30 @@ for: 7z a pdb.zip out\Default\*.pdb } - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + - ps: | + cd C:\projects\src + $missing_artifacts = $false + if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') { + Write-warning "Skipping artifact validation for doc-only PR" + } else { + $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip' + foreach($artifact_name in $artifacts_to_validate) { + if ($artifact_name -eq 'ffmpeg.zip') { + $artifact_file = "out\ffmpeg\ffmpeg.zip" + } elseif ($artifact_name -eq 'node_headers.zip') { + $artifact_file = $artifact_name + } else { + $artifact_file = "out\Default\$artifact_name" + } + if (-not(Test-Path $artifact_file)) { + Write-warning "$artifact_name is missing and cannot be added to artifacts" + $missing_artifacts = $true + } + } + } + if ($missing_artifacts) { + throw "Build failed due to missing artifacts" + } deploy_script: - cd electron @@ -192,28 +216,16 @@ for: on_finish: # Uncomment this lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - - ps: | - cd C:\projects\src - $missing_artifacts = $false - $artifacts_to_upload = @('dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip') - foreach($artifact_name in $artifacts_to_upload) { - if ($artifact_name -eq 'ffmpeg.zip') { - $artifact_file = "out\ffmpeg\ffmpeg.zip" - } elseif ($artifact_name -eq 'node_headers.zip') { - $artifact_file = $artifact_name - } else { - $artifact_file = "out\Default\$artifact_name" - } - if (Test-Path $artifact_file) { - appveyor-retry appveyor PushArtifact $artifact_file - } else { - Write-warning "$artifact_name is missing and cannot be added to artifacts" - $missing_artifacts = $true - } - } - if ($missing_artifacts) { - throw "Build failed due to missing artifacts" - } + - cd C:\projects\src + - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) + - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) + - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) + - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) + - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) + - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) + - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) + - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) + - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip From 2dee8783ccf39f0acb2ae1766a86b8b4103810b5 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 19:03:08 +0200 Subject: [PATCH 159/172] fix: avoid package.json check on built-in modules (#39425) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> --- ..._do_not_resolve_electron_entrypoints.patch | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/patches/node/fix_do_not_resolve_electron_entrypoints.patch b/patches/node/fix_do_not_resolve_electron_entrypoints.patch index 8d700b8fab6b3..b87b4d4a1b26d 100644 --- a/patches/node/fix_do_not_resolve_electron_entrypoints.patch +++ b/patches/node/fix_do_not_resolve_electron_entrypoints.patch @@ -6,19 +6,42 @@ Subject: fix: do not resolve electron entrypoints This wastes fs cycles and can result in strange behavior if this path actually exists on disk diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js -index 5a50d5d6afab6e6648f72a1c0efa1df4cd80bcd9..0be45309028b00a6957ee473322a9452a7fa7d67 100644 +index 5a50d5d6afab6e6648f72a1c0efa1df4cd80bcd9..ebc9999358ccf16689dc02322eb1aeb86355f39b 100644 --- a/lib/internal/modules/run_main.js +++ b/lib/internal/modules/run_main.js -@@ -13,6 +13,12 @@ const { +@@ -3,6 +3,7 @@ + const { + ObjectCreate, + StringPrototypeEndsWith, ++ StringPrototypeStartsWith, + } = primordials; + const CJSLoader = require('internal/modules/cjs/loader'); + const { Module, toRealPath, readPackageScope } = CJSLoader; +@@ -13,6 +14,13 @@ const { } = require('internal/modules/esm/handle_process_exit'); function resolveMainPath(main) { + // For built-in modules used as the main entry point we _never_ + // want to waste cycles resolving them to file paths on disk + // that actually might exist -+ if (typeof main === 'string' && main.startsWith('electron/js2c')) { ++ if (typeof main === 'string' && StringPrototypeStartsWith(main, 'electron/js2c')) { + return main; + } ++ // Note extension resolution for the main entry point can be deprecated in a // future major. // Module._findPath is monkey-patchable here. +@@ -28,6 +36,13 @@ function resolveMainPath(main) { + } + + function shouldUseESMLoader(mainPath) { ++ // For built-in modules used as the main entry point we _never_ ++ // want to waste cycles resolving them to file paths on disk ++ // that actually might exist ++ if (typeof mainPath === 'string' && StringPrototypeStartsWith(mainPath, 'electron/js2c')) { ++ return false; ++ } ++ + /** + * @type {string[]} userLoaders A list of custom loaders registered by the user + * (or an empty list when none have been registered). From 2598dc0ce6a49902f8fa9ab8c6398abb918e37b3 Mon Sep 17 00:00:00 2001 From: Pedro Pontes <pepontes@microsoft.com> Date: Mon, 21 Aug 2023 03:43:12 +0100 Subject: [PATCH 160/172] chore: cherry-pick 5 changes from Release-0-M116 (#39559) * chore: [22-x-y] cherry-pick 3 changes from Release-0-M116 * 8ff63d378f2c from v8 * 5486190be556 from angle * d671b099a57d from v8 * chore: cherry-pick missing changes * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/angle/.patches | 1 + patches/angle/cherry-pick-5486190be556.patch | 41 ++++++ patches/chromium/.patches | 1 + ..._loader_factories_during_destruction.patch | 93 +++++++++++++ patches/skia/.patches | 1 + ..._of_715_million_path_verbs_in_skpath.patch | 118 ++++++++++++++++ patches/v8/.patches | 3 + ..._fixedarray_slot_in_promise_builtins.patch | 126 ++++++++++++++++++ ...iler_check_for_read-only_property_on.patch | 31 +++++ ..._allsettled_mark_values_array_as_cow.patch | 105 +++++++++++++++ 10 files changed, 520 insertions(+) create mode 100644 patches/angle/cherry-pick-5486190be556.patch create mode 100644 patches/chromium/networkcontext_don_t_access_url_loader_factories_during_destruction.patch create mode 100644 patches/skia/enforce_an_upper_limit_of_715_million_path_verbs_in_skpath.patch create mode 100644 patches/v8/merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch create mode 100644 patches/v8/merged_compiler_check_for_read-only_property_on.patch create mode 100644 patches/v8/promise_allsettled_mark_values_array_as_cow.patch diff --git a/patches/angle/.patches b/patches/angle/.patches index e2bdc1e72193e..9a599c2bac4ef 100644 --- a/patches/angle/.patches +++ b/patches/angle/.patches @@ -4,3 +4,4 @@ cherry-pick-ce029c91a662.patch cherry-pick-aed05b609629.patch translator_limit_the_size_of_private_variables_in_webgl_shaders.patch webgl_limit_total_size_of_private_data.patch +cherry-pick-5486190be556.patch diff --git a/patches/angle/cherry-pick-5486190be556.patch b/patches/angle/cherry-pick-5486190be556.patch new file mode 100644 index 0000000000000..6e0753debcf90 --- /dev/null +++ b/patches/angle/cherry-pick-5486190be556.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Geoff Lang <geofflang@chromium.org> +Date: Fri, 21 Jul 2023 13:45:52 -0400 +Subject: Fix read size validation for RGBX formats. + +GL_RGBX8_ANGLE is the only format where the upload format is 3-channel +RGB, whilethe download format is 4-channel RGBX. As such, the internal +format corresponding to format+type expects 3-byte input/output. The +format is fixed here for readPixels to output 4 bytes per pixel. + +Bug: chromium:1458046 +Change-Id: Iec737ed64bade003cfab50dc5f595eb4875e81e4 +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4706957 +Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> +(cherry picked from commit 430a4f559cbc2bcd5d026e8b36ee46ddd80e9651) +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4765136 +Commit-Queue: Daniel Yip <danielyip@google.com> +Auto-Submit: Daniel Yip <danielyip@google.com> +(cherry picked from commit 4a372ad49ceddea6c13f79adb212a777ec770a66) + +diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp +index 4014953311976b0f1ae2d1842e8fced75ffecfc9..6c8d3680b7a8bb78894120ca6cac7882827a98e4 100644 +--- a/src/libANGLE/formatutils.cpp ++++ b/src/libANGLE/formatutils.cpp +@@ -1710,7 +1710,15 @@ const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type) + GLuint InternalFormat::computePixelBytes(GLenum formatType) const + { + const auto &typeInfo = GetTypeInfo(formatType); +- GLuint components = typeInfo.specialInterpretation ? 1u : componentCount; ++ GLuint components = componentCount; ++ if (sizedInternalFormat == GL_RGBX8_ANGLE) ++ { ++ components = 4; ++ } ++ else if (typeInfo.specialInterpretation) ++ { ++ components = 1; ++ } + return components * typeInfo.bytes; + } + diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 8846084992e62..a2a751ce7d86a 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -169,3 +169,4 @@ m114_webcodecs_fix_crash_when_changing_temporal_layer_count_in_av1.patch cherry-pick-933b9fad3a53.patch cherry-pick-b03973561862.patch cherry-pick-c60a1ab717c7.patch +networkcontext_don_t_access_url_loader_factories_during_destruction.patch diff --git a/patches/chromium/networkcontext_don_t_access_url_loader_factories_during_destruction.patch b/patches/chromium/networkcontext_don_t_access_url_loader_factories_during_destruction.patch new file mode 100644 index 0000000000000..e5ce868f03fc6 --- /dev/null +++ b/patches/chromium/networkcontext_don_t_access_url_loader_factories_during_destruction.patch @@ -0,0 +1,93 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Adam Rice <ricea@chromium.org> +Date: Tue, 8 Aug 2023 08:48:51 +0000 +Subject: NetworkContext: Don't access url_loader_factories_ during destruction + +Move the contents of `url_loader_factories_` to a temporary variable in +the destructor of network::NetworkContext so that re-entrant calls to +DestroyURLLoaderFactory() don't happen after it has started being +destroyed. + +BUG=1465833 + +(cherry picked from commit e579b20308290df03f045c5d0ccb852d96b24ce3) + +Change-Id: I476f0865256bdcba4ec934688597e69991968f84 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4733351 +Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> +Commit-Queue: Adam Rice <ricea@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1177648} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4756334 +Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Auto-Submit: Adam Rice <ricea@chromium.org> +Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> +Cr-Commit-Position: refs/branch-heads/5845@{#1252} +Cr-Branched-From: 5a5dff63a4a4c63b9b18589819bebb2566c85443-refs/heads/main@{#1160321} + +diff --git a/services/network/network_context.cc b/services/network/network_context.cc +index 6dc46954b070795de082d8542f8bae56d7b52dd4..2b12040f5ef2b7fd466a9b6d92e75faea8bd1808 100644 +--- a/services/network/network_context.cc ++++ b/services/network/network_context.cc +@@ -712,6 +712,8 @@ NetworkContext::NetworkContext( + } + + NetworkContext::~NetworkContext() { ++ is_destructing_ = true; ++ + // May be nullptr in tests. + if (network_service_) + network_service_->DeregisterNetworkContext(this); +@@ -775,6 +777,12 @@ NetworkContext::~NetworkContext() { + } + } + #endif // BUILDFLAG(IS_DIRECTORY_TRANSFER_REQUIRED) ++ ++ // Clear `url_loader_factories_` before deleting the contents, as it can ++ // result in re-entrant calls to DestroyURLLoaderFactory(). ++ std::set<std::unique_ptr<cors::CorsURLLoaderFactory>, ++ base::UniquePtrComparator> ++ url_loader_factories = std::move(url_loader_factories_); + } + + // static +@@ -993,6 +1001,9 @@ void NetworkContext::DisableQuic() { + + void NetworkContext::DestroyURLLoaderFactory( + cors::CorsURLLoaderFactory* url_loader_factory) { ++ if (is_destructing_) { ++ return; ++ } + auto it = url_loader_factories_.find(url_loader_factory); + DCHECK(it != url_loader_factories_.end()); + url_loader_factories_.erase(it); +diff --git a/services/network/network_context.h b/services/network/network_context.h +index 402a9de330140e78f14dbfae204f4c637803fcef..9e4db6927a42308b7ac30455f27ad97b92e2b0c3 100644 +--- a/services/network/network_context.h ++++ b/services/network/network_context.h +@@ -915,6 +915,10 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext + // DCHECKs on APIs used by external callers. + bool require_network_isolation_key_ = false; + ++ // True once the destructor has been called. Used to guard against re-entrant ++ // calls to DestroyURLLoaderFactory(). ++ bool is_destructing_ = false; ++ + // Indicating whether + // https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name is + // supported. +@@ -923,13 +927,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext + + // CorsURLLoaderFactory assumes that fields owned by the NetworkContext always + // live longer than the factory. Therefore we want the factories to be +- // destroyed before other fields above. In particular: +- // - This must be below |url_request_context_| so that the URLRequestContext +- // outlives all the URLLoaderFactories and URLLoaders that depend on it; +- // for the same reason, it must also be below |network_context_|. +- // - This must be below |loader_count_per_process_| that is touched by +- // CorsURLLoaderFactory::DestroyURLLoader (see also +- // https://crbug.com/1174943). ++ // destroyed before other fields above. This is accomplished by explicitly ++ // clearing `url_loader_factories_` in the destructor. + std::set<std::unique_ptr<cors::CorsURLLoaderFactory>, + base::UniquePtrComparator> + url_loader_factories_; diff --git a/patches/skia/.patches b/patches/skia/.patches index cad037071f416..478eeb5e04517 100644 --- a/patches/skia/.patches +++ b/patches/skia/.patches @@ -1,2 +1,3 @@ enforce_program_stack_limits_on_function_parameters.patch enforce_size_limits_on_struct_and_array_declarations.patch +enforce_an_upper_limit_of_715_million_path_verbs_in_skpath.patch diff --git a/patches/skia/enforce_an_upper_limit_of_715_million_path_verbs_in_skpath.patch b/patches/skia/enforce_an_upper_limit_of_715_million_path_verbs_in_skpath.patch new file mode 100644 index 0000000000000..b5514b740eaa0 --- /dev/null +++ b/patches/skia/enforce_an_upper_limit_of_715_million_path_verbs_in_skpath.patch @@ -0,0 +1,118 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Stiles <johnstiles@google.com> +Date: Thu, 3 Aug 2023 13:33:52 -0400 +Subject: Enforce an upper limit of 715 million path verbs in SkPath. + +Bug: chromium:1464215 +Change-Id: Iedb7d73fc80de5ffb881b664dd77314cc2c6b108 +Reviewed-on: https://skia-review.googlesource.com/c/skia/+/735316 +Reviewed-by: Brian Osman <brianosman@google.com> +Commit-Queue: John Stiles <johnstiles@google.com> + +diff --git a/relnotes/path_715M.md b/relnotes/path_715M.md +new file mode 100644 +index 0000000000000000000000000000000000000000..7be9a40f1fc5b4f6432c490725b05d536d497fb1 +--- /dev/null ++++ b/relnotes/path_715M.md +@@ -0,0 +1 @@ ++SkPath now enforces an upper limit of 715 million path verbs. +diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp +index 7caac5ca6f05d89a2986c3eea432eedcd201203f..1a9279784b5b7bab3e0ca6dad9d1fd49a9038965 100644 +--- a/src/core/SkPath.cpp ++++ b/src/core/SkPath.cpp +@@ -27,6 +27,7 @@ + #include "src/pathops/SkPathOpsPoint.h" + + #include <cmath> ++#include <limits.h> + #include <utility> + + struct SkPath_Storage_Equivalent { +@@ -3401,43 +3402,52 @@ bool SkPath::IsCubicDegenerate(const SkPoint& p1, const SkPoint& p2, + + SkPathVerbAnalysis sk_path_analyze_verbs(const uint8_t vbs[], int verbCount) { + SkPathVerbAnalysis info = {false, 0, 0, 0}; +- + bool needMove = true; + bool invalid = false; +- for (int i = 0; i < verbCount; ++i) { +- switch ((SkPathVerb)vbs[i]) { +- case SkPathVerb::kMove: +- needMove = false; +- info.points += 1; +- break; +- case SkPathVerb::kLine: +- invalid |= needMove; +- info.segmentMask |= kLine_SkPathSegmentMask; +- info.points += 1; +- break; +- case SkPathVerb::kQuad: +- invalid |= needMove; +- info.segmentMask |= kQuad_SkPathSegmentMask; +- info.points += 2; +- break; +- case SkPathVerb::kConic: +- invalid |= needMove; +- info.segmentMask |= kConic_SkPathSegmentMask; +- info.points += 2; +- info.weights += 1; +- break; +- case SkPathVerb::kCubic: +- invalid |= needMove; +- info.segmentMask |= kCubic_SkPathSegmentMask; +- info.points += 3; +- break; +- case SkPathVerb::kClose: +- invalid |= needMove; +- needMove = true; +- break; +- default: +- invalid = true; +- break; ++ ++ if (verbCount >= (INT_MAX / 3)) { ++ // A path with an extremely high number of quad, conic or cubic verbs could cause ++ // `info.points` to overflow. To prevent against this, we reject extremely large paths. This ++ // check is conservative and assumes the worst case (in particular, it assumes that every ++ // verb consumes 3 points, which would only happen for a path composed entirely of cubics). ++ // This limits us to 700 million verbs, which is large enough for any reasonable use case. ++ invalid = true; ++ } else { ++ for (int i = 0; i < verbCount; ++i) { ++ switch ((SkPathVerb)vbs[i]) { ++ case SkPathVerb::kMove: ++ needMove = false; ++ info.points += 1; ++ break; ++ case SkPathVerb::kLine: ++ invalid |= needMove; ++ info.segmentMask |= kLine_SkPathSegmentMask; ++ info.points += 1; ++ break; ++ case SkPathVerb::kQuad: ++ invalid |= needMove; ++ info.segmentMask |= kQuad_SkPathSegmentMask; ++ info.points += 2; ++ break; ++ case SkPathVerb::kConic: ++ invalid |= needMove; ++ info.segmentMask |= kConic_SkPathSegmentMask; ++ info.points += 2; ++ info.weights += 1; ++ break; ++ case SkPathVerb::kCubic: ++ invalid |= needMove; ++ info.segmentMask |= kCubic_SkPathSegmentMask; ++ info.points += 3; ++ break; ++ case SkPathVerb::kClose: ++ invalid |= needMove; ++ needMove = true; ++ break; ++ default: ++ invalid = true; ++ break; ++ } + } + } + info.valid = !invalid; diff --git a/patches/v8/.patches b/patches/v8/.patches index cf2d669daee39..97c3f467ecc99 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -25,3 +25,6 @@ cherry-pick-2e76270cf65e.patch utf-8_q_shared-struct_20fix_20using_20shared_20objects_20as.patch merged_runtime_set_instance_prototypes_directly_on_maps.patch merged_compiler_stackcheck_can_have_side_effects.patch +promise_allsettled_mark_values_array_as_cow.patch +merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch +merged_compiler_check_for_read-only_property_on.patch diff --git a/patches/v8/merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch b/patches/v8/merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch new file mode 100644 index 0000000000000..0b0ea37ede0ac --- /dev/null +++ b/patches/v8/merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch @@ -0,0 +1,126 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shu-yu Guo <syg@chromium.org> +Date: Wed, 2 Aug 2023 17:41:03 -0700 +Subject: Merged: [builtins] Clear FixedArray slot in Promise builtins + +Fixed: chromium:1468943 +(cherry picked from commit a84849ed718932b94dc877bb44a2d38eb8a0aef9) + +Change-Id: Ia2b181c373c15bd1840e2a1572c0e930cddcd788 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4753495 +Commit-Queue: Adam Klein <adamk@chromium.org> +Reviewed-by: Adam Klein <adamk@chromium.org> +Auto-Submit: Shu-yu Guo <syg@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.6@{#28} +Cr-Branched-From: e29c028f391389a7a60ee37097e3ca9e396d6fa4-refs/heads/11.6.189@{#3} +Cr-Branched-From: 95cbef20e2aa556a1ea75431a48b36c4de6b9934-refs/heads/main@{#88340} + +diff --git a/src/builtins/promise-all-element-closure.tq b/src/builtins/promise-all-element-closure.tq +index db3fb0134cf5bf0065174153171ef44a726a6fff..036e3c7b7473eae98f39a6da4472e826420086c8 100644 +--- a/src/builtins/promise-all-element-closure.tq ++++ b/src/builtins/promise-all-element-closure.tq +@@ -175,11 +175,22 @@ transitioning macro PromiseAllResolveElementClosure<F: type>( + *NativeContextSlot( + nativeContext, ContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX); + +- // If resolve and reject handlers close over values to keep track of whether +- // an input promise is already settled, mark the values array as COW before +- // letting it escape to user code. +- if (hasResolveAndRejectClosures) MakeFixedArrayCOW(values); +- ++ // After this point, values escapes to user code. ++ // ++ // If resolve and reject handlers close over values to keep track of ++ // whether an input promise is already settled, mark the values array as ++ // COW. The original values array is still needed to guard against resolve ++ // or reject being called multiple times for an element. ++ // ++ // Otherwise, clear the slot. ++ if (hasResolveAndRejectClosures) { ++ MakeFixedArrayCOW(values); ++ } else { ++ *ContextSlot( ++ promiseContext, ++ PromiseAllResolveElementContextSlots:: ++ kPromiseAllResolveElementValuesSlot) = kEmptyFixedArray; ++ } + const valuesArray = NewJSArray(arrayMap, values); + Call(promiseContext, resolve, Undefined, valuesArray); + } +diff --git a/src/builtins/promise-all.tq b/src/builtins/promise-all.tq +index 4d131abb44b7593d3e361d1d2f971380ee91850c..7205279526fa9edd93f154feb9694c22cae68606 100644 +--- a/src/builtins/promise-all.tq ++++ b/src/builtins/promise-all.tq +@@ -278,15 +278,16 @@ Reject(JSAny) { + + check(remainingElementsCount >= 0); + ++ const valuesRef:&FixedArray = ContextSlot( ++ resolveElementContext, ++ PromiseAllResolveElementContextSlots:: ++ kPromiseAllResolveElementValuesSlot); ++ const values = *valuesRef; ++ + if (remainingElementsCount > 0) { + // Pre-allocate the backing store for the {values} to the desired + // capacity. We may already have elements in "values" - this happens + // when the Thenable calls the resolve callback immediately. +- const valuesRef:&FixedArray = ContextSlot( +- resolveElementContext, +- PromiseAllResolveElementContextSlots:: +- kPromiseAllResolveElementValuesSlot); +- const values = *valuesRef; + // 'index' is a 1-based index and incremented after every Promise. Later we + // use 'values' as a 0-based array, so capacity 'index - 1' is enough. + const newCapacity = SmiUntag(index) - 1; +@@ -301,19 +302,23 @@ Reject(JSAny) { + // Let valuesArray be CreateArrayFromList(values). + // Perform ? Call(resultCapability.[[Resolve]], undefined, + // « valuesArray »). +- +- const values: FixedArray = *ContextSlot( +- resolveElementContext, +- PromiseAllResolveElementContextSlots:: +- kPromiseAllResolveElementValuesSlot); + const arrayMap = + *NativeContextSlot( + nativeContext, ContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX); + ++ // After this point, values escapes to user code. ++ // + // If resolve and reject handlers close over values to keep track of + // whether an input promise is already settled, mark the values array as +- // COW before letting it escape to user code. +- if (hasResolveAndRejectClosures) MakeFixedArrayCOW(values); ++ // COW. The original values array is still needed to guard against resolve ++ // or reject being called multiple times for an element. ++ // ++ // Otherwise, clear the slot. ++ if (hasResolveAndRejectClosures) { ++ MakeFixedArrayCOW(values); ++ } else { ++ *valuesRef = kEmptyFixedArray; ++ } + + const valuesArray = NewJSArray(arrayMap, values); + Call(nativeContext, UnsafeCast<JSAny>(resolve), Undefined, valuesArray); +diff --git a/src/builtins/promise-any.tq b/src/builtins/promise-any.tq +index 7e707e649f11bc946a6d1173180d7293fe94d8ce..45bafac0e6b09143b69b21a7292f9ed6b9c46239 100644 +--- a/src/builtins/promise-any.tq ++++ b/src/builtins/promise-any.tq +@@ -313,10 +313,14 @@ Reject(JSAny) { + + // We may already have elements in "errors" - this happens when the + // Thenable calls the reject callback immediately. +- const errors: FixedArray = *ContextSlot( ++ const errorsRef:&FixedArray = ContextSlot( + rejectElementContext, + PromiseAnyRejectElementContextSlots:: + kPromiseAnyRejectElementErrorsSlot); ++ const errors: FixedArray = *errorsRef; ++ ++ // After this point, errors escapes to user code. Clear the slot. ++ *errorsRef = kEmptyFixedArray; + + check(errors.length == index - 1); + const error = ConstructAggregateError(errors); diff --git a/patches/v8/merged_compiler_check_for_read-only_property_on.patch b/patches/v8/merged_compiler_check_for_read-only_property_on.patch new file mode 100644 index 0000000000000..0aeafb1bc81c8 --- /dev/null +++ b/patches/v8/merged_compiler_check_for_read-only_property_on.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tobias Tebbi <tebbi@chromium.org> +Date: Tue, 13 Jun 2023 11:50:11 +0200 +Subject: Merged: [compiler] check for read-only property on + AccessMode::kDefine + +(cherry picked from commit 95eda07ddbc1839e39b3d1ff5db329c0ceb6dfaa) + +Change-Id: Ic5799a32e7c312e41cd0a7e1e6073a235414d56f +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4665588 +Auto-Submit: Tobias Tebbi <tebbi@chromium.org> +Reviewed-by: Darius Mercadier <dmercadier@chromium.org> +Commit-Queue: Darius Mercadier <dmercadier@chromium.org> +Cr-Commit-Position: refs/branch-heads/11.4@{#53} +Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1} +Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241} + +diff --git a/src/compiler/access-info.cc b/src/compiler/access-info.cc +index 7c35df243af97d0fe7ae5b25bd31b01afe1d1e6b..b464581f27535207493c6854b4447bab4cbb3a5f 100644 +--- a/src/compiler/access-info.cc ++++ b/src/compiler/access-info.cc +@@ -758,8 +758,7 @@ PropertyAccessInfo AccessInfoFactory::ComputePropertyAccessInfo( + } + + if (index.is_found()) { +- if (access_mode == AccessMode::kStore || +- access_mode == AccessMode::kStoreInLiteral) { ++ if (IsAnyStore(access_mode)) { + DCHECK(!map.is_dictionary_map()); + + // Don't bother optimizing stores to read-only properties. diff --git a/patches/v8/promise_allsettled_mark_values_array_as_cow.patch b/patches/v8/promise_allsettled_mark_values_array_as_cow.patch new file mode 100644 index 0000000000000..8033855121d1b --- /dev/null +++ b/patches/v8/promise_allsettled_mark_values_array_as_cow.patch @@ -0,0 +1,105 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shu-yu Guo <syg@chromium.org> +Date: Thu, 27 Oct 2022 18:02:55 -0700 +Subject: Mark values array as COW +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Bug: chromium:1377790 +Change-Id: I36bb9e35ca7ecaaa7ed4605f1a19293bc662f341 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3988925 +Auto-Submit: Shu-yu Guo <syg@chromium.org> +Reviewed-by: Marja Hölttä <marja@chromium.org> +Commit-Queue: Marja Hölttä <marja@chromium.org> +Cr-Commit-Position: refs/heads/main@{#83969} + +diff --git a/src/builtins/promise-all-element-closure.tq b/src/builtins/promise-all-element-closure.tq +index 24b9cfb346e022a0ad80f7712b249d1c38ae562d..db3fb0134cf5bf0065174153171ef44a726a6fff 100644 +--- a/src/builtins/promise-all-element-closure.tq ++++ b/src/builtins/promise-all-element-closure.tq +@@ -174,6 +174,12 @@ transitioning macro PromiseAllResolveElementClosure<F: type>( + const arrayMap = + *NativeContextSlot( + nativeContext, ContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX); ++ ++ // If resolve and reject handlers close over values to keep track of whether ++ // an input promise is already settled, mark the values array as COW before ++ // letting it escape to user code. ++ if (hasResolveAndRejectClosures) MakeFixedArrayCOW(values); ++ + const valuesArray = NewJSArray(arrayMap, values); + Call(promiseContext, resolve, Undefined, valuesArray); + } +diff --git a/src/builtins/promise-all.tq b/src/builtins/promise-all.tq +index 29c468ed3eb34f9f348f115b8b6a77174e708bcc..4d131abb44b7593d3e361d1d2f971380ee91850c 100644 +--- a/src/builtins/promise-all.tq ++++ b/src/builtins/promise-all.tq +@@ -138,7 +138,8 @@ transitioning macro PerformPromiseAll<F1: type, F2: type>( + nativeContext: NativeContext, iter: iterator::IteratorRecord, + constructor: Constructor, capability: PromiseCapability, + promiseResolveFunction: JSAny, createResolveElementFunctor: F1, +- createRejectElementFunctor: F2): JSAny labels ++ createRejectElementFunctor: F2, ++ hasResolveAndRejectClosures: constexpr bool): JSAny labels + Reject(JSAny) { + const promise = capability.promise; + const resolve = capability.resolve; +@@ -308,6 +309,12 @@ Reject(JSAny) { + const arrayMap = + *NativeContextSlot( + nativeContext, ContextSlot::JS_ARRAY_PACKED_ELEMENTS_MAP_INDEX); ++ ++ // If resolve and reject handlers close over values to keep track of ++ // whether an input promise is already settled, mark the values array as ++ // COW before letting it escape to user code. ++ if (hasResolveAndRejectClosures) MakeFixedArrayCOW(values); ++ + const valuesArray = NewJSArray(arrayMap, values); + Call(nativeContext, UnsafeCast<JSAny>(resolve), Undefined, valuesArray); + } +@@ -319,7 +326,8 @@ Reject(JSAny) { + transitioning macro GeneratePromiseAll<F1: type, F2: type>( + implicit context: Context)( + receiver: JSAny, iterable: JSAny, createResolveElementFunctor: F1, +- createRejectElementFunctor: F2, message: constexpr string): JSAny { ++ createRejectElementFunctor: F2, message: constexpr string, ++ hasResolveAndRejectClosures: constexpr bool): JSAny { + const nativeContext = LoadNativeContext(context); + // Let C be the this value. + // If Type(C) is not Object, throw a TypeError exception. +@@ -352,7 +360,8 @@ transitioning macro GeneratePromiseAll<F1: type, F2: type>( + // IfAbruptRejectPromise(result, promiseCapability). + return PerformPromiseAll( + nativeContext, i, constructor, capability, promiseResolveFunction, +- createResolveElementFunctor, createRejectElementFunctor) ++ createResolveElementFunctor, createRejectElementFunctor, ++ hasResolveAndRejectClosures) + otherwise Reject; + } catch (e, _message) deferred { + goto Reject(e); +@@ -368,7 +377,7 @@ transitioning javascript builtin PromiseAll( + js-implicit context: Context, receiver: JSAny)(iterable: JSAny): JSAny { + return GeneratePromiseAll( + receiver, iterable, PromiseAllResolveElementFunctor{}, +- PromiseAllRejectElementFunctor{}, 'Promise.all'); ++ PromiseAllRejectElementFunctor{}, 'Promise.all', false); + } + + // ES#sec-promise.allsettled +@@ -377,7 +386,7 @@ transitioning javascript builtin PromiseAllSettled( + js-implicit context: Context, receiver: JSAny)(iterable: JSAny): JSAny { + return GeneratePromiseAll( + receiver, iterable, PromiseAllSettledResolveElementFunctor{}, +- PromiseAllSettledRejectElementFunctor{}, 'Promise.allSettled'); ++ PromiseAllSettledRejectElementFunctor{}, 'Promise.allSettled', true); + } + + extern macro PromiseAllResolveElementSharedFunConstant(): SharedFunctionInfo; +@@ -385,4 +394,6 @@ extern macro PromiseAllSettledRejectElementSharedFunConstant(): + SharedFunctionInfo; + extern macro PromiseAllSettledResolveElementSharedFunConstant(): + SharedFunctionInfo; ++ ++extern macro MakeFixedArrayCOW(FixedArray): void; + } From e940852250f22c2e5599b37d285e9747113ed836 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:03:25 +0900 Subject: [PATCH 161/172] fix: use tiled edges to calculate frame inset sizes in Linux (#39568) Adapt to the window frame size calculation changes in CL 3970920 by setting the inset sizes to 0 for tiled edges. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Athul Iddya <athul@iddya.com> --- shell/browser/ui/views/client_frame_view_linux.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/browser/ui/views/client_frame_view_linux.cc b/shell/browser/ui/views/client_frame_view_linux.cc index 82b8f93e85dfd..71497023bd157 100644 --- a/shell/browser/ui/views/client_frame_view_linux.cc +++ b/shell/browser/ui/views/client_frame_view_linux.cc @@ -150,7 +150,13 @@ void ClientFrameViewLinux::Init(NativeWindowViews* window, } gfx::Insets ClientFrameViewLinux::GetBorderDecorationInsets() const { - return frame_provider_->GetFrameThicknessDip(); + const auto insets = frame_provider_->GetFrameThicknessDip(); + // We shouldn't draw frame decorations for the tiled edges. + // See https://wayland.app/protocols/xdg-shell#xdg_toplevel:enum:state + return gfx::Insets::TLBR(tiled_edges().top ? 0 : insets.top(), + tiled_edges().left ? 0 : insets.left(), + tiled_edges().bottom ? 0 : insets.bottom(), + tiled_edges().right ? 0 : insets.right()); } gfx::Insets ClientFrameViewLinux::GetInputInsets() const { From 4938ca50f0a376b3d8c4ee07e59465b37fb231f3 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt <jkleinsc@electronjs.org> Date: Thu, 24 Aug 2023 23:19:08 -0400 Subject: [PATCH 162/172] ci: explicitly use python3 to start goma (#39652) ci: explicitly use python3 to start goma (#39650) * ci: explicitly use python3 to start goma * ci: explicitly use python3 for goma (cherry picked from commit 83760bd5c627c56c16eb93c2617dbb3896aaa626) --- appveyor-woa.yml | 4 ++-- appveyor.yml | 4 ++-- script/start-goma.ps1 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 57e0cd3cbbded..21504de780c9f 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -107,7 +107,7 @@ for: - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR - ps: >- if (Test-Path 'env:RAW_GOMA_AUTH') { - $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info + $goma_login = python3 $env:LOCAL_GOMA_DIR\goma_auth.py info if ($goma_login -eq 'Login as Fermi Planck') { Write-warning "Goma authentication is correct"; } else { @@ -157,7 +157,7 @@ for: - ninja -C out/Default electron:hunspell_dictionaries_zip - ninja -C out/Default electron:electron_chromedriver_zip - ninja -C out/Default third_party/electron_node:headers - - python %LOCAL_GOMA_DIR%\goma_ctl.py stat + - python3 %LOCAL_GOMA_DIR%\goma_ctl.py stat - ps: >- Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json diff --git a/appveyor.yml b/appveyor.yml index 0314cbb59c589..4a67dfb62d162 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -105,7 +105,7 @@ for: - ps: .\src\electron\script\start-goma.ps1 -gomaDir $env:LOCAL_GOMA_DIR - ps: >- if (Test-Path 'env:RAW_GOMA_AUTH') { - $goma_login = python $env:LOCAL_GOMA_DIR\goma_auth.py info + $goma_login = python3 $env:LOCAL_GOMA_DIR\goma_auth.py info if ($goma_login -eq 'Login as Fermi Planck') { Write-warning "Goma authentication is correct"; } else { @@ -155,7 +155,7 @@ for: - ninja -C out/Default electron:hunspell_dictionaries_zip - ninja -C out/Default electron:electron_chromedriver_zip - ninja -C out/Default third_party/electron_node:headers - - python %LOCAL_GOMA_DIR%\goma_ctl.py stat + - pytho3 %LOCAL_GOMA_DIR%\goma_ctl.py stat - ps: >- Get-CimInstance -Namespace root\cimv2 -Class Win32_product | Select vendor, description, @{l='install_location';e='InstallLocation'}, @{l='install_date';e='InstallDate'}, @{l='install_date_2';e='InstallDate2'}, caption, version, name, @{l='sku_number';e='SKUNumber'} | ConvertTo-Json | Out-File -Encoding utf8 -FilePath .\installed_software.json - python3 electron/build/profile_toolchain.py --output-json=out/Default/windows_toolchain_profile.json diff --git a/script/start-goma.ps1 b/script/start-goma.ps1 index f63d46c7e0fc0..bc3a1fe25b1d6 100755 --- a/script/start-goma.ps1 +++ b/script/start-goma.ps1 @@ -1,6 +1,6 @@ param([string]$gomaDir=$PWD) -$cmdPath = Join-Path -Path $gomaDir -ChildPath "goma_ctl.py" -Start-Process -FilePath cmd -ArgumentList "/C", "python", "$cmdPath", "ensure_start" +$cmdPath = Join-Path -Path $gomaDir -ChildPath "goma_ctl.py" +Start-Process -FilePath cmd -ArgumentList "/C", "python3", "$cmdPath", "ensure_start" $timedOut = $false; $waitTime = 0; $waitIncrement = 5; $timeout=120; Do { sleep $waitIncrement; $timedOut = (($waitTime+=$waitIncrement) -gt $timeout); iex "$gomaDir\gomacc.exe port 2" > $null; } Until(($LASTEXITCODE -eq 0) -or $timedOut) if ($timedOut) { From 33f9dce7c2a77a8b16a6f9f61615d5ee6a63614c Mon Sep 17 00:00:00 2001 From: Pedro Pontes <pepontes@microsoft.com> Date: Mon, 28 Aug 2023 07:18:56 +0100 Subject: [PATCH 163/172] chore: cherry-pick 2 changes from Release-1-M116 (#39648) * chore: [22-x-y] cherry-pick 2 changes from Release-1-M116 * 1939f7b78eda from chromium * e4669a74888d from angle * chore: [22-x-y] cherry-pick missing changes from Release-1-M116 * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + ...inter_to_popped_stack_memory_for_has.patch | 84 ++++ patches/v8/.patches | 2 + .../v8/merged_squashed_multiple_commits.patch | 51 +++ ...shared-struct_fix_for-in_enumeration.patch | 359 ++++++++++++++++++ 5 files changed, 497 insertions(+) create mode 100644 patches/chromium/don_t_keep_pointer_to_popped_stack_memory_for_has.patch create mode 100644 patches/v8/merged_squashed_multiple_commits.patch create mode 100644 patches/v8/shared-struct_fix_for-in_enumeration.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index a2a751ce7d86a..1dbbe3436139f 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -170,3 +170,4 @@ cherry-pick-933b9fad3a53.patch cherry-pick-b03973561862.patch cherry-pick-c60a1ab717c7.patch networkcontext_don_t_access_url_loader_factories_during_destruction.patch +don_t_keep_pointer_to_popped_stack_memory_for_has.patch diff --git a/patches/chromium/don_t_keep_pointer_to_popped_stack_memory_for_has.patch b/patches/chromium/don_t_keep_pointer_to_popped_stack_memory_for_has.patch new file mode 100644 index 0000000000000..67581df1d97b2 --- /dev/null +++ b/patches/chromium/don_t_keep_pointer_to_popped_stack_memory_for_has.patch @@ -0,0 +1,84 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Rune Lillesveen <futhark@chromium.org> +Date: Tue, 15 Aug 2023 15:04:39 +0000 +Subject: Don't keep pointer to popped stack memory for :has() + +The sibling_features pass into UpdateFeaturesFromCombinator may be +initialized to last_compound_in_adjacent_chain_features if null. The +outer while loop in +AddFeaturesToInvalidationSetsForLogicalCombinationInHas() could then +reference to the last_compound_in_adjacent_chain_features which is +popped from the stack on every outer iteration. That caused an ASAN +failure for reading stack memory that had been popped. + +Instead make sure each inner iteration restarts with the same +sibling_features pointer, which seems to have been the intent here. + +(cherry picked from commit 5e213507a2f0d6e3c96904a710407b01493670bd) + +Bug: 1470477 +Change-Id: I260c93016f8ab0d165e4b29ca1aea810bede5b97 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4759326 +Commit-Queue: Rune Lillesveen <futhark@chromium.org> +Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> +Cr-Original-Commit-Position: refs/heads/main@{#1181365} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4777251 +Cr-Commit-Position: refs/branch-heads/5845@{#1482} +Cr-Branched-From: 5a5dff63a4a4c63b9b18589819bebb2566c85443-refs/heads/main@{#1160321} + +diff --git a/third_party/blink/renderer/core/css/rule_feature_set.cc b/third_party/blink/renderer/core/css/rule_feature_set.cc +index ec7356285d7fa45b7d9c1701be484a121c2a0017..9cb6084b7fca4fc6ff2edd8defadf8fabf2899b5 100644 +--- a/third_party/blink/renderer/core/css/rule_feature_set.cc ++++ b/third_party/blink/renderer/core/css/rule_feature_set.cc +@@ -1227,6 +1227,7 @@ void RuleFeatureSet::AddFeaturesToInvalidationSetsForLogicalCombinationInHas( + descendant_features); + + const CSSSelector* compound_in_logical_combination = complex; ++ InvalidationSetFeatures* inner_sibling_features = sibling_features; + InvalidationSetFeatures last_compound_in_adjacent_chain_features; + while (compound_in_logical_combination) { + AddFeaturesToInvalidationSetsForLogicalCombinationInHasContext context( +@@ -1238,14 +1239,14 @@ void RuleFeatureSet::AddFeaturesToInvalidationSetsForLogicalCombinationInHas( + last_in_compound = + SkipAddingAndGetLastInCompoundForLogicalCombinationInHas( + compound_in_logical_combination, compound_containing_has, +- sibling_features, descendant_features, previous_combinator, +- add_features_method); ++ inner_sibling_features, descendant_features, ++ previous_combinator, add_features_method); + } else { + last_in_compound = + AddFeaturesAndGetLastInCompoundForLogicalCombinationInHas( + compound_in_logical_combination, compound_containing_has, +- sibling_features, descendant_features, previous_combinator, +- add_features_method); ++ inner_sibling_features, descendant_features, ++ previous_combinator, add_features_method); + } + + if (!last_in_compound) +@@ -1259,7 +1260,7 @@ void RuleFeatureSet::AddFeaturesToInvalidationSetsForLogicalCombinationInHas( + ? CSSSelector::kIndirectAdjacent + : previous_combinator, + context.last_compound_in_adjacent_chain, +- last_compound_in_adjacent_chain_features, sibling_features, ++ last_compound_in_adjacent_chain_features, inner_sibling_features, + descendant_features); + } + +diff --git a/third_party/blink/web_tests/external/wpt/css/selectors/has-sibling-chrome-crash.html b/third_party/blink/web_tests/external/wpt/css/selectors/has-sibling-chrome-crash.html +new file mode 100644 +index 0000000000000000000000000000000000000000..0306e3e39272c321fc3539aa582b4e239ffe2fa1 +--- /dev/null ++++ b/third_party/blink/web_tests/external/wpt/css/selectors/has-sibling-chrome-crash.html +@@ -0,0 +1,10 @@ ++<!DOCTYPE html> ++<title>CSS Selectors Test: Chrome crash issue 1470477 ++ ++ ++

PASS if this tests does not crash

diff --git a/patches/v8/.patches b/patches/v8/.patches index 97c3f467ecc99..24993535eefc4 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -28,3 +28,5 @@ merged_compiler_stackcheck_can_have_side_effects.patch promise_allsettled_mark_values_array_as_cow.patch merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch merged_compiler_check_for_read-only_property_on.patch +shared-struct_fix_for-in_enumeration.patch +merged_squashed_multiple_commits.patch diff --git a/patches/v8/merged_squashed_multiple_commits.patch b/patches/v8/merged_squashed_multiple_commits.patch new file mode 100644 index 0000000000000..92663ba55b787 --- /dev/null +++ b/patches/v8/merged_squashed_multiple_commits.patch @@ -0,0 +1,51 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Samuel=20Gro=C3=9F?= +Date: Thu, 17 Aug 2023 09:10:19 +0000 +Subject: Merged: Squashed multiple commits. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Merged: [runtime] Recreate enum cache on map update +Revision: 1c623f9ff6e077be1c66f155485ea4005ddb6574 + +Merged: [runtime] Don't try to create empty enum cache. +Revision: 5516e06237c9f0013121f47319e8c253c896d52d + +BUG=chromium:1470668,chromium:1472317 +R=tebbi@chromium.org + +Change-Id: I31d5491aba663661ba68bb55631747a195ed084e +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4788990 +Commit-Queue: Samuel Groß +Reviewed-by: Tobias Tebbi +Cr-Commit-Position: refs/branch-heads/11.6@{#32} +Cr-Branched-From: e29c028f391389a7a60ee37097e3ca9e396d6fa4-refs/heads/11.6.189@{#3} +Cr-Branched-From: 95cbef20e2aa556a1ea75431a48b36c4de6b9934-refs/heads/main@{#88340} + +diff --git a/src/objects/map-updater.cc b/src/objects/map-updater.cc +index be6568aac4730d08601e883b80092bbd6ee8081a..2ebfc84d3e326abf2602a1af8309024a46cb9c9d 100644 +--- a/src/objects/map-updater.cc ++++ b/src/objects/map-updater.cc +@@ -11,6 +11,7 @@ + #include "src/execution/isolate.h" + #include "src/handles/handles.h" + #include "src/objects/field-type.h" ++#include "src/objects/keys.h" + #include "src/objects/objects-inl.h" + #include "src/objects/objects.h" + #include "src/objects/property-details.h" +@@ -1035,6 +1036,13 @@ MapUpdater::State MapUpdater::ConstructNewMap() { + // the new descriptors to maintain descriptors sharing invariant. + split_map->ReplaceDescriptors(isolate_, *new_descriptors); + ++ // If the old descriptors had an enum cache, make sure the new ones do too. ++ if (old_descriptors_->enum_cache().keys().length() > 0 && ++ new_map->NumberOfEnumerableProperties() > 0) { ++ FastKeyAccumulator::InitializeFastPropertyEnumCache( ++ isolate_, new_map, new_map->NumberOfEnumerableProperties()); ++ } ++ + if (has_integrity_level_transition_) { + target_map_ = new_map; + state_ = kAtIntegrityLevelSource; diff --git a/patches/v8/shared-struct_fix_for-in_enumeration.patch b/patches/v8/shared-struct_fix_for-in_enumeration.patch new file mode 100644 index 0000000000000..3bb1caad79b34 --- /dev/null +++ b/patches/v8/shared-struct_fix_for-in_enumeration.patch @@ -0,0 +1,359 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shu-yu Guo +Date: Thu, 3 Nov 2022 08:48:39 -0700 +Subject: Fix for-in enumeration + +for-in enumeration creates an EnumCache, which is currently incorrectly +allocated in the per-thread heap. This CL preallocates the enum cache at +SharedStructType-creation time. + +Also drive-by fixes typos in the enum cache code. + +Bug: v8:12547, chromium:1379616 +Change-Id: I1930f88844eca5ccfeebd8dfdcce4ad0bd80ee38 +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3997701 +Commit-Queue: Shu-yu Guo +Reviewed-by: Camillo Bruni +Cr-Commit-Position: refs/heads/main@{#84047} + +diff --git a/src/builtins/builtins-struct.cc b/src/builtins/builtins-struct.cc +index a0d75e72086592283070d8014cd043ef3bab1ff5..e0b3831cdc69c1c0acb2ec24925adc310303856e 100644 +--- a/src/builtins/builtins-struct.cc ++++ b/src/builtins/builtins-struct.cc +@@ -94,6 +94,16 @@ BUILTIN(SharedStructTypeConstructor) { + // to it. + instance_map->set_constructor_or_back_pointer(*factory->null_value()); + ++ // Pre-create the enum cache in the shared space, as otherwise for-in ++ // enumeration will incorrectly create an enum cache in the per-thread heap. ++ if (num_properties == 0) { ++ instance_map->SetEnumLength(0); ++ } else { ++ FastKeyAccumulator::InitializeFastPropertyEnumCache( ++ isolate, instance_map, num_properties, AllocationType::kSharedOld); ++ DCHECK_EQ(num_properties, instance_map->EnumLength()); ++ } ++ + return *constructor; + } + +diff --git a/src/heap/factory.cc b/src/heap/factory.cc +index bcb2f6475ec357cb34f923c51e279641c644957d..d1285ab16f4113acd5cdee154f7b1ef133fd8e14 100644 +--- a/src/heap/factory.cc ++++ b/src/heap/factory.cc +@@ -415,9 +415,13 @@ Handle Factory::NewPrototypeInfo() { + } + + Handle Factory::NewEnumCache(Handle keys, +- Handle indices) { +- auto result = +- NewStructInternal(ENUM_CACHE_TYPE, AllocationType::kOld); ++ Handle indices, ++ AllocationType allocation) { ++ DCHECK(allocation == AllocationType::kOld || ++ allocation == AllocationType::kSharedOld); ++ DCHECK_EQ(allocation == AllocationType::kSharedOld, ++ keys->InSharedHeap() && indices->InSharedHeap()); ++ auto result = NewStructInternal(ENUM_CACHE_TYPE, allocation); + DisallowGarbageCollection no_gc; + result.set_keys(*keys); + result.set_indices(*indices); +diff --git a/src/heap/factory.h b/src/heap/factory.h +index 6c9cc2d4d8ed1e9c7e14ccb35f6ad61dfa850cfa..748a3f91c881d8bdc723a4f21fcb6adfe6d3876e 100644 +--- a/src/heap/factory.h ++++ b/src/heap/factory.h +@@ -183,8 +183,9 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase { + Handle NewPrototypeInfo(); + + // Create a new EnumCache struct. +- Handle NewEnumCache(Handle keys, +- Handle indices); ++ Handle NewEnumCache( ++ Handle keys, Handle indices, ++ AllocationType allocation = AllocationType::kOld); + + // Create a new Tuple2 struct. + Handle NewTuple2(Handle value1, Handle value2, +diff --git a/src/objects/descriptor-array.h b/src/objects/descriptor-array.h +index 5db091cbfe166a683f3c43273aece6d3d802d448..178e6d03af4be4512fc40257365437482be654eb 100644 +--- a/src/objects/descriptor-array.h ++++ b/src/objects/descriptor-array.h +@@ -65,10 +65,10 @@ class DescriptorArray + + void ClearEnumCache(); + inline void CopyEnumCacheFrom(DescriptorArray array); +- static void InitializeOrChangeEnumCache(Handle descriptors, +- Isolate* isolate, +- Handle keys, +- Handle indices); ++ static void InitializeOrChangeEnumCache( ++ Handle descriptors, Isolate* isolate, ++ Handle keys, Handle indices, ++ AllocationType allocation_if_initialize); + + // Accessors for fetching instance descriptor at descriptor number. + inline Name GetKey(InternalIndex descriptor_number) const; +diff --git a/src/objects/keys.cc b/src/objects/keys.cc +index ac21fbf9c3d2d22bbd7049a620849e25d1257b4d..a0796864f1ecc6f1f32ca50635b9cb55cd04d7db 100644 +--- a/src/objects/keys.cc ++++ b/src/objects/keys.cc +@@ -312,7 +312,7 @@ void TrySettingEmptyEnumCache(JSReceiver object) { + map.SetEnumLength(0); + } + +-bool CheckAndInitalizeEmptyEnumCache(JSReceiver object) { ++bool CheckAndInitializeEmptyEnumCache(JSReceiver object) { + if (object.map().EnumLength() == kInvalidEnumCacheSentinel) { + TrySettingEmptyEnumCache(object); + } +@@ -342,7 +342,7 @@ void FastKeyAccumulator::Prepare() { + only_own_has_simple_elements_ = false; + } + } +- bool has_no_properties = CheckAndInitalizeEmptyEnumCache(current); ++ bool has_no_properties = CheckAndInitializeEmptyEnumCache(current); + if (has_no_properties) continue; + last_prototype = current; + has_empty_prototype_ = false; +@@ -368,7 +368,7 @@ Handle ReduceFixedArrayTo(Isolate* isolate, + return isolate->factory()->CopyFixedArrayUpTo(array, length); + } + +-// Initializes and directly returns the enume cache. Users of this function ++// Initializes and directly returns the enum cache. Users of this function + // have to make sure to never directly leak the enum cache. + Handle GetFastEnumPropertyKeys(Isolate* isolate, + Handle object) { +@@ -398,51 +398,8 @@ Handle GetFastEnumPropertyKeys(Isolate* isolate, + return ReduceFixedArrayTo(isolate, keys, enum_length); + } + +- Handle descriptors = +- Handle(map->instance_descriptors(isolate), isolate); +- isolate->counters()->enum_cache_misses()->Increment(); +- +- // Create the keys array. +- int index = 0; +- bool fields_only = true; +- keys = isolate->factory()->NewFixedArray(enum_length); +- for (InternalIndex i : map->IterateOwnDescriptors()) { +- DisallowGarbageCollection no_gc; +- PropertyDetails details = descriptors->GetDetails(i); +- if (details.IsDontEnum()) continue; +- Object key = descriptors->GetKey(i); +- if (key.IsSymbol()) continue; +- keys->set(index, key); +- if (details.location() != PropertyLocation::kField) fields_only = false; +- index++; +- } +- DCHECK_EQ(index, keys->length()); +- +- // Optionally also create the indices array. +- Handle indices = isolate->factory()->empty_fixed_array(); +- if (fields_only) { +- indices = isolate->factory()->NewFixedArray(enum_length); +- index = 0; +- for (InternalIndex i : map->IterateOwnDescriptors()) { +- DisallowGarbageCollection no_gc; +- PropertyDetails details = descriptors->GetDetails(i); +- if (details.IsDontEnum()) continue; +- Object key = descriptors->GetKey(i); +- if (key.IsSymbol()) continue; +- DCHECK_EQ(PropertyKind::kData, details.kind()); +- DCHECK_EQ(PropertyLocation::kField, details.location()); +- FieldIndex field_index = FieldIndex::ForDescriptor(*map, i); +- indices->set(index, Smi::FromInt(field_index.GetLoadByFieldIndex())); +- index++; +- } +- DCHECK_EQ(index, indices->length()); +- } +- +- DescriptorArray::InitializeOrChangeEnumCache(descriptors, isolate, keys, +- indices); +- if (map->OnlyHasSimpleProperties()) map->SetEnumLength(enum_length); +- +- return keys; ++ return FastKeyAccumulator::InitializeFastPropertyEnumCache(isolate, map, ++ enum_length); + } + + template +@@ -451,7 +408,6 @@ MaybeHandle GetOwnKeysWithElements(Isolate* isolate, + GetKeysConversion convert, + bool skip_indices) { + Handle keys; +- ElementsAccessor* accessor = object->GetElementsAccessor(); + if (fast_properties) { + keys = GetFastEnumPropertyKeys(isolate, object); + } else { +@@ -463,6 +419,7 @@ MaybeHandle GetOwnKeysWithElements(Isolate* isolate, + if (skip_indices) { + result = keys; + } else { ++ ElementsAccessor* accessor = object->GetElementsAccessor(isolate); + result = accessor->PrependElementIndices(isolate, object, keys, convert, + ONLY_ENUMERABLE); + } +@@ -518,7 +475,7 @@ MaybeHandle FastKeyAccumulator::GetKeysFast( + if (enum_length == kInvalidEnumCacheSentinel) { + Handle keys; + // Try initializing the enum cache and return own properties. +- if (GetOwnKeysWithUninitializedEnumCache().ToHandle(&keys)) { ++ if (GetOwnKeysWithUninitializedEnumLength().ToHandle(&keys)) { + if (v8_flags.trace_for_in_enumerate) { + PrintF("| strings=%d symbols=0 elements=0 || prototypes>=1 ||\n", + keys->length()); +@@ -534,10 +491,70 @@ MaybeHandle FastKeyAccumulator::GetKeysFast( + skip_indices_); + } + ++// static ++Handle FastKeyAccumulator::InitializeFastPropertyEnumCache( ++ Isolate* isolate, Handle map, int enum_length, ++ AllocationType allocation) { ++ DCHECK_EQ(kInvalidEnumCacheSentinel, map->EnumLength()); ++ DCHECK_GT(enum_length, 0); ++ DCHECK_EQ(enum_length, map->NumberOfEnumerableProperties()); ++ DCHECK(!map->is_dictionary_map()); ++ ++ Handle descriptors = ++ Handle(map->instance_descriptors(isolate), isolate); ++ ++ // The enum cache should have been a hit if the number of enumerable ++ // properties is fewer than what's already in the cache. ++ DCHECK_LT(descriptors->enum_cache().keys().length(), enum_length); ++ isolate->counters()->enum_cache_misses()->Increment(); ++ ++ // Create the keys array. ++ int index = 0; ++ bool fields_only = true; ++ Handle keys = ++ isolate->factory()->NewFixedArray(enum_length, allocation); ++ for (InternalIndex i : map->IterateOwnDescriptors()) { ++ DisallowGarbageCollection no_gc; ++ PropertyDetails details = descriptors->GetDetails(i); ++ if (details.IsDontEnum()) continue; ++ Object key = descriptors->GetKey(i); ++ if (key.IsSymbol()) continue; ++ keys->set(index, key); ++ if (details.location() != PropertyLocation::kField) fields_only = false; ++ index++; ++ } ++ DCHECK_EQ(index, keys->length()); ++ ++ // Optionally also create the indices array. ++ Handle indices = isolate->factory()->empty_fixed_array(); ++ if (fields_only) { ++ indices = isolate->factory()->NewFixedArray(enum_length, allocation); ++ index = 0; ++ for (InternalIndex i : map->IterateOwnDescriptors()) { ++ DisallowGarbageCollection no_gc; ++ PropertyDetails details = descriptors->GetDetails(i); ++ if (details.IsDontEnum()) continue; ++ Object key = descriptors->GetKey(i); ++ if (key.IsSymbol()) continue; ++ DCHECK_EQ(PropertyKind::kData, details.kind()); ++ DCHECK_EQ(PropertyLocation::kField, details.location()); ++ FieldIndex field_index = FieldIndex::ForDescriptor(*map, i); ++ indices->set(index, Smi::FromInt(field_index.GetLoadByFieldIndex())); ++ index++; ++ } ++ DCHECK_EQ(index, indices->length()); ++ } ++ ++ DescriptorArray::InitializeOrChangeEnumCache(descriptors, isolate, keys, ++ indices, allocation); ++ if (map->OnlyHasSimpleProperties()) map->SetEnumLength(enum_length); ++ return keys; ++} ++ + MaybeHandle +-FastKeyAccumulator::GetOwnKeysWithUninitializedEnumCache() { ++FastKeyAccumulator::GetOwnKeysWithUninitializedEnumLength() { + Handle object = Handle::cast(receiver_); +- // Uninitalized enum cache ++ // Uninitialized enum length + Map map = object->map(); + if (object->elements() != ReadOnlyRoots(isolate_).empty_fixed_array() && + object->elements() != +diff --git a/src/objects/keys.h b/src/objects/keys.h +index 4497f1211a42fc6dafc906ea9076f7c44995ac4a..031c407620b6af91ef4eb4453f1415c2a608211b 100644 +--- a/src/objects/keys.h ++++ b/src/objects/keys.h +@@ -174,7 +174,7 @@ class KeyAccumulator final { + }; + + // The FastKeyAccumulator handles the cases where there are no elements on the +-// prototype chain and forwords the complex/slow cases to the normal ++// prototype chain and forwards the complex/slow cases to the normal + // KeyAccumulator. This significantly speeds up the cases where the OWN_ONLY + // case where we do not have to walk the prototype chain. + class FastKeyAccumulator { +@@ -200,6 +200,19 @@ class FastKeyAccumulator { + MaybeHandle GetKeys( + GetKeysConversion convert = GetKeysConversion::kKeepNumbers); + ++ // Initialize the the enum cache for a map with all of the following: ++ // - uninitialized enum length ++ // - fast properties (i.e. !is_dictionary_map()) ++ // - has >0 enumerable own properties ++ // ++ // The number of enumerable properties is passed in as an optimization, for ++ // when the caller has already computed it. ++ // ++ // Returns the keys. ++ static Handle InitializeFastPropertyEnumCache( ++ Isolate* isolate, Handle map, int enum_length, ++ AllocationType allocation = AllocationType::kOld); ++ + private: + void Prepare(); + MaybeHandle GetKeysFast(GetKeysConversion convert); +@@ -207,7 +220,7 @@ class FastKeyAccumulator { + MaybeHandle GetKeysWithPrototypeInfoCache( + GetKeysConversion convert); + +- MaybeHandle GetOwnKeysWithUninitializedEnumCache(); ++ MaybeHandle GetOwnKeysWithUninitializedEnumLength(); + + bool MayHaveElements(JSReceiver receiver); + bool TryPrototypeInfoCache(Handle receiver); +diff --git a/src/objects/objects.cc b/src/objects/objects.cc +index a7e1833f730e6e5869cd4925cca6dc908859000c..4a90a9ba970bffc78e38cad6e9e7e9053466a138 100644 +--- a/src/objects/objects.cc ++++ b/src/objects/objects.cc +@@ -4448,10 +4448,12 @@ void DescriptorArray::Replace(InternalIndex index, Descriptor* descriptor) { + // static + void DescriptorArray::InitializeOrChangeEnumCache( + Handle descriptors, Isolate* isolate, +- Handle keys, Handle indices) { ++ Handle keys, Handle indices, ++ AllocationType allocation_if_initialize) { + EnumCache enum_cache = descriptors->enum_cache(); + if (enum_cache == ReadOnlyRoots(isolate).empty_enum_cache()) { +- enum_cache = *isolate->factory()->NewEnumCache(keys, indices); ++ enum_cache = *isolate->factory()->NewEnumCache(keys, indices, ++ allocation_if_initialize); + descriptors->set_enum_cache(enum_cache); + } else { + enum_cache.set_keys(*keys); +diff --git a/test/mjsunit/shared-memory/shared-struct-surface.js b/test/mjsunit/shared-memory/shared-struct-surface.js +index 55a08ccec2a56ee9c0df5fa9a778fe22d6e7e1fb..301a8a114df16262d3ce1e228f951eb911593116 100644 +--- a/test/mjsunit/shared-memory/shared-struct-surface.js ++++ b/test/mjsunit/shared-memory/shared-struct-surface.js +@@ -76,3 +76,15 @@ let S = new SharedStructType(['field']); + assertEquals(1, entries.length); + assertArrayEquals(['field', 42], entries[0]); + })(); ++ ++(function TestForIn() { ++ let fieldNames = []; ++ for (let i = 0; i < 512; i++) { ++ fieldNames.push('field' + i); ++ } ++ let S2 = new SharedStructType(fieldNames); ++ let s = new S2(); ++ let propNames = []; ++ for (let prop in s) propNames.push(prop); ++ assertArrayEquals(propNames, fieldNames); ++})(); From b58903d195908d3a7534cbf4fc28771bde582cde Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Tue, 5 Sep 2023 09:16:31 +0100 Subject: [PATCH 164/172] chore: cherry-pick 1 changes from Release-2-M116 (#39689) * chore: [22-x-y] cherry-pick 1 changes from Release-2-M116 * 35c06406a658 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-35c06406a658.patch | 162 ++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 patches/chromium/cherry-pick-35c06406a658.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 1dbbe3436139f..258b2b941b70a 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -171,3 +171,4 @@ cherry-pick-b03973561862.patch cherry-pick-c60a1ab717c7.patch networkcontext_don_t_access_url_loader_factories_during_destruction.patch don_t_keep_pointer_to_popped_stack_memory_for_has.patch +cherry-pick-35c06406a658.patch diff --git a/patches/chromium/cherry-pick-35c06406a658.patch b/patches/chromium/cherry-pick-35c06406a658.patch new file mode 100644 index 0000000000000..e901fdea6fae8 --- /dev/null +++ b/patches/chromium/cherry-pick-35c06406a658.patch @@ -0,0 +1,162 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Guido Urdaneta +Date: Thu, 24 Aug 2023 11:12:43 +0000 +Subject: Handle object destruction in MediaStreamDeviceObserver + +MSDO executes some callbacks that can result in the destruction of +MSDO upon an external event such as removing a media device or the +user revoking permission. +This CL adds code to detect this condition and prevent further +processing that would result in UAF. It also removes some invalid +DCHECKs. + +Drive-by: minor style fixes + +(cherry picked from commit 7337133682ab0404b753c563dde2ae2b1dc13171) + +Bug: 1472492, b/296997707 +Change-Id: I76f019bb110e7d9cca276444bc23a7e43114d2cc +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4798398 +Reviewed-by: Palak Agarwal +Commit-Queue: Guido Urdaneta +Cr-Original-Commit-Position: refs/heads/main@{#1186452} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4810035 +Bot-Commit: Rubber Stamper +Cr-Commit-Position: refs/branch-heads/5845@{#1586} +Cr-Branched-From: 5a5dff63a4a4c63b9b18589819bebb2566c85443-refs/heads/main@{#1160321} + +diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.cc b/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.cc +index c553b70b3b3be78a1d6636037009210bc280e02e..ece0caa8dbeaadf8f2a78bfb5c76e6db6023f1b5 100644 +--- a/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.cc ++++ b/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.cc +@@ -37,11 +37,11 @@ MediaStreamDeviceObserver::MediaStreamDeviceObserver(LocalFrame* frame) { + if (frame) { + frame->GetInterfaceRegistry()->AddInterface(WTF::BindRepeating( + &MediaStreamDeviceObserver::BindMediaStreamDeviceObserverReceiver, +- WTF::Unretained(this))); ++ weak_factory_.GetWeakPtr())); + } + } + +-MediaStreamDeviceObserver::~MediaStreamDeviceObserver() {} ++MediaStreamDeviceObserver::~MediaStreamDeviceObserver() = default; + + MediaStreamDevices MediaStreamDeviceObserver::GetNonScreenCaptureDevices() { + MediaStreamDevices video_devices; +@@ -70,13 +70,21 @@ void MediaStreamDeviceObserver::OnDeviceStopped( + } + + for (Stream& stream : it->value) { +- if (IsAudioInputMediaType(device.type)) ++ if (IsAudioInputMediaType(device.type)) { + RemoveStreamDeviceFromArray(device, &stream.audio_devices); +- else ++ } else { + RemoveStreamDeviceFromArray(device, &stream.video_devices); +- +- if (stream.on_device_stopped_cb) ++ } ++ if (stream.on_device_stopped_cb) { ++ // Running `stream.on_device_stopped_cb` can destroy `this`. Use a weak ++ // pointer to detect that condition, and stop processing if it happens. ++ base::WeakPtr weak_this = ++ weak_factory_.GetWeakPtr(); + stream.on_device_stopped_cb.Run(device); ++ if (!weak_this) { ++ return; ++ } ++ } + } + + // |it| could have already been invalidated in the function call above. So we +@@ -85,8 +93,9 @@ void MediaStreamDeviceObserver::OnDeviceStopped( + // iterator from |label_stream_map_| (https://crbug.com/616884). Future work + // needs to be done to resolve this re-entrancy issue. + it = label_stream_map_.find(label); +- if (it == label_stream_map_.end()) ++ if (it == label_stream_map_.end()) { + return; ++ } + + Vector& streams = it->value; + auto* stream_it = streams.begin(); +@@ -122,8 +131,16 @@ void MediaStreamDeviceObserver::OnDeviceChanged( + DCHECK_EQ(1u, it->value.size()); + + Stream* stream = &it->value[0]; +- if (stream->on_device_changed_cb) ++ if (stream->on_device_changed_cb) { ++ // Running `stream->on_device_changed_cb` can destroy `this`. Use a weak ++ // pointer to detect that condition, and stop processing if it happens. ++ base::WeakPtr weak_this = ++ weak_factory_.GetWeakPtr(); + stream->on_device_changed_cb.Run(old_device, new_device); ++ if (!weak_this) { ++ return; ++ } ++ } + + // Update device list only for device changing. Removing device will be + // handled in its own callback. +@@ -278,9 +295,9 @@ void MediaStreamDeviceObserver::RemoveStreamDevice( + streams_to_remove.push_back(entry.key); + } + } +- DCHECK(device_found); +- for (const String& label : streams_to_remove) ++ for (const String& label : streams_to_remove) { + label_stream_map_.erase(label); ++ } + } + + base::UnguessableToken MediaStreamDeviceObserver::GetAudioSessionId( +diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.h b/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.h +index 55aba2c4e5bd046a008590436ed8eefa4f099d5c..c5a8b5b1e31011f5d2f9f2064cabb10a74c25bf7 100644 +--- a/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.h ++++ b/third_party/blink/renderer/modules/mediastream/media_stream_device_observer.h +@@ -116,6 +116,7 @@ class MODULES_EXPORT MediaStreamDeviceObserver + + using LabelStreamMap = HashMap>; + LabelStreamMap label_stream_map_; ++ base::WeakPtrFactory weak_factory_{this}; + }; + + } // namespace blink +diff --git a/third_party/blink/renderer/platform/exported/mediastream/web_platform_media_stream_source.cc b/third_party/blink/renderer/platform/exported/mediastream/web_platform_media_stream_source.cc +index be69e8c9741faf0728022ff1cc89ccf8d89a0629..b9f5e9c86537dace6f42e4c92ac255990eb910f7 100644 +--- a/third_party/blink/renderer/platform/exported/mediastream/web_platform_media_stream_source.cc ++++ b/third_party/blink/renderer/platform/exported/mediastream/web_platform_media_stream_source.cc +@@ -31,10 +31,12 @@ void WebPlatformMediaStreamSource::StopSource() { + + void WebPlatformMediaStreamSource::FinalizeStopSource() { + DCHECK(task_runner_->BelongsToCurrentThread()); +- if (!stop_callback_.is_null()) ++ if (!stop_callback_.is_null()) { + std::move(stop_callback_).Run(Owner()); +- if (Owner()) ++ } ++ if (Owner()) { + Owner().SetReadyState(WebMediaStreamSource::kReadyStateEnded); ++ } + } + + void WebPlatformMediaStreamSource::SetSourceMuted(bool is_muted) { +@@ -42,8 +44,9 @@ void WebPlatformMediaStreamSource::SetSourceMuted(bool is_muted) { + // Although this change is valid only if the ready state isn't already Ended, + // there's code further along (like in MediaStreamTrack) which filters + // that out already. +- if (!Owner()) ++ if (!Owner()) { + return; ++ } + Owner().SetReadyState(is_muted ? WebMediaStreamSource::kReadyStateMuted + : WebMediaStreamSource::kReadyStateLive); + } +@@ -72,7 +75,6 @@ void WebPlatformMediaStreamSource::SetStopCallback( + + void WebPlatformMediaStreamSource::ResetSourceStoppedCallback() { + DCHECK(task_runner_->BelongsToCurrentThread()); +- DCHECK(!stop_callback_.is_null()); + stop_callback_.Reset(); + } + From e29cdacb1309ffe175c13756fdc68e003af2a6b4 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:09:18 -0400 Subject: [PATCH 165/172] build: fix depot_tools patch application (#39751) build: fix depot_tools patch application (cherry picked from commit 34b79c15c2f2de2fa514538b7ccb4b3c473808ae) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- .circleci/config/base.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index a8f844352ad99..11b0373eab039 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -245,19 +245,19 @@ step-depot-tools-get: &step-depot-tools-get cd depot_tools cat > gclient.diff \<< 'EOF' diff --git a/gclient.py b/gclient.py - index 3a9c5c6..f222043 100755 + index c305c248..e6e0fbdc 100755 --- a/gclient.py +++ b/gclient.py - @@ -712,7 +712,8 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): - - if dep_type == 'cipd': - cipd_root = self.GetCipdRoot() - - for package in dep_value.get('packages', []): - + packages = dep_value.get('packages', []) - + for package in (x for x in packages if "infra/3pp/tools/swift-format" not in x.get('package')): - deps_to_add.append( - CipdDependency( - parent=self, + @@ -735,7 +735,8 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): + + if dep_type == 'cipd': + cipd_root = self.GetCipdRoot() + - for package in dep_value.get('packages', []): + + packages = dep_value.get('packages', []) + + for package in (x for x in packages if "infra/3pp/tools/swift-format" not in x.get('package')): + deps_to_add.append( + CipdDependency(parent=self, + name=name, EOF git apply --3way gclient.diff fi From 4995c9ee97513f30ada0734454c3c0a2b763f3bc Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Mon, 11 Sep 2023 18:05:12 +0100 Subject: [PATCH 166/172] chore: cherry-pick 1 changes from Release-3-M116 (#39758) chore: [22-x-y] cherry-pick 1 changes from Release-3-M116 * 038530c94a06 from v8 --- patches/v8/.patches | 1 + patches/v8/cherry-pick-038530c94a06.patch | 49 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 patches/v8/cherry-pick-038530c94a06.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 24993535eefc4..c63a77fef8ec9 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -30,3 +30,4 @@ merged_builtins_clear_fixedarray_slot_in_promise_builtins.patch merged_compiler_check_for_read-only_property_on.patch shared-struct_fix_for-in_enumeration.patch merged_squashed_multiple_commits.patch +cherry-pick-038530c94a06.patch diff --git a/patches/v8/cherry-pick-038530c94a06.patch b/patches/v8/cherry-pick-038530c94a06.patch new file mode 100644 index 0000000000000..9cc9a9bbf4093 --- /dev/null +++ b/patches/v8/cherry-pick-038530c94a06.patch @@ -0,0 +1,49 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tobias Tebbi +Date: Wed, 30 Aug 2023 10:59:48 +0200 +Subject: Merged: [turbofan] Growing a non-JSArray packed elements kind makes + it holey + +Bug: chromium:1473247 +(cherry picked from commit ae7dc61652805bc8e2b060d53b2b6da7cf846b6f) + +Change-Id: I5268513bc91ca0cc18e3e2115244c0b090afa0da +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4831892 +Auto-Submit: Leszek Swirski +Owners-Override: Leszek Swirski +Commit-Queue: Darius Mercadier +Reviewed-by: Darius Mercadier +Commit-Queue: Leszek Swirski +Cr-Commit-Position: refs/branch-heads/11.6@{#34} +Cr-Branched-From: e29c028f391389a7a60ee37097e3ca9e396d6fa4-refs/heads/11.6.189@{#3} +Cr-Branched-From: 95cbef20e2aa556a1ea75431a48b36c4de6b9934-refs/heads/main@{#88340} + +diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc +index 31b6d2dd0944a4d541947c773b175f86d24c86f6..72d97098c60e78b53cfa2356eabdc54f3eafc133 100644 +--- a/src/compiler/js-native-context-specialization.cc ++++ b/src/compiler/js-native-context-specialization.cc +@@ -3628,15 +3628,21 @@ JSNativeContextSpecialization::BuildElementAccess( + // the (potential) backing store growth would normalize and thus + // the elements kind of the {receiver} would change to slow mode. + // +- // For PACKED_*_ELEMENTS the {index} must be within the range ++ // For JSArray PACKED_*_ELEMENTS the {index} must be within the range + // [0,length+1[ to be valid. In case {index} equals {length}, + // the {receiver} will be extended, but kept packed. ++ // ++ // Non-JSArray PACKED_*_ELEMENTS always grow by adding holes because they ++ // lack the magical length property, which requires a map transition. ++ // So we can assume that this did not happen if we did not see this map. + Node* limit = + IsHoleyElementsKind(elements_kind) + ? graph()->NewNode(simplified()->NumberAdd(), elements_length, + jsgraph()->Constant(JSObject::kMaxGap)) +- : graph()->NewNode(simplified()->NumberAdd(), length, +- jsgraph()->OneConstant()); ++ : receiver_is_jsarray ++ ? graph()->NewNode(simplified()->NumberAdd(), length, ++ jsgraph()->OneConstant()) ++ : elements_length; + index = effect = graph()->NewNode( + simplified()->CheckBounds( + FeedbackSource(), CheckBoundsFlag::kConvertStringAndMinusZero), From 5f8ef8127732c181b090d389bead76bae384b761 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:12:58 -0700 Subject: [PATCH 167/172] fix: ensure app load is limited to real asar files when appropriate (#39811) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard --- lib/asar/fs-wrapper.ts | 4 +++- lib/browser/init.ts | 9 +++++++++ shell/common/node_bindings.cc | 7 +++++++ typings/internal-ambient.d.ts | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/asar/fs-wrapper.ts b/lib/asar/fs-wrapper.ts index 2059dc447fe54..30322482fc26f 100644 --- a/lib/asar/fs-wrapper.ts +++ b/lib/asar/fs-wrapper.ts @@ -27,7 +27,7 @@ const cachedArchives = new Map(); const getOrCreateArchive = (archivePath: string) => { const isCached = cachedArchives.has(archivePath); if (isCached) { - return cachedArchives.get(archivePath); + return cachedArchives.get(archivePath)!; } try { @@ -39,6 +39,8 @@ const getOrCreateArchive = (archivePath: string) => { } }; +process._getOrCreateArchive = getOrCreateArchive; + const asarRe = /\.asar/i; // Separate asar package's path from full path. diff --git a/lib/browser/init.ts b/lib/browser/init.ts index db29322a5e6dd..d2331dcc0eafe 100644 --- a/lib/browser/init.ts +++ b/lib/browser/init.ts @@ -84,11 +84,20 @@ const v8Util = process._linkedBinding('electron_common_v8_util'); let packagePath = null; let packageJson = null; const searchPaths: string[] = v8Util.getHiddenValue(global, 'appSearchPaths'); +const searchPathsOnlyLoadASAR: boolean = v8Util.getHiddenValue(global, 'appSearchPathsOnlyLoadASAR'); +// Borrow the _getOrCreateArchive asar helper +const getOrCreateArchive = process._getOrCreateArchive; +delete process._getOrCreateArchive; if (process.resourcesPath) { for (packagePath of searchPaths) { try { packagePath = path.join(process.resourcesPath, packagePath); + if (searchPathsOnlyLoadASAR) { + if (!getOrCreateArchive?.(packagePath)) { + continue; + } + } packageJson = Module._load(path.join(packagePath, 'package.json')); break; } catch { diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 6cb2c3956ba3e..ed8cc4d89e092 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -521,6 +521,13 @@ node::Environment* NodeBindings::CreateEnvironment( electron::fuses::IsOnlyLoadAppFromAsarEnabled() ? app_asar_search_paths : search_paths)); + context->Global()->SetPrivate( + context, + v8::Private::ForApi( + isolate, gin::ConvertToV8(isolate, "appSearchPathsOnlyLoadASAR") + .As()), + gin::ConvertToV8(isolate, + electron::fuses::IsOnlyLoadAppFromAsarEnabled())); } base::FilePath resources_path = GetResourcesPath(); diff --git a/typings/internal-ambient.d.ts b/typings/internal-ambient.d.ts index d972d03eda129..5bf421231574e 100644 --- a/typings/internal-ambient.d.ts +++ b/typings/internal-ambient.d.ts @@ -252,6 +252,7 @@ declare namespace NodeJS { // Additional properties _firstFileName?: string; _serviceStartupScript: string; + _getOrCreateArchive?: (path: string) => NodeJS.AsarArchive | null; helperExecPath: string; mainModule?: NodeJS.Module | undefined; From 056eacf1ce34c27db00df7bc21aa83a779b8a2d9 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 12 Sep 2023 11:44:10 -0700 Subject: [PATCH 168/172] chore: cherry-pick b2eab7500a18 from chromium (#39827) * chore: cherry-pick b2eab7500a18 from chromium * chore: update patches --------- Co-authored-by: John Kleinschmidt --- patches/config.json | 4 +- patches/libwebp/.patches | 1 + .../fix_oob_write_in_buildhuffmantable.patch | 353 ++++++++++++++++++ 3 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 patches/libwebp/.patches create mode 100644 patches/libwebp/fix_oob_write_in_buildhuffmantable.patch diff --git a/patches/config.json b/patches/config.json index e991ec3fea008..5a4f6a25b4e16 100644 --- a/patches/config.json +++ b/patches/config.json @@ -29,5 +29,7 @@ "src/electron/patches/dawn": "src/third_party/dawn", - "src/electron/patches/webrtc": "src/third_party/webrtc" + "src/electron/patches/webrtc": "src/third_party/webrtc", + + "src/electron/patches/libwebp": "src/third_party/libwebp/src" } diff --git a/patches/libwebp/.patches b/patches/libwebp/.patches new file mode 100644 index 0000000000000..8ed3324dfea36 --- /dev/null +++ b/patches/libwebp/.patches @@ -0,0 +1 @@ +fix_oob_write_in_buildhuffmantable.patch diff --git a/patches/libwebp/fix_oob_write_in_buildhuffmantable.patch b/patches/libwebp/fix_oob_write_in_buildhuffmantable.patch new file mode 100644 index 0000000000000..98b751c5b448d --- /dev/null +++ b/patches/libwebp/fix_oob_write_in_buildhuffmantable.patch @@ -0,0 +1,353 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Vincent Rabaud +Date: Thu, 7 Sep 2023 21:16:03 +0200 +Subject: Fix OOB write in BuildHuffmanTable. + +First, BuildHuffmanTable is called to check if the data is valid. +If it is and the table is not big enough, more memory is allocated. + +This will make sure that valid (but unoptimized because of unbalanced +codes) streams are still decodable. + +Bug: chromium:1479274 +Change-Id: I31c36dbf3aa78d35ecf38706b50464fd3d375741 +(cherry picked from commit 902bc9190331343b2017211debcec8d2ab87e17a) +(cherry picked from commit 2af26267cdfcb63a88e5c74a85927a12d6ca1d76) + +diff --git a/src/dec/vp8l_dec.c b/src/dec/vp8l_dec.c +index 13480551282eca71560641a68c632e13acd3cd79..186b0b2f826a17a4889299a90a068725d06be4f3 100644 +--- a/src/dec/vp8l_dec.c ++++ b/src/dec/vp8l_dec.c +@@ -253,11 +253,11 @@ static int ReadHuffmanCodeLengths( + int symbol; + int max_symbol; + int prev_code_len = DEFAULT_CODE_LENGTH; +- HuffmanCode table[1 << LENGTHS_TABLE_BITS]; ++ HuffmanTables tables; + +- if (!VP8LBuildHuffmanTable(table, LENGTHS_TABLE_BITS, +- code_length_code_lengths, +- NUM_CODE_LENGTH_CODES)) { ++ if (!VP8LHuffmanTablesAllocate(1 << LENGTHS_TABLE_BITS, &tables) || ++ !VP8LBuildHuffmanTable(&tables, LENGTHS_TABLE_BITS, ++ code_length_code_lengths, NUM_CODE_LENGTH_CODES)) { + goto End; + } + +@@ -277,7 +277,7 @@ static int ReadHuffmanCodeLengths( + int code_len; + if (max_symbol-- == 0) break; + VP8LFillBitWindow(br); +- p = &table[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK]; ++ p = &tables.curr_segment->start[VP8LPrefetchBits(br) & LENGTHS_TABLE_MASK]; + VP8LSetBitPos(br, br->bit_pos_ + p->bits); + code_len = p->value; + if (code_len < kCodeLengthLiterals) { +@@ -300,6 +300,7 @@ static int ReadHuffmanCodeLengths( + ok = 1; + + End: ++ VP8LHuffmanTablesDeallocate(&tables); + if (!ok) dec->status_ = VP8_STATUS_BITSTREAM_ERROR; + return ok; + } +@@ -307,7 +308,8 @@ static int ReadHuffmanCodeLengths( + // 'code_lengths' is pre-allocated temporary buffer, used for creating Huffman + // tree. + static int ReadHuffmanCode(int alphabet_size, VP8LDecoder* const dec, +- int* const code_lengths, HuffmanCode* const table) { ++ int* const code_lengths, ++ HuffmanTables* const table) { + int ok = 0; + int size = 0; + VP8LBitReader* const br = &dec->br_; +@@ -362,8 +364,7 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, + VP8LMetadata* const hdr = &dec->hdr_; + uint32_t* huffman_image = NULL; + HTreeGroup* htree_groups = NULL; +- HuffmanCode* huffman_tables = NULL; +- HuffmanCode* huffman_table = NULL; ++ HuffmanTables* huffman_tables = &hdr->huffman_tables_; + int num_htree_groups = 1; + int num_htree_groups_max = 1; + int max_alphabet_size = 0; +@@ -372,6 +373,10 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, + int* mapping = NULL; + int ok = 0; + ++ // Check the table has been 0 initialized (through InitMetadata). ++ assert(huffman_tables->root.start == NULL); ++ assert(huffman_tables->curr_segment == NULL); ++ + if (allow_recursion && VP8LReadBits(br, 1)) { + // use meta Huffman codes. + const int huffman_precision = VP8LReadBits(br, 3) + 2; +@@ -434,16 +439,15 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, + + code_lengths = (int*)WebPSafeCalloc((uint64_t)max_alphabet_size, + sizeof(*code_lengths)); +- huffman_tables = (HuffmanCode*)WebPSafeMalloc(num_htree_groups * table_size, +- sizeof(*huffman_tables)); + htree_groups = VP8LHtreeGroupsNew(num_htree_groups); + +- if (htree_groups == NULL || code_lengths == NULL || huffman_tables == NULL) { ++ if (htree_groups == NULL || code_lengths == NULL || ++ !VP8LHuffmanTablesAllocate(num_htree_groups * table_size, ++ huffman_tables)) { + dec->status_ = VP8_STATUS_OUT_OF_MEMORY; + goto Error; + } + +- huffman_table = huffman_tables; + for (i = 0; i < num_htree_groups_max; ++i) { + // If the index "i" is unused in the Huffman image, just make sure the + // coefficients are valid but do not store them. +@@ -468,19 +472,20 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, + int max_bits = 0; + for (j = 0; j < HUFFMAN_CODES_PER_META_CODE; ++j) { + int alphabet_size = kAlphabetSize[j]; +- htrees[j] = huffman_table; + if (j == 0 && color_cache_bits > 0) { + alphabet_size += (1 << color_cache_bits); + } +- size = ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_table); ++ size = ++ ReadHuffmanCode(alphabet_size, dec, code_lengths, huffman_tables); ++ htrees[j] = huffman_tables->curr_segment->curr_table; + if (size == 0) { + goto Error; + } + if (is_trivial_literal && kLiteralMap[j] == 1) { +- is_trivial_literal = (huffman_table->bits == 0); ++ is_trivial_literal = (htrees[j]->bits == 0); + } +- total_size += huffman_table->bits; +- huffman_table += size; ++ total_size += htrees[j]->bits; ++ huffman_tables->curr_segment->curr_table += size; + if (j <= ALPHA) { + int local_max_bits = code_lengths[0]; + int k; +@@ -515,14 +520,13 @@ static int ReadHuffmanCodes(VP8LDecoder* const dec, int xsize, int ysize, + hdr->huffman_image_ = huffman_image; + hdr->num_htree_groups_ = num_htree_groups; + hdr->htree_groups_ = htree_groups; +- hdr->huffman_tables_ = huffman_tables; + + Error: + WebPSafeFree(code_lengths); + WebPSafeFree(mapping); + if (!ok) { + WebPSafeFree(huffman_image); +- WebPSafeFree(huffman_tables); ++ VP8LHuffmanTablesDeallocate(huffman_tables); + VP8LHtreeGroupsFree(htree_groups); + } + return ok; +@@ -1358,7 +1362,7 @@ static void ClearMetadata(VP8LMetadata* const hdr) { + assert(hdr != NULL); + + WebPSafeFree(hdr->huffman_image_); +- WebPSafeFree(hdr->huffman_tables_); ++ VP8LHuffmanTablesDeallocate(&hdr->huffman_tables_); + VP8LHtreeGroupsFree(hdr->htree_groups_); + VP8LColorCacheClear(&hdr->color_cache_); + VP8LColorCacheClear(&hdr->saved_color_cache_); +@@ -1673,7 +1677,7 @@ int VP8LDecodeImage(VP8LDecoder* const dec) { + + if (dec == NULL) return 0; + +- assert(dec->hdr_.huffman_tables_ != NULL); ++ assert(dec->hdr_.huffman_tables_.root.start != NULL); + assert(dec->hdr_.htree_groups_ != NULL); + assert(dec->hdr_.num_htree_groups_ > 0); + +diff --git a/src/dec/vp8li_dec.h b/src/dec/vp8li_dec.h +index 72b2e861208447f45e5ee12eac57b9c36ff2cd31..32540a4b88a05cc74b88f11da3f143e83be81c9c 100644 +--- a/src/dec/vp8li_dec.h ++++ b/src/dec/vp8li_dec.h +@@ -51,7 +51,7 @@ typedef struct { + uint32_t* huffman_image_; + int num_htree_groups_; + HTreeGroup* htree_groups_; +- HuffmanCode* huffman_tables_; ++ HuffmanTables huffman_tables_; + } VP8LMetadata; + + typedef struct VP8LDecoder VP8LDecoder; +diff --git a/src/utils/huffman_utils.c b/src/utils/huffman_utils.c +index 0cba0fbb7d4f3a945cf9f9909a3e4c1b96ec92da..9efd6283ac30210fb7450250f855cbd1d75f55ec 100644 +--- a/src/utils/huffman_utils.c ++++ b/src/utils/huffman_utils.c +@@ -177,21 +177,24 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits, + if (num_open < 0) { + return 0; + } +- if (root_table == NULL) continue; + for (; count[len] > 0; --count[len]) { + HuffmanCode code; + if ((key & mask) != low) { +- table += table_size; ++ if (root_table != NULL) table += table_size; + table_bits = NextTableBitSize(count, len, root_bits); + table_size = 1 << table_bits; + total_size += table_size; + low = key & mask; +- root_table[low].bits = (uint8_t)(table_bits + root_bits); +- root_table[low].value = (uint16_t)((table - root_table) - low); ++ if (root_table != NULL) { ++ root_table[low].bits = (uint8_t)(table_bits + root_bits); ++ root_table[low].value = (uint16_t)((table - root_table) - low); ++ } ++ } ++ if (root_table != NULL) { ++ code.bits = (uint8_t)(len - root_bits); ++ code.value = (uint16_t)sorted[symbol++]; ++ ReplicateValue(&table[key >> root_bits], step, table_size, code); + } +- code.bits = (uint8_t)(len - root_bits); +- code.value = (uint16_t)sorted[symbol++]; +- ReplicateValue(&table[key >> root_bits], step, table_size, code); + key = GetNextKey(key, len); + } + } +@@ -211,25 +214,83 @@ static int BuildHuffmanTable(HuffmanCode* const root_table, int root_bits, + ((1 << MAX_CACHE_BITS) + NUM_LITERAL_CODES + NUM_LENGTH_CODES) + // Cut-off value for switching between heap and stack allocation. + #define SORTED_SIZE_CUTOFF 512 +-int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits, ++int VP8LBuildHuffmanTable(HuffmanTables* const root_table, int root_bits, + const int code_lengths[], int code_lengths_size) { +- int total_size; ++ const int total_size = ++ BuildHuffmanTable(NULL, root_bits, code_lengths, code_lengths_size, NULL); + assert(code_lengths_size <= MAX_CODE_LENGTHS_SIZE); +- if (root_table == NULL) { +- total_size = BuildHuffmanTable(NULL, root_bits, +- code_lengths, code_lengths_size, NULL); +- } else if (code_lengths_size <= SORTED_SIZE_CUTOFF) { ++ if (total_size == 0 || root_table == NULL) return total_size; ++ ++ if (root_table->curr_segment->curr_table + total_size >= ++ root_table->curr_segment->start + root_table->curr_segment->size) { ++ // If 'root_table' does not have enough memory, allocate a new segment. ++ // The available part of root_table->curr_segment is left unused because we ++ // need a contiguous buffer. ++ const int segment_size = root_table->curr_segment->size; ++ struct HuffmanTablesSegment* next = ++ (HuffmanTablesSegment*)WebPSafeMalloc(1, sizeof(*next)); ++ if (next == NULL) return 0; ++ // Fill the new segment. ++ // We need at least 'total_size' but if that value is small, it is better to ++ // allocate a big chunk to prevent more allocations later. 'segment_size' is ++ // therefore chosen (any other arbitrary value could be chosen). ++ next->size = total_size > segment_size ? total_size : segment_size; ++ next->start = ++ (HuffmanCode*)WebPSafeMalloc(next->size, sizeof(*next->start)); ++ if (next->start == NULL) { ++ WebPSafeFree(next); ++ return 0; ++ } ++ next->curr_table = next->start; ++ next->next = NULL; ++ // Point to the new segment. ++ root_table->curr_segment->next = next; ++ root_table->curr_segment = next; ++ } ++ if (code_lengths_size <= SORTED_SIZE_CUTOFF) { + // use local stack-allocated array. + uint16_t sorted[SORTED_SIZE_CUTOFF]; +- total_size = BuildHuffmanTable(root_table, root_bits, +- code_lengths, code_lengths_size, sorted); +- } else { // rare case. Use heap allocation. ++ BuildHuffmanTable(root_table->curr_segment->curr_table, root_bits, ++ code_lengths, code_lengths_size, sorted); ++ } else { // rare case. Use heap allocation. + uint16_t* const sorted = + (uint16_t*)WebPSafeMalloc(code_lengths_size, sizeof(*sorted)); + if (sorted == NULL) return 0; +- total_size = BuildHuffmanTable(root_table, root_bits, +- code_lengths, code_lengths_size, sorted); ++ BuildHuffmanTable(root_table->curr_segment->curr_table, root_bits, ++ code_lengths, code_lengths_size, sorted); + WebPSafeFree(sorted); + } + return total_size; + } ++ ++int VP8LHuffmanTablesAllocate(int size, HuffmanTables* huffman_tables) { ++ // Have 'segment' point to the first segment for now, 'root'. ++ HuffmanTablesSegment* const root = &huffman_tables->root; ++ huffman_tables->curr_segment = root; ++ // Allocate root. ++ root->start = (HuffmanCode*)WebPSafeMalloc(size, sizeof(*root->start)); ++ if (root->start == NULL) return 0; ++ root->curr_table = root->start; ++ root->next = NULL; ++ root->size = size; ++ return 1; ++} ++ ++void VP8LHuffmanTablesDeallocate(HuffmanTables* const huffman_tables) { ++ HuffmanTablesSegment *current, *next; ++ if (huffman_tables == NULL) return; ++ // Free the root node. ++ current = &huffman_tables->root; ++ next = current->next; ++ WebPSafeFree(current->start); ++ current->start = NULL; ++ current->next = NULL; ++ current = next; ++ // Free the following nodes. ++ while (current != NULL) { ++ next = current->next; ++ WebPSafeFree(current->start); ++ WebPSafeFree(current); ++ current = next; ++ } ++} +diff --git a/src/utils/huffman_utils.h b/src/utils/huffman_utils.h +index 13b7ad1ac40c5316f5506d9b4cbf5039c9fd5600..98415c532895374ea28fc1dc5c9a15c751ea9ba0 100644 +--- a/src/utils/huffman_utils.h ++++ b/src/utils/huffman_utils.h +@@ -43,6 +43,29 @@ typedef struct { + // or non-literal symbol otherwise + } HuffmanCode32; + ++// Contiguous memory segment of HuffmanCodes. ++typedef struct HuffmanTablesSegment { ++ HuffmanCode* start; ++ // Pointer to where we are writing into the segment. Starts at 'start' and ++ // cannot go beyond 'start' + 'size'. ++ HuffmanCode* curr_table; ++ // Pointer to the next segment in the chain. ++ struct HuffmanTablesSegment* next; ++ int size; ++} HuffmanTablesSegment; ++ ++// Chained memory segments of HuffmanCodes. ++typedef struct HuffmanTables { ++ HuffmanTablesSegment root; ++ // Currently processed segment. At first, this is 'root'. ++ HuffmanTablesSegment* curr_segment; ++} HuffmanTables; ++ ++// Allocates a HuffmanTables with 'size' contiguous HuffmanCodes. Returns 0 on ++// memory allocation error, 1 otherwise. ++int VP8LHuffmanTablesAllocate(int size, HuffmanTables* huffman_tables); ++void VP8LHuffmanTablesDeallocate(HuffmanTables* const huffman_tables); ++ + #define HUFFMAN_PACKED_BITS 6 + #define HUFFMAN_PACKED_TABLE_SIZE (1u << HUFFMAN_PACKED_BITS) + +@@ -78,9 +101,7 @@ void VP8LHtreeGroupsFree(HTreeGroup* const htree_groups); + // the huffman table. + // Returns built table size or 0 in case of error (invalid tree or + // memory error). +-// If root_table is NULL, it returns 0 if a lookup cannot be built, something +-// > 0 otherwise (but not the table size). +-int VP8LBuildHuffmanTable(HuffmanCode* const root_table, int root_bits, ++int VP8LBuildHuffmanTable(HuffmanTables* const root_table, int root_bits, + const int code_lengths[], int code_lengths_size); + + #ifdef __cplusplus From a953199af39a587ca510bbb6486f118ffa12fe8f Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 12 Sep 2023 16:52:15 -0700 Subject: [PATCH 169/172] build: use aks backed runners for linux builds (#39838) * build: use aks backed runners for linux builds (#39403) * build: test aks runner * build: stress test * build: use super-large nodes for publish jobs * build: try using aks for everything... * build: shared host not great * build: clean up * build: apparently tests dont run in kube infra? * build: do not change test size * ci: fixup known hosts for linux publish (#39437) * ci: fixup known hosts for linux publish * build: use 2023 known hosts * build: use rebuilt docker image * Revert "build: use rebuilt docker image" This reverts commit f9506a9cc04c1fa2ecf26436372f1bb2a44937a5. --------- Co-authored-by: Samuel Attard --------- Co-authored-by: John Kleinschmidt --- .circleci/config/base.yml | 19 +++++++++++-------- .circleci/fix-known-hosts.sh | 5 +++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 11b0373eab039..ae7cf695c9ba4 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -42,7 +42,9 @@ executors: size: description: "Docker executor size" type: enum - enum: ["medium", "xlarge", "2xlarge"] + # aks-linux-medium === 8 core (32 core host, shared with other builds) + # aks-linux-large === 32 core + enum: ["medium", "xlarge", "electronjs/aks-linux-medium", "electronjs/aks-linux-large"] docker: - image: ghcr.io/electron/build:e6bebd08a51a0d78ec23e5b3fd7e7c0846412328 resource_class: << parameters.size >> @@ -1481,6 +1483,7 @@ commands: - *step-minimize-workspace-size-from-checkout - *step-fix-sync - *step-setup-env-for-build + - *step-fix-known-hosts-linux - *step-setup-goma-for-build - *step-wait-for-goma - *step-gn-gen-default @@ -1586,7 +1589,7 @@ jobs: linux-x64-testing: executor: name: linux-docker - size: xlarge + size: electronjs/aks-linux-large environment: <<: *env-global <<: *env-testing-build @@ -1601,7 +1604,7 @@ jobs: linux-x64-testing-asan: executor: name: linux-docker - size: 2xlarge + size: electronjs/aks-linux-large environment: <<: *env-global <<: *env-testing-build @@ -1643,7 +1646,7 @@ jobs: linux-x64-publish: executor: name: linux-docker - size: 2xlarge + size: electronjs/aks-linux-large environment: <<: *env-linux-2xlarge-release <<: *env-release-build @@ -1665,7 +1668,7 @@ jobs: linux-arm-testing: executor: name: linux-docker - size: 2xlarge + size: electronjs/aks-linux-large environment: <<: *env-global <<: *env-arm @@ -1683,7 +1686,7 @@ jobs: linux-arm-publish: executor: name: linux-docker - size: 2xlarge + size: electronjs/aks-linux-large environment: <<: *env-linux-2xlarge-release <<: *env-arm @@ -1707,7 +1710,7 @@ jobs: linux-arm64-testing: executor: name: linux-docker - size: 2xlarge + size: electronjs/aks-linux-large environment: <<: *env-global <<: *env-arm64 @@ -1736,7 +1739,7 @@ jobs: linux-arm64-publish: executor: name: linux-docker - size: 2xlarge + size: electronjs/aks-linux-large environment: <<: *env-linux-2xlarge-release <<: *env-arm64 diff --git a/.circleci/fix-known-hosts.sh b/.circleci/fix-known-hosts.sh index d6d36e791ad5e..9820dbf5255f1 100755 --- a/.circleci/fix-known-hosts.sh +++ b/.circleci/fix-known-hosts.sh @@ -3,5 +3,6 @@ set -e mkdir -p ~/.ssh -echo "|1|B3r+7aO0/x90IdefihIjxIoJrrk=|OJddGDfhbuLFc1bUyy84hhIw57M= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== -|1|rGlEvW55DtzNZp+pzw9gvyOyKi4=|LLWr+7qlkAlw3YGGVfLHHxB/kR0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts +echo "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl +github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg= +github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=" >> ~/.ssh/known_hosts From 6132e80a4f109056ad303052341e2f278284eb67 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:55:16 -0400 Subject: [PATCH 170/172] build: run on circle hosts for forks (#39865) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard --- .circleci/config.yml | 3 +++ .circleci/config/base.yml | 23 ++++++++++++++--------- .circleci/config/params.js | 11 +++++++++++ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 .circleci/config/params.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 372018b9e2532..e6e1900a3058d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,6 +65,9 @@ jobs: curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=$CIRCLECI_BINARY bash node build.js name: Pack config.yml + - run: + name: Set params + command: node .circleci/config/params.js - continuation/continue: configuration_path: .circleci/config-staging/built.yml parameters: /tmp/pipeline-parameters.json diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index ae7cf695c9ba4..49038bb1e472d 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -34,6 +34,11 @@ parameters: type: enum default: all enum: ["all", "osx-x64", "osx-arm64", "mas-x64", "mas-arm64"] + + large-linux-executor: + type: enum + default: electronjs/aks-linux-large + enum: ["electronjs/aks-linux-large", "2xlarge"] # Executors executors: @@ -42,9 +47,9 @@ executors: size: description: "Docker executor size" type: enum - # aks-linux-medium === 8 core (32 core host, shared with other builds) # aks-linux-large === 32 core - enum: ["medium", "xlarge", "electronjs/aks-linux-medium", "electronjs/aks-linux-large"] + # 2xlarge should not be used directly, use the pipeline param instead + enum: ["medium", "xlarge", "electronjs/aks-linux-large", "2xlarge"] docker: - image: ghcr.io/electron/build:e6bebd08a51a0d78ec23e5b3fd7e7c0846412328 resource_class: << parameters.size >> @@ -1589,7 +1594,7 @@ jobs: linux-x64-testing: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-global <<: *env-testing-build @@ -1604,7 +1609,7 @@ jobs: linux-x64-testing-asan: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-global <<: *env-testing-build @@ -1646,7 +1651,7 @@ jobs: linux-x64-publish: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-linux-2xlarge-release <<: *env-release-build @@ -1668,7 +1673,7 @@ jobs: linux-arm-testing: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-global <<: *env-arm @@ -1686,7 +1691,7 @@ jobs: linux-arm-publish: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-linux-2xlarge-release <<: *env-arm @@ -1710,7 +1715,7 @@ jobs: linux-arm64-testing: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-global <<: *env-arm64 @@ -1739,7 +1744,7 @@ jobs: linux-arm64-publish: executor: name: linux-docker - size: electronjs/aks-linux-large + size: << pipeline.parameters.large-linux-executor >> environment: <<: *env-linux-2xlarge-release <<: *env-arm64 diff --git a/.circleci/config/params.js b/.circleci/config/params.js new file mode 100644 index 0000000000000..d214cfc93470b --- /dev/null +++ b/.circleci/config/params.js @@ -0,0 +1,11 @@ +const fs = require('fs'); + +const PARAMS_PATH = '/tmp/pipeline-parameters.json'; + +const content = JSON.parse(fs.readFileSync(PARAMS_PATH, 'utf-8')); + +// Choose resource class for linux hosts +const currentBranch = process.env.CIRCLE_BRANCH || ''; +content['large-linux-executor'] = /^pull\/[0-9-]+$/.test(currentBranch) ? '2xlarge' : 'electronjs/aks-linux-large'; + +fs.writeFileSync(PARAMS_PATH, JSON.stringify(content)); From d892c2b1c8e53e0ed9dc887989f0a9fe3239fe56 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:36:11 -0400 Subject: [PATCH 171/172] build: fixup autoninja (#39899) chore: set GOMA_DIR for autoninja (cherry picked from commit 94f24bde4dd19764fbbae083f5970b007c9dc8b2) (cherry picked from commit 90c1f6e1cb8d22d94dd01791dc4b9c3e0a7e86fc) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt --- .circleci/config/base.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 49038bb1e472d..9bfab60d07c1f 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -352,7 +352,7 @@ step-setup-goma-for-build: &step-setup-goma-for-build exit 1 fi echo 'export GN_GOMA_FILE='`node -e "console.log(require('./src/utils/goma.js').gnFilePath)"` >> $BASH_ENV - echo 'export LOCAL_GOMA_DIR='`node -e "console.log(require('./src/utils/goma.js').dir)"` >> $BASH_ENV + echo 'export GOMA_DIR='`node -e "console.log(require('./src/utils/goma.js').dir)"` >> $BASH_ENV echo 'export GOMA_FALLBACK_ON_AUTH_FAILURE=true' >> $BASH_ENV cd .. touch "${TMPDIR:=/tmp}"/.goma-ready @@ -781,8 +781,8 @@ step-show-goma-stats: &step-show-goma-stats command: | set +e set +o pipefail - $LOCAL_GOMA_DIR/goma_ctl.py stat - $LOCAL_GOMA_DIR/diagnose_goma_log.py + $GOMA_DIR/goma_ctl.py stat + $GOMA_DIR/diagnose_goma_log.py true when: always background: true From 1c1c13234f606f80b5684d4846f4ab52df4a9d28 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Thu, 28 Sep 2023 03:32:33 -0700 Subject: [PATCH 172/172] chore: cherry-pick 3fbd1dca6a4d from libvpx (#40026) * chore: cherry-pick 3fbd1dca6a4d from libvpx * build: update patches config * chore: update patches --- patches/config.json | 4 ++- patches/libvpx/.patches | 1 + patches/libvpx/cherry-pick-3fbd1dca6a4d.patch | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 patches/libvpx/.patches create mode 100644 patches/libvpx/cherry-pick-3fbd1dca6a4d.patch diff --git a/patches/config.json b/patches/config.json index 5a4f6a25b4e16..9c81622c958e5 100644 --- a/patches/config.json +++ b/patches/config.json @@ -31,5 +31,7 @@ "src/electron/patches/webrtc": "src/third_party/webrtc", - "src/electron/patches/libwebp": "src/third_party/libwebp/src" + "src/electron/patches/libwebp": "src/third_party/libwebp/src", + + "src/electron/patches/libvpx": "src/third_party/libvpx/source/libvpx" } diff --git a/patches/libvpx/.patches b/patches/libvpx/.patches new file mode 100644 index 0000000000000..f7f40d85ea71e --- /dev/null +++ b/patches/libvpx/.patches @@ -0,0 +1 @@ +cherry-pick-3fbd1dca6a4d.patch diff --git a/patches/libvpx/cherry-pick-3fbd1dca6a4d.patch b/patches/libvpx/cherry-pick-3fbd1dca6a4d.patch new file mode 100644 index 0000000000000..799bb5837897b --- /dev/null +++ b/patches/libvpx/cherry-pick-3fbd1dca6a4d.patch @@ -0,0 +1,27 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: James Zern +Date: Mon, 25 Sep 2023 18:55:59 -0700 +Subject: VP8: disallow thread count changes + +Currently allocations are done at encoder creation time. Going from +threaded to non-threaded would cause a crash. + +Bug: chromium:1486441 +Change-Id: Ie301c2a70847dff2f0daae408fbef1e4d42e73d4 + +diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c +index 94fb6e256e8f4f1077aa6e2aef84e3bc7070da0f..f68339d2b4f4b2ca654a835cc56c537fb5e7d260 100644 +--- a/vp8/encoder/onyx_if.c ++++ b/vp8/encoder/onyx_if.c +@@ -1443,6 +1443,11 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) { + last_h = cpi->oxcf.Height; + prev_number_of_layers = cpi->oxcf.number_of_layers; + ++ if (cpi->initial_width) { ++ // TODO(https://crbug.com/1486441): Allow changing thread counts; the ++ // allocation is done once in vp8_create_compressor(). ++ oxcf->multi_threaded = cpi->oxcf.multi_threaded; ++ } + cpi->oxcf = *oxcf; + + switch (cpi->oxcf.Mode) {