Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: build document.domain removal binary #30768

Draft
wants to merge 60 commits into
base: release/14.0.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5b42419
remove experimentalSkipDomainInjection, add and deprecate injectDocum…
cacieprins Oct 17, 2024
151952d
remove experimentalSkipDomainInjection, add injectDocumentDomain
cacieprins Oct 17, 2024
dc4fb0b
begin rethreading domain injection
cacieprins Oct 18, 2024
330adc4
complete document domain transition
cacieprins Oct 21, 2024
2000405
move some cookie specs to separate test run
cacieprins Oct 22, 2024
0f822b5
origin and privileged commands with default docdom inject
cacieprins Oct 23, 2024
8275e4d
fix privileged channel when injecting document domain
cacieprins Oct 23, 2024
4a52817
rm unnecessary .getOrigin abstraction in cors lib
cacieprins Oct 23, 2024
b3b60a1
move remote-states in prep for refactor Replace Conditional with Poly…
cacieprins Oct 23, 2024
a8f6406
refactor remote states to strategy pattern
cacieprins Oct 24, 2024
c54224b
cookie commands work as expected w cross origin bridge on different o…
cacieprins Oct 28, 2024
110996b
some origin tests updated
cacieprins Oct 30, 2024
4895219
run tests with document domain enabled
cacieprins Oct 30, 2024
33d33cd
run tests actually
cacieprins Oct 30, 2024
1d348c9
use correct config, swap conditional
cacieprins Oct 30, 2024
8b943d0
check-ts
cacieprins Oct 30, 2024
1166858
inject documetn domain for webkit tests
cacieprins Oct 30, 2024
25c3ac7
do not exec injectDocumetnDomain in parallel
cacieprins Oct 30, 2024
b4c0be3
fix ServerBase construction in tests to include cfg now
cacieprins Oct 31, 2024
3e613f0
pass cfg to ServerBase
cacieprins Oct 31, 2024
b6090f7
improved integration tests
cacieprins Oct 31, 2024
4da149d
remove document domain checks for all server integration specs - will…
cacieprins Nov 1, 2024
9bcc1f3
tests for injecting document domain when configured to
cacieprins Nov 1, 2024
e8ccb4d
square away server integration tests
cacieprins Nov 5, 2024
db047b7
ensure cookies are set correctly, potentially
cacieprins Nov 7, 2024
55fa5b1
errors pkg snapshots
cacieprins Nov 7, 2024
018816c
fix config tests
cacieprins Nov 8, 2024
5622cc5
fixing config tests
cacieprins Nov 8, 2024
b01df45
somewhat improves tests for cors policies in packages/network
cacieprins Nov 12, 2024
03f34bb
fix ts err in server-base
cacieprins Nov 12, 2024
c3ac388
Merge branch 'release/14.0.0' into cacie/29590/document-domain-subdom…
cacieprins Nov 12, 2024
376627b
enable injectDocumentDomain for cy in cy tests
cacieprins Nov 13, 2024
52156bf
fix Policy type ref
cacieprins Nov 13, 2024
18ae100
refactor cypress-schematic ct spec to be less prone to timeouts
cacieprins Nov 14, 2024
e66d194
run vite-dev-server tests with injectDocumentDomain
cacieprins Nov 14, 2024
19ce24e
rm document domain assertion from page_loading system test
cacieprins Nov 14, 2024
3d2a0c1
add system tests that test with injectDocumentDomain and others that …
cacieprins Nov 15, 2024
edbdb36
fix results_spec snapshot
cacieprins Nov 15, 2024
dd9a50d
update experimentalSkipDomainInjection system test
cacieprins Nov 18, 2024
70c0a8f
different behavior for certain net_stubbing tests based on injectDocu…
cacieprins Nov 19, 2024
29110af
fix ts
cacieprins Nov 19, 2024
e1e0829
extract origin key logic from remote states, for now
cacieprins Nov 21, 2024
ec669b8
move server-base and response-middleware over to new pattern
cacieprins Nov 21, 2024
e448022
WIP - reentry
cacieprins Nov 22, 2024
e19fb59
Merge branch 'release/14.0.0' into cacie/29590/document-domain-subdom…
cacieprins Dec 4, 2024
9a1c30e
fix build, remove console.log
cacieprins Dec 4, 2024
e97d548
check-ts
cacieprins Dec 4, 2024
941701f
fix spec frame injection
cacieprins Dec 5, 2024
e651ef6
remove injection for localhost
cacieprins Dec 5, 2024
0ec1b12
mostly fix vite-dev-server app integration tests
cacieprins Dec 6, 2024
5de96f0
fix codeframe in certain cases in chrome
cacieprins Dec 9, 2024
0d6b14d
drop internal stack frames from stacks intended for determining code …
cacieprins Dec 10, 2024
5afda0f
some improvements to vite ct error codeframes
cacieprins Dec 13, 2024
6cde8b9
fix proxy unit tests to use document domain injection util class
cacieprins Dec 13, 2024
69b7f6b
rm .only
cacieprins Dec 13, 2024
ddce890
fix all vite ct error specs
cacieprins Dec 13, 2024
a6b486f
rm console.log
cacieprins Dec 13, 2024
a857a38
slight refactor to util class to make easier to test
cacieprins Dec 16, 2024
ec653df
fix refactor - missing rename in files.js
cacieprins Dec 16, 2024
ce19f25
build binary for document domain changes [run ci]
AtofStryker Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 64 additions & 8 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ mainBuildFilters: &mainBuildFilters
- /^release\/\d+\.\d+\.\d+$/
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- 'update-v8-snapshot-cache-on-develop'
- 'feat/support_vite_6'
- 'document-domain-binary'
- 'publish-binary'
- 'cacie/29590/document-domain-subdomains'

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand All @@ -42,7 +43,7 @@ macWorkflowFilters: &darwin-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'feat/support_vite_6', << pipeline.git.branch >> ]
- equal: [ 'document-domain-binary', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -53,7 +54,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'feat/support_vite_6', << pipeline.git.branch >> ]
- equal: [ 'document-domain-binary', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -76,7 +77,7 @@ windowsWorkflowFilters: &windows-workflow-filters
- equal: [ develop, << pipeline.git.branch >> ]
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
- equal: [ 'build-binary-placeholder', << pipeline.git.branch >> ]
- equal: [ 'document-domain-binary', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -152,7 +153,7 @@ commands:
name: Set environment variable to determine whether or not to persist artifacts
command: |
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "feat/support_vite_6" ]]; then
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "document-domain-binary" ]]; then
export SHOULD_PERSIST_ARTIFACTS=true
fi' >> "$BASH_ENV"
# You must run `setup_should_persist_artifacts` command and be using bash before running this command
Expand Down Expand Up @@ -573,6 +574,11 @@ commands:
description: chrome channel to install
type: string
default: ''
inject-document-domain:
description: run subset of tests with injectDocumentDomain config enabled
type: boolean
default: false

