Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update browser internal images to chrome 124 and firefox 125 #29391

Merged
merged 11 commits into from Apr 30, 2024
41 changes: 11 additions & 30 deletions .circleci/workflows.yml
Expand Up @@ -74,7 +74,7 @@ windowsWorkflowFilters: &windows-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'bump-electron-27.3.10', << pipeline.git.branch >> ]
- equal: [ 'chore/update_internal_browser_images', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -83,7 +83,7 @@ executors:
# the Docker image with Cypress dependencies and Chrome browser
cy-doc:
docker:
- image: cypress/browsers-internal:node18.17.1-chrome118-ff115
- image: cypress/browsers-internal:node18.17.1-chrome124-ff125
# by default, we use "medium" to balance performance + CI costs. bump or reduce on a per-job basis if needed.
resource_class: medium
environment:
Expand All @@ -93,7 +93,7 @@ executors:
# Docker image with non-root "node" user
non-root-docker-user:
docker:
- image: cypress/browsers-internal:node18.17.1-chrome118-ff115
- image: cypress/browsers-internal:node18.17.1-chrome124-ff125
user: node
environment:
PLATFORM: linux
Expand Down Expand Up @@ -653,34 +653,21 @@ commands:
browser: <<parameters.browser>>
- run:
command: |
if [[ $PLATFORM == 'windows' && '<<parameters.browser>>' == 'chrome' && '<<parameters.package>>' == 'app' && '<<parameters.type>>' == 'e2e' ]]; then
IS_WINDOWS_APP_INTEGRATION_TEST=true
else
IS_WINDOWS_APP_INTEGRATION_TEST=false
fi
echo Current working directory is $PWD
echo Total containers $CIRCLE_NODE_TOTAL

if [[ -v MAIN_RECORD_KEY ]]; then
# internal PR
cmd=$([[ <<parameters.percy>> == 'true' ]] && echo 'yarn percy exec --parallel -- --') || true

if [[ "$IS_WINDOWS_APP_INTEGRATION_TEST" = true ]]; then
echo "on windows running app-integration tests. Skipping flaky tests"
# if windows app integration tests, skip some very flaky tests that fail to load for undetermined reasons
TESTFILES=$(cd packages/<<parameters.package>> && /usr/bin/find cypress/e2e -regextype posix-extended -name '*.cy.*' -not -regex '.*(experimentalRetries|reporter.command_errors|ct-framework-errors|reporter-ct-vite|reporter-ct-webpack|reporter.errors|reporter.hooks|cypress-in-cypress|runner.ui|specs|studio).*' | circleci tests split --total=$CIRCLE_NODE_TOTAL)
# Do NOT record on windows packages/app due to encryption issues
$cmd yarn workspace @packages/<<parameters.package>> cypress:run:<<parameters.type>> --browser <<parameters.browser>> --spec $TESTFILES
else
DEBUG=<<parameters.debug>> \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
CYPRESS_INTERNAL_ENABLE_TELEMETRY="true" \
$cmd yarn workspace @packages/<<parameters.package>> cypress:run:<<parameters.type>> --browser <<parameters.browser>> --record --parallel --group <<parameters.package>>-<<parameters.type>>
fi
DEBUG=<<parameters.debug>> \
CYPRESS_CONFIG_ENV=production \
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
PERCY_ENABLE=${PERCY_TOKEN:-0} \
PERCY_PARALLEL_TOTAL=-1 \
CYPRESS_INTERNAL_ENABLE_TELEMETRY="true" \
$cmd yarn workspace @packages/<<parameters.package>> cypress:run:<<parameters.type>> --browser <<parameters.browser>> --record --parallel --group <<parameters.package>>-<<parameters.type>>
else
# external PR

Expand All @@ -701,12 +688,6 @@ commands:
# To run the `yarn` command, we need to walk out of the package folder.
cd ../..

if [[ "$IS_WINDOWS_APP_INTEGRATION_TEST" = true ]]; then
echo "on windows running app-integration tests. Skipping flaky tests"
# if windows app integration tests, skip some very flaky tests that fail to load for undetermined reasons
TESTFILES=$(cd packages/<<parameters.package>> && /usr/bin/find cypress/e2e -regextype posix-extended -name '*.cy.*' -not -regex '.*(experimentalRetries|reporter.command_errors|ct-framework-errors|reporter-ct-vite|reporter-ct-webpack|reporter.errors|reporter.hooks|cypress-in-cypress|runner.ui|specs|studio).*' | circleci tests split --total=$CIRCLE_NODE_TOTAL)
fi

DEBUG=<<parameters.debug>> \
CYPRESS_CONFIG_ENV=production \
PERCY_PARALLEL_NONCE=$CIRCLE_WORKFLOW_WORKSPACE_ID \
Expand Down
23 changes: 23 additions & 0 deletions packages/proxy/lib/http/response-middleware.ts
Expand Up @@ -345,6 +345,28 @@ const OmitProblematicHeaders: ResponseMiddleware = function () {
this.next()
}

const MaybeSetOriginAgentClusterHeader: ResponseMiddleware = function () {
if (process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT) {
const origin = new URL(this.req.proxiedUrl).origin

if (process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS && process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS === origin) {
// For cypress-in-cypress tests exclusively, we need to bucket all origin-agent-cluster requests
// from HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS to include Origin-Agent-Cluster=false. This has to do with changed
// behavior starting in Chrome 119. The new behavior works like the following:
// - If the first page from an origin does not set the header,
// then no other pages from that origin will be origin-keyed, even if those other pages do set the header.
// - If the first page from an origin sets the header and is made origin-keyed,
// then all other pages from that origin will be origin-keyed whether they ask for it or not.
// To work around this, any request that matches the origin of HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS
// should set the Origin-Agent-Cluster=false header to avoid origin-keyed agent clusters.
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin-Agent-Cluster for more details.
this.res.setHeader('Origin-Agent-Cluster', '?0')
}
}

this.next()
}

const SetInjectionLevel: ResponseMiddleware = function () {
const span = telemetry.startSpan({ name: 'set:injection:level', parentSpan: this.resMiddlewareSpan, isVerbose })

Expand Down Expand Up @@ -933,6 +955,7 @@ export default {
InterceptResponse,
PatchExpressSetHeader,
OmitProblematicHeaders, // Since we might modify CSP headers, this middleware needs to come BEFORE SetInjectionLevel
MaybeSetOriginAgentClusterHeader, // NOTE: only used in cypress-in-cypress testing. this is otherwise a no-op
SetInjectionLevel,
MaybePreventCaching,
MaybeStripDocumentDomainFeaturePolicy,
Expand Down
60 changes: 60 additions & 0 deletions packages/proxy/test/unit/http/response-middleware.spec.ts
Expand Up @@ -19,6 +19,7 @@ describe('http/response-middleware', function () {
'InterceptResponse',
'PatchExpressSetHeader',
'OmitProblematicHeaders',
'MaybeSetOriginAgentClusterHeader',
'SetInjectionLevel',
'MaybePreventCaching',
'MaybeStripDocumentDomainFeaturePolicy',
Expand Down Expand Up @@ -448,6 +449,65 @@ describe('http/response-middleware', function () {
}
})

describe('MaybeSetOriginAgentClusterHeader', function () {
const { MaybeSetOriginAgentClusterHeader } = ResponseMiddleware

let CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT
let PREVIOUS_HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS
let ctx

beforeEach(function () {
CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT = process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT
PREVIOUS_HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS = process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS
ctx = {
req: {
proxiedUrl: 'http://localhost:4455',
},
res: {
setHeader: sinon.stub(),
on: (event, listener) => {},
off: (event, listener) => {},
},
}
})

afterEach(function () {
beforeEach(function () {
process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT = CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT
process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS = PREVIOUS_HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS
})
})

it('doesn\'t set the Origin-Agent-Cluster for the request if cypress-in-cypress testing is off', function () {
delete process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT

return testMiddleware([MaybeSetOriginAgentClusterHeader], ctx)
.then(() => {
expect(ctx.res.setHeader).not.to.be.called
})
})

it('doesn\'t set the Origin-Agent-Cluster for the request if cypress-in-cypress testing is on but url does NOT match http proxy', function () {
process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT = '1'
process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS = 'http://localhost:4456'

return testMiddleware([MaybeSetOriginAgentClusterHeader], ctx)
.then(() => {
expect(ctx.res.setHeader).not.to.be.called
})
})

it('sets the Origin-Agent-Cluster for the request if cypress-in-cypress testing is on and url matches http proxy', function () {
process.env.CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT = '1'
process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS = 'http://localhost:4455'

return testMiddleware([MaybeSetOriginAgentClusterHeader], ctx)
.then(() => {
expect(ctx.res.setHeader).to.be.calledWith('Origin-Agent-Cluster', '?0')
})
})
})

describe('SetInjectionLevel', function () {
const { SetInjectionLevel } = ResponseMiddleware
let ctx
Expand Down
2 changes: 1 addition & 1 deletion system-tests/__snapshots__/browser_crash_handling_spec.js
Expand Up @@ -496,7 +496,7 @@ exports['Browser Crash Handling / when the tab closes in chrome / fails'] = `
Running: chrome_tab_close.cy.js (1 of 2)


We detected that the Chrome browser process closed unexpectedly.
We detected that the Chrome tab running Cypress tests closed unexpectedly.

We have failed the current spec and aborted the run.

Expand Down
4 changes: 2 additions & 2 deletions system-tests/__snapshots__/component_testing_spec.ts.js
Expand Up @@ -786,9 +786,9 @@ exports['experimentalSingleTabRunMode / executes all specs in a single tab'] = `

(Screenshots)

- /XXX/XXX/XXX/cypress/screenshots/1_fails.cy.js/simple failing spec -- fails (fai (1280x599)
- /XXX/XXX/XXX/cypress/screenshots/1_fails.cy.js/simple failing spec -- fails (fai (1280x633)
led).png
- /XXX/XXX/XXX/cypress/screenshots/1_fails.cy.js/simple failing spec -- fails agai (1280x599)
- /XXX/XXX/XXX/cypress/screenshots/1_fails.cy.js/simple failing spec -- fails agai (1280x633)
n (failed).png


Expand Down
4 changes: 2 additions & 2 deletions system-tests/__snapshots__/retries_spec.ts.js
Expand Up @@ -164,8 +164,8 @@ exports['retries / supports retries (chrome)'] = `

(Screenshots)

- /XXX/XXX/XXX/cypress/screenshots/fail-twice.cy.js/fail twice (failed).png (1280x599)
- /XXX/XXX/XXX/cypress/screenshots/fail-twice.cy.js/fail twice (failed) (attempt 2 (1280x599)
- /XXX/XXX/XXX/cypress/screenshots/fail-twice.cy.js/fail twice (failed).png (1280x633)
- /XXX/XXX/XXX/cypress/screenshots/fail-twice.cy.js/fail twice (failed) (attempt 2 (1280x633)
).png


Expand Down