Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/server/lib/browsers/cdp_automation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ export type CyCookie = Pick<chrome.cookies.Cookie, 'name' | 'value' | 'expiratio
// https://developer.chrome.com/extensions/cookies#method-getAll
type CyCookieFilter = chrome.cookies.GetAllDetails

export const screencastOpts: Protocol.Page.StartScreencastRequest = {
format: 'jpeg',
everyNthFrame: Number(process.env.CYPRESS_EVERY_NTH_FRAME || 5),
export function screencastOpts (everyNthFrame = Number(process.env.CYPRESS_EVERY_NTH_FRAME || 5)): Protocol.Page.StartScreencastRequest {
return {
format: 'jpeg',
everyNthFrame,
}
}

function convertSameSiteExtensionToCdp (str: CyCookie['sameSite']): Protocol.Network.CookieSameSite | undefined {
Expand Down
7 changes: 4 additions & 3 deletions packages/server/lib/browsers/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const debug = debugModule('cypress:server:browsers:chrome')
const LOAD_EXTENSION = '--load-extension='
const CHROME_VERSIONS_WITH_BUGGY_ROOT_LAYER_SCROLLING = '66 67'.split(' ')
const CHROME_VERSION_INTRODUCING_PROXY_BYPASS_ON_LOOPBACK = 72
const CHROME_VERSION_WITH_FPS_INCREASE = 89

const CHROME_PREFERENCE_PATHS = {
default: path.join('Default', 'Preferences'),
Expand Down Expand Up @@ -260,7 +261,7 @@ const _connectToChromeRemoteInterface = function (port, onError, browserDisplayN
})
}

const _maybeRecordVideo = async function (client, options) {
const _maybeRecordVideo = async function (client, options, browserMajorVersion) {
if (!options.onScreencastFrame) {
debug('options.onScreencastFrame is false')

Expand All @@ -273,7 +274,7 @@ const _maybeRecordVideo = async function (client, options) {
client.send('Page.screencastFrameAck', { sessionId: meta.sessionId })
})

await client.send('Page.startScreencast', screencastOpts)
await client.send('Page.startScreencast', browserMajorVersion >= CHROME_VERSION_WITH_FPS_INCREASE ? screencastOpts() : screencastOpts(1))
Copy link
Contributor

@flotwig flotwig Oct 7, 2021

Choose a reason for hiding this comment

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

nit: In general, I try to avoid creating function overloads for stuff like this or doing boolean logic in the function declaration (like in screencastOpts()). But I get why you wrote it the way you did, and it passes lint, so I won't nit-pick too hard.


return client
}
Expand Down Expand Up @@ -528,7 +529,7 @@ export = {
await originalBrowserKill.apply(launchedBrowser, args)
}

await this._maybeRecordVideo(criClient, options)
await this._maybeRecordVideo(criClient, options, browser.majorVersion)
await this._navigateUsingCRI(criClient, url)
await this._handleDownloads(criClient, options.downloadsFolder, automation)

Expand Down