Skip to content

Commit 788dfd1

Browse files
jennifer-shehaneAtofStrykercacieprins
authored
chore: bump firefox version we test against to 141 (#32078)
* chore: bump firefox version we test against to 141 * account for unspecified sameSite which is now available in firefox 140 * fix expected error string for invalid cookie * override FORCE_FIREFOX_CDP firefox 141 * fix cdp override in ff 141+ * maybe fix cookeie system tests? seem to time out locally * set family as well as name * fix system tests fore ff 141 * fix ff deprecation * rm erroneous err param * assume firefox is modern in cookies driver e2e test * Update system-tests/lib/system-tests.ts * we do still run tests against firefox 134 --------- Co-authored-by: Bill Glesias <bglesias@gmail.com> Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com> Co-authored-by: Cacie Prins <cacie@cypress.io>
1 parent e045246 commit 788dfd1

File tree

17 files changed

+63
-33
lines changed

17 files changed

+63
-33
lines changed

.circleci/workflows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2.1
22

33
chrome-stable-version: &chrome-stable-version "138.0.7204.183"
44
chrome-beta-version: &chrome-beta-version "139.0.7258.66"
5-
firefox-stable-version: &firefox-stable-version "137.0"
5+
firefox-stable-version: &firefox-stable-version "141.0"
66

77
orbs:
88
browser-tools: circleci/browser-tools@2.1.1

cli/types/cypress.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,7 +3815,7 @@ declare namespace Cypress {
38153815
validate?: () => Promise<false | void> | void
38163816
}
38173817

3818-
type SameSiteStatus = 'no_restriction' | 'strict' | 'lax'
3818+
type SameSiteStatus = 'no_restriction' | 'strict' | 'lax' | 'unspecified'
38193819

38203820
interface SelectFileOptions extends Loggable, Timeoutable, ActionableOptions {
38213821
/**
@@ -3866,8 +3866,8 @@ declare namespace Cypress {
38663866
*/
38673867
expiry: number
38683868
/**
3869-
* The cookie's SameSite value. If set, should be one of `lax`, `strict`, or `no_restriction`.
3870-
* `no_restriction` is the equivalent of `SameSite=None`. Pass `undefined` to use the browser's default.
3869+
* The cookie's SameSite value. If set, should be one of `lax`, `strict`, `no_restriction`, or `unspecified`.
3870+
* `no_restriction` is the equivalent of `SameSite=None`. Pass `undefined` to use the browser's default ('unspecified' is the default for Firefox 140 and up).
38713871
* Note: `no_restriction` can only be used if the secure flag is set to `true`.
38723872
* @default undefined
38733873
*/

packages/driver/cypress/e2e/commands/cookies.cy.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,10 +1374,18 @@ describe('src/cy/commands/cookies', () => {
13741374

13751375
cy.setCookie('five', 'bar')
13761376

1377-
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1624668
1378-
// TODO(webkit): pw webkit has the same issue as firefox (no "unspecified" state), need a patched binary
1379-
if (Cypress.isBrowser('firefox') || Cypress.isBrowser('webkit')) {
1380-
cy.getCookie('five').should('include', { sameSite: 'no_restriction' })
1377+
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1550032
1378+
// Firefox bidi returns "unspecified" for sameSite;
1379+
// webkit & firefox < 135 return "no_restriction" for sameSite;
1380+
// other browsers do not return sameSite at all
1381+
const sameSite = (
1382+
(Cypress.isBrowser('firefox') && Number(Cypress.browser.majorVersion) < 135) ||
1383+
Cypress.isBrowser('webkit')
1384+
) ? 'no_restriction' :
1385+
Cypress.isBrowser('firefox') ? 'unspecified' : null
1386+
1387+
if (sameSite) {
1388+
cy.getCookie('five').should('include', { sameSite })
13811389
} else {
13821390
cy.getCookie('five').should('not.have.property', 'sameSite')
13831391
}
@@ -1515,7 +1523,7 @@ describe('src/cy/commands/cookies', () => {
15151523
assertLogLength(this.logs, 1)
15161524
expect(lastLog.get('error').message).to.eq(stripIndent`
15171525
If a \`sameSite\` value is supplied to \`cy.setCookie()\`, it must be a string from the following list:
1518-
> no_restriction, lax, strict
1526+
> no_restriction, lax, strict, unspecified
15191527
You passed:
15201528
> bad`)
15211529

packages/driver/cypress/e2e/e2e/e2e_cookies.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const cleanse = (cookies) => {
88
})
99
}
1010

11-
const firefoxDefaultSameSite = Cypress.isBrowser({ family: 'firefox' }) ? { sameSite: 'no_restriction' } : {}
11+
const firefoxDefaultSameSite = Cypress.isBrowser({ family: 'firefox' }) ? { sameSite: 'unspecified' } : {}
1212

1313
describe('e2e cookies spec', () => {
1414
it('simple cookie', () => {

packages/driver/cypress/e2e/e2e/origin/cookie_login.cy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ describe('cy.origin - cookie login', { browser: '!webkit' }, () => {
192192
verifyIdpNotLoggedIn({ expectNullCookie: false })
193193
})
194194

195-
// FIXME: Currently in Firefox, the default cookie setting in the extension is no_restriction, which can be set with Secure=false.
196-
it('SameSite=None -> not logged in', { browser: '!firefox' }, () => {
195+
it('SameSite=None -> not logged in', () => {
197196
cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => {
198197
cy.get('[data-cy="username"]').type(username)
199198
cy.get('[data-cy="cookieProps"]').type('SameSite=None')

packages/driver/src/cy/commands/cookies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function pickCookieProps (cookie) {
2121
// different defaults, and Firefox lacks support for `unspecified`, so
2222
// `undefined` is used in lieu of `unspecified`
2323
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1624668
24-
const VALID_SAMESITE_VALUES = ['no_restriction', 'lax', 'strict']
24+
const VALID_SAMESITE_VALUES = ['no_restriction', 'lax', 'strict', 'unspecified']
2525

2626
function normalizeSameSite (sameSite?: string) {
2727
if (_.isUndefined(sameSite)) {

packages/errors/__snapshot-html__/CDP_FIREFOX_DEPRECATED.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/errors/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ export const AllCypressErrors = {
11641164
return errTemplate`Still waiting to connect to ${fmt.off(_.capitalize(browserName))}, retrying in 1 second ${fmt.meta(`(attempt ${attempt}/${connectRetryThreshold})`)}`
11651165
},
11661166
CDP_FIREFOX_DEPRECATED: () => {
1167-
return errTemplate`Since Firefox 129, Chrome DevTools Protocol (CDP) has been deprecated in Firefox. In Firefox 135 and above, Cypress defaults to automating the Firefox browser with WebDriver BiDi. Cypress will no longer support CDP within Firefox in the future and is planned for removal in Cypress 15.`
1167+
return errTemplate`Since Firefox 129, Chrome DevTools Protocol (CDP) has been deprecated in Firefox. In Firefox 135 and above, Cypress defaults to automating the Firefox browser with WebDriver BiDi. CDP support was removed in Firefox 141. Cypress will no longer support CDP in Firefox 141+, and will be removed for older versions of Firefox in Cypress 15.`
11681168
},
11691169
BROWSER_PROCESS_CLOSED_UNEXPECTEDLY: (browserName: string) => {
11701170
return errTemplate`\

packages/server/lib/browsers/firefox.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,25 +409,31 @@ export function clearInstanceState (options: GracefulShutdownOptions = {}) {
409409
}
410410
}
411411

412-
function shouldUseBiDi (browser: Browser): boolean {
412+
function shouldUseCdp (browser: Browser): boolean {
413413
try {
414414
// Gating on firefox version 135 to turn on BiDi as this is when all of our internal Cypress tests were able to pass.
415-
return (browser.family === 'firefox' && !process.env.FORCE_FIREFOX_CDP && Number(browser.majorVersion) >= 135)
415+
// CDP is not supported in Firefox 141+, so we always use BiDi for FF141+.
416+
return (
417+
browser.family === 'firefox' && (
418+
Number(browser.majorVersion) < 135 ||
419+
(Number(browser.majorVersion) < 141 && !!process.env.FORCE_FIREFOX_CDP)
420+
)
421+
)
416422
} catch (err: unknown) {
417423
return false
418424
}
419425
}
420426

421427
export async function connectToNewSpec (browser: Browser, options: BrowserNewTabOpts, automation: Automation) {
422-
if (shouldUseBiDi(browser)) {
428+
if (shouldUseCdp(browser)) {
429+
debug('connectToNewSpec cdp')
430+
await firefoxUtil.connectToNewSpecCDP(options, automation, browserCriClient!)
431+
} else {
423432
debug('connectToNewSpec bidi')
424433
await firefoxUtil.connectToNewSpecBiDi(options, automation, browserBidiClient!)
425434

426435
debug('registering middleware')
427436
automation.use(browserBidiClient!.automationMiddleware)
428-
} else {
429-
debug('connectToNewSpec cdp')
430-
await firefoxUtil.connectToNewSpecCDP(options, automation, browserCriClient!)
431437
}
432438
}
433439

@@ -450,9 +456,10 @@ async function recordVideo (videoApi: RunModeVideoApi) {
450456
}
451457

452458
export async function open (browser: Browser, url: string, options: BrowserLaunchOpts, automation: Automation): Promise<BrowserInstance> {
453-
const USE_WEBDRIVER_BIDI = shouldUseBiDi(browser)
459+
const USE_WEBDRIVER_BIDI = !shouldUseCdp(browser)
454460

455-
if (!USE_WEBDRIVER_BIDI) {
461+
// Even if the user has set FORCE_FIREFOX_CDP, we override this and use BiDi in FF141+
462+
if (!USE_WEBDRIVER_BIDI || (USE_WEBDRIVER_BIDI && !!process.env.FORCE_FIREFOX_CDP)) {
456463
errors.warning('CDP_FIREFOX_DEPRECATED')
457464
}
458465

@@ -620,6 +627,8 @@ export async function open (browser: Browser, url: string, options: BrowserLaunc
620627

621628
debug('launch in firefox', { url, args: launchOptions.args })
622629

630+
const { FORCE_FIREFOX_CDP, ...launchEnvs } = process.env
631+
623632
const geckoDriverOptions: GeckodriverParameters = {
624633
host: '127.0.0.1',
625634
// geckodriver port is assigned under the hood by @wdio/utils
@@ -636,7 +645,7 @@ export async function open (browser: Browser, url: string, options: BrowserLaunc
636645
stdio: ['ignore', 'pipe', 'pipe'],
637646
env: {
638647
...BROWSER_ENVS,
639-
...process.env,
648+
...launchEnvs,
640649
},
641650
},
642651
jsdebugger: Debug.enabled(GECKODRIVER_DEBUG_NAMESPACE_VERBOSE) || false,

packages/server/lib/socket-base.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ export class SocketBase {
227227

228228
debug('automation:client connected')
229229

230+
debug('cdp forced for firefox?', !!process.env.FORCE_FIREFOX_CDP && Number(options.getCurrentBrowser()?.majorVersion) < 141)
230231
// only send the necessary config
231232
automationClient.emit('automation:config', {
232-
IS_CDP_FORCED_FOR_FIREFOX: !!process.env.FORCE_FIREFOX_CDP,
233+
IS_CDP_FORCED_FOR_FIREFOX: !!process.env.FORCE_FIREFOX_CDP && Number(options.getCurrentBrowser()?.majorVersion) < 141,
233234
})
234235

235236
// if our automation disconnects then we're

0 commit comments

Comments
 (0)