steps:
- restore_cached_workspace
- when:
Expand All @@ -594,11 +600,20 @@ commands:
echo Current working directory is $PWD
echo Total containers $CIRCLE_NODE_TOTAL


if << parameters.inject-document-domain >> ; then
YARN_CMD="cypress:run:inject-document-domain"
PARALLEL=""
else
YARN_CMD="cypress:run"
PARALLEL="--parallel --group 5x-driver-<<parameters.browser>>"
fi

if [[ -v MAIN_RECORD_KEY ]]; then
# internal PR
CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \
CYPRESS_INTERNAL_ENABLE_TELEMETRY="true" \
yarn cypress:run --record --parallel --group 5x-driver-<<parameters.browser>> --browser <<parameters.browser>> --runner-ui
yarn $YARN_CMD --record $PARALLEL --browser <<parameters.browser>> --runner-ui
else
# external PR
TESTFILES=$(circleci tests glob "cypress/e2e/**/*.cy.*" | circleci tests split --total=$CIRCLE_NODE_TOTAL)
Expand All @@ -607,7 +622,7 @@ commands:
if [[ -z "$TESTFILES" ]]; then
echo "Empty list of test files"
fi
yarn cypress:run --browser <<parameters.browser>> --spec $TESTFILES --runner-ui
yarn $YARN_CMD --browser <<parameters.browser>> --spec $TESTFILES --runner-ui
fi
working_directory: packages/driver
- verify-mocha-results
Expand Down Expand Up @@ -1976,6 +1991,16 @@ jobs:
- run-driver-integration-tests:
browser: chrome
install-chrome-channel: stable

