Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane committed Dec 10, 2024
2 parents c645017 + dcd0e92 commit f14fd12
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 52 deletions.
9 changes: 9 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ in this [GitHub issue](https://github.com/cypress-io/cypress/issues/30447). Addr
- Updated `jQuery` from `3.4.1` to `3.7.1`. Addressed in [#30345](https://github.com/cypress-io/cypress/pull/30345).
- Updated `react` from `17.0.2` to `18.3.1` and `react-dom` from `17.0.2` to `18.3.1`. Addresses [#30511](https://github.com/cypress-io/cypress/issues/30511).

## 13.16.2

_Released 12/17/2024 (PENDING)_

**Bugfixes:**

- Fixed an issue where targets may hang if `Network.enable` is not implemented for the target. Addresses [#29876](https://github.com/cypress-io/cypress/issues/29876).
- Updated Firefox `userChrome.css` to correctly hide the toolbox during headless mode. Addresses [#30721](https://github.com/cypress-io/cypress/issues/30721).

## 13.16.1

_Released 12/03/2024_
Expand Down
5 changes: 2 additions & 3 deletions packages/server/lib/browsers/browser-cri-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,8 @@ export class BrowserCriClient {
try {
await browserClient.send('Runtime.runIfWaitingForDebugger', undefined, sessionId)
} catch (error) {
// it's possible that the target was closed before we could enable
// network and continue, in that case, just ignore
debug('error running Runtime.runIfWaitingForDebugger:', error)
// it's possible that the target was closed before we could tell it to run, in that case, just ignore
debug('error running Runtime.runIfWaitingForDebugger: %o', error)
}
}

Expand Down
16 changes: 10 additions & 6 deletions packages/server/lib/browsers/cri-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ export class CriClient implements ICriClient {
this._isChildTarget = !!this.host

if (this._isChildTarget) {
// If crash listeners are added at the browser level, tabs/page connections do not
// emit them.
// If crash listeners are added at the browser level, tabs/page connections do not emit them.
this.cdpConnection.on('Target.targetCrashed', async (event) => {
debug('crash event detected', event)
if (event.targetId !== this.targetId) {
Expand Down Expand Up @@ -368,13 +367,18 @@ export class CriClient implements ICriClient {
if (event.targetInfo.type !== 'service_worker' && event.targetInfo.type !== 'page' && event.targetInfo.type !== 'other') {
await this.cdpConnection.send('Network.enable', this.protocolManager?.networkEnableOptions ?? DEFAULT_NETWORK_ENABLE_OPTIONS, event.sessionId)
}
} catch (error) {
// it's possible that the target was closed before we could enable network, in that case, just ignore
debug('error attaching to target cri: %o', { error, event })
}

if (event.waitingForDebugger) {
if (event.waitingForDebugger) {
try {
await this.cdpConnection.send('Runtime.runIfWaitingForDebugger', undefined, event.sessionId)
} catch (error) {
// it's possible that the target was closed before we could tell it to run, in that case, just ignore
debug('error running Runtime.runIfWaitingForDebugger: %o', { error, event })
}
} catch (error) {
// it's possible that the target was closed before we could enable network and continue, in that case, just ignore
debug('error attaching to target cri', error)
}
}

Expand Down
10 changes: 7 additions & 3 deletions packages/server/lib/browsers/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ toolbar {
overflow: hidden !important;
display: none;
}
toolbox {
height: 0px !important;
min-height: 0px !important;
overflow: hidden !important;
border: none !important;
}
`

let browserCriClient: BrowserCriClient | undefined
Expand Down Expand Up @@ -556,11 +561,10 @@ export async function open (browser: Browser, url: string, options: BrowserLaunc
}

// resolution of exactly 1280x720
// (height must account for firefox url bar, which we can only shrink to 2px)
const BROWSER_ENVS = {
MOZ_REMOTE_SETTINGS_DEVTOOLS: '1',
MOZ_HEADLESS_WIDTH: '1280',
MOZ_HEADLESS_HEIGHT: '722',
MOZ_HEADLESS_HEIGHT: '720',
...launchOptions.env,
}

Expand Down
51 changes: 41 additions & 10 deletions packages/server/test/unit/browsers/cri-client_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import EventEmitter from 'events'
import { ProtocolManagerShape } from '@packages/types'
import type { CriClient } from '../../../lib/browsers/cri-client'
import pDefer from 'p-defer'
import type Protocol from 'devtools-protocol'
const { expect, proxyquire, sinon } = require('../../spec_helper')

const DEBUGGER_URL = 'http://foo'
Expand Down Expand Up @@ -108,11 +109,9 @@ describe('lib/browsers/cri-client', function () {
it('does not enable network', async () => {
await Promise.all(['service_worker', 'page', 'other'].map((type) => {
return fireCDPEvent('Target.attachedToTarget', {
// do not need entire event payload for this test
// @ts-ignore
targetInfo: {
type,
},
} as Protocol.Target.TargetInfo,
})
}))

Expand All @@ -123,30 +122,62 @@ describe('lib/browsers/cri-client', function () {
describe('target type is something other than service worker, page, or other', () => {
it('enables network', async () => {
await fireCDPEvent('Target.attachedToTarget', {
// do not need entire event payload for this test
// @ts-ignore
targetInfo: {
type: 'somethin else',
},
type: 'iframe',
} as Protocol.Target.TargetInfo,
})

expect(criStub.send).to.have.been.calledWith('Network.enable')
})
})

describe('target is waiting for debugger', () => {
const sessionId = 'abc123'

it('sends Runtime.runIfWaitingForDebugger', async () => {
const sessionId = 'abc123'
await fireCDPEvent('Target.attachedToTarget', {
waitingForDebugger: true,
sessionId,
targetInfo: { type: 'service_worker' } as Protocol.Target.TargetInfo,
})

expect(criStub.send).to.have.been.calledWith('Runtime.runIfWaitingForDebugger', undefined, sessionId)
})

it('does not send Runtime.runIfWaitingForDebugger if not waiting for debugger', async () => {
await fireCDPEvent('Target.attachedToTarget', {
waitingForDebugger: false,
sessionId,
targetInfo: { type: 'service_worker' } as Protocol.Target.TargetInfo,
})

expect(criStub.send).not.to.have.been.calledWith('Runtime.runIfWaitingForDebugger')
})

it('sends Runtime.runIfWaitingForDebugger even if Network.enable throws', async () => {
criStub.send.withArgs('Network.enable').throws(new Error('ProtocolError: Inspected target closed'))

await fireCDPEvent('Target.attachedToTarget', {
waitingForDebugger: true,
sessionId,
// @ts-ignore
targetInfo: { type: 'service_worker' },
targetInfo: { type: 'iframe' } as Protocol.Target.TargetInfo,
})

expect(criStub.send).to.have.been.calledWith('Network.enable').and.to.have.thrown()
expect(criStub.send).to.have.been.calledWith('Runtime.runIfWaitingForDebugger', undefined, sessionId)
})

it('continues even if Runtime.runIfWaitingForDebugger throws', async () => {
criStub.send.withArgs('Runtime.runIfWaitingForDebugger').throws(new Error('ProtocolError: Inspected target closed'))

await fireCDPEvent('Target.attachedToTarget', {
waitingForDebugger: true,
sessionId,
targetInfo: { type: 'service_worker' } as Protocol.Target.TargetInfo,
})

expect(criStub.send).to.have.been.calledWith('Runtime.runIfWaitingForDebugger', undefined, sessionId).and.to.have.thrown()
})
})
})

Expand Down
4 changes: 2 additions & 2 deletions packages/server/test/unit/browsers/firefox_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describe('lib/browsers/firefox', () => {
env: {
MOZ_REMOTE_SETTINGS_DEVTOOLS: '1',
MOZ_HEADLESS_WIDTH: '1280',
MOZ_HEADLESS_HEIGHT: '722',
MOZ_HEADLESS_HEIGHT: '720',
},
}),
jsdebugger: false,
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('lib/browsers/firefox', () => {
env: {
MOZ_REMOTE_SETTINGS_DEVTOOLS: '1',
MOZ_HEADLESS_WIDTH: '1280',
MOZ_HEADLESS_HEIGHT: '722',
MOZ_HEADLESS_HEIGHT: '720',
},
}),
jsdebugger: true,
Expand Down
22 changes: 0 additions & 22 deletions system-tests/lib/normalizeStdout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,28 +180,6 @@ export const normalizeStdout = function (str: string, options: any = {}) {
str = str.split('\n').filter((line) => !line.includes(wdsFailedMsg)).join('\n')
}

// in Firefox 133, height dimensions are off by 43/44 pixels (677px local and 676px CI), so we need to fix the offset to match common snapshots
if (options.browser === 'firefox') {
const dimensionRegex = new RegExp(/(\((?<width>\d+)x(?<height>\d+)\))/g)

const matches = dimensionRegex.exec(str)

if (matches?.groups?.height && matches?.groups?.width) {
const height = parseInt(matches?.groups?.height)

let expectedHeight = height
const expectedWidth = matches?.groups?.width

if (height === 676) { // only happens on default height for whatever reason in firefox 133...
expectedHeight = height + 44
} else if (height === 677) { // only happens on default height for whatever reason in firefox 133...
expectedHeight = height + 43
}

str = str.replaceAll(`(${expectedWidth}x${height})`, `(${expectedWidth}x${expectedHeight})`)
}
}

if (options.sanitizeScreenshotDimensions) {
// screenshot dimensions
str = str.replace(/(\(\d+x\d+\))/g, replaceScreenshotDims)
Expand Down
7 changes: 1 addition & 6 deletions system-tests/lib/pluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ module.exports = {
if (config.env['NO_RESIZE']) return

if (browser.family === 'firefox') {
// this is needed to ensure correct error screenshot / video recording
// resolution of exactly 1280x720
// (height must account for firefox url bar, which we can only shrink to 2px)
options.args.push(
'-width', '1280', '-height', '722',
)
options.args.push('-width', '1280', '-height', '720')
} else if (browser.name === 'electron') {
options.preferences.width = 1280
options.preferences.height = 720
Expand Down

5 comments on commit f14fd12

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f14fd12 Dec 10, 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/14.0.0/linux-x64/release/14.0.0-f14fd12350dfafe8ef7992750f746b72088b4769/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f14fd12 Dec 10, 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/14.0.0/linux-arm64/release/14.0.0-f14fd12350dfafe8ef7992750f746b72088b4769/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f14fd12 Dec 10, 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/14.0.0/darwin-arm64/release/14.0.0-f14fd12350dfafe8ef7992750f746b72088b4769/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f14fd12 Dec 10, 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/14.0.0/darwin-x64/release/14.0.0-f14fd12350dfafe8ef7992750f746b72088b4769/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f14fd12 Dec 10, 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/14.0.0/win32-x64/release/14.0.0-f14fd12350dfafe8ef7992750f746b72088b4769/cypress.tgz

Please sign in to comment.