Skip to content

Commit d98bad5

Browse files
committed
misc: throw error when chrome 137 branded is used when the @cypress/puppeteeris used in headed mode or if --load-extension is added to launch options via a user testing an extension
empty commit to run ci
1 parent 8f8bb60 commit d98bad5

File tree

8 files changed

+62
-5
lines changed

8 files changed

+62
-5
lines changed

.circleci/workflows.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mainBuildFilters: &mainBuildFilters
3838
- /^release\/\d+\.\d+\.\d+$/
3939
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
4040
- 'update-v8-snapshot-cache-on-develop'
41-
- 'fix/top_framebust_window_location'
41+
- 'misc/throw_error_on_extension_chrome_137'
4242

4343
# usually we don't build Mac app - it takes a long time
4444
# but sometimes we want to really confirm we are doing the right thing
@@ -49,7 +49,7 @@ macWorkflowFilters: &darwin-workflow-filters
4949
- equal: [ develop, << pipeline.git.branch >> ]
5050
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
5151
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
52-
- equal: [ 'fix/top_framebust_window_location', << pipeline.git.branch >> ]
52+
- equal: [ 'misc/throw_error_on_extension_chrome_137', << pipeline.git.branch >> ]
5353
- matches:
5454
pattern: /^release\/\d+\.\d+\.\d+$/
5555
value: << pipeline.git.branch >>
@@ -60,7 +60,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
6060
- equal: [ develop, << pipeline.git.branch >> ]
6161
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
6262
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
63-
- equal: [ 'fix/top_framebust_window_location', << pipeline.git.branch >> ]
63+
- equal: [ 'misc/throw_error_on_extension_chrome_137', << pipeline.git.branch >> ]
6464
- matches:
6565
pattern: /^release\/\d+\.\d+\.\d+$/
6666
value: << pipeline.git.branch >>
@@ -83,7 +83,7 @@ windowsWorkflowFilters: &windows-workflow-filters
8383
- equal: [ develop, << pipeline.git.branch >> ]
8484
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
8585
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
86-
- equal: [ 'fix/top_framebust_window_location', << pipeline.git.branch >> ]
86+
- equal: [ 'misc/throw_error_on_extension_chrome_137', << pipeline.git.branch >> ]
8787
- matches:
8888
pattern: /^release\/\d+\.\d+\.\d+$/
8989
value: << pipeline.git.branch >>
@@ -157,7 +157,7 @@ commands:
157157
name: Set environment variable to determine whether or not to persist artifacts
158158
command: |
159159
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
160-
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "fix/top_framebust_window_location" ]]; then
160+
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "misc/throw_error_on_extension_chrome_137" ]]; then
161161
export SHOULD_PERSIST_ARTIFACTS=true
162162
fi' >> "$BASH_ENV"
163163
# You must run `setup_should_persist_artifacts` command and be using bash before running this command

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ _Released 5/20/2025 (PENDING)_
1515

1616
**Misc:**
1717