driver-integration-tests-chrome-inject-document-domain:
<<: *defaults
parallelism: 5
resource_class: medium+
steps:
- run-driver-integration-tests:
browser: chrome
install-chrome-channel: stable
inject-document-domain: true

driver-integration-tests-chrome-beta:
<<: *defaults
Expand All @@ -1986,6 +2011,16 @@ jobs:
browser: chrome:beta
install-chrome-channel: beta

driver-integration-tests-chrome-beta-inject-document-domain:
<<: *defaults
resource_class: medium+
parallelism: 5
steps:
- run-driver-integration-tests:
browser: chrome:beta
install-chrome-channel: beta
inject-document-domain: true

driver-integration-tests-firefox:
<<: *defaults
resource_class: medium+
Expand All @@ -2008,6 +2043,8 @@ jobs:
steps:
- run-driver-integration-tests:
browser: webkit
# inject document domain must be true for webkit, as cy.origin is not supported
inject-document-domain: true

run-reporter-component-tests-chrome:
<<: *defaults
Expand Down Expand Up @@ -2790,7 +2827,8 @@ linux-x64-workflow: &linux-x64-workflow
- run-vite-dev-server-integration-tests
- driver-integration-tests-firefox
- driver-integration-tests-chrome
- driver-integration-tests-chrome-beta
- driver-integration-tests-chrome-inject-document-domain
- driver-integration-tests-chrome-beta-inject-document-domain
- driver-integration-tests-electron
- driver-integration-tests-webkit
- driver-integration-memory-tests
Expand Down Expand Up @@ -2847,10 +2885,18 @@ linux-x64-workflow: &linux-x64-workflow
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-chrome-inject-document-domain:
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-chrome-beta:
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-chrome-beta-inject-document-domain:
context: test-runner:cypress-record-key
requires:
- build
- driver-integration-tests-firefox:
context: test-runner:cypress-record-key
requires:
Expand Down Expand Up @@ -2974,6 +3020,8 @@ linux-x64-workflow: &linux-x64-workflow
- driver-integration-tests-firefox
- driver-integration-tests-chrome
- driver-integration-tests-chrome-beta
- driver-integration-tests-chrome-inject-document-domain
- driver-integration-tests-chrome-beta-inject-document-domain
- driver-integration-tests-electron
- driver-integration-tests-webkit
- driver-integration-memory-tests
Expand Down Expand Up @@ -3202,10 +3250,18 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow
context: test-runner:cypress-record-key
requires:
- contributor-pr
- driver-integration-tests-chrome-inject-document-domain:
context: test-runner:cypress-record-key
requires:
- contributor-pr
- driver-integration-tests-chrome-beta:
context: test-runner:cypress-record-key
requires:
- contributor-pr
- driver-integration-tests-chrome-beta-inject-document-domain:
context: test-runner:cypress-record-key
requires:
- contributor-pr
- driver-integration-tests-firefox:
context: test-runner:cypress-record-key
requires:
Expand Down
5 changes: 3 additions & 2 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ declare namespace Cypress {
strategy: 'file' | 'http'
origin: string
fileServer: string | null
props: Record<string, any>
visiting: string
props: Record<string, any> | null
}

