Skip to content

Commit

Permalink
adds explanation comment and test
Browse files Browse the repository at this point in the history
  • Loading branch information
cacieprins committed May 3, 2024
1 parent e439881 commit f432813
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/server/lib/browsers/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ let browserCriClient: BrowserCriClient | undefined
* @param userDir
*/
const _getChromePreferences = (userDir: string): Bluebird<ChromePreferences> => {
/**
* By returning empty objects here, the user is indicating that they do not want
* Chrome preferences read. If they do not provide preferences via config,
* this effectively prevents Cypress from writing to the Chrome preferences files.
* See: _writeChromePreferences
*/
if (process.env.IGNORE_CHROME_PREFERENCES) {
debug('ignoring chrome preferences...')

Expand Down Expand Up @@ -598,13 +604,16 @@ export = {
launchOptions.preferences = _mergeChromePreferences(preferences, launchOptions.preferences as ChromePreferences)
}

const p = _disableRestorePagesPrompt(userDir)

debug(p)
await p
const [extDest] = await Bluebird.all([
this._writeExtension(
browser,
options,
),
_removeRootExtension(),
_disableRestorePagesPrompt(userDir),
// Chrome adds a lock file to the user data dir. If we are restarting the run and browser, we need to remove it.
fs.unlink(path.join(userDir, 'SingletonLock')).catch(() => {}),
_writeChromePreferences(userDir, preferences, launchOptions.preferences as ChromePreferences),
Expand Down
31 changes: 31 additions & 0 deletions packages/server/test/unit/browsers/chrome_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,37 @@ describe('lib/browsers/chrome', () => {
})
})

context('when IGNORE_CHROME_PREFERENCES env is set', () => {
let oldPref
let writeJson

beforeEach(function () {
oldPref = process.env.IGNORE_CHROME_PREFERENCES
process.env.IGNORE_CHROME_PREFERENCES = true
this.readJson.rejects({ code: 'ENOENT' })
writeJson = sinon.stub(fs, 'outputJson').resolves()
})

afterEach(() => {
process.env.IGNORE_CHROME_PREFERENCES = oldPref
writeJson.restore()
})

it('does not write preferences', async function () {
chrome._writeExtension.restore()
utils.getProfileDir.restore()

await chrome.open({
isHeadless: true,
isHeaded: false,
name: 'chromium',
channel: 'stable',
}, 'http://', openOpts, this.automation)

expect(writeJson).not.to.be.called
})
})

it('DEPRECATED: normalizes --load-extension if provided in plugin', function () {
plugins.registerEvent('before:browser:launch', (browser, config) => {
return Promise.resolve(['--foo=bar', '--load-extension=/foo/bar/baz.js'])
Expand Down

4 comments on commit f432813

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f432813 May 3, 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.9.0/linux-x64/ryanm/chore/bump-electron-f432813d1671afe182044bf8f7ccce5576ff766f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f432813 May 3, 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.9.0/linux-arm64/ryanm/chore/bump-electron-f432813d1671afe182044bf8f7ccce5576ff766f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f432813 May 3, 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/13.9.0/darwin-arm64/ignore-chrom-prefs-f432813d1671afe182044bf8f7ccce5576ff766f/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f432813 May 3, 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/13.9.0/darwin-x64/ignore-chrom-prefs-f432813d1671afe182044bf8f7ccce5576ff766f/cypress.tgz

Please sign in to comment.