Skip to content

Commit

Permalink
refactor: clean up experimentalSkipDomainInjection removal (#30826)
Browse files Browse the repository at this point in the history
* chore: clean up experimentalSkipDomainInjection removal

* rm corepack yarn line

* update snapshots

* rm dead code, update error message
  • Loading branch information
cacieprins authored Jan 7, 2025
1 parent 71d3a50 commit 6411c4f
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 189 deletions.
4 changes: 1 addition & 3 deletions packages/config/__snapshots__/index.spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports['config/src/index .getBreakingKeys returns list of breaking config keys
'experimentalSessionSupport',
'experimentalSessionAndOrigin',
'experimentalShadowDomSupport',
'experimentalSkipDomainInjection',
'firefoxGcInterval',
'ignoreTestFiles',
'integrationFolder',
Expand Down Expand Up @@ -41,7 +42,6 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
'experimentalMemoryManagement': false,
'experimentalModifyObstructiveThirdPartyCode': false,
'injectDocumentDomain': false,
'experimentalSkipDomainInjection': null,
'experimentalOriginDependencies': false,
'experimentalSourceRewriting': false,
'experimentalSingleTabRunMode': false,
Expand Down Expand Up @@ -133,7 +133,6 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
'experimentalMemoryManagement': false,
'experimentalModifyObstructiveThirdPartyCode': false,
'injectDocumentDomain': false,
'experimentalSkipDomainInjection': null,
'experimentalOriginDependencies': false,
'experimentalSourceRewriting': false,
'experimentalSingleTabRunMode': false,
Expand Down Expand Up @@ -221,7 +220,6 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key
'experimentalMemoryManagement',
'experimentalModifyObstructiveThirdPartyCode',
'injectDocumentDomain',
'experimentalSkipDomainInjection',
'experimentalOriginDependencies',
'experimentalSourceRewriting',
'experimentalSingleTabRunMode',
Expand Down
27 changes: 4 additions & 23 deletions packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,6 @@ const driverConfigOptions: Array<DriverConfigOption> = [
defaultValue: false,
validation: validate.isBoolean,
requireRestartOnChange: 'server',
},
{
name: 'experimentalSkipDomainInjection',
defaultValue: null,
validation: validate.isNullOrArrayOfStrings,
isExperimental: true,
requireRestartOnChange: 'server',
}, {
name: 'experimentalOriginDependencies',
defaultValue: false,
Expand Down Expand Up @@ -665,6 +658,10 @@ export const breakingOptions: Readonly<BreakingOption[]> = [
name: 'experimentalShadowDomSupport',
errorKey: 'EXPERIMENTAL_SHADOW_DOM_REMOVED',
isWarning: true,
}, {
name: 'experimentalSkipDomainInjection',
errorKey: 'EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED',
isWarning: false,
}, {
name: 'firefoxGcInterval',
errorKey: 'FIREFOX_GC_INTERVAL_REMOVED',
Expand Down Expand Up @@ -737,12 +734,6 @@ export const breakingRootOptions: Array<BreakingOption> = [
isWarning: false,
testingTypes: ['e2e'],
},
{
name: 'experimentalSkipDomainInjection',
errorKey: 'EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY',
isWarning: false,
testingTypes: ['e2e'],
},
{
name: 'experimentalOriginDependencies',
errorKey: 'EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY',
Expand Down Expand Up @@ -774,11 +765,6 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
errorKey: 'JIT_COMPONENT_TESTING',
isWarning: false,
},
{
name: 'experimentalSkipDomainInjection',
errorKey: 'EXPERIMENTAL_SKIP_DOMAIN_INJECTION',
isWarning: false,
},
{
name: 'injectDocumentDomain',
errorKey: 'INJECT_DOCUMENT_DOMAIN_DEPRECATION',
Expand Down Expand Up @@ -811,11 +797,6 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
errorKey: 'EXPERIMENTAL_ORIGIN_DEPENDENCIES_E2E_ONLY',
isWarning: false,
},
{
name: 'experimentalSkipDomainInjection',
errorKey: 'EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY',
isWarning: false,
},
{
name: 'injectDocumentDomain',
errorKey: 'INJECT_DOCUMENT_DOMAIN_E2E_ONLY',
Expand Down
2 changes: 0 additions & 2 deletions packages/config/test/project/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,6 @@ describe('config/src/project/utils', () => {
excludeSpecPattern: { value: '*.hot-update.js', from: 'default' },
execTimeout: { value: 60000, from: 'default' },
experimentalModifyObstructiveThirdPartyCode: { value: false, from: 'default' },
experimentalSkipDomainInjection: { value: null, from: 'default' },
experimentalCspAllowList: { value: false, from: 'default' },
experimentalInteractiveRunEvents: { value: false, from: 'default' },
experimentalMemoryManagement: { value: false, from: 'default' },
Expand Down Expand Up @@ -1191,7 +1190,6 @@ describe('config/src/project/utils', () => {
excludeSpecPattern: { value: '*.hot-update.js', from: 'default' },
execTimeout: { value: 60000, from: 'default' },
experimentalModifyObstructiveThirdPartyCode: { value: false, from: 'default' },
experimentalSkipDomainInjection: { value: null, from: 'default' },
experimentalCspAllowList: { value: false, from: 'default' },
experimentalInteractiveRunEvents: { value: false, from: 'default' },
experimentalMemoryManagement: { value: false, from: 'default' },
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/cypress/error_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ export default {
This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.
${isSkipDomainInjectionEnabled ? `
If \`experimentalSkipDomainInjection\` is enabled for this domain, a ${cmd('origin')} command is required.
Unless \`injectDocumentDomain\` is disabled, a ${cmd('origin')} command is required.
` : ''}
Using ${cmd('origin')} to wrap the commands run on \`${autOrigin}\` will likely fix this issue.
Expand Down

This file was deleted.

9 changes: 1 addition & 8 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1350,20 +1350,13 @@ export const AllCypressErrors = {
return errTemplate`\
The ${fmt.highlight(`justInTimeCompile`)} configuration is only supported for Component Testing.`
},
EXPERIMENTAL_SKIP_DOMAIN_INJECTION: () => {
EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED: () => {
return errTemplate`\
The ${fmt.highlight(`experimentalSkipDomainInjection`)} experiment is over. ${fmt.highlight('document.domain')} injection is now off by default.
Read the migration guide for Cypress v14.0.0: https://on.cypress.com/migration-guide
`
},
EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY: () => {
return errTemplate`\
The ${fmt.highlight(`experimentalSkipDomainInjection`)} experiment is over, and this configuration option is no longer honored.
Read the migration guide for Cypress v14.0.0: https://on.cypress.com/migration-guide
`
},
// TODO: link to docs on injectDocumentDomain
INJECT_DOCUMENT_DOMAIN_DEPRECATION: () => {
return errTemplate`\
Expand Down
8 changes: 1 addition & 7 deletions packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,6 @@ describe('visual error templates', () => {
}
},

EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY: () => {
return {
default: [],
}
},

PROXY_ENCOUNTERED_INVALID_HEADER_NAME: () => {
const err = makeErr()

Expand All @@ -1422,7 +1416,7 @@ describe('visual error templates', () => {
}
},

EXPERIMENTAL_SKIP_DOMAIN_INJECTION: () => {
EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED: () => {
return {
default: [],
}
Expand Down
4 changes: 0 additions & 4 deletions packages/frontend-shared/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,6 @@
"experimentalMemoryManagement": {
"name": "Memory Management",
"description": "Enables support for improved memory management within Chromium-based browsers."
},
"experimentalSkipDomainInjection": {
"name": "Skip Domain Injection",
"description": "Disables setting `document.domain` to the application's super domain on injection."
}
},
"device": {
Expand Down
3 changes: 1 addition & 2 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1196,10 +1196,9 @@ enum ErrorTypeEnum {
EXPERIMENTAL_SESSION_SUPPORT_REMOVED
EXPERIMENTAL_SHADOW_DOM_REMOVED
EXPERIMENTAL_SINGLE_TAB_RUN_MODE
EXPERIMENTAL_SKIP_DOMAIN_INJECTION
EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED
EXPERIMENTAL_STUDIO_E2E_ONLY
EXPERIMENTAL_STUDIO_REMOVED
EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY
EXTENSION_NOT_LOADED
FIREFOX_CDP_FAILED_TO_CONNECT
FIREFOX_COULD_NOT_CONNECT
Expand Down
33 changes: 0 additions & 33 deletions packages/network/lib/cors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash'
import minimatch from 'minimatch'
import * as uri from './uri'
import debugModule from 'debug'
import _parseDomain from '@cypress/parse-domain'
Expand Down Expand Up @@ -162,19 +161,6 @@ export const urlSameSiteMatch = (frameUrl: string, topUrl: string): boolean => {
})
}

/**
* @param url - the url to check the policy against.
* @param arrayOfStringOrGlobPatterns - an array of url strings or globs to match against
* @returns {boolean} - whether or not a match was found
*/
const doesUrlHostnameMatchGlobArray = (url: string, arrayOfStringOrGlobPatterns: string[]): boolean => {
let { hostname } = uri.parse(url)

return !!arrayOfStringOrGlobPatterns.find((globPattern) => {
return minimatch(hostname || '', globPattern)
})
}

/**
* Returns the policy that will be used for the specified url.
* @param url - the url to check the policy against.
Expand All @@ -187,25 +173,6 @@ export const policyFromConfig = (config: { injectDocumentDomain: boolean }): Pol
'same-origin'
}

/**
* @param url - The url to check for injection
* @param opts - an options object containing the skipDomainInjectionForDomains config. Default is undefined.
* @returns {boolean} whether or not document.domain should be injected solely based on the url.
*/
export const shouldInjectDocumentDomain = (url: string, opts?: {
skipDomainInjectionForDomains: string[] | null
}) => {
// When determining if we want to injection document domain,
// We need to make sure the experimentalSkipDomainInjection feature flag is off.
// If on, we need to make sure the glob pattern doesn't exist in the array so we cover possible intersections (google).
if (_.isArray(opts?.skipDomainInjectionForDomains)) {
// if we match the glob, we want to return false
return !doesUrlHostnameMatchGlobArray(url, opts?.skipDomainInjectionForDomains as string[])
}

return true
}

/**
* Checks the supplied url and props against the determined policy.
* The policy is same-super-domain-origin unless the domain is in the list of strict same origin domains,
Expand Down
18 changes: 0 additions & 18 deletions packages/network/test/unit/cors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,22 +552,4 @@ describe('lib/cors', () => {
expect(cors.policyFromConfig({ injectDocumentDomain: true })).to.equal('same-super-domain-origin')
})
})

context('.shouldInjectDocumentDomain', () => {
it('returns false when "skipDomainInjectionForDomains" is configured and contains a matching blob pattern ', () => {
expect(cors.shouldInjectDocumentDomain('http://www.cypress.io', {
skipDomainInjectionForDomains: ['*.cypress.io'],
})).to.be.false
})

it('returns true when "skipDomainInjectionForDomains" exists, but doesn\'t contain a matching glob pattern', () => {
expect(cors.shouldInjectDocumentDomain('http://www.cypress.io', {
skipDomainInjectionForDomains: ['*.foobar.com'],
})).to.be.true
})

it('returns true otherwise', () => {
expect(cors.shouldInjectDocumentDomain('http://www.cypress.io')).to.be.true
})
})
})
2 changes: 0 additions & 2 deletions packages/server/lib/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ interface StringValues {
const _summaries: StringValues = {
experimentalInteractiveRunEvents: 'Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode.',
experimentalModifyObstructiveThirdPartyCode: 'Applies `modifyObstructiveCode` to third party `.html` and `.js`, removes subresource integrity, and modifies the user agent in Electron.',
experimentalSkipDomainInjection: 'Disables setting document.domain to the document\'s super domain on injection.',
experimentalSourceRewriting: 'Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm.',
experimentalSingleTabRunMode: 'Runs all component specs in a single tab, trading spec isolation for faster run mode execution.',
experimentalStudio: 'Generate and save commands directly to your test suite by interacting with your app as an end user would.',
Expand All @@ -76,7 +75,6 @@ const _summaries: StringValues = {
const _names: StringValues = {
experimentalInteractiveRunEvents: 'Interactive Mode Run Events',
experimentalModifyObstructiveThirdPartyCode: 'Modify Obstructive Third Party Code',
experimentalSkipDomainInjection: 'Use Default document.domain',
experimentalSingleTabRunMode: 'Single Tab Run Mode',
experimentalSourceRewriting: 'Improved Source Rewriting',
experimentalStudio: 'Studio',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
exports['e2e experimentalSkipDomainInjection=true / fails with an error message about experimentalSkipDomainInjection being removed'] = `
The following configuration option is invalid:
- experimentalSkipDomainInjection
https://on.cypress.io/configuration
The following configuration option is invalid:
- experimentalSkipDomainInjection
https://on.cypress.io/configuration
The experimentalSkipDomainInjection experiment is over. document.domain injection is now off by default.
Read the migration guide for Cypress v14.0.0: https://on.cypress.com/migration-guide
Expand Down
1 change: 0 additions & 1 deletion system-tests/__snapshots__/results_spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ exports['module api and after:run results'] = `
"experimentalMemoryManagement": false,
"experimentalModifyObstructiveThirdPartyCode": false,
"injectDocumentDomain": false,
"experimentalSkipDomainInjection": null,
"experimentalOriginDependencies": false,
"experimentalSourceRewriting": false,
"experimentalSingleTabRunMode": false,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('e2e experimentalSkipDomainInjection=true', () => {
browser: '!webkit', // TODO(webkit): fix+unskip (needs multidomain support)
// keep the port the same to prevent issues with the snapshot
port: PORT,
spec: 'experimental_skip_domain_injection.cy.ts',
snapshot: true,
expectedExitCode: 1,
config: {
Expand Down

2 comments on commit 6411c4f

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6411c4f Jan 7, 2025

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/14.0.0/linux-x64/release/14.0.0-6411c4f5bf04f78bf6a7c6ab6e0b04401f12c591/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6411c4f Jan 7, 2025

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/14.0.0/linux-arm64/release/14.0.0-6411c4f5bf04f78bf6a7c6ab6e0b04401f12c591/cypress.tgz

Please sign in to comment.