interface Backend {
Expand Down Expand Up @@ -3113,6 +3112,8 @@ declare namespace Cypress {
* @default null
*/
experimentalSkipDomainInjection: string[] | null
// TODO: document
injectDocumentDomain: boolean
/**
* Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm.
* @default false
Expand Down
63 changes: 32 additions & 31 deletions npm/cypress-schematic/src/ct.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { describe, it } from 'vitest'
import { describe, it, beforeEach, afterEach } from 'vitest'
import Fixtures, { ProjectFixtureDir } from '@tooling/system-tests'
import * as FixturesScaffold from '@tooling/system-tests/lib/dep-installer'
import execa from 'execa'
import path from 'path'
import * as fs from 'fs-extra'

const scaffoldAngularProject = async (project: string) => {
const projectPath = Fixtures.projectPath(project)

Fixtures.removeProject(project)
await Fixtures.scaffoldProject(project)
await FixturesScaffold.scaffoldProjectNodeModules({ project })
await fs.remove(path.join(projectPath, 'cypress.config.ts'))
await fs.remove(path.join(projectPath, 'cypress'))

return projectPath
}

const runCommandInProject = (command: string, projectPath: string) => {
const [ex, ...args] = command.split(' ')

Expand All @@ -38,25 +26,38 @@ const cypressSchematicPackagePath = path.join(__dirname, '..')

const ANGULAR_PROJECTS: ProjectFixtureDir[] = ['angular-18', 'angular-19']

describe('ng add @cypress/schematic / e2e and ct', { timeout: 1000 * 60 * 5 }, function () {
for (const project of ANGULAR_PROJECTS) {
it('should install ct files with option and no component specs', async () => {
const projectPath = await scaffoldAngularProject(project)
const timeout = 1000 * 60 * 5

await runCommandInProject(`yarn add @cypress/schematic@file:${cypressSchematicPackagePath}`, projectPath)
await runCommandInProject('yarn ng add @cypress/schematic --e2e --component', projectPath)
await copyAngularMount(projectPath)
await runCommandInProject('yarn ng run angular:ct --watch false --spec src/app/app.component.cy.ts', projectPath)
})

it('should generate component alongside component spec', async () => {
const projectPath = await scaffoldAngularProject(project)

await runCommandInProject(`yarn add @cypress/schematic@file:${cypressSchematicPackagePath}`, projectPath)
await runCommandInProject('yarn ng add @cypress/schematic --e2e --component', projectPath)
await copyAngularMount(projectPath)
await runCommandInProject('yarn ng generate c foo', projectPath)
await runCommandInProject('yarn ng run angular:ct --watch false --spec src/app/foo/foo.component.cy.ts', projectPath)
describe('ng add @cypress/schematic / e2e and ct', function () {
for (const project of ANGULAR_PROJECTS) {
describe(project, () => {
const projectPath: string = Fixtures.projectPath(project)

beforeEach(async () => {
await Fixtures.scaffoldProject(project)
await FixturesScaffold.scaffoldProjectNodeModules({ project })
await fs.remove(path.join(projectPath, 'cypress.config.ts'))
await fs.remove(path.join(projectPath, 'cypress'))

await runCommandInProject(`yarn add @cypress/schematic@file:${cypressSchematicPackagePath}`, projectPath)
}, timeout)

afterEach(() => {
Fixtures.removeProject(project)
}, timeout)

it('should install ct files with option and no component specs', async () => {
await runCommandInProject('yarn ng add @cypress/schematic --e2e --component', projectPath)
await copyAngularMount(projectPath)
await runCommandInProject('yarn ng run angular:ct --watch false --spec src/app/app.component.cy.ts', projectPath)
}, timeout)

it('should generate component alongside component spec', async () => {
await runCommandInProject('yarn ng add @cypress/schematic --e2e --component', projectPath)
await copyAngularMount(projectPath)
await runCommandInProject('yarn ng generate c foo', projectPath)
await runCommandInProject('yarn ng run angular:ct --watch false --spec src/app/foo/foo.component.cy.ts', projectPath)
}, timeout)
})
}
})
1 change: 1 addition & 0 deletions npm/vite-dev-server/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineConfig({

return await e2ePluginSetup(on, config)
},
injectDocumentDomain: true, // because these are cy in cy test, document domain injection is necessary
},
retries: {
runMode: 2,
Expand Down
6 changes: 0 additions & 6 deletions npm/vite-dev-server/src/plugins/cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ export const Cypress = (
configureServer: async (server: ViteDevServer) => {
server.middlewares.use(`${base}index.html`, async (req, res) => {
let transformedIndexHtml = await server.transformIndexHtml(base, '')
const viteImport = `<script type="module" src="${options.cypressConfig.devServerPublicPathRoute}/@vite/client"></script>`

// If we're doing cy-in-cy, we need to be able to access the Cypress instance from the parent frame.
if (process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING) {
transformedIndexHtml = transformedIndexHtml.replace(viteImport, `<script>document.domain = 'localhost';</script>${viteImport}`)
}

return res.end(transformedIndexHtml)
})
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,6 @@
"devtools-protocol": "0.0.1346313",
"sharp": "0.29.3",
"vue-template-compiler": "2.6.12"
}
},
"packageManager": "[email protected]+sha512.ff4579ab459bb25aa7c0ff75b62acebe576f6084b36aa842971cf250a5d8c6cd3bc9420b22ce63c7f93a0857bc6ef29291db39c3e7a23aab5adfd5a4dd6c5d71"
}
3 changes: 3 additions & 0 deletions packages/config/__snapshots__/index.spec.ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys 1
'experimentalRunAllSpecs': false,
'experimentalMemoryManagement': false,
'experimentalModifyObstructiveThirdPartyCode': false,
'injectDocumentDomain': false,
'experimentalSkipDomainInjection': null,
'experimentalOriginDependencies': false,
'experimentalSourceRewriting': false,
Expand Down Expand Up @@ -131,6 +132,7 @@ exports['config/src/index .getDefaultValues returns list of public config keys f
'experimentalRunAllSpecs': false,
'experimentalMemoryManagement': false,
'experimentalModifyObstructiveThirdPartyCode': false,
'injectDocumentDomain': false,
'experimentalSkipDomainInjection': null,
'experimentalOriginDependencies': false,
'experimentalSourceRewriting': false,
Expand Down Expand Up @@ -218,6 +220,7 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key
'experimentalRunAllSpecs',
'experimentalMemoryManagement',
'experimentalModifyObstructiveThirdPartyCode',
'injectDocumentDomain',
'experimentalSkipDomainInjection',
'experimentalOriginDependencies',
'experimentalSourceRewriting',
Expand Down
21 changes: 21 additions & 0 deletions packages/config/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ const driverConfigOptions: Array<DriverConfigOption> = [
isExperimental: true,
requireRestartOnChange: 'server',
}, {
name: 'injectDocumentDomain',
defaultValue: false,
validation: validate.isBoolean,
requireRestartOnChange: 'server',
},
{
name: 'experimentalSkipDomainInjection',
defaultValue: null,
validation: validate.isNullOrArrayOfStrings,
Expand Down Expand Up @@ -768,6 +774,16 @@ 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',
isWarning: true,
},
],
component: [
{
Expand Down Expand Up @@ -800,5 +816,10 @@ export const testingTypeBreakingOptions: { e2e: Array<BreakingOption>, component
errorKey: 'EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY',
isWarning: false,
},
{
name: 'injectDocumentDomain',
errorKey: 'INJECT_DOCUMENT_DOMAIN_E2E_ONLY',
isWarning: false,
},
],
}
Loading
Loading