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
2 changes: 1 addition & 1 deletion .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1

chrome-stable-version: &chrome-stable-version "138.0.7204.183"
chrome-beta-version: &chrome-beta-version "139.0.7258.66"
firefox-stable-version: &firefox-stable-version "137.0"
firefox-stable-version: &firefox-stable-version "141.0"

orbs:
browser-tools: circleci/browser-tools@2.1.1
Expand Down
6 changes: 3 additions & 3 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3815,7 +3815,7 @@ declare namespace Cypress {
validate?: () => Promise<false | void> | void
}

type SameSiteStatus = 'no_restriction' | 'strict' | 'lax'
type SameSiteStatus = 'no_restriction' | 'strict' | 'lax' | 'unspecified'

interface SelectFileOptions extends Loggable, Timeoutable, ActionableOptions {
/**
Expand Down Expand Up @@ -3866,8 +3866,8 @@ declare namespace Cypress {
*/
expiry: number
/**
* The cookie's SameSite value. If set, should be one of `lax`, `strict`, or `no_restriction`.
* `no_restriction` is the equivalent of `SameSite=None`. Pass `undefined` to use the browser's default.
* The cookie's SameSite value. If set, should be one of `lax`, `strict`, `no_restriction`, or `unspecified`.
* `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).
* Note: `no_restriction` can only be used if the secure flag is set to `true`.
* @default undefined
*/
Expand Down
18 changes: 13 additions & 5 deletions packages/driver/cypress/e2e/commands/cookies.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1374,10 +1374,18 @@ describe('src/cy/commands/cookies', () => {

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

// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1624668
// TODO(webkit): pw webkit has the same issue as firefox (no "unspecified" state), need a patched binary
if (Cypress.isBrowser('firefox') || Cypress.isBrowser('webkit')) {
cy.getCookie('five').should('include', { sameSite: 'no_restriction' })
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1550032
// Firefox bidi returns "unspecified" for sameSite;
// webkit & firefox < 135 return "no_restriction" for sameSite;
// other browsers do not return sameSite at all
const sameSite = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the comment is helpful, but do we need the conditional logic as we really test the version of firefox rolling forward?

Copy link
Contributor

Choose a reason for hiding this comment

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

We still test against FF 134 in CI

Copy link
Contributor

Choose a reason for hiding this comment

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

That's my fault I keep thinking Cypress 15 🥴

(Cypress.isBrowser('firefox') && Number(Cypress.browser.majorVersion) < 135) ||
Cypress.isBrowser('webkit')
) ? 'no_restriction' :
Cypress.isBrowser('firefox') ? 'unspecified' : null

if (sameSite) {
cy.getCookie('five').should('include', { sameSite })
} else {
cy.getCookie('five').should('not.have.property', 'sameSite')
}
Expand Down Expand Up @@ -1515,7 +1523,7 @@ describe('src/cy/commands/cookies', () => {
assertLogLength(this.logs, 1)
expect(lastLog.get('error').message).to.eq(stripIndent`
If a \`sameSite\` value is supplied to \`cy.setCookie()\`, it must be a string from the following list:
> no_restriction, lax, strict
> no_restriction, lax, strict, unspecified
You passed:
> bad`)

Expand Down
2 changes: 1 addition & 1 deletion packages/driver/cypress/e2e/e2e/e2e_cookies.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const cleanse = (cookies) => {
})
}

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

describe('e2e cookies spec', () => {
it('simple cookie', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/driver/cypress/e2e/e2e/origin/cookie_login.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ describe('cy.origin - cookie login', { browser: '!webkit' }, () => {
verifyIdpNotLoggedIn({ expectNullCookie: false })
})

// FIXME: Currently in Firefox, the default cookie setting in the extension is no_restriction, which can be set with Secure=false.
it('SameSite=None -> not logged in', { browser: '!firefox' }, () => {
it('SameSite=None -> not logged in', () => {
cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => {
cy.get('[data-cy="username"]').type(username)
cy.get('[data-cy="cookieProps"]').type('SameSite=None')
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function pickCookieProps (cookie) {
// different defaults, and Firefox lacks support for `unspecified`, so
// `undefined` is used in lieu of `unspecified`
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1624668
const VALID_SAMESITE_VALUES = ['no_restriction', 'lax', 'strict']
const VALID_SAMESITE_VALUES = ['no_restriction', 'lax', 'strict', 'unspecified']

function normalizeSameSite (sameSite?: string) {
if (_.isUndefined(sameSite)) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ export const AllCypressErrors = {
return errTemplate`Still waiting to connect to ${fmt.off(_.capitalize(browserName))}, retrying in 1 second ${fmt.meta(`(attempt ${attempt}/${connectRetryThreshold})`)}`
},
CDP_FIREFOX_DEPRECATED: () => {
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.`
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.`
},
BROWSER_PROCESS_CLOSED_UNEXPECTEDLY: (browserName: string) => {
return errTemplate`\
Expand Down
27 changes: 18 additions & 9 deletions packages/server/lib/browsers/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,25 +409,31 @@ export function clearInstanceState (options: GracefulShutdownOptions = {}) {
}
}

function shouldUseBiDi (browser: Browser): boolean {
function shouldUseCdp (browser: Browser): boolean {
try {
// Gating on firefox version 135 to turn on BiDi as this is when all of our internal Cypress tests were able to pass.
return (browser.family === 'firefox' && !process.env.FORCE_FIREFOX_CDP && Number(browser.majorVersion) >= 135)
// CDP is not supported in Firefox 141+, so we always use BiDi for FF141+.
return (
browser.family === 'firefox' && (
Number(browser.majorVersion) < 135 ||
(Number(browser.majorVersion) < 141 && !!process.env.FORCE_FIREFOX_CDP)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say it might be worth mentioning FORCE_FIREFOX_CDP doesn't work in Firefox 141 plus in a console warning but I am not convinced this option is used enough to warrant the extra work

Copy link
Contributor

Choose a reason for hiding this comment

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

It's implied by the new warning message

)
)
} catch (err: unknown) {
return false
}
}

export async function connectToNewSpec (browser: Browser, options: BrowserNewTabOpts, automation: Automation) {
if (shouldUseBiDi(browser)) {
if (shouldUseCdp(browser)) {
debug('connectToNewSpec cdp')
await firefoxUtil.connectToNewSpecCDP(options, automation, browserCriClient!)
} else {
debug('connectToNewSpec bidi')
await firefoxUtil.connectToNewSpecBiDi(options, automation, browserBidiClient!)

debug('registering middleware')
automation.use(browserBidiClient!.automationMiddleware)
} else {
debug('connectToNewSpec cdp')
await firefoxUtil.connectToNewSpecCDP(options, automation, browserCriClient!)
}
}

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

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

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

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

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

const { FORCE_FIREFOX_CDP, ...launchEnvs } = process.env

const geckoDriverOptions: GeckodriverParameters = {
host: '127.0.0.1',
// geckodriver port is assigned under the hood by @wdio/utils
Expand All @@ -636,7 +645,7 @@ export async function open (browser: Browser, url: string, options: BrowserLaunc
stdio: ['ignore', 'pipe', 'pipe'],
env: {
...BROWSER_ENVS,
...process.env,
...launchEnvs,
},
},
jsdebugger: Debug.enabled(GECKODRIVER_DEBUG_NAMESPACE_VERBOSE) || false,
Expand Down
3 changes: 2 additions & 1 deletion packages/server/lib/socket-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ export class SocketBase {

debug('automation:client connected')

debug('cdp forced for firefox?', !!process.env.FORCE_FIREFOX_CDP && Number(options.getCurrentBrowser()?.majorVersion) < 141)
// only send the necessary config
automationClient.emit('automation:config', {
IS_CDP_FORCED_FOR_FIREFOX: !!process.env.FORCE_FIREFOX_CDP,
IS_CDP_FORCED_FOR_FIREFOX: !!process.env.FORCE_FIREFOX_CDP && Number(options.getCurrentBrowser()?.majorVersion) < 141,
})

// if our automation disconnects then we're
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/unit/browsers/firefox_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('lib/browsers/firefox', () => {
beforeEach(function () {
// majorVersion >= 86 indicates CDP support for Firefox, which provides
// the CDP debugger URL for the after:browser:launch tests
this.browser = { name: 'firefox', channel: 'stable', majorVersion: 100, path: '/path/to/binary' }
this.browser = { name: 'firefox', family: 'firefox', channel: 'stable', majorVersion: 100, path: '/path/to/binary' }
this.automation = {
use: sinon.stub().returns({}),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports['CDP deprecated in Firefox / logs a warning to the user that CDP is depr
────────────────────────────────────────────────────────────────────────────────────────────────────

Running: simple_passing.cy.js (1 of 1)
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.
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.


simple passing spec
Expand Down
7 changes: 6 additions & 1 deletion system-tests/lib/system-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,12 @@ const systemTests = {
const s = this.servers

if (s) {
await Bluebird.map(s, stopServer)
try {
await Bluebird.map(s, stopServer)
} catch (err) {
console.error('Error stopping server', err)
throw err
}
}
})
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const otherHttpsUrl = Cypress.env('otherHttpsUrl')
let defaultSameSite = undefined

if (Cypress.isBrowser('firefox')) {
// firefox will default to "no_restriction"
// firefox will default to "unspecified"
// @see https://bugzilla.mozilla.org/show_bug.cgi?id=1624668
defaultSameSite = 'no_restriction'
defaultSameSite = 'unspecified'
}

describe('cookies', () => {
Expand Down
10 changes: 9 additions & 1 deletion system-tests/projects/e2e/cypress/e2e/multi_cookies.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ describe('set:cookies', () => {
'domain': '127.0.0.3',
'secure': false,
'httpOnly': false,
...(Cypress.isBrowser({ family: 'firefox' }) ? { sameSite: 'no_restriction' } : {}),
...(
Cypress.isBrowser('webkit') || (
Cypress.isBrowser({ family: 'firefox' }) && Cypress.browser.majorVersion < 135
)
? { sameSite: 'no_restriction' }
: Cypress.isBrowser({ family: 'firefox' }) ?
{ sameSite: 'unspecified' } :
{}
),
},

{
Expand Down
2 changes: 1 addition & 1 deletion system-tests/projects/e2e/cypress/e2e/request.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('redirects + requests', () => {
}

if (Cypress.isBrowser('firefox')) {
expectedCookie.sameSite = 'no_restriction'
expectedCookie.sameSite = 'unspecified'
}

expect(cookies[1]).to.deep.eq(expectedCookie)
Expand Down
2 changes: 1 addition & 1 deletion system-tests/test/cdp_deprecated_firefox_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('CDP deprecated in Firefox', () => {
snapshot: true,
spec: 'simple_passing.cy.js',
onStdout: (stdout) => {
expect(stdout).to.include('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.')
expect(stdout).to.include(`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.`)
},
})
})
Loading