From 6411c4f5bf04f78bf6a7c6ab6e0b04401f12c591 Mon Sep 17 00:00:00 2001 From: Cacie Prins Date: Tue, 7 Jan 2025 11:07:01 -0500 Subject: [PATCH] refactor: clean up experimentalSkipDomainInjection removal (#30826) * chore: clean up experimentalSkipDomainInjection removal * rm corepack yarn line * update snapshots * rm dead code, update error message --- .../config/__snapshots__/index.spec.ts.js | 4 +- packages/config/src/options.ts | 27 ++---------- packages/config/test/project/utils.spec.ts | 2 - packages/driver/src/cypress/error_messages.ts | 2 +- ...MENTAL_SKIP_DOMAIN_INJECTION_REMOVED.html} | 0 ..._USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY.html | 41 ------------------ packages/errors/src/errors.ts | 9 +--- .../test/unit/visualSnapshotErrors_spec.ts | 8 +--- .../frontend-shared/src/locales/en-US.json | 4 -- packages/graphql/schemas/schema.graphql | 3 +- packages/network/lib/cors.ts | 33 -------------- packages/network/test/unit/cors_spec.ts | 18 -------- packages/server/lib/experiments.ts | 2 - ...erimental_skip_domain_injection_spec.ts.js | 12 ++++++ system-tests/__snapshots__/results_spec.ts.js | 1 - .../experimental_skip_domain_injection.cy.ts | 43 ------------------- ...experimental_skip_domain_injection_spec.ts | 1 - 17 files changed, 21 insertions(+), 189 deletions(-) rename packages/errors/__snapshot-html__/{EXPERIMENTAL_SKIP_DOMAIN_INJECTION.html => EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED.html} (100%) delete mode 100644 packages/errors/__snapshot-html__/EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY.html delete mode 100644 system-tests/projects/e2e/cypress/e2e/experimental_skip_domain_injection.cy.ts diff --git a/packages/config/__snapshots__/index.spec.ts.js b/packages/config/__snapshots__/index.spec.ts.js index cce307440959..fa1ab1e23cb4 100644 --- a/packages/config/__snapshots__/index.spec.ts.js +++ b/packages/config/__snapshots__/index.spec.ts.js @@ -9,6 +9,7 @@ exports['config/src/index .getBreakingKeys returns list of breaking config keys 'experimentalSessionSupport', 'experimentalSessionAndOrigin', 'experimentalShadowDomSupport', + 'experimentalSkipDomainInjection', 'firefoxGcInterval', 'ignoreTestFiles', 'integrationFolder', @@ -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, @@ -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, @@ -221,7 +220,6 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key 'experimentalMemoryManagement', 'experimentalModifyObstructiveThirdPartyCode', 'injectDocumentDomain', - 'experimentalSkipDomainInjection', 'experimentalOriginDependencies', 'experimentalSourceRewriting', 'experimentalSingleTabRunMode', diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index 67cf09718462..e704f67d77e4 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -234,13 +234,6 @@ const driverConfigOptions: Array = [ defaultValue: false, validation: validate.isBoolean, requireRestartOnChange: 'server', - }, - { - name: 'experimentalSkipDomainInjection', - defaultValue: null, - validation: validate.isNullOrArrayOfStrings, - isExperimental: true, - requireRestartOnChange: 'server', }, { name: 'experimentalOriginDependencies', defaultValue: false, @@ -665,6 +658,10 @@ export const breakingOptions: Readonly = [ 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', @@ -737,12 +734,6 @@ export const breakingRootOptions: Array = [ 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', @@ -774,11 +765,6 @@ export const testingTypeBreakingOptions: { e2e: Array, component errorKey: 'JIT_COMPONENT_TESTING', isWarning: false, }, - { - name: 'experimentalSkipDomainInjection', - errorKey: 'EXPERIMENTAL_SKIP_DOMAIN_INJECTION', - isWarning: false, - }, { name: 'injectDocumentDomain', errorKey: 'INJECT_DOCUMENT_DOMAIN_DEPRECATION', @@ -811,11 +797,6 @@ export const testingTypeBreakingOptions: { e2e: Array, 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', diff --git a/packages/config/test/project/utils.spec.ts b/packages/config/test/project/utils.spec.ts index 74f8df95f123..ab47b455d667 100644 --- a/packages/config/test/project/utils.spec.ts +++ b/packages/config/test/project/utils.spec.ts @@ -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' }, @@ -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' }, diff --git a/packages/driver/src/cypress/error_messages.ts b/packages/driver/src/cypress/error_messages.ts index 1f84ca8bd1ad..34e998fe8d6b 100644 --- a/packages/driver/src/cypress/error_messages.ts +++ b/packages/driver/src/cypress/error_messages.ts @@ -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. diff --git a/packages/errors/__snapshot-html__/EXPERIMENTAL_SKIP_DOMAIN_INJECTION.html b/packages/errors/__snapshot-html__/EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED.html similarity index 100% rename from packages/errors/__snapshot-html__/EXPERIMENTAL_SKIP_DOMAIN_INJECTION.html rename to packages/errors/__snapshot-html__/EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED.html diff --git a/packages/errors/__snapshot-html__/EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY.html b/packages/errors/__snapshot-html__/EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY.html deleted file mode 100644 index 45cef108724b..000000000000 --- a/packages/errors/__snapshot-html__/EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - -
The 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
-
-
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 6cc108c6eba2..9df295c5ed1e 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -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`\ diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 3f47f7b931f0..88d8fa118b84 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -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() @@ -1422,7 +1416,7 @@ describe('visual error templates', () => { } }, - EXPERIMENTAL_SKIP_DOMAIN_INJECTION: () => { + EXPERIMENTAL_SKIP_DOMAIN_INJECTION_REMOVED: () => { return { default: [], } diff --git a/packages/frontend-shared/src/locales/en-US.json b/packages/frontend-shared/src/locales/en-US.json index 446e788f9293..9d555da87ff0 100644 --- a/packages/frontend-shared/src/locales/en-US.json +++ b/packages/frontend-shared/src/locales/en-US.json @@ -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": { diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 5a1ae40046d9..0faec7ad8153 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -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 diff --git a/packages/network/lib/cors.ts b/packages/network/lib/cors.ts index 5a55705c5f9c..c784e820ada6 100644 --- a/packages/network/lib/cors.ts +++ b/packages/network/lib/cors.ts @@ -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' @@ -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. @@ -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, diff --git a/packages/network/test/unit/cors_spec.ts b/packages/network/test/unit/cors_spec.ts index efdb22dc6449..9548edc65f43 100644 --- a/packages/network/test/unit/cors_spec.ts +++ b/packages/network/test/unit/cors_spec.ts @@ -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 - }) - }) }) diff --git a/packages/server/lib/experiments.ts b/packages/server/lib/experiments.ts index 27d2274c9fdf..b043ec1ef068 100644 --- a/packages/server/lib/experiments.ts +++ b/packages/server/lib/experiments.ts @@ -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.', @@ -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', diff --git a/system-tests/__snapshots__/experimental_skip_domain_injection_spec.ts.js b/system-tests/__snapshots__/experimental_skip_domain_injection_spec.ts.js index 8d5cc8fa9a49..96dbb141630e 100644 --- a/system-tests/__snapshots__/experimental_skip_domain_injection_spec.ts.js +++ b/system-tests/__snapshots__/experimental_skip_domain_injection_spec.ts.js @@ -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 diff --git a/system-tests/__snapshots__/results_spec.ts.js b/system-tests/__snapshots__/results_spec.ts.js index 19f9c620e234..ba61829ae392 100644 --- a/system-tests/__snapshots__/results_spec.ts.js +++ b/system-tests/__snapshots__/results_spec.ts.js @@ -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, diff --git a/system-tests/projects/e2e/cypress/e2e/experimental_skip_domain_injection.cy.ts b/system-tests/projects/e2e/cypress/e2e/experimental_skip_domain_injection.cy.ts deleted file mode 100644 index fb906537dd7c..000000000000 --- a/system-tests/projects/e2e/cypress/e2e/experimental_skip_domain_injection.cy.ts +++ /dev/null @@ -1,43 +0,0 @@ -describe('expected behavior when experimentalSkipDomainInjection=true', () => { - it('Handles cross-site/cross-origin navigation the same way without the experimental flag enabled', () => { - cy.visit('/primary_origin.html') - cy.get('a[data-cy="cross_origin_secondary_link"]').click() - cy.origin('http://www.foobar.com:4466', () => { - cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') - }) - }) - - it('errors appropriately when doing a sub domain navigation w/o cy.origin()', () => { - const timeout = 500 - - cy.on('fail', (err) => { - expect(err.name).to.equal('CypressError') - expect(err.message).to.contain(`Timed out retrying after ${timeout}ms: The command was expected to run against origin \`http://app.foobar.com:4466\` but the application is at origin \`http://www.foobar.com:4466\`.`) - expect(err.message).to.contain('This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') - expect(err.message).to.contain('Using `cy.origin()` to wrap the commands run on `http://www.foobar.com:4466` will likely fix this issue.') - expect(err.message).to.include(`cy.origin('http://www.foobar.com:4466', () => {\`\n\` \`\n\`})`) - expect(err.message).to.include('If `experimentalSkipDomainInjection` is enabled for this domain, a `cy.origin()` command is required.') - - // make sure that the secondary origin failures do NOT show up as spec failures or AUT failures - expect(err.message).not.to.include(`The following error originated from your test code, not from Cypress`) - expect(err.message).not.to.include(`The following error originated from your application code, not from Cypress`) - }) - - // with experimentalSkipDomainInjection, sub domain navigations require a cy.origin() block - cy.visit('http://app.foobar.com:4466/primary_origin.html') - cy.get('a[data-cy="cross_origin_secondary_link"]').click() - cy.get('[data-cy="dom-check"]', { - timeout, - }).should('have.text', 'From a secondary origin') - }) - - it('allows sub-domain navigations with the use of cy.origin()', () => { - cy.visit('http://app.foobar.com:4466/primary_origin.html') - cy.get('a[data-cy="cross_origin_secondary_link"]').click() - - // with experimentalSkipDomainInjection, sub domain navigations require a cy.origin() block - cy.origin('http://www.foobar.com:4466', () => { - cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') - }) - }) -}) diff --git a/system-tests/test/experimental_skip_domain_injection_spec.ts b/system-tests/test/experimental_skip_domain_injection_spec.ts index c488a4f3a6c1..e6b2ef430ff2 100644 --- a/system-tests/test/experimental_skip_domain_injection_spec.ts +++ b/system-tests/test/experimental_skip_domain_injection_spec.ts @@ -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: {