18+
- Chrome 137+ no longer supports `--load-extension` in branded Chrome, breaking the `@cypress/puppeteer` plugin in `open` mode and headed `run` mode and [`launchOptions.extensions`](https://docs.cypress.io/api/node-events/browser-launch-api#Add-browser-extensions). We recommend using Chrome for Testing or Chromium to continue using these features. See Cypress Docker image examples for [Chrome for Testing](https://github.com/cypress-io/cypress-docker-images/tree/master/examples/chrome-for-testing) and [Chromium](https://github.com/cypress-io/cypress-docker-images/tree/master/examples/chromium). Addresses [#31702](https://github.com/cypress-io/cypress/issues/31702) and [#31703](https://github.com/cypress-io/cypress/issues/31703).
1819
- Cursor is now available as an IDE option for opening files in Cypress, if it is installed on your system. Addressed in [#31691](https://github.com/cypress-io/cypress/pull/31691).
1920
- The error shown when the `--record` flag is missing has been updated to be shorter. Addressed in [#31676](https://github.com/cypress-io/cypress/pull/31676).
2021

npm/puppeteer/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Before using `@cypress/puppeteer`, ensure the following requirements are met:
4848
- Only Chromium-based browsers are supported, such as Chrome for Testing, Chromium, and Electron.
4949
- Chrome-branded browsers (e.g., standard Chrome) are not supported in version 137+ due to Chrome's removal of the `--load-extension` flag. We recommend using Chrome for Testing or Chromium instead. See Cypress Docker image examples for [Chrome for Testing](https://github.com/cypress-io/cypress-docker-images/tree/master/examples/chrome-for-testing) and [Chromium](https://github.com/cypress-io/cypress-docker-images/tree/master/examples/chromium).
5050

51+
As of Chrome 137, the `@cypress/puppeteer` plugin will not work in `cypress open` mode (or headed `run` mode) with official branded versions of Chrome (`stable`, `beta`, `dev`, and `canary`). If you need to run the `@cypress/puppeteer` in `cypress open` mode, you will need to use Electron, [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing), Chromium, or another Chrome variant that supports loading web extensions. The plugin will work as expected in `cypress run` mode in any version of Chrome.
52+
5153
## Usage
5254

5355
`@cypress/puppeteer` is set up in your Cypress config and support file, then executed in your spec. See [API](#api) and [Examples](#examples) below for more details.

npm/puppeteer/src/plugin/setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ export function setup (options: SetupOptions) {
6363

6464
try {
6565
options.on('after:browser:launch', (browser: Cypress.Browser, options: Cypress.AfterBrowserLaunchDetails) => {
66+
if (Number(browser.majorVersion) >= 137 && browser.name === 'chrome' && browser.isHeaded) {
67+
// @see https://github.com/cypress-io/cypress/issues/31703
68+
throw pluginError('@cypress/puppeteer does not work in Google Chrome v137 and higher in cypress open mode (or headed run mode). If you need to use @cypress/puppeteer in headed mode, please use Electron, Chrome for Testing, Chromium, or another Chrome variant that supports loading extensions.')
69+
}
70+
6671
cypressBrowser = browser
6772
debuggerUrl = options.webSocketDebuggerUrl
6873
})

npm/puppeteer/test/unit/setup.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ describe('#setup', () => {
274274
await task({ name: testTask, args: [] })
275275
expect(activateMainTabExport.activateMainTab).not.to.be.called
276276
})
277+
278+
it('catastrophically fails when the browser is Google Chromed Branded 137 and up and we are running in headed mode', async () => {
279+
setup({ on, onMessage, puppeteer: mockPuppeteer as PuppeteerNode })
280+
expect(() => {
281+
on.withArgs('after:browser:launch').yield({ family: 'chromium', isHeaded: true, name: 'chrome', majorVersion: '137' }, { webSocketDebuggerUrl: 'ws://debugger' })
282+
}).to.throw('@cypress/puppeteer does not work in Google Chrome v137 and higher in cypress open mode (or headed run mode). If you need to use @cypress/puppeteer in headed mode, please use Electron, Chrome for Testing, Chromium, or another Chrome variant that supports loading extensions.')
283+
})
277284
})
278285

279286
describe('validation', () => {

packages/errors/src/errors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ export const AllCypressErrors = {
9898
9999
This option will not have an effect in ${fmt.off(_.capitalize(browser))}. Tests that rely on web security being disabled will not run as expected.`
100100
},
101+
CHROME_137_LOAD_EXTENSION_NOT_SUPPORTED: () => {
102+
return errTemplate`\
103+
Google Chrome v137 and higher does not allow loading extensions via --load-extension. If you need to load an extension to test with Cypress, please use Chrome for Testing, Chromium, or another Chrome variant that supports loading extensions.`
104+
},
101105
BROWSER_UNSUPPORTED_LAUNCH_OPTION: (browser: string, options: string[]) => {
102106
return errTemplate`\
103107
Warning: The following browser launch options were provided but are not supported by ${fmt.highlightSecondary(browser)}

packages/server/lib/browsers/chrome.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ const _normalizeArgExtensions = function (extPath, args, pluginExtensions, brows
145145
return arg.includes(LOAD_EXTENSION)
146146
})
147147

148+
if (loadExtension || pluginExtensions.length > 0) {
149+
// @see https://github.com/cypress-io/cypress/issues/31702
150+
if (Number(browser.majorVersion) >= 137 && browser.name === 'chrome') {
151+
// eslint-disable-next-line no-console
152+
errors.warning('CHROME_137_LOAD_EXTENSION_NOT_SUPPORTED')
153+
}
154+
}
155+
148156
if (loadExtension) {
149157
args = _.without(args, loadExtension)
150158

packages/server/test/unit/browsers/chrome_spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,36 @@ describe('lib/browsers/chrome', () => {
270270
})
271271
})
272272

273+
it('warns the user if `--load-extension` is passed into branded chrome 137 and up', async function () {
274+
sinon.stub(console, 'log')
275+
276+
plugins.registerEvent('before:browser:launch', (browser, config) => {
277+
return Promise.resolve({ args: ['--foo=bar', '--load-extension=/foo/bar/baz.js,/quux.js'] })
278+
})
279+
280+
await chrome.open({ isHeaded: true, majorVersion: '137', name: 'chrome' }, 'http://', { onWarning: () => {}, onError: () => {} }, this.automation)
281+
282+
// eslint-disable-next-line no-console
283+
expect(console.log).to.have.been.calledWith(
284+
'\u001b[35mGoogle Chrome v137 and higher does not allow loading extensions via --load-extension. If you need to load an extension to test with Cypress, please use Chrome for Testing, Chromium, or another Chrome variant that supports loading extensions.\u001b[39m',
285+
)
286+
})
287+
288+
it('warns the user if launchOptions.extensions is passed into branded chrome 137 and up', async function () {
289+
sinon.stub(console, 'log')
290+
291+
plugins.registerEvent('before:browser:launch', (browser, config) => {
292+
return Promise.resolve({ args: ['--foo=bar'], extensions: ['/foo/bar/baz.js', '/quux.js'] })
293+
})
294+
295+
await chrome.open({ isHeaded: true, majorVersion: '139', name: 'chrome' }, 'http://', { onWarning: () => {}, onError: () => {} }, this.automation)
296+
297+
// eslint-disable-next-line no-console
298+
expect(console.log).to.have.been.calledWith(
299+
'\u001b[35mGoogle Chrome v137 and higher does not allow loading extensions via --load-extension. If you need to load an extension to test with Cypress, please use Chrome for Testing, Chromium, or another Chrome variant that supports loading extensions.\u001b[39m',
300+
)
301+
})
302+
273303
it('cleans up an unclean browser profile exit status', function () {
274304
this.readJson.withArgs('/profile/dir/Default/Preferences').resolves({
275305
profile: {

0 commit comments

Comments
 (0)