From c0d942be2cbf60362a37d47eff1b75e538b13da6 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:07:38 -0500 Subject: [PATCH 01/19] Attempt to run tests without the feature flag and the multi-domain folder --- packages/driver/cypress.json | 3 +-- packages/driver/package.json | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/driver/cypress.json b/packages/driver/cypress.json index 911238c1181a..f6d381383ca1 100644 --- a/packages/driver/cypress.json +++ b/packages/driver/cypress.json @@ -13,6 +13,5 @@ "retries": { "runMode": 2, "openMode": 0 - }, - "experimentalSessionAndOrigin": true + } } diff --git a/packages/driver/package.json b/packages/driver/package.json index aca090231a17..c226b090d9ec 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -4,8 +4,10 @@ "private": true, "scripts": { "clean-deps": "rm -rf node_modules", - "cypress:open": "node ../../scripts/cypress open", + "cypress:open": "node ../../scripts/cypress open --spec [\"cypress/integration/**/*\", \"!cypress/integration/e2e/multi-domain/*\"]", "cypress:run": "node ../../scripts/cypress run", + "cypress:open-experimentalSessionAndOrigin": "node ../../scripts/cypress open --config experimentalSessionAndOrigin=true", + "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true --spec \"cypress/integration/e2e/multi-domain/**/*\"", "postinstall": "patch-package", "start": "node -e 'console.log(require(`chalk`).red(`\nError:\n\tRunning \\`yarn start\\` is no longer needed for driver/cypress tests.\n\tWe now automatically spawn the server in the pluginsFile.\n\tChanges to the server will be watched and reloaded automatically.`))'" }, From 29cf4b9f7ad4ebc3b6088915ad62ac9acfd744fc Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:21:13 -0500 Subject: [PATCH 02/19] do it for real this time dummy --- packages/driver/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/driver/package.json b/packages/driver/package.json index c226b090d9ec..86d47e508408 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -4,8 +4,8 @@ "private": true, "scripts": { "clean-deps": "rm -rf node_modules", - "cypress:open": "node ../../scripts/cypress open --spec [\"cypress/integration/**/*\", \"!cypress/integration/e2e/multi-domain/*\"]", - "cypress:run": "node ../../scripts/cypress run", + "cypress:open": "node ../../scripts/cypress open", + "cypress:run": "node ../../scripts/cypress run --spec [\"cypress/integration/**/*\", \"!cypress/integration/e2e/multi-domain/*\"]", "cypress:open-experimentalSessionAndOrigin": "node ../../scripts/cypress open --config experimentalSessionAndOrigin=true", "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true --spec \"cypress/integration/e2e/multi-domain/**/*\"", "postinstall": "patch-package", From ca1235addd425ea67fe0317bbb4059fd5210ac73 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:35:41 -0500 Subject: [PATCH 03/19] trying circleci changes --- circle.yml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index 24c0fb2c3f9b..84f58f2edf6c 100644 --- a/circle.yml +++ b/circle.yml @@ -406,6 +406,10 @@ commands: description: chrome channel to install type: string default: '' + experimentalSessionAndOrigin: + description: experimental flag to apply + type: boolean + default: false steps: - restore_cached_workspace - when: @@ -424,7 +428,12 @@ commands: if [[ -v MAIN_RECORD_KEY ]]; then # internal PR CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - yarn cypress:run --record --parallel --group 5x-driver-<> --browser <> + if <> + then + yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<> --browser <> + else + yarn cypress:run --record --parallel --group 5x-driver-<> --browser <> + fi else # external PR TESTFILES=$(circleci tests glob "cypress/integration/**/*spec.*" | circleci tests split --total=$CIRCLE_NODE_TOTAL) @@ -433,7 +442,12 @@ commands: if [[ -z "$TESTFILES" ]]; then echo "Empty list of test files" fi - yarn cypress:run --browser <> --spec $TESTFILES + if <> + then + yarn cypress:run-experimentalSessionAndOrigin --browser <> --spec $TESTFILES + else + yarn cypress:run --browser <> --spec $TESTFILES + fi fi working_directory: packages/driver - verify-mocha-results @@ -1276,7 +1290,6 @@ jobs: steps: - run-driver-integration-tests: browser: chrome:beta - install-chrome-channel: beta driver-integration-tests-firefox: <<: *defaults @@ -1294,6 +1307,44 @@ jobs: - run-driver-integration-tests: browser: electron + driver-integration-tests-chrome-experimentalSessionAndOrigin: + <<: *defaults + resource_class: medium + parallelism: 5 + steps: + - run-driver-integration-tests: + browser: chrome + install-chrome-channel: stable + experimentalSessionAndOrigin: true + + driver-integration-tests-chrome-beta-experimentalSessionAndOrigin: + <<: *defaults + resource_class: medium + parallelism: 5 + steps: + - run-driver-integration-tests: + browser: chrome:beta + install-chrome-channel: beta + experimentalSessionAndOrigin: true + + driver-integration-tests-firefox-experimentalSessionAndOrigin: + <<: *defaults + resource_class: medium + parallelism: 5 + steps: + - run-driver-integration-tests: + browser: firefox + experimentalSessionAndOrigin: true + + driver-integration-tests-electron-experimentalSessionAndOrigin: + <<: *defaults + resource_class: medium + parallelism: 5 + steps: + - run-driver-integration-tests: + browser: electron + experimentalSessionAndOrigin: true + desktop-gui-integration-tests-7x: <<: *defaults parallelism: 7 @@ -2180,6 +2231,10 @@ linux-workflow: &linux-workflow - driver-integration-tests-chrome - driver-integration-tests-chrome-beta - driver-integration-tests-electron + - driver-integration-tests-firefox-experimentalSessionAndOrigin + - driver-integration-tests-chrome-experimentalSessionAndOrigin + - driver-integration-tests-chrome-beta-experimentalSessionAndOrigin + - driver-integration-tests-electron-experimentalSessionAndOrigin - system-tests-non-root - system-tests-firefox - system-tests-electron From 1cfd4717fbfc390ea5e5719d449a054d2775cd15 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:37:01 -0500 Subject: [PATCH 04/19] valid file??? --- circle.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 84f58f2edf6c..d60db123df92 100644 --- a/circle.yml +++ b/circle.yml @@ -1290,6 +1290,7 @@ jobs: steps: - run-driver-integration-tests: browser: chrome:beta + install-chrome-channel: beta driver-integration-tests-firefox: <<: *defaults @@ -1307,7 +1308,7 @@ jobs: - run-driver-integration-tests: browser: electron - driver-integration-tests-chrome-experimentalSessionAndOrigin: + driver-integration-tests-chrome-experimentalSessionAndOrigin: <<: *defaults resource_class: medium parallelism: 5 From 12045e20d9f808f16451beb19331ebf93c7cb2c5 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:40:38 -0500 Subject: [PATCH 05/19] moar changes! --- circle.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/circle.yml b/circle.yml index d60db123df92..e54b48445fed 100644 --- a/circle.yml +++ b/circle.yml @@ -2136,6 +2136,22 @@ linux-workflow: &linux-workflow context: test-runner:cypress-record-key requires: - build + - driver-integration-tests-chrome-experimentalSessionAndOrigin: + context: test-runner:cypress-record-key + requires: + - build + - driver-integration-tests-chrome-beta-experimentalSessionAndOrigin: + context: test-runner:cypress-record-key + requires: + - build + - driver-integration-tests-firefox-experimentalSessionAndOrigin: + context: test-runner:cypress-record-key + requires: + - build + - driver-integration-tests-electron-experimentalSessionAndOrigin: + context: test-runner:cypress-record-key + requires: + - build - runner-integration-tests-chrome: context: [test-runner:cypress-record-key, test-runner:percy] requires: From 40e0b129e79d457cc4993c7768ac16863fd6b267 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:51:38 -0500 Subject: [PATCH 06/19] i am a master of bash scripting --- circle.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index e54b48445fed..0e73af70c671 100644 --- a/circle.yml +++ b/circle.yml @@ -428,7 +428,7 @@ commands: if [[ -v MAIN_RECORD_KEY ]]; then # internal PR CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - if <> + if [[ <> == true ]] then yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<> --browser <> else @@ -442,7 +442,7 @@ commands: if [[ -z "$TESTFILES" ]]; then echo "Empty list of test files" fi - if <> + if [[ <> == true ]] then yarn cypress:run-experimentalSessionAndOrigin --browser <> --spec $TESTFILES else From e5b573404ca3de2dcf9439baf4775305f97ec7ff Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 16:55:35 -0500 Subject: [PATCH 07/19] try another exclude pattern --- packages/driver/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/driver/package.json b/packages/driver/package.json index 86d47e508408..998bc304c5aa 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -5,7 +5,7 @@ "scripts": { "clean-deps": "rm -rf node_modules", "cypress:open": "node ../../scripts/cypress open", - "cypress:run": "node ../../scripts/cypress run --spec [\"cypress/integration/**/*\", \"!cypress/integration/e2e/multi-domain/*\"]", + "cypress:run": "node ../../scripts/cypress run --spec \"cypress/integration/*/!(multi-domain)/**/*\"", "cypress:open-experimentalSessionAndOrigin": "node ../../scripts/cypress open --config experimentalSessionAndOrigin=true", "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true --spec \"cypress/integration/e2e/multi-domain/**/*\"", "postinstall": "patch-package", From cca9134c89bd65b51faf642c6bbb844c37be06a9 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 17:09:03 -0500 Subject: [PATCH 08/19] one more time with feeling --- circle.yml | 4 ++-- packages/driver/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index 0e73af70c671..e54b48445fed 100644 --- a/circle.yml +++ b/circle.yml @@ -428,7 +428,7 @@ commands: if [[ -v MAIN_RECORD_KEY ]]; then # internal PR CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - if [[ <> == true ]] + if <> then yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<> --browser <> else @@ -442,7 +442,7 @@ commands: if [[ -z "$TESTFILES" ]]; then echo "Empty list of test files" fi - if [[ <> == true ]] + if <> then yarn cypress:run-experimentalSessionAndOrigin --browser <> --spec $TESTFILES else diff --git a/packages/driver/package.json b/packages/driver/package.json index 998bc304c5aa..0115f8893bf4 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -5,7 +5,7 @@ "scripts": { "clean-deps": "rm -rf node_modules", "cypress:open": "node ../../scripts/cypress open", - "cypress:run": "node ../../scripts/cypress run --spec \"cypress/integration/*/!(multi-domain)/**/*\"", + "cypress:run": "node ../../scripts/cypress run --spec \"cypress/integration/**/!(multi-domain)/**/*\"", "cypress:open-experimentalSessionAndOrigin": "node ../../scripts/cypress open --config experimentalSessionAndOrigin=true", "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true --spec \"cypress/integration/e2e/multi-domain/**/*\"", "postinstall": "patch-package", From 922e0840d6a9fdad42a6be316217aba53763ad16 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 17:17:46 -0500 Subject: [PATCH 09/19] lets do it again --- circle.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/circle.yml b/circle.yml index e54b48445fed..c1fdb3252115 100644 --- a/circle.yml +++ b/circle.yml @@ -428,8 +428,7 @@ commands: if [[ -v MAIN_RECORD_KEY ]]; then # internal PR CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - if <> - then + if <>; then yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<> --browser <> else yarn cypress:run --record --parallel --group 5x-driver-<> --browser <> @@ -442,8 +441,7 @@ commands: if [[ -z "$TESTFILES" ]]; then echo "Empty list of test files" fi - if <> - then + if <>; then yarn cypress:run-experimentalSessionAndOrigin --browser <> --spec $TESTFILES else yarn cypress:run --browser <> --spec $TESTFILES From c10a8d3be5cab96e2489b51ad99cf5aa6b741c54 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 17:27:00 -0500 Subject: [PATCH 10/19] maybe this? --- circle.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index c1fdb3252115..d0a1edf62ea6 100644 --- a/circle.yml +++ b/circle.yml @@ -427,10 +427,11 @@ commands: if [[ -v MAIN_RECORD_KEY ]]; then # internal PR - CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ if <>; then + CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<> --browser <> else + CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ yarn cypress:run --record --parallel --group 5x-driver-<> --browser <> fi else From f05a88a89f3c2e6845fab59b7e00d059f8a4fee1 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Tue, 19 Apr 2022 17:37:39 -0500 Subject: [PATCH 11/19] different parallel group --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index d0a1edf62ea6..49a982791e36 100644 --- a/circle.yml +++ b/circle.yml @@ -429,7 +429,7 @@ commands: # internal PR if <>; then CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ - yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<> --browser <> + yarn cypress:run-experimentalSessionAndOrigin --record --parallel --group 5x-driver-<>-experimentalSessionAndOrigin --browser <> else CYPRESS_RECORD_KEY=$MAIN_RECORD_KEY \ yarn cypress:run --record --parallel --group 5x-driver-<> --browser <> From a2556b4dd44826191b35fc558595b3b74e6c4d12 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 07:19:22 -0500 Subject: [PATCH 12/19] lets try this --- packages/driver/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/driver/package.json b/packages/driver/package.json index 0115f8893bf4..889d2fec4b54 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -5,7 +5,7 @@ "scripts": { "clean-deps": "rm -rf node_modules", "cypress:open": "node ../../scripts/cypress open", - "cypress:run": "node ../../scripts/cypress run --spec \"cypress/integration/**/!(multi-domain)/**/*\"", + "cypress:run": "node ../../scripts/cypress run --spec \"cypress/integration/*/*\",\"cypress/integration/*/!(multi-domain)/**/*\"", "cypress:open-experimentalSessionAndOrigin": "node ../../scripts/cypress open --config experimentalSessionAndOrigin=true", "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true --spec \"cypress/integration/e2e/multi-domain/**/*\"", "postinstall": "patch-package", From 31d73c692849321463557865a428c48038282f3d Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 08:38:03 -0500 Subject: [PATCH 13/19] updating tests phase 1 --- .../integration/e2e/{stability_spec.js => stability_spec.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/driver/cypress/integration/e2e/{stability_spec.js => stability_spec.ts} (100%) diff --git a/packages/driver/cypress/integration/e2e/stability_spec.js b/packages/driver/cypress/integration/e2e/stability_spec.ts similarity index 100% rename from packages/driver/cypress/integration/e2e/stability_spec.js rename to packages/driver/cypress/integration/e2e/stability_spec.ts From 3a0e1e7870bcd1a06b69ba9dc63abb7d0ddc08fc Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 08:38:41 -0500 Subject: [PATCH 14/19] updating tests phase 2 --- .../integration/commands/navigation_spec.js | 70 +++-------------- .../e2e/multi-domain/stability_spec.ts | 75 +++++++++++++++++++ .../cypress/integration/e2e/stability_spec.ts | 32 -------- 3 files changed, 84 insertions(+), 93 deletions(-) create mode 100644 packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts delete mode 100644 packages/driver/cypress/integration/e2e/stability_spec.ts diff --git a/packages/driver/cypress/integration/commands/navigation_spec.js b/packages/driver/cypress/integration/commands/navigation_spec.js index b4bda839fbc1..7bfa5767cd1b 100644 --- a/packages/driver/cypress/integration/commands/navigation_spec.js +++ b/packages/driver/cypress/integration/commands/navigation_spec.js @@ -1410,22 +1410,9 @@ describe('src/cy/commands/navigation', () => { cy.on('fail', (err) => { const { lastLog } = this - expect(err.message).to.equal(stripIndent`\ - \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - You likely forgot to use \`cy.origin()\`:\n - \`cy.visit('http://localhost:3500/fixtures/generic.html')\` - \`\`\n - \`cy.origin('http://localhost:3501', () => {\` - \` cy.visit('http://localhost:3501/fixtures/generic.html')\` - \` \` - \`})\`\n - The new URL is considered a different origin because the following parts of the URL are different:\n - > port\n - You may only \`cy.visit()\` same-origin URLs within a single test.\n - The previous URL you visited was:\n - > 'http://localhost:3500'\n - You're attempting to visit this URL:\n - > 'http://localhost:3501'`) + expect(err.message).to.include('`cy.visit()` failed because you are attempting to visit a URL that is of a different origin.') + expect(err.message).to.include('The new URL is considered a different origin because the following parts of the URL are different:') + expect(err.message).to.include('> port') expect(err.docsUrl).to.eq('https://on.cypress.io/cannot-visit-different-origin-domain') assertLogLength(this.logs, 2) @@ -1442,22 +1429,9 @@ describe('src/cy/commands/navigation', () => { cy.on('fail', (err) => { const { lastLog } = this - expect(err.message).to.equal(stripIndent`\ - \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - You likely forgot to use \`cy.origin()\`:\n - \`cy.visit('http://localhost:3500/fixtures/generic.html')\` - \`\`\n - \`cy.origin('https://localhost:3500', () => {\` - \` cy.visit('https://localhost:3500/fixtures/generic.html')\` - \` \` - \`})\`\n - The new URL is considered a different origin because the following parts of the URL are different:\n - > protocol\n - You may only \`cy.visit()\` same-origin URLs within a single test.\n - The previous URL you visited was:\n - > 'http://localhost:3500'\n - You're attempting to visit this URL:\n - > 'https://localhost:3500'`) + expect(err.message).to.include('`cy.visit()` failed because you are attempting to visit a URL that is of a different origin.') + expect(err.message).to.include('The new URL is considered a different origin because the following parts of the URL are different:') + expect(err.message).to.include('> protocol') expect(err.docsUrl).to.eq('https://on.cypress.io/cannot-visit-different-origin-domain') assertLogLength(this.logs, 2) @@ -1476,7 +1450,7 @@ describe('src/cy/commands/navigation', () => { expect(err.message).to.equal(stripIndent`\ \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - You likely forgot to use \`cy.origin()\`:\n + In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n \`cy.visit('http://localhost:3500/fixtures/generic.html')\` \`\`\n \`cy.origin('http://google.com:3500', () => {\` @@ -1508,7 +1482,7 @@ describe('src/cy/commands/navigation', () => { expect(err.message).to.equal(stripIndent`\ \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - You likely forgot to use \`cy.origin()\`:\n + In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n \`cy.visit('http://127.0.0.1:3500/fixtures/generic.html')\` \`\`\n \`cy.origin('http://126.0.0.1:3500', () => {\` @@ -2284,7 +2258,7 @@ describe('src/cy/commands/navigation', () => { }) }) - it('waits for stability at the end of the command queue when not stable', { experimentalSessionAndOrigin: false }, (done) => { + it('waits for stability at the end of the command queue when not stable', (done) => { cy .visit('/fixtures/generic.html') .then((win) => { @@ -2306,32 +2280,6 @@ describe('src/cy/commands/navigation', () => { return null }) }) - - it('does not wait for stability at the end of the command queue when not stable with experimentalSessionAndOrigin', (done) => { - const onLoad = cy.spy() - - cy - .visit('/fixtures/generic.html') - .then((win) => { - cy.on('window:load', onLoad) - - cy.on('command:queue:end', () => { - expect(onLoad).not.have.been.called - done() - }) - - cy.on('command:queue:before:end', () => { - // force us to become unstable immediately - // else the beforeunload event fires at the end - // of the tick which is too late - cy.isStable(false, 'testing') - - win.location.href = '/timeout?ms=100' - }) - - return null - }) - }) }) context('#url:changed', () => { diff --git a/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts b/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts new file mode 100644 index 000000000000..69e5b2ee70ea --- /dev/null +++ b/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts @@ -0,0 +1,75 @@ +describe('stability', () => { + describe('before each transitions', () => { + describe('transitioning from a before block to an it block while unstable', () => { + beforeEach(() => { + cy.visit('/fixtures/auth/index.html') + cy.window().then((win) => { + win.location.href = 'http://localhost:3500/timeout?ms=1000' + }) + }) + + it('fails if the page does not load within the page load timeout', { defaultCommandTimeout: 50, pageLoadTimeout: 500 }, (done) => { + cy.on('fail', (err) => { + expect(err.message).to.include(`Timed out after waiting \`500ms\` for your remote page to load.`) + done() + }) + + cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com + }) + + it('waits for the page to load before running the command', { defaultCommandTimeout: 50 }, () => { + cy.get('body').invoke('text').should('equal', 'timeout') + }) + + it('will retry and fail the command after the page loads', { defaultCommandTimeout: 50 }, (done) => { + cy.on('fail', (err) => { + expect(err.message).to.include(`Timed out retrying after 50ms: expected 'timeout' to equal 'not timeout'`) + done() + }) + + cy.get('body').invoke('text').should('equal', 'not timeout') + }) + }) + }) + + context('#page loading', () => { + beforeEach(function () { + this.logs = [] + + cy.on('log:added', (attrs, log) => { + if (attrs.name === 'page load') { + this.lastLog = log + this.logs.push(log) + } + }) + + return null + }) + + it('does not wait for stability at the end of the command queue when not stable with experimentalSessionAndOrigin', (done) => { + const onLoad = cy.spy() + + cy + .visit('/fixtures/generic.html') + .then((win) => { + cy.on('window:load', onLoad) + + cy.on('command:queue:end', () => { + expect(onLoad).not.have.been.called + done() + }) + + cy.on('command:queue:before:end', () => { + // force us to become unstable immediately + // else the beforeunload event fires at the end + // of the tick which is too late + cy.isStable(false, 'testing') + + win.location.href = '/timeout?ms=100' + }) + + return null + }) + }) + }) +}) diff --git a/packages/driver/cypress/integration/e2e/stability_spec.ts b/packages/driver/cypress/integration/e2e/stability_spec.ts deleted file mode 100644 index b6d541845f79..000000000000 --- a/packages/driver/cypress/integration/e2e/stability_spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -describe('stability', () => { - describe('transitioning from a before block to an it block while unstable', () => { - beforeEach(() => { - cy.visit('/fixtures/auth/index.html') - cy.window().then((win) => { - win.location.href = 'http://localhost:3500/timeout?ms=1000' - }) - }) - - it('fails if the page does not load within the page load timeout', { defaultCommandTimeout: 50, pageLoadTimeout: 500 }, (done) => { - cy.on('fail', (err) => { - expect(err.message).to.include(`Timed out after waiting \`500ms\` for your remote page to load.`) - done() - }) - - cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - }) - - it('waits for the page to load before running the command', { defaultCommandTimeout: 50 }, () => { - cy.get('body').invoke('text').should('equal', 'timeout') - }) - - it('will retry and fail the command after the page loads', { defaultCommandTimeout: 50 }, (done) => { - cy.on('fail', (err) => { - expect(err.message).to.include(`Timed out retrying after 50ms: expected 'timeout' to equal 'not timeout'`) - done() - }) - - cy.get('body').invoke('text').should('equal', 'not timeout') - }) - }) -}) From 1407109e75854dcce8d08c588c1d3b081cd58715 Mon Sep 17 00:00:00 2001 From: Matt Henkes Date: Wed, 20 Apr 2022 09:55:45 -0500 Subject: [PATCH 15/19] Apply suggestions from code review Co-authored-by: Matt Schile --- .../cypress/integration/e2e/multi-domain/stability_spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts b/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts index 69e5b2ee70ea..fbdb53c04393 100644 --- a/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts +++ b/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts @@ -60,9 +60,9 @@ describe('stability', () => { }) cy.on('command:queue:before:end', () => { - // force us to become unstable immediately - // else the beforeunload event fires at the end - // of the tick which is too late + // force us to become unstable immediately + // else the beforeunload event fires at the end + // of the tick which is too late cy.isStable(false, 'testing') win.location.href = '/timeout?ms=100' From dab4ceb23003fa7b09a56f96b3c00b36b0286ee4 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 09:56:06 -0500 Subject: [PATCH 16/19] Update tests --- .../integration/commands/navigation_spec.js | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/driver/cypress/integration/commands/navigation_spec.js b/packages/driver/cypress/integration/commands/navigation_spec.js index 7bfa5767cd1b..398875022084 100644 --- a/packages/driver/cypress/integration/commands/navigation_spec.js +++ b/packages/driver/cypress/integration/commands/navigation_spec.js @@ -1410,9 +1410,22 @@ describe('src/cy/commands/navigation', () => { cy.on('fail', (err) => { const { lastLog } = this - expect(err.message).to.include('`cy.visit()` failed because you are attempting to visit a URL that is of a different origin.') - expect(err.message).to.include('The new URL is considered a different origin because the following parts of the URL are different:') - expect(err.message).to.include('> port') + expect(err.message).to.equal(stripIndent`\ + \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n + In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n + \`cy.visit('http://localhost:3500/fixtures/generic.html')\` + \`\`\n + \`cy.origin('http://localhost:3501', () => {\` + \` cy.visit('http://localhost:3501/fixtures/generic.html')\` + \` \` + \`})\`\n + The new URL is considered a different origin because the following parts of the URL are different:\n + > port\n + You may only \`cy.visit()\` same-origin URLs within a single test.\n + The previous URL you visited was:\n + > 'http://localhost:3500'\n + You're attempting to visit this URL:\n + > 'http://localhost:3501'`) expect(err.docsUrl).to.eq('https://on.cypress.io/cannot-visit-different-origin-domain') assertLogLength(this.logs, 2) @@ -1429,9 +1442,22 @@ describe('src/cy/commands/navigation', () => { cy.on('fail', (err) => { const { lastLog } = this - expect(err.message).to.include('`cy.visit()` failed because you are attempting to visit a URL that is of a different origin.') - expect(err.message).to.include('The new URL is considered a different origin because the following parts of the URL are different:') - expect(err.message).to.include('> protocol') + expect(err.message).to.equal(stripIndent`\ + \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n + In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n + \`cy.visit('http://localhost:3500/fixtures/generic.html')\` + \`\`\n + \`cy.origin('https://localhost:3500', () => {\` + \` cy.visit('https://localhost:3500/fixtures/generic.html')\` + \` \` + \`})\`\n + The new URL is considered a different origin because the following parts of the URL are different:\n + > protocol\n + You may only \`cy.visit()\` same-origin URLs within a single test.\n + The previous URL you visited was:\n + > 'http://localhost:3500'\n + You're attempting to visit this URL:\n + > 'https://localhost:3500'`) expect(err.docsUrl).to.eq('https://on.cypress.io/cannot-visit-different-origin-domain') assertLogLength(this.logs, 2) From 89303510e486a75130372b96a2e7a6964760685d Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 11:30:51 -0500 Subject: [PATCH 17/19] Run more tests --- .../integration/commands/navigation_spec.js | 31 ++++++++++---- .../e2e/multi-domain/stability_spec.ts | 41 ------------------- packages/driver/package.json | 2 +- 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/packages/driver/cypress/integration/commands/navigation_spec.js b/packages/driver/cypress/integration/commands/navigation_spec.js index 398875022084..a521f339ace7 100644 --- a/packages/driver/cypress/integration/commands/navigation_spec.js +++ b/packages/driver/cypress/integration/commands/navigation_spec.js @@ -1409,10 +1409,11 @@ describe('src/cy/commands/navigation', () => { it('throws when attempting to visit a 2nd domain on different port', function (done) { cy.on('fail', (err) => { const { lastLog } = this + const experimentalMessage = Cypress.config('experimentalSessionAndOrigin') ? `You likely forgot to use \`cy.origin()\`:\n` : `In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n` expect(err.message).to.equal(stripIndent`\ \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n + ${experimentalMessage} \`cy.visit('http://localhost:3500/fixtures/generic.html')\` \`\`\n \`cy.origin('http://localhost:3501', () => {\` @@ -1441,10 +1442,11 @@ describe('src/cy/commands/navigation', () => { it('throws when attempting to visit a 2nd domain on different protocol', function (done) { cy.on('fail', (err) => { const { lastLog } = this + const experimentalMessage = Cypress.config('experimentalSessionAndOrigin') ? `You likely forgot to use \`cy.origin()\`:\n` : `In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n` expect(err.message).to.equal(stripIndent`\ \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n + ${experimentalMessage} \`cy.visit('http://localhost:3500/fixtures/generic.html')\` \`\`\n \`cy.origin('https://localhost:3500', () => {\` @@ -1473,10 +1475,11 @@ describe('src/cy/commands/navigation', () => { it('throws when attempting to visit a 2nd domain on different superdomain', function (done) { cy.on('fail', (err) => { const { lastLog } = this + const experimentalMessage = Cypress.config('experimentalSessionAndOrigin') ? `You likely forgot to use \`cy.origin()\`:\n` : `In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n` expect(err.message).to.equal(stripIndent`\ \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n + ${experimentalMessage} \`cy.visit('http://localhost:3500/fixtures/generic.html')\` \`\`\n \`cy.origin('http://google.com:3500', () => {\` @@ -1505,10 +1508,11 @@ describe('src/cy/commands/navigation', () => { it('throws attempting to visit 2 unique ip addresses', function (done) { cy.on('fail', (err) => { const { lastLog } = this + const experimentalMessage = Cypress.config('experimentalSessionAndOrigin') ? `You likely forgot to use \`cy.origin()\`:\n` : `In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n` expect(err.message).to.equal(stripIndent`\ \`cy.visit()\` failed because you are attempting to visit a URL that is of a different origin.\n - In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n + ${experimentalMessage} \`cy.visit('http://127.0.0.1:3500/fixtures/generic.html')\` \`\`\n \`cy.origin('http://126.0.0.1:3500', () => {\` @@ -2284,15 +2288,28 @@ describe('src/cy/commands/navigation', () => { }) }) - it('waits for stability at the end of the command queue when not stable', (done) => { + it('tests waiting on stability at the end of the command queue', (done) => { cy .visit('/fixtures/generic.html') .then((win) => { - cy.on('window:load', () => { + // We do not wait if the experimentalSessionAndOrigin feature is enabled + if (Cypress.config('experimentalSessionAndOrigin')) { + const onLoad = cy.spy() + + cy.on('window:load', onLoad) + cy.on('command:queue:end', () => { + expect(onLoad).not.have.been.called done() }) - }) + } else { + // We do wait if the experimentalSessionAndOrigin feature is not enabled + cy.on('window:load', () => { + cy.on('command:queue:end', () => { + done() + }) + }) + } cy.on('command:queue:before:end', () => { // force us to become unstable immediately diff --git a/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts b/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts index fbdb53c04393..26486e41c651 100644 --- a/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts +++ b/packages/driver/cypress/integration/e2e/multi-domain/stability_spec.ts @@ -31,45 +31,4 @@ describe('stability', () => { }) }) }) - - context('#page loading', () => { - beforeEach(function () { - this.logs = [] - - cy.on('log:added', (attrs, log) => { - if (attrs.name === 'page load') { - this.lastLog = log - this.logs.push(log) - } - }) - - return null - }) - - it('does not wait for stability at the end of the command queue when not stable with experimentalSessionAndOrigin', (done) => { - const onLoad = cy.spy() - - cy - .visit('/fixtures/generic.html') - .then((win) => { - cy.on('window:load', onLoad) - - cy.on('command:queue:end', () => { - expect(onLoad).not.have.been.called - done() - }) - - cy.on('command:queue:before:end', () => { - // force us to become unstable immediately - // else the beforeunload event fires at the end - // of the tick which is too late - cy.isStable(false, 'testing') - - win.location.href = '/timeout?ms=100' - }) - - return null - }) - }) - }) }) diff --git a/packages/driver/package.json b/packages/driver/package.json index 889d2fec4b54..6641bc4c0d00 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -7,7 +7,7 @@ "cypress:open": "node ../../scripts/cypress open", "cypress:run": "node ../../scripts/cypress run --spec \"cypress/integration/*/*\",\"cypress/integration/*/!(multi-domain)/**/*\"", "cypress:open-experimentalSessionAndOrigin": "node ../../scripts/cypress open --config experimentalSessionAndOrigin=true", - "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true --spec \"cypress/integration/e2e/multi-domain/**/*\"", + "cypress:run-experimentalSessionAndOrigin": "node ../../scripts/cypress run --config experimentalSessionAndOrigin=true", "postinstall": "patch-package", "start": "node -e 'console.log(require(`chalk`).red(`\nError:\n\tRunning \\`yarn start\\` is no longer needed for driver/cypress tests.\n\tWe now automatically spawn the server in the pluginsFile.\n\tChanges to the server will be watched and reloaded automatically.`))'" }, From 2c98eb17582ef70b07066b1e8c8bb2723035428e Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 13:18:02 -0500 Subject: [PATCH 18/19] Re-locate system test --- .../integration/commands/navigation_spec.js | 45 +++++++++ .../__snapshots__/navigation_spec.ts.js | 95 ------------------- .../navigation_cross_origin_errors.ts | 10 -- system-tests/test/navigation_spec.ts | 48 ---------- 4 files changed, 45 insertions(+), 153 deletions(-) delete mode 100644 system-tests/__snapshots__/navigation_spec.ts.js delete mode 100644 system-tests/projects/e2e/cypress/integration/navigation_cross_origin_errors.ts delete mode 100644 system-tests/test/navigation_spec.ts diff --git a/packages/driver/cypress/integration/commands/navigation_spec.js b/packages/driver/cypress/integration/commands/navigation_spec.js index a521f339ace7..91ef8a4226ad 100644 --- a/packages/driver/cypress/integration/commands/navigation_spec.js +++ b/packages/driver/cypress/integration/commands/navigation_spec.js @@ -2164,6 +2164,51 @@ describe('src/cy/commands/navigation', () => { .get('#does-not-exist', { timeout: 200 }).should('have.class', 'foo') }) + it('displays cross origin failures when navigating to a cross origin', { pageLoadTimeout: 3000 }, function (done) { + cy.on('fail', (err) => { + const { lastLog } = this + + if (Cypress.config('experimentalSessionAndOrigin')) { + // When the experimentalSessionAndOrigin feature is enabled, we will timeout and display this message. + expect(err.message).to.equal(stripIndent`\ + Timed out after waiting \`3000ms\` for your remote page to load on origin(s):\n + - \`http://localhost:3500\`\n + A cross-origin request for \`http://www.foobar.com:3500/fixtures/multi-domain-secondary.html\` was detected.\n + A command that triggers cross-origin navigation must be immediately followed by a \`cy.origin()\` command:\n + \`cy.origin(\'http://foobar.com:3500\', () => {\` + \` \` + \`})\`\n + If the cross-origin request was an intermediary state, you can try increasing the \`pageLoadTimeout\` value in \`cypress.json\` to wait longer.\n + Browsers will not fire the \`load\` event until all stylesheets and scripts are done downloading.\n + When this \`load\` event occurs, Cypress will continue running commands.`) + + expect(err.docsUrl).to.eq('https://on.cypress.io/origin') + } else { + // When the experimentalSessionAndOrigin feature is disabled, we will immediately and display this message. + expect(err.message).to.equal(stripIndent`\ + Cypress detected a cross origin error happened on page load:\n + > Blocked a frame with origin "http://localhost:3500" from accessing a cross-origin frame.\n + Before the page load, you were bound to the origin policy:\n + > http://localhost:3500\n + A cross origin error happens when your application navigates to a new URL which does not match the origin policy above.\n + A new URL does not match the origin policy if the 'protocol', 'port' (if specified), and/or 'host' (unless of the same superdomain) are different.\n + Cypress does not allow you to navigate to a different origin URL within a single test.\n + You may need to restructure some of your test code to avoid this problem.\n + Alternatively you can also disable Chrome Web Security in Chromium-based browsers which will turn off this restriction by setting { chromeWebSecurity: false } in \`cypress.json\`.`) + + expect(err.docsUrl).to.eq('https://on.cypress.io/cross-origin-violation') + } + + assertLogLength(this.logs, 6) + expect(lastLog.get('error')).to.eq(err) + + done() + }) + + cy.visit('/fixtures/multi-domain.html') + cy.get('a[data-cy="cross-origin-secondary-link"]').click() + }) + return null }) }) diff --git a/system-tests/__snapshots__/navigation_spec.ts.js b/system-tests/__snapshots__/navigation_spec.ts.js deleted file mode 100644 index 38df39d3a9c0..000000000000 --- a/system-tests/__snapshots__/navigation_spec.ts.js +++ /dev/null @@ -1,95 +0,0 @@ -exports['e2e cross origin navigation / captures cross origin failures when "experimentalSessionAndOrigin" config value is falsy'] = ` - -==================================================================================================== - - (Run Starting) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Cypress: 1.2.3 │ - │ Browser: FooBrowser 88 │ - │ Specs: 1 found (navigation_cross_origin_errors.ts) │ - │ Searched: cypress/integration/navigation_cross_origin_errors.ts │ - │ Experiments: experimentalSessionAndOrigin=false │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - -──────────────────────────────────────────────────────────────────────────────────────────────────── - - Running: navigation_cross_origin_errors.ts (1 of 1) - - - navigation cross origin errors - 1) displays cross origin failures when "experimentalSessionAndOrigin" is turned off - - - 0 passing - 1 failing - - 1) navigation cross origin errors - displays cross origin failures when "experimentalSessionAndOrigin" is turned off: - CypressError: Cypress detected a cross origin error happened on page load: - - > [Cross origin error message] - -Before the page load, you were bound to the origin policy: - - > http://localhost:13370 - -A cross origin error happens when your application navigates to a new URL which does not match the origin policy above. - -A new URL does not match the origin policy if the 'protocol', 'port' (if specified), and/or 'host' (unless of the same superdomain) are different. - -Cypress does not allow you to navigate to a different origin URL within a single test. - -You may need to restructure some of your test code to avoid this problem. - -Alternatively you can also disable Chrome Web Security in Chromium-based browsers which will turn off this restriction by setting { chromeWebSecurity: false } in \`cypress.json\`. - -https://on.cypress.io/cross-origin-violation - [stack trace lines] - - - - - (Results) - - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ Tests: 1 │ - │ Passing: 0 │ - │ Failing: 1 │ - │ Pending: 0 │ - │ Skipped: 0 │ - │ Screenshots: 1 │ - │ Video: true │ - │ Duration: X seconds │ - │ Spec Ran: navigation_cross_origin_errors.ts │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - - - (Screenshots) - - - /XXX/XXX/XXX/cypress/screenshots/navigation_cross_origin_errors.ts/navigation cr (1280x720) - oss origin errors -- displays cross origin failures when experimentalSessionAndO - rigin is turned off (failed).png - - - (Video) - - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/navigation_cross_origin_errors. (X second) - ts.mp4 - - -==================================================================================================== - - (Run Finished) - - - Spec Tests Passing Failing Pending Skipped - ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ - │ ✖ navigation_cross_origin_errors.ts XX:XX 1 - 1 - - │ - └────────────────────────────────────────────────────────────────────────────────────────────────┘ - ✖ 1 of 1 failed (100%) XX:XX 1 - 1 - - - - -` diff --git a/system-tests/projects/e2e/cypress/integration/navigation_cross_origin_errors.ts b/system-tests/projects/e2e/cypress/integration/navigation_cross_origin_errors.ts deleted file mode 100644 index 7e1654adc89a..000000000000 --- a/system-tests/projects/e2e/cypress/integration/navigation_cross_origin_errors.ts +++ /dev/null @@ -1,10 +0,0 @@ -describe('navigation cross origin errors', () => { - it('displays cross origin failures when "experimentalSessionAndOrigin" is turned off', function () { - // @ts-ignore - cy.visit('/jquery.html').window().then((win) => { - const constructedCrossOriginAnchor = win.$(`cross origin`).appendTo(win.document.body) - - constructedCrossOriginAnchor.get(0).click() - }) - }) -}) diff --git a/system-tests/test/navigation_spec.ts b/system-tests/test/navigation_spec.ts deleted file mode 100644 index b4f83ade06e0..000000000000 --- a/system-tests/test/navigation_spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import systemTests, { expect } from '../lib/system-tests' - -const PORT = 13370 -const onServer = function (app) { - app.get('/cross_origin.html', (req, res) => { - res.send('

cross origin

') - }) -} - -describe('e2e cross origin navigation', () => { - systemTests.setup({ - servers: [{ - port: 4466, - onServer, - }], - settings: { - hosts: { - '*.foobar.com': '127.0.0.1', - }, - }, - }) - - // TODO: convert to cypress-in-cypress test if possible - // https://github.com/cypress-io/cypress/issues/20973 - systemTests.it('captures cross origin failures when "experimentalSessionAndOrigin" config value is falsy', { - // keep the port the same to prevent issues with the snapshot - port: PORT, - spec: 'navigation_cross_origin_errors.ts', - browser: ['chrome', 'electron'], - snapshot: true, - expectedExitCode: 1, - config: { - experimentalSessionAndOrigin: false, - }, - async onRun (exec) { - const res = await exec() - - expect(res.stdout).to.contain('Cypress detected a cross origin error happened on page load') - expect(res.stdout).to.contain('Before the page load, you were bound to the origin policy:') - expect(res.stdout).to.contain('A cross origin error happens when your application navigates to a new URL which does not match the origin policy above.') - expect(res.stdout).to.contain('A new URL does not match the origin policy if the \'protocol\', \'port\' (if specified), and/or \'host\' (unless of the same superdomain) are different.') - expect(res.stdout).to.contain('Cypress does not allow you to navigate to a different origin URL within a single test.') - expect(res.stdout).to.contain('You may need to restructure some of your test code to avoid this problem.') - expect(res.stdout).to.contain('Alternatively you can also disable Chrome Web Security in Chromium-based browsers which will turn off this restriction by setting { chromeWebSecurity: false } in `cypress.json`.') - expect(res.stdout).to.contain('https://on.cypress.io/cross-origin-violation') - }, - }) -}) From 7990696e77b1086b031f1bb1d7b18fb2b56920a2 Mon Sep 17 00:00:00 2001 From: mjhenkes Date: Wed, 20 Apr 2022 13:39:22 -0500 Subject: [PATCH 19/19] Flex message for firefox --- .../driver/cypress/integration/commands/navigation_spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/driver/cypress/integration/commands/navigation_spec.js b/packages/driver/cypress/integration/commands/navigation_spec.js index 91ef8a4226ad..ef4cf515a8e1 100644 --- a/packages/driver/cypress/integration/commands/navigation_spec.js +++ b/packages/driver/cypress/integration/commands/navigation_spec.js @@ -2184,10 +2184,12 @@ describe('src/cy/commands/navigation', () => { expect(err.docsUrl).to.eq('https://on.cypress.io/origin') } else { + const error = Cypress.isBrowser('firefox') ? 'Permission denied to access property "document" on cross-origin object' : 'Blocked a frame with origin "http://localhost:3500" from accessing a cross-origin frame.' + // When the experimentalSessionAndOrigin feature is disabled, we will immediately and display this message. expect(err.message).to.equal(stripIndent`\ Cypress detected a cross origin error happened on page load:\n - > Blocked a frame with origin "http://localhost:3500" from accessing a cross-origin frame.\n + > ${error}\n Before the page load, you were bound to the origin policy:\n > http://localhost:3500\n A cross origin error happens when your application navigates to a new URL which does not match the origin policy above.\n