-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add modify obstructive user agent code for electron to strip el… (
#22958) * feat: add modify obstructive user agent code for electron to strip electron and cypress out of the UA string. * fix user agent destructuring error within unit tests * remove explicit CDP command and opt for _setUserAgent. add test to not override passed in user agent via config * add get user agent method to electron and update tests * move user agent override in electron under experimentalModifyObstructiveThirdPartyCode over experimentalSessionAndOrigin * move position of setting user agent to browser launch, hopefully fixing issues in CI with parallelization between parent/child processes * update stale documentation and remove no longer necessary stub of getUserAgent * add user agent to get user agent debug log Co-authored-by: Matt Schile <[email protected]>
- Loading branch information
1 parent
45ec63d
commit 2612219
Showing
5 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/driver/cypress/e2e/e2e/origin/user_agent_override.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// @see https://github.com/cypress-io/cypress/issues/22953 | ||
// We modify the user agent to strip cypress and electron out of the user agent string to appear more chrome-like | ||
// this only happens in electron and when the experimentalModifyObstructiveThirdPartyCode flag is set to true | ||
describe('user agent override', { | ||
browser: 'electron', | ||
}, () => { | ||
it('persists modified user agent after cy.visit', () => { | ||
cy.wrap(window.navigator.userAgent).as('userAgentBefore') | ||
cy.visit('/fixtures/primary-origin.html') | ||
cy.wrap(window.navigator.userAgent).then((userAgentAfter) => { | ||
cy.get('@userAgentBefore').then((userAgentBefore) => { | ||
expect(userAgentBefore).to.equal(userAgentAfter) | ||
}) | ||
}) | ||
}) | ||
|
||
it('persists modified user agent after cy.reload', () => { | ||
cy.wrap(window.navigator.userAgent).as('userAgentBefore') | ||
cy.visit('/fixtures/primary-origin.html') | ||
cy.reload() | ||
cy.wrap(window.navigator.userAgent).then((userAgentAfter) => { | ||
cy.get('@userAgentBefore').then((userAgentBefore) => { | ||
expect(userAgentBefore).to.equal(userAgentAfter) | ||
}) | ||
}) | ||
}) | ||
|
||
it('persists modified user agent after cy.go', () => { | ||
cy.visit('/fixtures/primary-origin.html') | ||
cy.get('a[data-cy="cross-origin-secondary-link"]').click() | ||
|
||
cy.origin('http://foobar.com:3500', { | ||
args: { | ||
userAgentBefore: window.navigator.userAgent, | ||
}, | ||
}, ({ userAgentBefore }) => { | ||
cy.visit('http://www.foobar.com:3500/fixtures/dom.html') | ||
|
||
cy.go('back') | ||
cy.wrap(window.navigator.userAgent).then((userAgentAfter) => { | ||
expect(userAgentBefore).to.equal(userAgentAfter) | ||
}) | ||
|
||
cy.go('forward') | ||
cy.wrap(window.navigator.userAgent).then((userAgentAfter) => { | ||
expect(userAgentBefore).to.equal(userAgentAfter) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2612219
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
2612219
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
2612219
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
2612219
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
2612219
There was a problem hiding this comment.
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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: