Skip to content

Commit

Permalink
fix: update userChrome.css to correctly hide the toolbox in firefox (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mschile authored Dec 10, 2024
1 parent e96593b commit dcd0e92
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ _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

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 @@ -370,7 +370,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 @@ -560,11 +565,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
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 @@ -274,7 +274,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 @@ -339,7 +339,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
19 changes: 0 additions & 19 deletions system-tests/lib/normalizeStdout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,25 +180,6 @@ export const normalizeStdout = function (str: string, options: any = {}) {
str = str.split('\n').filter((line) => !line.includes(wdsFailedMsg)).join('\n')
}

// in Firefox 130, height dimensions are off by 1 pixel in CI, so we need to fix the offset to match common snapshots
if (options.browser === 'firefox' && process.env.CI) {
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)

// only happens on default height for whatever reason in firefox 130...
if (height === 719) {
const expectedHeight = height + 1
const expectedWidth = matches?.groups?.width

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

3 comments on commit dcd0e92

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dcd0e92 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/13.16.2/linux-x64/develop-dcd0e92ced2fe16cc337ec8914fce4b22e98682a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dcd0e92 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/13.16.2/linux-arm64/develop-dcd0e92ced2fe16cc337ec8914fce4b22e98682a/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dcd0e92 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/13.16.2/win32-x64/develop-dcd0e92ced2fe16cc337ec8914fce4b22e98682a/cypress.tgz

Please sign in to comment.