Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:cypress-io/cypress into angular-…
Browse files Browse the repository at this point in the history
…signals-ct-harness
  • Loading branch information
AtofStryker committed Jun 24, 2024
2 parents 001813e + 7b07c75 commit 6090456
Show file tree
Hide file tree
Showing 19 changed files with 318 additions and 68 deletions.
2 changes: 1 addition & 1 deletion browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chrome:beta": "127.0.6533.4",
"chrome:beta": "127.0.6533.17",
"chrome:stable": "126.0.6478.114",
"chrome:minimum": "64.0.3282.0"
}
12 changes: 11 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@

_Released 7/02/2024 (PENDING)_

**Performance:**

- Improved performance of `experimentalSourceRewriting` option. Fixed in [#29540](https://github.com/cypress-io/cypress/pull/29540).

**Features:**

- Adds Signal support for Angular Component Testing versions 17.2 and up. Addresses [#29264](https://github.com/cypress-io/cypress/issues/29264).

**Bugfixes:**

- Fixed an issue where Chrome launch instances would not recreate the browser CRI client correctly after recovering from an unexpected browser closure. Fixes [#27657](https://github.com/cypress-io/cypress/issues/27657). Fixed in [#29663](https://github.com/cypress-io/cypress/pull/29663).
- Fixed an issue where Firefox 129 (Firefox Nightly) would not launch with Cypress. Fixes [#29713](https://github.com/cypress-io/cypress/issues/29713). Fixed in [#29720](https://github.com/cypress-io/cypress/pull/29720).

**Dependency Updates:**

- Updated `tmp` from `0.2.1` to `0.2.3`. Addresses [#29693](https://github.com/cypress-io/cypress/issues/29693).
- Updated `ws` from `5.2.3` to `5.2.4`. Addressed in [#29698](https://github.com/cypress-io/cypress/pull/29698).

## 13.12.0
Expand All @@ -27,7 +37,7 @@ _Released 6/18/2024_
- When capture protocol script fails verification, an appropriate error is now displayed. Previously, an error regarding Test Replay archive location was shown. Addressed in [#29603](https://github.com/cypress-io/cypress/pull/29603).
- Fixed an issue where receiving HTTP responses with invalid headers raised an error. Now cypress removes the invalid headers and gives a warning in the console with debug mode on. Fixes [#28865](https://github.com/cypress-io/cypress/issues/28865).

**Misc:**
**Misc:**

- Report afterSpec durations to Cloud API when running in record mode with Test Replay enabled. Addressed in [#29500](https://github.com/cypress-io/cypress/pull/29500).

Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"request-progress": "^3.0.0",
"semver": "^7.5.3",
"supports-color": "^8.1.1",
"tmp": "~0.2.1",
"tmp": "~0.2.3",
"untildify": "^4.0.0",
"yauzl": "^2.10.0"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/data-context/src/data/coreDataShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export interface CoreDataShape {
} | null
cloudProject: CloudDataShape
eventCollectorSource: EventCollectorSource | null
didBrowserPreviouslyHaveUnexpectedExit: boolean
}

/**
Expand Down Expand Up @@ -251,6 +252,7 @@ export function makeCoreData (modeOptions: Partial<AllModeOptions> = {}): CoreDa
testsForRunResults: {},
},
eventCollectorSource: null,
didBrowserPreviouslyHaveUnexpectedExit: false,
}

async function machineId (): Promise<string | null> {
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@vue/compiler-sfc": "3.2.47",
"@vue/test-utils": "2.3.2",
"@vueuse/core": "7.2.2",
"autoprefixer": "^10.4.14",
"autoprefixer": "^10.4.19",
"axe-core": "4.4.1",
"browser-logos": "github:alrra/browser-logos",
"combine-properties": "0.1.0",
Expand All @@ -69,6 +69,7 @@
"postcss": "^8.4.22",
"shiki": "^0.9.12",
"tailwindcss": "^3.3.1",
"type-fest": "^2.3.4",
"unplugin-icons": "0.19.0",
"unplugin-vue-components": "^0.27.0",
"vite": "5.2.11",
Expand Down
43 changes: 23 additions & 20 deletions packages/rewriter/lib/js-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function resolveLocationReference () {
)
}

const replaceableProps = ['parent', 'top', 'location']

/**
* Given an Identifier or a Literal, return a property name that should use `resolveWindowReference`.
* @param node
Expand All @@ -70,12 +72,12 @@ function getReplaceablePropOfMemberExpression (node: n.MemberExpression) {
const { property } = node

// something.(top|parent)
if (n.Identifier.check(property) && ['parent', 'top', 'location'].includes(property.name)) {
if (n.Identifier.check(property) && replaceableProps.includes(property.name)) {
return property.name
}

// something['(top|parent)']
if (n.Literal.check(property) && ['parent', 'top', 'location'].includes(String(property.value))) {
if (n.Literal.check(property) && replaceableProps.includes(String(property.value))) {
return String(property.value)
}

Expand Down Expand Up @@ -104,6 +106,7 @@ export const jsRules: Visitor<{}> = {
}

path.replace(resolveWindowReference(path.get('object').node, prop))
this.reportChanged()

return false
},
Expand All @@ -120,6 +123,7 @@ export const jsRules: Visitor<{}> = {
if (isAssignee && node.name === 'location') {
// `location = 'something'`, rewrite to intercepted href setter since relative urls can break this
path.replace(b.memberExpression(resolveLocationReference(), b.identifier('href')))
this.reportChanged()

return false
}
Expand Down Expand Up @@ -147,40 +151,38 @@ export const jsRules: Visitor<{}> = {
}
}

if (path.scope.declares(node.name)) {
// identifier has been declared in local scope, don't care about replacing
// identifier has been declared in local scope, don't care about replacing
if (!replaceableProps.includes(node.name) || path.scope.declares(node.name)) {
return this.traverse(path)
}

if (node.name === 'location') {
path.replace(resolveLocationReference())

return false
}
switch (node.name) {
case 'location':
path.replace(resolveLocationReference())
this.reportChanged()

if (['parent', 'top'].includes(node.name)) {
path.replace(resolveWindowReference(globalIdentifier, node.name))
return false
case 'parent':
case 'top':
path.replace(resolveWindowReference(globalIdentifier, node.name))
this.reportChanged()

return false
return false
default:
return this.traverse(path)
}

this.traverse(path)
},
visitAssignmentExpression (path) {
const { node } = path

const finish = () => {
this.traverse(path)
}

if (!n.MemberExpression.check(node.left)) {
return finish()
return this.traverse(path)
}

const propBeingSet = getReplaceablePropOfMemberExpression(node.left)

if (!propBeingSet) {
return finish()
return this.traverse(path)
}

if (node.operator !== '=') {
Expand All @@ -194,6 +196,7 @@ export const jsRules: Visitor<{}> = {
const objBeingSetOn = node.left.object

path.replace(resolveWindowReference(objBeingSetOn, propBeingSet, node.right))
this.reportChanged()

return false
},
Expand Down
30 changes: 25 additions & 5 deletions packages/rewriter/lib/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export function rewriteJsSourceMap (url: string, js: string, inputSourceMap: any

const ast = recast.parse(js, { sourceFileName })

astTypes.visit(ast, jsRules)
const visitor = astTypes.PathVisitor.fromMethodsObject(jsRules)

visitor.visit(ast)

if (!visitor.wasChangeReported() && inputSourceMap) {
return inputSourceMap
}

return recast.print(ast, {
inputSourceMap,
Expand All @@ -50,18 +56,32 @@ export function rewriteJsSourceMap (url: string, js: string, inputSourceMap: any
export function _rewriteJsUnsafe (url: string, js: string, deferSourceMapRewrite?: DeferSourceMapRewriteFn): string {
const ast = recast.parse(js)

let didRewrite: boolean

try {
astTypes.visit(ast, jsRules)
const visitor = astTypes.PathVisitor.fromMethodsObject(jsRules)

visitor.visit(ast)

didRewrite = visitor.wasChangeReported()
} catch (err: any) {
// if visiting fails, it points to a bug in our rewriting logic, so raise the error to the driver
return _generateDriverError(url, err)
}

const { code } = recast.print(ast, defaultPrintOpts)
let rewritten: string

if (didRewrite) {
const { code } = recast.print(ast, defaultPrintOpts)

rewritten = code
} else {
rewritten = js
}

if (!deferSourceMapRewrite) {
// no sourcemaps
return sourceMaps.stripMappingUrl(code)
return sourceMaps.stripMappingUrl(rewritten)
}

// get an ID that can be used to lazy-generate the source map later
Expand All @@ -71,7 +91,7 @@ export function _rewriteJsUnsafe (url: string, js: string, deferSourceMapRewrite
// using a relative URL ensures that required cookies + other headers are sent along
// and can be reused if the user's sourcemap requires an HTTP request to be made
`/__cypress/source-maps/${sourceMapId}.map`,
code,
rewritten,
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rewriter/test/unit/js-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('js rewriter', function () {

err.stack = 'stack'

sinon.stub(astTypes, 'visit').throws(err)
sinon.stub(astTypes.PathVisitor, 'fromMethodsObject').throws(err)

const actual = _rewriteJsUnsafe(URL, 'console.log()')

Expand Down
6 changes: 6 additions & 0 deletions packages/server/lib/browsers/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ const defaultPreferences = {

'privacy.trackingprotection.enabled': false,

// CDP is deprecated in Firefox 129 and up.
// In order to enable CDP, we need to set
// remote.active-protocol=2
// @see https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/
// @see https://github.com/cypress-io/cypress/issues/29713
'remote.active-protocols': 2,
// Enable Remote Agent
// https://bugzilla.mozilla.org/show_bug.cgi?id=1544393
'remote.enabled': true,
Expand Down
5 changes: 5 additions & 0 deletions packages/server/lib/browsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ export = {
// so that there is a default for each browser but
// enable the browser to configure the interface
instance.once('exit', async (code, signal) => {
// When the browser has unexpectedly exited, we need to send a signal to the attempt launcher to recreate the browser CRI clients.
// We do NOT want to attempt to use existing CRI clients as the previous instance of the browser was terminated.
// @see https://github.com/cypress-io/cypress/issues/27657
ctx.coreData.didBrowserPreviouslyHaveUnexpectedExit = true

debug('browser instance exit event received %o', { code, signal })

ctx.actions.app.setBrowserStatus('closed')
Expand Down
8 changes: 8 additions & 0 deletions packages/server/lib/modes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ async function waitForBrowserToConnect (options: { project: Project, socketId: s

debug('waiting for socket to connect and browser to launch...')

const coreData = require('@packages/data-context').getCtx().coreData

if (coreData.didBrowserPreviouslyHaveUnexpectedExit) {
debug(`browser previously exited. Setting shouldLaunchNewTab=false to recreate the correct browser automation clients.`)
options.shouldLaunchNewTab = false
coreData.didBrowserPreviouslyHaveUnexpectedExit = false
}

return Bluebird.all([
waitForSocketConnection(project, socketId),
// TODO: remove the need to extend options and coerce this type
Expand Down
Loading

5 comments on commit 6090456

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6090456 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.0/linux-arm64/angular-signals-ct-harness-6090456071ff8e39854a297c8015ed4a97b46c16/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6090456 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.0/linux-x64/angular-signals-ct-harness-6090456071ff8e39854a297c8015ed4a97b46c16/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6090456 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.0/win32-x64/angular-signals-ct-harness-6090456071ff8e39854a297c8015ed4a97b46c16/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6090456 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.0/darwin-arm64/angular-signals-ct-harness-6090456071ff8e39854a297c8015ed4a97b46c16/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6090456 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.0/darwin-x64/angular-signals-ct-harness-6090456071ff8e39854a297c8015ed4a97b46c16/cypress.tgz

Please sign in to comment.