From 451e096497c973b354ef0820162257b620a7faa1 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Tue, 27 Sep 2022 15:10:58 -0400 Subject: [PATCH 1/5] chore: enforce strict origin spec bridges chore: refactor spec bridges to strictly enforce same origin fix: wrap fullCrossOrigin injection around feature flag inside buffered response --- .../unit/cross-origin-callback-loader.spec.ts | 28 ++-- packages/app/src/runner/aut-iframe.ts | 8 +- packages/app/src/runner/event-manager.ts | 20 +-- packages/app/src/runner/index.ts | 6 +- .../cypress/e2e/commands/navigation.cy.js | 8 +- .../cypress/e2e/e2e/origin/basic_login.cy.ts | 34 ++--- .../e2e/e2e/origin/commands/actions.cy.ts | 66 +++++----- .../e2e/e2e/origin/commands/aliasing.cy.ts | 6 +- .../e2e/e2e/origin/commands/assertions.cy.ts | 4 +- .../e2e/e2e/origin/commands/connectors.cy.ts | 14 +- .../e2e/e2e/origin/commands/cookies.cy.ts | 26 ++-- .../e2e/e2e/origin/commands/files.cy.ts | 10 +- .../e2e/origin/commands/local_storage.cy.ts | 4 +- .../e2e/e2e/origin/commands/location.cy.ts | 12 +- .../cypress/e2e/e2e/origin/commands/log.cy.ts | 4 +- .../e2e/e2e/origin/commands/misc.cy.ts | 26 ++-- .../e2e/e2e/origin/commands/navigation.cy.ts | 50 +++---- .../origin/commands/network_requests.cy.ts | 12 +- .../e2e/e2e/origin/commands/querying.cy.ts | 26 ++-- .../e2e/origin/commands/querying_shadow.cy.ts | 4 +- .../e2e/e2e/origin/commands/screenshot.cy.ts | 46 +++---- .../origin/commands/spies_stubs_clocks.cy.ts | 22 ++-- .../e2e/e2e/origin/commands/traversal.cy.ts | 72 +++++----- .../commands/unsupported_commands.cy.ts | 10 +- .../e2e/e2e/origin/commands/viewport.cy.ts | 26 ++-- .../e2e/e2e/origin/commands/waiting.cy.ts | 8 +- .../e2e/e2e/origin/commands/window.cy.ts | 12 +- .../cypress/e2e/e2e/origin/config_env.cy.ts | 38 +++--- .../e2e/e2e/origin/cookie_behavior.cy.ts | 60 ++++----- .../cypress/e2e/e2e/origin/cookie_login.cy.ts | 123 +++++++++--------- .../cypress/e2e/e2e/origin/cypress_api.cy.ts | 46 +++---- .../e2e/e2e/origin/dependencies.cy.jsx | 2 +- .../cypress/e2e/e2e/origin/dependencies.cy.ts | 28 ++-- .../cypress/e2e/e2e/origin/events.cy.ts | 26 ++-- .../cypress/e2e/e2e/origin/integrity.cy.ts | 8 +- .../cypress/e2e/e2e/origin/logging.cy.ts | 8 +- .../cypress/e2e/e2e/origin/navigation.cy.ts | 68 +++++----- .../cypress/e2e/e2e/origin/origin.cy.ts | 40 +++--- .../driver/cypress/e2e/e2e/origin/rerun.cy.ts | 2 +- .../cypress/e2e/e2e/origin/snapshots.cy.ts | 12 +- .../cypress/e2e/e2e/origin/spec_bridge.cy.ts | 2 +- .../e2e/e2e/origin/uncaught_errors.cy.ts | 60 ++++----- .../e2e/e2e/origin/user_agent_override.cy.ts | 2 +- .../cypress/e2e/e2e/origin/validation.cy.ts | 44 ++++--- .../driver/cypress/e2e/e2e/origin/yield.cy.ts | 30 ++--- .../driver/cypress/fixtures/auth/index.html | 2 +- packages/driver/cypress/plugins/server.js | 8 +- .../driver/src/cross-origin/communicator.ts | 22 ++-- packages/driver/src/cross-origin/cypress.ts | 9 +- .../driver/src/cross-origin/events/misc.ts | 3 +- packages/driver/src/cy/commands/navigation.ts | 6 +- .../driver/src/cy/commands/origin/index.ts | 20 +-- packages/driver/src/cy/commands/waiting.ts | 6 +- packages/driver/src/cy/ensures.ts | 2 +- packages/driver/src/cypress/error_messages.ts | 24 ++-- packages/driver/src/cypress/log.ts | 8 +- packages/driver/src/cypress/state.ts | 2 +- packages/network/lib/cors.ts | 8 +- packages/proxy/lib/http/request-middleware.ts | 4 +- .../proxy/lib/http/response-middleware.ts | 9 +- packages/proxy/lib/http/util/buffers.ts | 2 +- .../proxy/lib/http/util/top-simulation.ts | 4 +- .../test/unit/http/request-middleware.spec.ts | 20 +-- .../unit/http/response-middleware.spec.ts | 34 ++--- .../unit/http/util/top-simulation.spec.ts | 10 +- packages/runner/injection/cross-origin.js | 2 +- packages/server/lib/remote_states.ts | 6 +- packages/server/lib/server-e2e.ts | 10 +- .../server/test/integration/server_spec.js | 72 +++++----- .../server/test/unit/remote_states.spec.ts | 24 ++-- .../__snapshots__/web_security_spec.js | 18 +-- .../e2e/cypress/e2e/cy_origin_error.cy.ts | 2 +- 72 files changed, 757 insertions(+), 743 deletions(-) diff --git a/npm/webpack-preprocessor/test/unit/cross-origin-callback-loader.spec.ts b/npm/webpack-preprocessor/test/unit/cross-origin-callback-loader.spec.ts index 8bf7ac4b2a82..22888cd11839 100644 --- a/npm/webpack-preprocessor/test/unit/cross-origin-callback-loader.spec.ts +++ b/npm/webpack-preprocessor/test/unit/cross-origin-callback-loader.spec.ts @@ -63,7 +63,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('is a noop when cy.origin() callback does not contain Cypress.require()', () => { const source = `it('test', () => { - cy.origin('http://foobar.com:3500', () => {}) + cy.origin('http://www.foobar.com:3500', () => {}) })` const { originalMap, resultingSource, resultingMap, store } = callLoader(source) @@ -74,7 +74,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('is a noop when last argument to cy.origin() is not a callback', () => { const source = `it('test', () => { - cy.origin('http://foobar.com:3500', {}) + cy.origin('http://www.foobar.com:3500', {}) })` const { originalMap, resultingSource, resultingMap, store } = callLoader(source) @@ -93,14 +93,14 @@ describe('./lib/cross-origin-callback-loader', () => { it('replaces cy.origin() callback with an object', () => { const { resultingSource, resultingMap } = callLoader(stripIndent` it('test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.require('../support/utils') }) })`) expect(resultingSource).to.equal(stripIndent` it('test', () => { - cy.origin('http://foobar.com:3500', { + cy.origin('http://www.foobar.com:3500', { "callbackName": "__cypressCrossOriginCallback", "outputFilePath": "/path/to/tmp/cross-origin-cb-abc123.js" }); @@ -112,7 +112,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('replaces cy.other() when specified in commands', () => { const { resultingSource, resultingMap } = callLoader(stripIndent` it('test', () => { - cy.other('http://foobar.com:3500', () => { + cy.other('http://www.foobar.com:3500', () => { Cypress.require('../support/utils') }) })`, @@ -120,7 +120,7 @@ describe('./lib/cross-origin-callback-loader', () => { expect(resultingSource).to.equal(stripIndent` it('test', () => { - cy.other('http://foobar.com:3500', { + cy.other('http://www.foobar.com:3500', { "callbackName": "__cypressCrossOriginCallback", "outputFilePath": "/path/to/tmp/cross-origin-cb-abc123.js" }); @@ -132,7 +132,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('adds the file to the store, replacing Cypress.require() with require()', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.require('../support/utils') }) })`, @@ -148,7 +148,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('works when callback is a function expression', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', function () { + cy.origin('http://www.foobar.com:3500', function () { Cypress.require('../support/utils') }) })`, @@ -163,7 +163,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('works when dep is not assigned to a variable', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.require('../support/utils') }) })`, @@ -178,7 +178,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('works when dep is assigned to a variable', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const utils = Cypress.require('../support/utils') utils.foo() }) @@ -196,7 +196,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('works with multiple Cypress.require()s', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.require('../support/commands') const utils = Cypress.require('../support/utils') const _ = Cypress.require('lodash') @@ -219,7 +219,7 @@ describe('./lib/cross-origin-callback-loader', () => { `it('test', () => { cy .wrap({}) - .origin('http://foobar.com:3500', () => { + .origin('http://www.foobar.com:3500', () => { Cypress.require('../support/commands') }) })`, @@ -234,7 +234,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('works when result of require() is invoked', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const someVar = 'someValue' const result = Cypress.require('./fn')(someVar) expect(result).to.equal('mutated someVar') @@ -255,7 +255,7 @@ describe('./lib/cross-origin-callback-loader', () => { it('works when dependencies passed into called', () => { const { store } = callLoader( `it('test', () => { - cy.origin('http://foobar.com:3500', { args: { foo: 'foo'}}, ({ foo }) => { + cy.origin('http://www.foobar.com:3500', { args: { foo: 'foo'}}, ({ foo }) => { const result = Cypress.require('./fn')(foo) expect(result).to.equal('mutated someVar') }) diff --git a/packages/app/src/runner/aut-iframe.ts b/packages/app/src/runner/aut-iframe.ts index 3b3a319eeff5..f8fba8d44a93 100644 --- a/packages/app/src/runner/aut-iframe.ts +++ b/packages/app/src/runner/aut-iframe.ts @@ -92,9 +92,9 @@ export class AutIframe { } /** - * If the AUT is cross origin relative to top, a security error is thrown and the method returns false - * If the AUT is cross origin relative to top and chromeWebSecurity is false, origins of the AUT and top need to be compared and returns false - * Otherwise, if top and the AUT match origins, the method returns true. + * If the AUT is cross super domain origin relative to top, a security error is thrown and the method returns false + * If the AUT is cross super domain origin relative to top and chromeWebSecurity is false, origins of the AUT and top need to be compared and returns false + * Otherwise, if top and the AUT match super domain origins, the method returns true. * If the AUT origin is "about://blank", that means the src attribute has been stripped off the iframe and is adhering to same origin policy */ doesAUTMatchTopSuperDomainOrigin = () => { @@ -163,7 +163,7 @@ export class AutIframe { }) // The iframe is in a cross origin state. - // Remove the src attribute to adhere to same super domain origin policy so we can interact with the frame. NOTE: This should only be done ONCE. + // Remove the src attribute to adhere to same super domain origin so we can interact with the frame. NOTE: This should only be done ONCE. this.removeSrcAttribute() return diff --git a/packages/app/src/runner/event-manager.ts b/packages/app/src/runner/event-manager.ts index 90b8bff4a430..427a9c9b10b4 100644 --- a/packages/app/src/runner/event-manager.ts +++ b/packages/app/src/runner/event-manager.ts @@ -611,8 +611,8 @@ export class EventManager { }) // Reflect back to the requesting origin the status of the 'duringUserTestExecution' state - Cypress.primaryOriginCommunicator.on('sync:during:user:test:execution', ({ specBridgeResponseEvent }, superDomainOrigin) => { - Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, specBridgeResponseEvent, cy.state('duringUserTestExecution')) + Cypress.primaryOriginCommunicator.on('sync:during:user:test:execution', ({ specBridgeResponseEvent }, origin) => { + Cypress.primaryOriginCommunicator.toSpecBridge(origin, specBridgeResponseEvent, cy.state('duringUserTestExecution')) }) Cypress.on('request:snapshot:from:spec:bridge', ({ log, name, options, specBridge, addSnapshot }: { @@ -653,22 +653,22 @@ export class EventManager { Cypress.primaryOriginCommunicator.toAllSpecBridges('before:unload', origin) }) - Cypress.primaryOriginCommunicator.on('expect:origin', (superDomainOrigin) => { - this.localBus.emit('expect:origin', superDomainOrigin) + Cypress.primaryOriginCommunicator.on('expect:origin', (origin) => { + this.localBus.emit('expect:origin', origin) }) - Cypress.primaryOriginCommunicator.on('viewport:changed', (viewport, superDomainOrigin) => { + Cypress.primaryOriginCommunicator.on('viewport:changed', (viewport, origin) => { const callback = () => { - Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, 'viewport:changed:end') + Cypress.primaryOriginCommunicator.toSpecBridge(origin, 'viewport:changed:end') } Cypress.primaryOriginCommunicator.emit('sync:viewport', viewport) this.localBus.emit('viewport:changed', viewport, callback) }) - Cypress.primaryOriginCommunicator.on('before:screenshot', (config, superDomainOrigin) => { + Cypress.primaryOriginCommunicator.on('before:screenshot', (config, origin) => { const callback = () => { - Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, 'before:screenshot:end') + Cypress.primaryOriginCommunicator.toSpecBridge(origin, 'before:screenshot:end') } handleBeforeScreenshot(config, callback) @@ -861,9 +861,9 @@ export class EventManager { this.ws.emit('spec:changed', specFile) } - notifyCrossOriginBridgeReady (superDomainOrigin) { + notifyCrossOriginBridgeReady (origin) { // Any multi-origin event appends the origin as the third parameter and we do the same here for this short circuit - Cypress.primaryOriginCommunicator.emit('bridge:ready', undefined, superDomainOrigin) + Cypress.primaryOriginCommunicator.emit('bridge:ready', undefined, origin) } snapshotUnpinned () { diff --git a/packages/app/src/runner/index.ts b/packages/app/src/runner/index.ts index 221de8f51195..7a421b32f647 100644 --- a/packages/app/src/runner/index.ts +++ b/packages/app/src/runner/index.ts @@ -194,11 +194,11 @@ export async function teardown () { * Add a cross origin iframe for cy.origin support */ export function addCrossOriginIframe (location) { - const id = `Spec Bridge: ${location.superDomainOrigin}` + const id = `Spec Bridge: ${location.origin}` // if it already exists, don't add another one if (document.getElementById(id)) { - getEventManager().notifyCrossOriginBridgeReady(location.superDomainOrigin) + getEventManager().notifyCrossOriginBridgeReady(location.origin) return } @@ -209,7 +209,7 @@ export function addCrossOriginIframe (location) { // container since it needs to match the size of the top window for screenshots $container: document.body, className: 'spec-bridge-iframe', - src: `${location.superDomainOrigin}/${getRunnerConfigFromWindow().namespace}/spec-bridge-iframes`, + src: `${location.origin}/${getRunnerConfigFromWindow().namespace}/spec-bridge-iframes`, }) } diff --git a/packages/driver/cypress/e2e/commands/navigation.cy.js b/packages/driver/cypress/e2e/commands/navigation.cy.js index 073f37fe5a42..cccfc66cda22 100644 --- a/packages/driver/cypress/e2e/commands/navigation.cy.js +++ b/packages/driver/cypress/e2e/commands/navigation.cy.js @@ -1553,7 +1553,7 @@ describe('src/cy/commands/navigation', () => { ${experimentalMessage} \`cy.visit('http://localhost:3500/fixtures/generic.html')\` \`\`\n - \`cy.origin('http://foobar.com:3500', () => {\` + \`cy.origin('http://www.foobar.com:3500', () => {\` \` cy.visit('http://www.foobar.com:3500/fixtures/generic.html')\` \` \` \`})\`\n @@ -2241,10 +2241,10 @@ describe('src/cy/commands/navigation', () => { expect(err.message).to.contain(stripIndent`\ Cypress detected a cross origin error happened on page load:\n > ${error}\n - Before the page load, you were bound to the origin policy:\n + Before the page load, you were bound to the origin:\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 + A cross origin error happens when your application navigates to a new URL which does not match the origin above.\n + A new URL does not match the origin if the 'protocol', 'port' (if specified), and/or 'host' 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 }`) diff --git a/packages/driver/cypress/e2e/e2e/origin/basic_login.cy.ts b/packages/driver/cypress/e2e/e2e/origin/basic_login.cy.ts index a06c7a1a4406..f70894cf2c46 100644 --- a/packages/driver/cypress/e2e/e2e/origin/basic_login.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/basic_login.cy.ts @@ -4,7 +4,7 @@ describe('basic login', () => { it('logs in with idp redirect', () => { cy.visit('/fixtures/auth/index.html') // Establishes primary origin cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.get('[data-cy="login"]').click() }) @@ -23,7 +23,7 @@ describe('basic login', () => { win.location.href = 'http://www.idp.com:3500/fixtures/auth/idp.html' }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('FJohnson') cy.get('[data-cy="login"]').click() }) @@ -37,7 +37,7 @@ describe('basic login', () => { it('visits foobar first', () => { cy.visit('http://www.foobar.com:3500/fixtures/auth/index.html') // Establishes primary origin cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.get('[data-cy="login"]').click() }) @@ -60,7 +60,7 @@ describe('basic login', () => { // Primary established via base url // TODO: baseUrl does not establish primary without a visit it.skip('logs in with primary set via baseurl', { baseUrl: 'http://localhost:3500' }, () => { - cy.origin('http://idp.com:3500', () => { // primary origin is localhost + cy.origin('http://www.idp.com:3500', () => { // primary origin is localhost cy.visit('http://www.idp.com:3500/fixtures/auth/idp.html') cy.get('[data-cy="username"]').type('FJohnson') cy.get('[data-cy="login"]').click() @@ -77,7 +77,7 @@ describe('basic login', () => { it('logs in with primary set via visit', () => { cy.visit('/fixtures/auth/index.html') - cy.origin('http://idp.com:3500', () => { // primary origin is localhost + cy.origin('http://www.idp.com:3500', () => { // primary origin is localhost cy.visit('http://www.idp.com:3500/fixtures/auth/idp.html') cy.get('[data-cy="username"]').type('FJohnson') cy.get('[data-cy="login"]').click() @@ -94,7 +94,7 @@ describe('basic login', () => { const login = (name) => { cy.session(name, () => { // Note, this assumes localhost is the primary origin, ideally we'd be able to specify this directly. - cy.origin('http://idp.com:3500', { args: name }, (name) => { + cy.origin('http://www.idp.com:3500', { args: name }, (name) => { cy.visit('http://www.idp.com:3500/fixtures/auth/idp.html') cy.get('[data-cy="username"]').type(name) cy.get('[data-cy="login"]').click() @@ -154,9 +154,9 @@ describe('Multi-step Auth', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-with-approval"]').click() // takes you to foobar.com.../approval cy.url() //fail - cy.origin('http://foobar.com:3500', () => { // Parent origin is localhost + cy.origin('http://www.foobar.com:3500', () => { // Parent origin is localhost cy.get('[data-cy="approve-orig"]').click() // takes you to idp.com - cy.origin('http://idp.com:3500', () => { // Parent origin is foobar.com + cy.origin('http://www.idp.com:3500', () => { // Parent origin is foobar.com cy.get('[data-cy="username"]').type('MarkyMark') cy.get('[data-cy="login"]').click() // Takes you back to localhost }) // Does not wait on foobar.com because there are no subsequent commands (would wait forever) @@ -172,11 +172,11 @@ describe('Multi-step Auth', () => { it.skip('final-auth redirects back to localhost - flat', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-with-approval"]').click() // takes you to foobar.com.../approval - cy.origin('http://foobar.com:3500', () => { // Parent origin is localhost + cy.origin('http://www.foobar.com:3500', () => { // Parent origin is localhost cy.get('[data-cy="approve-orig"]').click() // takes you to idp.com }) // Exits and moves on to the next command - cy.origin('http://idp.com:3500', () => { // Parent origin is localhost + cy.origin('http://www.idp.com:3500', () => { // Parent origin is localhost cy.get('[data-cy="username"]').type('MarkyMark') cy.get('[data-cy="login"]').click() // Takes you back to localhost }) // Exits and moves on to the next command @@ -189,10 +189,10 @@ describe('Multi-step Auth', () => { // TODO: cy.origin does not work in cy.origin yet. it.skip('final auth redirects back to localhost - nested - approval first', () => { - cy.origin('http://foobar.com:3500', () => { // parent origin is localhost + cy.origin('http://www.foobar.com:3500', () => { // parent origin is localhost cy.visit('http://www.foobar.com:3500/fixtures/auth/approval.html') cy.get('[data-cy="approve-orig"]').click() // takes you to idp.com - cy.origin('http://idp.com:3500', () => { // parent origin is foobar.com + cy.origin('http://www.idp.com:3500', () => { // parent origin is foobar.com cy.get('[data-cy="username"]').type('MarkyMark') cy.get('[data-cy="login"]').click() // Takes you back to localhost }) // Does not wait on foobar.com because there are no subsequent commands (would wait forever) @@ -208,9 +208,9 @@ describe('Multi-step Auth', () => { it.skip('final auth redirects back to approval page - nested', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-with-approval"]').click() // takes you to foobar.com.../approval - cy.origin('http://foobar.com:3500', () => { // parent origin is localhost + cy.origin('http://www.foobar.com:3500', () => { // parent origin is localhost cy.get('[data-cy="approve-me"]').click() // takes you to idp.com - cy.origin('http://idp.com:3500', () => { // parent origin is foobar.com + cy.origin('http://www.idp.com:3500', () => { // parent origin is foobar.com cy.get('[data-cy="username"]').type('MarkyMark') cy.get('[data-cy="login"]').click() // Takes you back to foobar.com.../approval }) // Exits and moves on to the next command @@ -227,16 +227,16 @@ describe('Multi-step Auth', () => { it('final auth redirects back to approval page - flat', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-with-approval"]').click() // takes you to foobar.com.../approval - cy.origin('http://foobar.com:3500', () => { // parent origin is localhost + cy.origin('http://www.foobar.com:3500', () => { // parent origin is localhost cy.get('[data-cy="approve-me"]').click() // takes you to idp.com }) // waits on localhost forever, this breaks - cy.origin('http://idp.com:3500', () => { // parent origin is localhost + cy.origin('http://www.idp.com:3500', () => { // parent origin is localhost cy.get('[data-cy="username"]').type('MarkyMark') cy.get('[data-cy="login"]').click() // Takes you back to foobar.com.../approval }) // Exits and moves on to the next command - cy.origin('http://foobar.com:3500', () => { // parent origin is localhost + cy.origin('http://www.foobar.com:3500', () => { // parent origin is localhost cy.get('[data-cy="login-success"]').click() // Takes you back to localhost }) // Exits and moves on to the next command diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/actions.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/actions.cy.ts index c5d3adccf0b8..ac5324b31d31 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/actions.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/actions.cy.ts @@ -8,7 +8,7 @@ context('cy.origin actions', () => { it('.type()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').type('foo') .should('have.value', 'foo') }) @@ -17,7 +17,7 @@ context('cy.origin actions', () => { it('.focus()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').focus() .should('be.focused') }) @@ -26,7 +26,7 @@ context('cy.origin actions', () => { it('.blur()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').type('foo').blur() .should('not.be.focused') }) @@ -35,7 +35,7 @@ context('cy.origin actions', () => { it('.clear()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input') .type('foo').should('have.value', 'foo') .clear().should('have.value', '') @@ -45,7 +45,7 @@ context('cy.origin actions', () => { it('.submit()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterFormSubmitted = new Promise((resolve) => { cy.once('form:submitted', resolve) }) @@ -58,7 +58,7 @@ context('cy.origin actions', () => { it('.click()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').then(($btn) => { const onClick = new Promise((resolve) => { $btn.on('click', () => resolve()) @@ -73,7 +73,7 @@ context('cy.origin actions', () => { it('.dblclick()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').then(($btn) => { const afterDblClick = new Promise((resolve) => { $btn.on('dblclick', () => resolve()) @@ -88,7 +88,7 @@ context('cy.origin actions', () => { it('.rightclick()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').then(($btn) => { const afterContextmenu = new Promise((resolve) => { $btn.on('contextmenu', () => resolve()) @@ -103,7 +103,7 @@ context('cy.origin actions', () => { it('.check()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]') .check().should('be.checked') }) @@ -112,7 +112,7 @@ context('cy.origin actions', () => { it('.uncheck()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]') .check().should('be.checked') .uncheck().should('not.be.checked') @@ -122,7 +122,7 @@ context('cy.origin actions', () => { it('.select()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('select[name="foods"]') .select('Japanese').should('have.value', 'Japanese') }) @@ -131,7 +131,7 @@ context('cy.origin actions', () => { it('.scrollIntoView()', () => { cy.get('a[data-cy="scrolling-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#scroll-into-view-vertical h5') .should('not.be.visible') .scrollIntoView().should('be.visible') @@ -141,7 +141,7 @@ context('cy.origin actions', () => { it('.scrollTo()', () => { cy.get('a[data-cy="scrolling-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#scroll-into-view-vertical h5').should('not.be.visible') cy.get('#scroll-into-view-vertical').scrollTo(0, 300) cy.get('#scroll-into-view-vertical h5').should('be.visible') @@ -151,7 +151,7 @@ context('cy.origin actions', () => { it('.trigger()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').then(($btn) => { const afterClick = new Promise((resolve) => { $btn.on('click', () => resolve()) @@ -166,7 +166,7 @@ context('cy.origin actions', () => { it('.selectFile()', () => { cy.get('a[data-cy="files-form-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap(Cypress.Buffer.from('foo')).as('foo') cy.get('#basic') @@ -193,7 +193,7 @@ context('cy.origin actions', () => { it('.get()', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -220,7 +220,7 @@ context('cy.origin actions', () => { it('.get()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button') }) @@ -242,7 +242,7 @@ context('cy.origin actions', () => { it('.alias()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').as('buttonAlias') }) @@ -266,7 +266,7 @@ context('cy.origin actions', () => { it('.click()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button-inside-a').click() }) @@ -319,7 +319,7 @@ context('cy.origin actions', () => { it('.dblclick()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').dblclick() }) @@ -367,7 +367,7 @@ context('cy.origin actions', () => { it('.rightclick()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').rightclick() }) @@ -415,7 +415,7 @@ context('cy.origin actions', () => { it('.type()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('input#input').type('foo') }) @@ -487,7 +487,7 @@ context('cy.origin actions', () => { // TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23480 it.skip('.submit()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('form#multiple-inputs-and-input-submit input[name="fname"]').type('foo') cy.get('form#multiple-inputs-and-input-submit input[name="lname"]').type('bar') cy.get('form#multiple-inputs-and-input-submit').submit() @@ -522,7 +522,7 @@ context('cy.origin actions', () => { it('.focus()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').focus() }) @@ -545,7 +545,7 @@ context('cy.origin actions', () => { it('.blur()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // FIXME: snapshot shows the primary domain (before type). Should be secondary cy.get('#input').type('foo').blur() }) @@ -569,7 +569,7 @@ context('cy.origin actions', () => { it('.clear()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // FIXME: snapshot shows the primary domain. Should be secondary cy.get('#input').type('foo').clear() }) @@ -595,7 +595,7 @@ context('cy.origin actions', () => { it('.check()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]').check() }) @@ -639,7 +639,7 @@ context('cy.origin actions', () => { it('.uncheck()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]') .check().uncheck() }) @@ -684,7 +684,7 @@ context('cy.origin actions', () => { it('.select()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // TODO: wrong selected value is displayed in the snapshot after cy.get('select[name="foods"]').select('Japanese') }) @@ -730,7 +730,7 @@ context('cy.origin actions', () => { it('.scrollIntoView()', () => { cy.get('a[data-cy="scrolling-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // FIXME: snapshot of primary is showing for scrollIntoView cy.get('#scroll-into-view-vertical h5') .should('not.be.visible') @@ -758,7 +758,7 @@ context('cy.origin actions', () => { it('.scrollTo()', () => { cy.get('a[data-cy="scrolling-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#scroll-into-view-vertical h5').should('not.be.visible') cy.get('#scroll-into-view-vertical').scrollTo(0, 300) }) @@ -778,7 +778,7 @@ context('cy.origin actions', () => { it('.trigger()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').trigger('click') }) @@ -803,7 +803,7 @@ context('cy.origin actions', () => { it('.selectFile()', () => { cy.get('a[data-cy="files-form-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#basic').selectFile({ contents: Cypress.Buffer.from('foo'), fileName: 'foo.txt' }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/aliasing.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/aliasing.cy.ts index e225b4270f97..2d6f77ebbc9d 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/aliasing.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/aliasing.cy.ts @@ -9,7 +9,7 @@ context('cy.origin aliasing', () => { it('supports dom elements inside origin', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]').as('checkbox') cy.get('@checkbox').click().should('be.checked') }) @@ -23,7 +23,7 @@ context('cy.origin aliasing', () => { cy.get('[data-cy="cross-origin-secondary-link"]').as('link') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('@link').click() }) }) @@ -43,7 +43,7 @@ context('cy.origin aliasing', () => { it('.as()', () => { cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').as('buttonAlias') }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/assertions.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/assertions.cy.ts index 2dd1ae3ba854..6e12063ae998 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/assertions.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/assertions.cy.ts @@ -7,7 +7,7 @@ context('cy.origin assertions', () => { }) it('.should() and .and()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]') .should('not.be.checked').and('not.be.disabled') }) @@ -33,7 +33,7 @@ context('cy.origin assertions', () => { // TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23148 it.skip('.should() and .and()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get(':checkbox[name="colors"][value="blue"]') .should('not.be.checked').and('not.be.disabled') }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/connectors.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/connectors.cy.ts index 5790fb55920c..ab8690605a3b 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/connectors.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/connectors.cy.ts @@ -7,7 +7,7 @@ context('cy.origin connectors', () => { }) it('.each()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-name>[name="colors"]').each(($element, index) => { expect($element.prop('type')).to.equal('checkbox') }) @@ -15,19 +15,19 @@ context('cy.origin connectors', () => { }) it('.its()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').its('length').should('eq', 3) }) }) it('.invoke()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').invoke('text').should('eq', 'button') }) }) it('.spread()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const arr = ['foo', 'bar', 'baz'] cy.wrap(arr).spread((foo, bar, baz) => { @@ -39,7 +39,7 @@ context('cy.origin connectors', () => { }) it('.then()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').then(($list) => { expect($list).to.have.length(3) }) @@ -58,7 +58,7 @@ context('cy.origin connectors', () => { }) it('.its()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').its('length') }) @@ -92,7 +92,7 @@ context('cy.origin connectors', () => { }) it('.invoke()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').invoke('text') }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/cookies.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/cookies.cy.ts index 5bd9d056ea61..4887980fdc22 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/cookies.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/cookies.cy.ts @@ -8,7 +8,7 @@ describe('cy.origin cookies', () => { }) it('.getCookie(), .getCookies(), and .setCookie()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.getCookies().should('be.empty') cy.setCookie('foo', 'bar') @@ -19,7 +19,7 @@ describe('cy.origin cookies', () => { }) it('.clearCookie()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.setCookie('foo', 'bar') cy.getCookie('foo').should('not.be.null') cy.clearCookie('foo') @@ -28,7 +28,7 @@ describe('cy.origin cookies', () => { }) it('.clearCookies()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.setCookie('foo', 'bar') cy.setCookie('faz', 'baz') @@ -58,7 +58,7 @@ describe('cy.origin cookies', () => { expect(logs[0].get('state')).to.eq('failed') expect(logs[0].get('name')).to.eq('getCookie') expect(logs[0].get('message')).to.eq('foo') - expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') + expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://www.foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') done() }) @@ -73,7 +73,7 @@ describe('cy.origin cookies', () => { expect(logs[0].get('state')).to.eq('failed') expect(logs[0].get('name')).to.eq('getCookies') expect(logs[0].get('message')).to.eq('') - expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') + expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://www.foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') done() }) @@ -88,7 +88,7 @@ describe('cy.origin cookies', () => { expect(logs[0].get('state')).to.eq('failed') expect(logs[0].get('name')).to.eq('setCookie') expect(logs[0].get('message')).to.eq('foo, bar') - expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') + expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://www.foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') done() }) @@ -103,7 +103,7 @@ describe('cy.origin cookies', () => { expect(logs[0].get('state')).to.eq('failed') expect(logs[0].get('name')).to.eq('clearCookie') expect(logs[0].get('message')).to.eq('foo') - expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') + expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://www.foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') done() }) @@ -118,7 +118,7 @@ describe('cy.origin cookies', () => { expect(logs[0].get('state')).to.eq('failed') expect(logs[0].get('name')).to.eq('clearCookies') expect(logs[0].get('message')).to.eq('') - expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') + expect(err.message).to.eq('Timed out retrying after 100ms: The command was expected to run against origin `http://localhost:3500` but the application is at origin `http://www.foobar.com:3500`.\n\nThis commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.') done() }) @@ -140,7 +140,7 @@ describe('cy.origin cookies', () => { }) it('.getCookie()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.getCookies().should('be.empty') cy.setCookie('foo', 'bar') cy.getCookie('foo').its('value').should('equal', 'bar') @@ -161,7 +161,7 @@ describe('cy.origin cookies', () => { }) it('.getCookies()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.getCookies().should('be.empty') cy.setCookie('foo', 'bar') @@ -189,7 +189,7 @@ describe('cy.origin cookies', () => { }) it('.setCookie()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.getCookies().should('be.empty') cy.setCookie('foo', 'bar') @@ -210,7 +210,7 @@ describe('cy.origin cookies', () => { }) it('.clearCookie()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.setCookie('foo', 'bar') cy.getCookie('foo').should('not.be.null') cy.clearCookie('foo') @@ -232,7 +232,7 @@ describe('cy.origin cookies', () => { }) it('.clearCookies()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.setCookie('foo', 'bar') cy.setCookie('faz', 'baz') diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/files.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/files.cy.ts index d688ad1ed37f..ec90c2d88038 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/files.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/files.cy.ts @@ -7,7 +7,7 @@ context('cy.origin files', () => { }) it('.fixture()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.fixture('example.json').then((json) => { expect(json).to.be.an('object') expect(json.example).to.be.true @@ -16,7 +16,7 @@ context('cy.origin files', () => { }) it('.readFile()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.readFile('cypress/fixtures/example.json').then((json) => { expect(json).to.be.an('object') expect(json.example).to.be.true @@ -25,7 +25,7 @@ context('cy.origin files', () => { }) it('.writeFile()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const contents = JSON.stringify({ foo: 'bar' }) cy.stub(Cypress, 'backend').resolves({ @@ -59,7 +59,7 @@ context('cy.origin files', () => { }) it('.readFile()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.readFile('cypress/fixtures/example.json') }) @@ -73,7 +73,7 @@ context('cy.origin files', () => { }) it('.writeFile()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const contents = JSON.stringify({ foo: 'bar' }) cy.stub(Cypress, 'backend').resolves({ diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/local_storage.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/local_storage.cy.ts index 77a1294480a3..7debeaa90432 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/local_storage.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/local_storage.cy.ts @@ -7,7 +7,7 @@ context('cy.origin local storage', () => { }) it('.clearLocalStorage()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((win) => { win.localStorage.setItem('foo', 'bar') expect(win.localStorage.getItem('foo')).to.equal('bar') @@ -32,7 +32,7 @@ context('cy.origin local storage', () => { }) it('.clearLocalStorage()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((win) => { win.localStorage.setItem('foo', 'bar') expect(win.localStorage.getItem('foo')).to.equal('bar') diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/location.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/location.cy.ts index 0457b1a1282f..9072399b4139 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/location.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/location.cy.ts @@ -7,13 +7,13 @@ context('cy.origin location', () => { }) it('.hash()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.hash().should('be.empty') }) }) it('.location()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.location().should((location) => { expect(location.href).to.equal('http://www.foobar.com:3500/fixtures/secondary-origin.html') expect(location.origin).to.equal('http://www.foobar.com:3500') @@ -22,7 +22,7 @@ context('cy.origin location', () => { }) it('.url()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.url().should('equal', 'http://www.foobar.com:3500/fixtures/secondary-origin.html') }) }) @@ -39,7 +39,7 @@ context('cy.origin location', () => { }) it('.hash()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.hash() }) @@ -51,7 +51,7 @@ context('cy.origin location', () => { }) it('.location()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.location() }) @@ -77,7 +77,7 @@ context('cy.origin location', () => { }) it('.url()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.url() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/log.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/log.cy.ts index 859f714cce26..2db1a85c41a7 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/log.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/log.cy.ts @@ -16,7 +16,7 @@ context('cy.origin log', () => { }) it('logs in primary and secondary origins', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterLogAdded = new Promise((resolve) => { const listener = (attrs) => { if (attrs.message === 'test log in cy.origin') { @@ -42,7 +42,7 @@ context('cy.origin log', () => { }) it('has a different id in a second test', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterLogAdded = new Promise((resolve) => { const listener = (attrs) => { if (attrs.message === 'test log in cy.origin') { diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/misc.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/misc.cy.ts index e929d07d6116..cce9a63d8eb9 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/misc.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/misc.cy.ts @@ -7,37 +7,37 @@ context('cy.origin misc', () => { }) it('.end()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').end().should('be.null') }) }) it('.exec()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.exec('echo foobar').its('stdout').should('contain', 'foobar') }) }) it('.focused()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').click().focused().should('have.id', 'button') }) }) it('.wrap()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap({ foo: 'bar' }).should('deep.equal', { foo: 'bar' }) }) }) it('.debug()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').debug().should('have.id', 'button') }) }) it('.pause()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterPaused = new Promise((resolve) => { cy.once('paused', () => { Cypress.emit('resume:all') @@ -54,7 +54,7 @@ context('cy.origin misc', () => { }) it('.task()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.task('return:arg', 'works').should('eq', 'works') }) }) @@ -71,7 +71,7 @@ context('cy.origin misc', () => { }) it('.exec()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.exec('echo foobar') }) @@ -87,7 +87,7 @@ context('cy.origin misc', () => { }) it('.focused()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').click().focused() }) @@ -108,7 +108,7 @@ context('cy.origin misc', () => { }) it('.wrap()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const arr = ['foo', 'bar', 'baz'] cy.wrap(arr).spread((foo, bar, baz) => { @@ -129,7 +129,7 @@ context('cy.origin misc', () => { }) it('.debug()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#button').debug() }) @@ -149,7 +149,7 @@ context('cy.origin misc', () => { }) it('.pause()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterPaused = new Promise((resolve) => { cy.once('paused', () => { Cypress.emit('resume:all') @@ -178,7 +178,7 @@ context('cy.origin misc', () => { }) it('.task()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.task('return:arg', 'works') }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/navigation.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/navigation.cy.ts index 68b83a17a25c..5d631cb481e0 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/navigation.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/navigation.cy.ts @@ -6,7 +6,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/dom.html') cy.go('back') @@ -21,7 +21,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((localWindow) => { // Define a custom property on window that we can assert the presence of. // After reloading, this property should not exist. @@ -57,7 +57,7 @@ context('cy.origin navigation', () => { expect(primaryVisitLoadSpy).to.be.calledOnce }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const secondaryCyBeforeLoadSpy = cy.spy() const secondaryCyLoadSpy = cy.spy() const secondaryVisitBeforeLoadSpy = cy.spy() @@ -86,7 +86,7 @@ context('cy.origin navigation', () => { it('supports visiting primary first', () => { cy.visit('/fixtures/primary-origin.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') @@ -94,7 +94,7 @@ context('cy.origin navigation', () => { }) it('supports skipping visiting primary first', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') @@ -105,12 +105,12 @@ context('cy.origin navigation', () => { it.skip('supports nesting a third origin', () => { cy.visit('/fixtures/primary-origin.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.visit('http://www.idp.com:3500/fixtures/dom.html') }) }) @@ -121,7 +121,7 @@ context('cy.origin navigation', () => { cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') cy.visit('http://www.foobar.com:3500/fixtures/dom.html') @@ -162,7 +162,7 @@ context('cy.origin navigation', () => { cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html#hashchange') cy.location('hash').should('equal', '#hashchange') @@ -170,7 +170,7 @@ context('cy.origin navigation', () => { }) it('navigates back to primary', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') }) @@ -185,7 +185,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // this call should succeed because we can visit a cross-origin cy.visit('http://www.idp.com:3500/fixtures/dom.html') }) @@ -203,7 +203,7 @@ context('cy.origin navigation', () => { In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use \`cy.origin()\`:\n \`cy.visit('http://localhost:3500/fixtures/primary-origin.html')\` \`\`\n - \`cy.origin('http://foobar.com:3500', () => {\` + \`cy.origin('http://www.foobar.com:3500', () => {\` \` cy.visit('http://www.foobar.com:3500/fixtures/dom.html')\` \` \` \`})\`\n @@ -227,7 +227,7 @@ context('cy.origin navigation', () => { it('supports the query string option', () => { cy.visit('/fixtures/primary-origin.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html', { qs: { foo: 'bar' } }) cy.location('search').should('equal', '?foo=bar') @@ -256,7 +256,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') @@ -265,7 +265,7 @@ context('cy.origin navigation', () => { it('succeeds when the secondary is already defined but the AUT is still on the primary', () => { // setup the secondary to be on the secondary origin - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') @@ -275,7 +275,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') // verify there aren't any issues when the AUT is on primary but the spec bridge is on secondary (cross-origin) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') @@ -287,7 +287,7 @@ context('cy.origin navigation', () => { cy.on('window:load', primaryCyLoadSpy) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const secondaryCyLoadSpy = cy.spy() cy.on('window:load', secondaryCyLoadSpy) @@ -339,7 +339,7 @@ context('cy.origin navigation', () => { }) it('supports auth options and adding auth to subsequent requests', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/basic_auth', { auth: { username: 'cypress', @@ -365,7 +365,7 @@ context('cy.origin navigation', () => { }) }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('body').should('have.text', 'basic auth worked') }) @@ -376,7 +376,7 @@ context('cy.origin navigation', () => { win.location.href = 'http://www.foobar.com:3500/basic_auth' }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('body').should('have.text', 'basic auth worked') }) }) @@ -396,7 +396,7 @@ context('cy.origin navigation', () => { win.location.href = 'http://www.foobar.com:3500/fixtures/primary-origin.html' }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((win) => { win.location.href = 'http://www.foobar.com:3500/basic_auth' }) @@ -433,7 +433,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((win) => { win.location.href = 'http://www.foobar.com:3500/fixtures/dom.html' }) @@ -457,7 +457,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/dom.html') cy.go('back') @@ -478,7 +478,7 @@ context('cy.origin navigation', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="dom-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.reload() }) @@ -496,7 +496,7 @@ context('cy.origin navigation', () => { it('visit()', () => { cy.visit('/fixtures/primary-origin.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/secondary-origin.html') cy.get('[data-cy="dom-check"]').should('have.text', 'From a secondary origin') diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/network_requests.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/network_requests.cy.ts index d4925cd4616f..7e05cfa03a90 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/network_requests.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/network_requests.cy.ts @@ -7,8 +7,8 @@ context('cy.origin network requests', () => { }) it('.request() to secondary origin', () => { - cy.origin('http://foobar.com:3500', () => { - cy.request('http://www.foobar.com:3500/fixtures/example.json').should((response) => { + cy.origin('http://www.foobar.com:3500', () => { + cy.request('/fixtures/example.json').should((response) => { expect(response.status).to.equal(200) expect(response.allRequestResponses[0]['Request URL']).to.equal('http://www.foobar.com:3500/fixtures/example.json') }) @@ -25,7 +25,7 @@ context('cy.origin network requests', () => { }) it('.request() to primary origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.request('http://localhost:3500/fixtures/example.json').should((response) => { expect(response.status).to.equal(200) expect(response.allRequestResponses[0]['Request URL']).to.equal('http://localhost:3500/fixtures/example.json') @@ -45,8 +45,8 @@ context('cy.origin network requests', () => { }) it('.request()', () => { - cy.origin('http://foobar.com:3500', () => { - cy.request('http://www.foobar.com:3500/fixtures/example.json') + cy.origin('http://www.foobar.com:3500', () => { + cy.request('/fixtures/example.json') }) cy.shouldWithTimeout(() => { @@ -67,7 +67,7 @@ context('cy.origin network requests', () => { expect(consoleProps.Yielded).to.have.property('status').that.equals(200) expect(renderProps).to.have.property('indicator').that.equals('successful') - expect(renderProps).to.have.property('message').that.equals('GET 200 http://www.foobar.com:3500/fixtures/example.json') + expect(renderProps).to.have.property('message').that.equals('GET 200 /fixtures/example.json') }) }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/querying.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/querying.cy.ts index a78d7fa5dd4c..615d5fdadd64 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/querying.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/querying.cy.ts @@ -7,19 +7,19 @@ context('cy.origin querying', () => { }) it('.get()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input') }) }) it('.contains()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.contains('Nested Find') }) }) it('.within()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').within(() => { cy.get('#input') }) @@ -27,7 +27,7 @@ context('cy.origin querying', () => { }) it('.root()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.root().should('match', 'html') }) }) @@ -36,7 +36,7 @@ context('cy.origin querying', () => { it('.get()', (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -50,7 +50,7 @@ context('cy.origin querying', () => { it('.contains()', (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -64,7 +64,7 @@ context('cy.origin querying', () => { it('.within()', (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -80,7 +80,7 @@ context('cy.origin querying', () => { it('.root()', (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -94,7 +94,7 @@ context('cy.origin querying', () => { it('does not get elements in the runner', (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -108,7 +108,7 @@ context('cy.origin querying', () => { it('does not contain elements in the runner', (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -132,7 +132,7 @@ context('cy.origin querying', () => { }) it('.contains()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.contains('Nested Find') }) @@ -155,7 +155,7 @@ context('cy.origin querying', () => { }) it('.within()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').within(() => { cy.get('#input') }) @@ -177,7 +177,7 @@ context('cy.origin querying', () => { }) it('.root()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.root() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/querying_shadow.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/querying_shadow.cy.ts index 43117e65f5c1..60077167cb1a 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/querying_shadow.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/querying_shadow.cy.ts @@ -7,7 +7,7 @@ context('cy.origin shadow dom', () => { }) it('.shadow()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#shadow-element-1').shadow().find('p.shadow-1') .should('have.text', 'Shadow Content 1') }) @@ -25,7 +25,7 @@ context('cy.origin shadow dom', () => { }) it('.shadow()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#shadow-element-1').shadow() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/screenshot.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/screenshot.cy.ts index 5c677e7f438e..e39368c6bff5 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/screenshot.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/screenshot.cy.ts @@ -23,7 +23,7 @@ context('cy.origin screenshot', () => { }) it('captures the fullPage', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { const automationStub = cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.screenshot({ capture: 'fullPage' }) @@ -37,7 +37,7 @@ context('cy.origin screenshot', () => { }) it('captures the runner', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { const automationStub = cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.screenshot({ capture: 'runner' }) @@ -49,7 +49,7 @@ context('cy.origin screenshot', () => { }) it('captures the viewport', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { const automationStub = cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.screenshot({ capture: 'viewport' }) @@ -81,7 +81,7 @@ context('cy.origin screenshot', () => { }) it('supports multiple titles', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { const automationStub = cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.screenshot() @@ -92,7 +92,7 @@ context('cy.origin screenshot', () => { }) it('supports the blackout option', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.screenshot({ @@ -110,7 +110,7 @@ context('cy.origin screenshot', () => { }) it('supports element screenshots', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { const automationStub = cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.get('.tall-element').screenshot() @@ -122,7 +122,7 @@ context('cy.origin screenshot', () => { }) it('supports screenshot retrying with appropriate naming', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { const automationStub = cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) cy.state('runnable')._currentRetry = 2 @@ -135,7 +135,7 @@ context('cy.origin screenshot', () => { }) it('calls the onBeforeScreenshot callback', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) const onBeforeScreenshot = cy.stub() @@ -145,7 +145,7 @@ context('cy.origin screenshot', () => { }) it('calls the onAfterScreenshot callback', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) const onAfterScreenshot = cy.stub() @@ -155,7 +155,7 @@ context('cy.origin screenshot', () => { }) it('supports the Cypress.screenshot callbacks', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').resolves(serverResult) const onAfterScreenshot = cy.stub() const onBeforeScreenshot = cy.stub() @@ -172,7 +172,7 @@ context('cy.origin screenshot', () => { }) it('supports pausing timers', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').returns(Cypress.Promise.delay(500, serverResult)) cy.window().then((win) => { @@ -205,7 +205,7 @@ context('cy.origin screenshot', () => { }) it('does not pause timers when disableTimersAndAnimations is false', function () { - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').returns(Cypress.Promise.delay(500, serverResult)) cy.window().then((win) => { @@ -235,7 +235,7 @@ context('cy.origin screenshot', () => { expect(err.message).to.include('setTimeout error after screenshot') }) - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').returns(Cypress.Promise.delay(100, serverResult)) cy.window().then((win) => { @@ -260,7 +260,7 @@ context('cy.origin screenshot', () => { expect(err.docsUrl).to.deep.eq(['https://on.cypress.io/uncaught-exception-from-application']) }) - cy.origin('http://foobar.com:3500', { args: this.serverResult }, (serverResult) => { + cy.origin('http://www.foobar.com:3500', { args: this.serverResult }, (serverResult) => { cy.stub(Cypress, 'automation').withArgs('take:screenshot').returns(Cypress.Promise.delay(100, serverResult)) cy.window().then((win) => { @@ -283,7 +283,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 400) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-color.html?color=yellow') const screenShotPromiseWithPath = new Promise((resolve) => { cy.screenshot('crop-check', { @@ -309,7 +309,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-full-page.html') const screenShotPromiseWithPath = new Promise((resolve) => { cy.screenshot('fullPage', { @@ -335,7 +335,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-full-page-same.html') const screenShotPromiseWithPath = new Promise((resolve) => { @@ -362,7 +362,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-element.html') const screenShotPromiseWithPath = new Promise((resolve) => { @@ -389,7 +389,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-color.html?color=yellow') const screenShotPromiseWithPath = new Promise((resolve) => { cy.screenshot('app-clip', { @@ -415,7 +415,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-color.html?color=yellow') const screenShotPromiseWithPath = new Promise((resolve) => { @@ -442,7 +442,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-full-page.html') const screenShotPromiseWithPath = new Promise((resolve) => { @@ -469,7 +469,7 @@ context('cy.origin screenshot', () => { cy.viewport(600, 200) cy.visit('/') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/screenshot-element.html') const screenShotPromiseWithPath = new Promise((resolve) => { cy.get('.element').screenshot('element-clip', { @@ -509,7 +509,7 @@ context('cy.origin screenshot', () => { }) it('.screenshot()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.screenshot({ capture: 'fullPage' }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/spies_stubs_clocks.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/spies_stubs_clocks.cy.ts index ad06cd0f2f05..3634e120004c 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/spies_stubs_clocks.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/spies_stubs_clocks.cy.ts @@ -7,7 +7,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('spy()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const foo = { bar () { } } cy.spy(foo, 'bar') @@ -17,7 +17,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('stub()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const foo = { bar () { } } cy.stub(foo, 'bar') @@ -28,7 +28,7 @@ context('cy.origin spies, stubs, and clock', () => { context('resets stubs', () => { it('creates the stub', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const stubEnv = cy.stub(Cypress, 'env').withArgs('foo').returns('bar') expect(Cypress.env('foo')).to.equal('bar') @@ -39,7 +39,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('verifies the stub got restored', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { expect(Cypress.env('foo')).to.be.undefined // @ts-ignore expect(Cypress.env.isSinonProxy).to.be.undefined @@ -49,7 +49,7 @@ context('cy.origin spies, stubs, and clock', () => { context('resets spies', () => { it('creates the spy', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const stubEnv = cy.spy(Cypress, 'env') Cypress.env() @@ -60,7 +60,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('verifies the spy got restored', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // @ts-ignore expect(Cypress.env.isSinonProxy).to.be.undefined }) @@ -68,7 +68,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('clock() and tick()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const now = Date.UTC(2022, 0, 12) cy.clock(now) @@ -101,7 +101,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('spy()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const foo = { bar () { } } cy.spy(foo, 'bar') @@ -119,7 +119,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('.stub()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const foo = { bar () { } } cy.stub(foo, 'bar') @@ -137,7 +137,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('.clock()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const now = Date.UTC(2022, 0, 12) cy.clock(now) @@ -157,7 +157,7 @@ context('cy.origin spies, stubs, and clock', () => { }) it('.tick()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const now = Date.UTC(2022, 0, 12) cy.clock(now) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/traversal.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/traversal.cy.ts index 7e8510170fba..af34204be873 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/traversal.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/traversal.cy.ts @@ -7,110 +7,110 @@ context('cy.origin traversal', () => { }) it('.children()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').children().should('have.length', 3) }) }) it('.closest()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').closest('form') }) }) it('.eq()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').eq(1).should('have.id', 'name') }) }) it('.filter()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-name>input') .filter('[name="dogs"]').should('have.length', 4) }) }) it('.find()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').find('input').should('have.length', 3) }) }) it('.first()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').first().should('have.id', 'input') }) }) it('.last()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').last().should('have.id', 'age') }) }) it('.next()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').next().should('have.id', 'name') }) }) it('.nextAll()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').nextAll().should('have.length', 2) }) }) it('.nextUntil()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').nextUntil('#age').should('have.length', 1) }) }) it('.not()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').not('#age').should('have.length', 2) }) }) it('.parent()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').parent().should('have.id', 'dom') }) }) it('.parents()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').parents().should('have.length', 3) }) }) it('.parentsUntil()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').parentsUntil('body').should('have.length', 1) }) }) it('.prev()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#age').prev().should('have.id', 'name') }) }) it('.prevAll()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#age').prevAll().should('have.length', 2) }) }) it('.prevUntil()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#age').prevUntil('#input').should('have.length', 1) }) }) it('.siblings()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').siblings().should('have.length', 2) }) }) @@ -128,7 +128,7 @@ context('cy.origin traversal', () => { }) it('.children()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').children() }) @@ -157,7 +157,7 @@ context('cy.origin traversal', () => { }) it('.closest()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').closest('form') }) @@ -184,7 +184,7 @@ context('cy.origin traversal', () => { }) it('.eq()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').eq(1) }) @@ -214,7 +214,7 @@ context('cy.origin traversal', () => { }) it('.filter()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-name>input') .filter('[name="dogs"]') }) @@ -243,7 +243,7 @@ context('cy.origin traversal', () => { }) it('.find()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').find('input') }) @@ -274,7 +274,7 @@ context('cy.origin traversal', () => { }) it('.first()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').first() }) @@ -305,7 +305,7 @@ context('cy.origin traversal', () => { }) it('.last()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').last() }) @@ -336,7 +336,7 @@ context('cy.origin traversal', () => { }) it('.next()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').next() }) @@ -362,7 +362,7 @@ context('cy.origin traversal', () => { }) it('.nextAll()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').nextAll() }) @@ -391,7 +391,7 @@ context('cy.origin traversal', () => { }) it('.nextUntil()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').nextUntil('#age') }) @@ -417,7 +417,7 @@ context('cy.origin traversal', () => { }) it('.not()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id>input').not('#age') }) @@ -451,7 +451,7 @@ context('cy.origin traversal', () => { }) it('.parent()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').parent() }) @@ -477,7 +477,7 @@ context('cy.origin traversal', () => { }) it('.parents()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').parents() }) @@ -506,7 +506,7 @@ context('cy.origin traversal', () => { }) it('.parentsUntil()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#by-id').parentsUntil('body') }) @@ -532,7 +532,7 @@ context('cy.origin traversal', () => { }) it('.prev()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#age').prev() }) @@ -558,7 +558,7 @@ context('cy.origin traversal', () => { }) it('.prevAll()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#age').prevAll() }) @@ -587,7 +587,7 @@ context('cy.origin traversal', () => { }) it('.prevUntil()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#age').prevUntil('#input') }) @@ -613,7 +613,7 @@ context('cy.origin traversal', () => { }) it('.siblings()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#input').siblings() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/unsupported_commands.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/unsupported_commands.cy.ts index facd558ef6e0..c10d24347bf8 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/unsupported_commands.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/unsupported_commands.cy.ts @@ -11,7 +11,7 @@ context('cy.origin unsupported commands', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.route('api') }) }) @@ -23,7 +23,7 @@ context('cy.origin unsupported commands', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.server() }) }) @@ -35,7 +35,7 @@ context('cy.origin unsupported commands', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.origin('barbaz.com', () => {}) }) }) @@ -47,7 +47,7 @@ context('cy.origin unsupported commands', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.intercept('/foo') }) }) @@ -59,7 +59,7 @@ context('cy.origin unsupported commands', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.session('/foo') }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/viewport.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/viewport.cy.ts index 02bdf8cd553b..75ed312a0ee4 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/viewport.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/viewport.cy.ts @@ -8,7 +8,7 @@ context('cy.origin viewport', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const viewportChangedSpy = cy.spy() cy.on('viewport:changed', viewportChangedSpy) @@ -33,7 +33,7 @@ context('cy.origin viewport', () => { context('.viewport()', () => { it('changes the viewport', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((win) => { expect(win.innerHeight).to.equal(660) expect(win.innerWidth).to.equal(1000) @@ -47,7 +47,7 @@ context('cy.origin viewport', () => { }) it('resets the viewport between tests', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().then((win) => { expect(win.innerHeight).to.equal(660) expect(win.innerWidth).to.equal(1000) @@ -57,7 +57,7 @@ context('cy.origin viewport', () => { context('cy.on(\'viewport:changed\')', () => { it('calls viewport:changed handler in cy.origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const viewportChangedSpy = cy.spy() cy.on('viewport:changed', viewportChangedSpy) @@ -73,7 +73,7 @@ context('cy.origin viewport', () => { cy.on('viewport:changed', viewportChangedSpy) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.viewport(320, 480) }).then(() => { expect(viewportChangedSpy).not.to.be.called @@ -86,7 +86,7 @@ context('cy.origin viewport', () => { before(() => { viewportChangedSpyPrimary = cy.spy() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // using global since a function can't be passed to cy.origin // and we need to be able to remove the listener in the 'after' hook globalThis.viewportChangedSpySecondary = cy.spy() @@ -95,7 +95,7 @@ context('cy.origin viewport', () => { after(() => { Cypress.off('viewport:changed', viewportChangedSpyPrimary) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.off('viewport:changed', globalThis.viewportChangedSpySecondary) }) @@ -103,7 +103,7 @@ context('cy.origin viewport', () => { }) it('calls viewport:changed handler in cy.origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.on('viewport:changed', globalThis.viewportChangedSpySecondary) cy.viewport(320, 480).then(() => { @@ -115,7 +115,7 @@ context('cy.origin viewport', () => { it('does NOT call viewport:changed handler of primary', () => { Cypress.on('viewport:changed', viewportChangedSpyPrimary) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.viewport(320, 480) }).then(() => { expect(viewportChangedSpyPrimary).not.to.be.called @@ -128,7 +128,7 @@ context('cy.origin viewport', () => { cy.on('viewport:changed', viewportChangedSpy) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // change the viewport in the secondary first cy.viewport(320, 480) @@ -149,7 +149,7 @@ context('cy.origin viewport', () => { }) it('syncs the viewport across multiple origins', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.viewport(320, 480) cy.window().its('innerHeight').should('eq', 480) @@ -160,7 +160,7 @@ context('cy.origin viewport', () => { win.location.href = 'http://www.idp.com:3500/fixtures/primary-origin.html' }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { const viewportChangedSpy = cy.spy() cy.on('viewport:changed', viewportChangedSpy) @@ -190,7 +190,7 @@ context('cy.origin viewport', () => { }) it('.viewport()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.viewport(320, 480) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/waiting.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/waiting.cy.ts index f758ff1300e1..9e8c2572a11f 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/waiting.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/waiting.cy.ts @@ -24,7 +24,7 @@ const abortRequests = () => { context('cy.origin waiting', () => { before(() => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { let reqQueue: XMLHttpRequest[] = [] window.xhrGet = (url) => { @@ -45,7 +45,7 @@ context('cy.origin waiting', () => { let logs: Map beforeEach(() => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { window.abortRequests() }) @@ -62,7 +62,7 @@ context('cy.origin waiting', () => { context('number', () => { it('waits for the specified value', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const delay = cy.spy(Cypress.Promise, 'delay') cy.wait(50).then(() => { @@ -332,7 +332,7 @@ context('cy.origin waiting', () => { context('#consoleProps', () => { it('number', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wait(200) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/commands/window.cy.ts b/packages/driver/cypress/e2e/e2e/origin/commands/window.cy.ts index c878244d2e34..2f7a4d835c0d 100644 --- a/packages/driver/cypress/e2e/e2e/origin/commands/window.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/commands/window.cy.ts @@ -7,19 +7,19 @@ context('cy.origin window', () => { }) it('.window()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().should('have.property', 'top') }) }) it('.document()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().should('have.property', 'charset').and('eq', 'UTF-8') }) }) it('.title()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.title().should('include', 'DOM Fixture') }) }) @@ -36,7 +36,7 @@ context('cy.origin window', () => { }) it('.window()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window() }) @@ -49,7 +49,7 @@ context('cy.origin window', () => { }) it('.document()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document() }) @@ -62,7 +62,7 @@ context('cy.origin window', () => { }) it('.title()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.title() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/config_env.cy.ts b/packages/driver/cypress/e2e/e2e/origin/config_env.cy.ts index 61fb510b38ac..a6df37a4b7a2 100644 --- a/packages/driver/cypress/e2e/e2e/origin/config_env.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/config_env.cy.ts @@ -24,7 +24,7 @@ done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // @ts-ignore Cypress.config('chromeWebSecurity', false) }) @@ -34,7 +34,7 @@ context('serializable', () => { it(`syncs initial Cypress.${fnName}() from the primary origin to the secondary (synchronously)`, () => { Cypress[fnName](USED_KEYS.foo, 'bar') - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const bar = Cypress[fnName](USED_KEYS.foo) expect(bar).to.equal('bar') @@ -43,7 +43,7 @@ it(`syncs serializable values in the Cypress.${fnName}() again to the secondary even after spec bridge is created`, () => { Cypress[fnName](USED_KEYS.foo, 'baz') - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const baz = Cypress[fnName](USED_KEYS.foo) expect(baz).to.equal('baz') @@ -51,7 +51,7 @@ }) it(`syncs serializable Cypress.${fnName}() values outwards from secondary (synchronously)`, () => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { Cypress[fnName](USED_KEYS.bar, 'baz') }).then(() => { const baz = Cypress[fnName](USED_KEYS.bar) @@ -63,7 +63,7 @@ it(`syncs serializable Cypress.${fnName}() values outwards from secondary even if the value is undefined`, () => { Cypress[fnName](USED_KEYS.foo, 'bar') - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { Cypress[fnName](USED_KEYS.foo, undefined) }).then(() => { expect(Cypress[fnName]('foo')).to.be.undefined @@ -71,7 +71,7 @@ }) it(`syncs serializable Cypress.${fnName}() values outwards from secondary (commands/async)`, () => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { cy.then(() => { Cypress[fnName](USED_KEYS.bar, 'quux') }) @@ -83,7 +83,7 @@ }) it(`persists Cypress.${fnName}() changes made in the secondary, assuming primary has not overwritten with a serializable value`, () => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const quux = Cypress[fnName](USED_KEYS.bar) expect(quux).to.equal('quux') @@ -97,7 +97,7 @@ }, }, () => { return new Promise((resolve) => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { setTimeout(() => { // this value STILL gets set, but will be blown away on the next origin with whatever exists in the primary Cypress[fnName](USED_KEYS.baz, 'qux') @@ -119,7 +119,7 @@ [USED_KEYS.baz]: 'quux', }, }, () => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { // in previous test, 'baz' was set to 'qux' after the callback window was closed. // this should be overwritten by 'quux' that exists in the primary const quux = Cypress[fnName](USED_KEYS.baz) @@ -134,7 +134,7 @@ [USED_KEYS.baz]: undefined, }, }, () => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const isNowUndefined = Cypress[fnName](USED_KEYS.baz) expect(isNowUndefined).to.be.undefined @@ -147,7 +147,7 @@ it('does not sync unserializable values from the primary to the secondary', () => { Cypress[fnName](USED_KEYS.unserializable, unserializableFunc) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const isUndefined = Cypress[fnName](USED_KEYS.unserializable) expect(isUndefined).to.be.undefined @@ -156,7 +156,7 @@ it('does not overwrite unserializable values in the primary when none exist in the secondary', () => { Cypress[fnName](USED_KEYS.unserializable, unserializableFunc) - cy.origin('http://foobar.com:3500', () => undefined) + cy.origin('http://www.foobar.com:3500', () => undefined) const isFunc = Cypress[fnName](USED_KEYS.unserializable) @@ -165,7 +165,7 @@ it('overwrites unserializable values in the primary when serializable values of same key exist in secondary', () => { Cypress[fnName](USED_KEYS.unserializable, unserializableFunc) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { Cypress[fnName](USED_KEYS.unserializable, undefined) }).then(() => { const isNowUndefined = Cypress[fnName](USED_KEYS.unserializable) @@ -175,7 +175,7 @@ }) it('overwrites unserializable values in the secondary when serializable values of same key exist in primary', () => { - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const unserializableFuncSecondary = () => undefined Cypress[fnName](USED_KEYS.unserializable, unserializableFuncSecondary) @@ -183,7 +183,7 @@ Cypress[fnName](USED_KEYS.unserializable, undefined) }) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const isUndefined = Cypress[fnName](USED_KEYS.unserializable) expect(isUndefined).to.be.undefined @@ -196,7 +196,7 @@ it('does not overwrite unserializable values in the primary when unserializable values of same key exist in secondary', () => { Cypress[fnName](USED_KEYS.unserializable, unserializableFunc) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const unserializableFuncSecondary = () => undefined Cypress[fnName](USED_KEYS.unserializable, unserializableFuncSecondary) @@ -215,7 +215,7 @@ Cypress[fnName](USED_KEYS.unserializable, partiallyUnserializableObject) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const doesNotContainPartialAProperty = Cypress[fnName](USED_KEYS.unserializable) expect(doesNotContainPartialAProperty?.a).to.be.undefined @@ -238,7 +238,7 @@ }, function () { Cypress[fnName](USED_KEYS.error, new Error('error')) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const isUndefined = Cypress[fnName](USED_KEYS.error) expect(isUndefined).to.be.undefined @@ -251,7 +251,7 @@ }, () => { Cypress[fnName](USED_KEYS.error, new Error('error')) - cy.origin('http://foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { + cy.origin('http://www.foobar.com:3500', { args: { fnName, USED_KEYS } }, ({ fnName, USED_KEYS }) => { const isErrorObj = Cypress[fnName](USED_KEYS.error) // We preserve the error structure, but on preprocessing to the spec bridge, the error is converted to a flat object diff --git a/packages/driver/cypress/e2e/e2e/origin/cookie_behavior.cy.ts b/packages/driver/cypress/e2e/e2e/origin/cookie_behavior.cy.ts index d0e6c81554c7..370853db3575 100644 --- a/packages/driver/cypress/e2e/e2e/origin/cookie_behavior.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/cookie_behavior.cy.ts @@ -110,7 +110,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: originUrl, }, (originUrl) => { @@ -140,7 +140,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, () => { cy.window().then((win) => { return cy.wrap(makeRequest(win, '/set-cookie?cookie=foo1=bar1; Domain=foobar.com', 'fetch')) @@ -167,7 +167,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, () => { cy.window().then((win) => { return cy.wrap(makeRequest(win, '/set-cookie?cookie=foo1=bar1; Domain=foobar.com', 'fetch')) @@ -193,7 +193,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, () => { cy.window().then((win) => { // set the cookie in the browser @@ -221,7 +221,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, () => { cy.window().then((win) => { // do NOT set the cookie in the browser @@ -253,7 +253,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -286,7 +286,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -333,7 +333,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -382,7 +382,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -413,7 +413,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -455,7 +455,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -499,7 +499,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -534,7 +534,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -567,7 +567,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -599,7 +599,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { }) it('does set cookie if withCredentials is true, and sends cookie if withCredentials is true', () => { - cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, (req) => { + cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, (req) => { expect(req['headers']['cookie']).to.equal('bar1=baz1') req.reply({ @@ -610,7 +610,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -629,7 +629,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { // cy.getCookie('bar1').its('value').should('equal', 'baz1') cy.window().then((win) => { - return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, 'xmlHttpRequest', true)) + return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, 'xmlHttpRequest', true)) }) cy.wait('@cookieCheck') @@ -652,7 +652,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -686,7 +686,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -722,7 +722,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { // can only set third-party SameSite=None with Secure attribute, which is only possibly over https if (scheme === 'https') { it('does set cookie if credentials is "include", and sends cookie if credentials is "include"', () => { - cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, (req) => { + cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, (req) => { expect(req['headers']['cookie']).to.equal('bar1=baz1') req.reply({ @@ -733,7 +733,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -754,7 +754,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { // cy.getCookie('bar1').its('value').should('equal', 'baz1') cy.window().then((win) => { - return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, 'fetch', 'include')) + return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, 'fetch', 'include')) }) cy.wait('@cookieCheck') @@ -778,7 +778,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -818,7 +818,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -856,7 +856,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, () => { cy.window().then((win) => { return cy.wrap(makeRequest(win, '/set-cookie?cookie=foo=bar; Domain=www.foobar.com; Path=/', 'fetch')) @@ -888,7 +888,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { cy.visit('/fixtures/primary-origin.html') cy.get(`a[data-cy="cookie-${scheme}"]`).click() - // cookie jar should now mimic http://foobar.com:3500 / https://foobar.com:3502 as top + // cookie jar should now mimic http://www.foobar.com:3500 / https://foobar.com:3502 as top cy.origin(originUrl, { args: { scheme, @@ -1262,7 +1262,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { }) it('does set cookie if withCredentials is true, and sends cookie if withCredentials is true', () => { - cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, (req) => { + cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, (req) => { expect(req['headers']['cookie']).to.equal('bar1=baz1') req.reply({ @@ -1283,7 +1283,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { // cy.getCookie('bar1').its('value').should('equal', 'baz1') cy.window().then((win) => { - return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, 'xmlHttpRequest', true)) + return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, 'xmlHttpRequest', true)) }) cy.wait('@cookieCheck') @@ -1353,7 +1353,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { // can only set third-party SameSite=None with Secure attribute, which is only possibly over https if (scheme === 'https') { it('does set cookie if credentials is "include", and sends cookie if credentials is "include"', () => { - cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, (req) => { + cy.intercept(`${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, (req) => { expect(req['headers']['cookie']).to.equal('bar1=baz1') req.reply({ @@ -1376,7 +1376,7 @@ describe('Cookie Behavior with experimentalSessionAndOrigin=true', () => { // cy.getCookie('bar1').its('value').should('equal', 'baz1') cy.window().then((win) => { - return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-credentials`, 'fetch', 'include')) + return cy.wrap(makeRequest(win, `${scheme}://www.barbaz.com:${sameOriginPort}/test-request-credentials`, 'fetch', 'include')) }) cy.wait('@cookieCheck') diff --git a/packages/driver/cypress/e2e/e2e/origin/cookie_login.cy.ts b/packages/driver/cypress/e2e/e2e/origin/cookie_login.cy.ts index 6903cdfc0aa0..b56425d24dd8 100644 --- a/packages/driver/cypress/e2e/e2e/origin/cookie_login.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/cookie_login.cy.ts @@ -12,14 +12,15 @@ describe('cy.origin - cookie login', () => { } const verifyIdpNotLoggedIn = (config = {}) => { - const { isHttps, cookieKey, expectNullCookie } = _.defaults(config, { + const { isHttps, cookieKey, expectNullCookie, subdomain } = _.defaults(config, { isHttps: false, cookieKey: 'user', expectNullCookie: true, + subdomain: 'www', }) const [protocol, port] = isHttps ? ['https', '3502'] : ['http', '3501'] - cy.origin(`${protocol}://idp.com:${port}`, { args: { cookieKey, expectNullCookie } }, ({ cookieKey, expectNullCookie }) => { + cy.origin(`${protocol}://${subdomain}.idp.com:${port}`, { args: { cookieKey, expectNullCookie } }, ({ cookieKey, expectNullCookie }) => { cy.get('h1') .invoke('text') .should('equal', 'Not logged in') @@ -81,7 +82,7 @@ describe('cy.origin - cookie login', () => { cy.session(username, () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -104,7 +105,7 @@ describe('cy.origin - cookie login', () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login-alias"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -115,7 +116,7 @@ describe('cy.origin - cookie login', () => { it('handles browser-sent cookies being overridden by server-kept cookies', () => { cy.visit('https://localhost:3502/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login-override"]').click() - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -126,7 +127,7 @@ describe('cy.origin - cookie login', () => { it('cy.clearCookie() -> not logged in', () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -139,7 +140,7 @@ describe('cy.origin - cookie login', () => { it('cy.clearCookies() -> not logged in', () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -161,7 +162,7 @@ describe('cy.origin - cookie login', () => { }) it('no SameSite (defaults to Lax) -> logged in', () => { - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -170,7 +171,7 @@ describe('cy.origin - cookie login', () => { }) it('SameSite=Lax -> logged in', () => { - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('SameSite=Lax') cy.get('[data-cy="login"]').click() @@ -180,7 +181,7 @@ describe('cy.origin - cookie login', () => { }) it('SameSite=Strict -> not logged in', () => { - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('SameSite=Strict') cy.get('[data-cy="login"]').click() @@ -193,7 +194,7 @@ describe('cy.origin - cookie login', () => { // FIXME: Currently in Firefox, the default cookie setting in the extension is no_restriction, which can be set with Secure=false. it('SameSite=None -> not logged in', { browser: '!firefox' }, () => { - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('SameSite=None') cy.get('[data-cy="login"]').click() @@ -204,7 +205,7 @@ describe('cy.origin - cookie login', () => { }) it('invalid SameSite (defaults to Lax) -> logged in', () => { - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('SameSite=Invalid') cy.get('[data-cy="login"]').click() @@ -225,7 +226,7 @@ describe('cy.origin - cookie login', () => { cy.visit('https://localhost:3502/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login-https"]').click() - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Secure') cy.get('[data-cy="login"]').click() @@ -238,7 +239,7 @@ describe('cy.origin - cookie login', () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Secure') cy.get('[data-cy="login"]').click() @@ -253,7 +254,7 @@ describe('cy.origin - cookie login', () => { cy.visit('https://localhost:3502/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login-https"]').click() - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -265,7 +266,7 @@ describe('cy.origin - cookie login', () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -286,7 +287,7 @@ describe('cy.origin - cookie login', () => { it('no Domain + superdomain -> logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -297,7 +298,7 @@ describe('cy.origin - cookie login', () => { it('no Domain + subdomain -> logged in', () => { cy.get('[data-cy="cookie-login-subdomain"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) @@ -308,7 +309,7 @@ describe('cy.origin - cookie login', () => { it('Domain + superdomain -> logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Domain=idp.com') cy.get('[data-cy="localhostCookieProps"]').type('Domain=localhost') @@ -321,7 +322,7 @@ describe('cy.origin - cookie login', () => { it('Domain + subdomain -> logged in', () => { cy.get('[data-cy="cookie-login-subdomain"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Domain=idp.com') cy.get('[data-cy="localhostCookieProps"]').type('Domain=localhost') @@ -334,7 +335,7 @@ describe('cy.origin - cookie login', () => { it('subdomain Domain + superdomain -> not logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Domain=baz.idp.com') cy.get('[data-cy="localhostCookieProps"]').type('Domain=localhost') @@ -348,7 +349,7 @@ describe('cy.origin - cookie login', () => { it('subdomain Domain + subdomain -> logged in', () => { cy.get('[data-cy="cookie-login-subdomain"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Domain=baz.idp.com') cy.get('[data-cy="localhostCookieProps"]').type('Domain=localhost') @@ -361,14 +362,16 @@ describe('cy.origin - cookie login', () => { it('subdomain Domain + different subdomain -> not logged in', () => { cy.get('[data-cy="cookie-login-subdomain"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Domain=qux.foobar.com') cy.get('[data-cy="login"]').click() }) // Domain=subdomain requires request to be on that subdomain - verifyIdpNotLoggedIn() + verifyIdpNotLoggedIn({ + 'subdomain': 'baz', + }) }) }) @@ -384,7 +387,7 @@ describe('cy.origin - cookie login', () => { it('path matches -> logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Path=/verify-cookie-login') cy.get('[data-cy="localhostCookieProps"]').type('Path=/welcome') @@ -397,7 +400,7 @@ describe('cy.origin - cookie login', () => { it('path does not match -> not logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieProps"]').type('Path=/nope') cy.get('[data-cy="login"]').click() @@ -420,7 +423,7 @@ describe('cy.origin - cookie login', () => { it('expired -> not logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { const expires = (new Date()).toUTCString() cy.get('[data-cy="username"]').type(username) @@ -433,7 +436,7 @@ describe('cy.origin - cookie login', () => { it('expired -> not accessible via cy.getCookie()', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { const expires = (new Date()).toUTCString() cy.get('[data-cy="username"]').type(username) @@ -446,7 +449,7 @@ describe('cy.origin - cookie login', () => { it('expired -> not accessible via document.cookie', () => { cy.get('[data-cy="cookie-login-land-on-idp"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { const expires = (new Date()).toUTCString() cy.get('[data-cy="username"]').type(username) @@ -454,7 +457,7 @@ describe('cy.origin - cookie login', () => { cy.get('[data-cy="login"]').click() }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.clearCookie('user') cy.document().its('cookie').should('not.include', 'user=') }) @@ -472,7 +475,7 @@ describe('cy.origin - cookie login', () => { it('past max-age -> not logged in', () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="localhostCookieProps"]').type('Max-Age=1') cy.get('[data-cy="login"]').click() @@ -488,7 +491,7 @@ describe('cy.origin - cookie login', () => { // as it happens even using cy.setCookie() it('past max-age -> not accessible via cy.getCookie()', { browser: '!firefox' }, () => { cy.get('[data-cy="cookie-login"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="localhostCookieProps"]').type('Max-Age=1') cy.get('[data-cy="login"]').click() @@ -501,13 +504,13 @@ describe('cy.origin - cookie login', () => { it('past max-age -> not accessible via document.cookie', () => { cy.get('[data-cy="cookie-login-land-on-idp"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="localhostCookieProps"]').type('Max-Age=1') cy.get('[data-cy="login"]').click() }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.wait(1500) // give cookie time to expire cy.reload() cy.document().its('cookie').should('not.include', 'user=') @@ -522,7 +525,7 @@ describe('cy.origin - cookie login', () => { it('past Max-Age, before Expires -> not logged in', () => { const expires = dayjs().add(1, 'day').toDate().toUTCString() - cy.origin('http://foobar.com:3500', { args: { username, expires } }, ({ username, expires }) => { + cy.origin('http://www.foobar.com:3500', { args: { username, expires } }, ({ username, expires }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="localhostCookieProps"]').type(`Max-Age=1; Expires=${expires}`) cy.get('[data-cy="login"]').click() @@ -534,7 +537,7 @@ describe('cy.origin - cookie login', () => { }) it('before Max-Age, past Expires -> logged in', () => { - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { const expires = (new Date()).toUTCString() cy.get('[data-cy="username"]').type(username) @@ -560,7 +563,7 @@ describe('cy.origin - cookie login', () => { }) it('__Host- + Secure + Path=/ -> logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Host-user') cy.get('[data-cy="cookieProps"]').type('Secure; Path=/') @@ -571,7 +574,7 @@ describe('cy.origin - cookie login', () => { }) it('__Host-, no Secure -> not logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Host-user') cy.get('[data-cy="cookieProps"]').type('Path=/') @@ -583,7 +586,7 @@ describe('cy.origin - cookie login', () => { }) it('__Host-, no Path -> logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Host-user') cy.get('[data-cy="cookieProps"]').type('Secure') @@ -594,7 +597,7 @@ describe('cy.origin - cookie login', () => { }) it('__Host-, disallowed Path -> not logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Host-user') cy.get('[data-cy="cookieProps"]').type('Secure; Path=/nope') @@ -606,7 +609,7 @@ describe('cy.origin - cookie login', () => { }) it('__Host- + Domain -> not logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Host-user') cy.get('[data-cy="cookieProps"]').type('Secure; Path=/; Domain=foobar.com') @@ -629,7 +632,7 @@ describe('cy.origin - cookie login', () => { }) it('__Secure- + Secure flag -> logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Secure-user') cy.get('[data-cy="cookieProps"]').type('Secure') @@ -640,7 +643,7 @@ describe('cy.origin - cookie login', () => { }) it('__Secure, no Secure flag -> not logged in', () => { - cy.origin('https://foobar.com:3502', { args: { username } }, ({ username }) => { + cy.origin('https://www.foobar.com:3502', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="cookieKey"]').clear().type('__Secure-user') cy.get('[data-cy="login"]').click() @@ -662,19 +665,19 @@ describe('cy.origin - cookie login', () => { it('gets cookie set by http request', () => { cy.get('[data-cy="cookie-login-land-on-idp"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) - cy.origin('http://idp.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.idp.com:3500', { args: { username } }, ({ username }) => { cy.document().its('cookie').should('include', `user=${username}`) }) }) it('works when setting cookie', () => { cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().then((doc) => { doc.cookie = 'key=value' }) @@ -685,7 +688,7 @@ describe('cy.origin - cookie login', () => { it('works when setting cookie with extra, benign parts', () => { cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().then((doc) => { doc.cookie = 'key=value; wont=beset' }) @@ -696,7 +699,7 @@ describe('cy.origin - cookie login', () => { it('cookie properties are preserved when set via automation', () => { cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().then((doc) => { doc.cookie = 'key=value; SameSite=Strict; Path=/foo' }) @@ -719,7 +722,7 @@ describe('cy.origin - cookie login', () => { it('does not set cookie when invalid', () => { cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().then((doc) => { doc.cookie = '=value' }) @@ -730,7 +733,7 @@ describe('cy.origin - cookie login', () => { it('works when setting subsequent cookies', () => { cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().then((doc) => { doc.cookie = 'key1=value1' }) @@ -746,7 +749,7 @@ describe('cy.origin - cookie login', () => { it('makes cookie available to cy.getCookie()', () => { cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.document().then((doc) => { doc.cookie = 'key=value' }) @@ -757,12 +760,12 @@ describe('cy.origin - cookie login', () => { it('no longer returns cookie after cy.clearCookie()', () => { cy.get('[data-cy="cookie-login-land-on-idp"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.clearCookie('user') cy.document().its('cookie').should('equal', '') }) @@ -770,12 +773,12 @@ describe('cy.origin - cookie login', () => { it('no longer returns cookie after cy.clearCookies()', () => { cy.get('[data-cy="cookie-login-land-on-idp"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.clearCookies() cy.document().its('cookie').should('equal', '') }) @@ -783,12 +786,12 @@ describe('cy.origin - cookie login', () => { it('works when setting cookie in addition to cookie that already exists from http request', () => { cy.get('[data-cy="cookie-login-land-on-idp"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.get('[data-cy="username"]').type(username) cy.get('[data-cy="login"]').click() }) - cy.origin('http://idp.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.idp.com:3500', { args: { username } }, ({ username }) => { cy.document().then((doc) => { doc.cookie = 'key=value' }) @@ -801,13 +804,13 @@ describe('cy.origin - cookie login', () => { }) it('sets and reads document.cookie prior to attaching', () => { - cy.origin('http://foobar.com:3500', () => {}).then(() => { + cy.origin('http://www.foobar.com:3500', () => {}).then(() => { // Force remove the spec bridge - window?.top?.document.getElementById('Spec Bridge: http://foobar.com:3500')?.remove() + window?.top?.document.getElementById('Spec Bridge: http://www.foobar.com:3500')?.remove() }) cy.get('[data-cy="document-cookie"]').click() - cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => { + cy.origin('http://www.foobar.com:3500', { args: { username } }, ({ username }) => { cy.document().its('cookie').should('include', 'name=value') cy.get('[data-cy="doc-cookie"]').invoke('text').should('equal', 'name=value') cy.getCookie('name').then((cookie) => { diff --git a/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts b/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts index 361828c7cb50..2885165f439f 100644 --- a/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/cypress_api.cy.ts @@ -8,7 +8,7 @@ describe('cy.origin Cypress API', () => { context('Commands', () => { it('adds a custom command', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // @ts-ignore Cypress.Commands.add('foo', () => 'bar') @@ -17,14 +17,14 @@ describe('cy.origin Cypress API', () => { }) // persists added command through spec bridge - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // @ts-ignore cy.foo().should('equal', 'bar') }) }) it('overwrites an existing command in the spec bridge', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // @ts-ignore Cypress.Commands.overwrite('foo', () => 'baz') @@ -33,7 +33,7 @@ describe('cy.origin Cypress API', () => { }) // persists overwritten command through spec bridge - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // @ts-ignore cy.foo().should('equal', 'baz') }) @@ -46,7 +46,7 @@ describe('cy.origin Cypress API', () => { keystrokeDelay: 30, }) - cy.origin('http://foobar.com:3500', { args: defaults }, (primaryKeyboardDefaults) => { + cy.origin('http://www.foobar.com:3500', { args: defaults }, (primaryKeyboardDefaults) => { const crossOriginKeyboardDefaults = Cypress.Keyboard.defaults({}) expect(crossOriginKeyboardDefaults).to.not.deep.equal(primaryKeyboardDefaults) @@ -54,7 +54,7 @@ describe('cy.origin Cypress API', () => { }) it('allows a user to configure defaults', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const crossOriginKeyboardDefaults = Cypress.Keyboard.defaults({ keystrokeDelay: 60, }) @@ -65,7 +65,7 @@ describe('cy.origin Cypress API', () => { }) // persists default configuration changes through spec bridge - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const crossOriginKeyboardDefaults = Cypress.Keyboard.defaults({}) expect(crossOriginKeyboardDefaults).to.deep.include({ @@ -84,7 +84,7 @@ describe('cy.origin Cypress API', () => { onAfterScreenshot: () => undefined, }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const crossOriginScreenshotDefaults = Cypress.Screenshot.defaults({}) expect(crossOriginScreenshotDefaults).to.not.deep.include({ @@ -97,7 +97,7 @@ describe('cy.origin Cypress API', () => { }) it('allows a user to configure defaults', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const crossOriginScreenshotDefaults = Cypress.Screenshot.defaults({ blackout: ['foo'], overwrite: true, @@ -110,7 +110,7 @@ describe('cy.origin Cypress API', () => { }) // persists default configuration changes through spec bridge - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const crossOriginScreenshotDefaults = Cypress.Screenshot.defaults({}) expect(crossOriginScreenshotDefaults).to.deep.include({ @@ -123,7 +123,7 @@ describe('cy.origin Cypress API', () => { context('dom', () => { it('provides a sanity check that the dom API exists on Cypress.*', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]').then(($el) => { expect(Cypress.dom.isAttached($el)).to.be.true }) @@ -133,37 +133,37 @@ describe('cy.origin Cypress API', () => { context('properties', () => { it('has arch property synced from primary', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.arch }, (theArch) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.arch }, (theArch) => { expect(Cypress.arch).to.equal(theArch) }) }) it('has browser property synced from primary', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.browser }, (theBrowser) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.browser }, (theBrowser) => { expect(Cypress.browser).to.deep.equal(theBrowser) }) }) it('has currentTest property synced from primary', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.currentTest }, (theCurrentTest) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.currentTest }, (theCurrentTest) => { expect(Cypress.currentTest).to.deep.equal(theCurrentTest) }) }) it('has platform property synced from primary', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.platform }, (thePlatform) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.platform }, (thePlatform) => { expect(Cypress.platform).to.equal(thePlatform) }) }) it('has testingType property synced from primary', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.testingType }, (theTestingType) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.testingType }, (theTestingType) => { expect(Cypress.testingType).to.deep.equal(theTestingType) }) }) it('has spec property synced from primary', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.spec }, (theSpec) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.spec }, (theSpec) => { expect(Cypress.spec).to.deep.equal(theSpec) }) }) @@ -171,13 +171,13 @@ describe('cy.origin Cypress API', () => { context('methods', () => { it('isCy()', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { expect(Cypress.isCy(cy)).to.be.true }) }) it('isBrowser()', () => { - cy.origin('http://foobar.com:3500', { args: Cypress.browser }, (theBrowser) => { + cy.origin('http://www.foobar.com:3500', { args: Cypress.browser }, (theBrowser) => { expect(Cypress.isBrowser(theBrowser.name)).to.equal(true) }) }) @@ -189,7 +189,7 @@ describe('cy.origin Cypress API', () => { logs.push(log) }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.log({ name: 'log', message: 'test log', @@ -211,7 +211,7 @@ describe('cy.origin Cypress API', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.Server.defaults({}) }) }) @@ -223,7 +223,7 @@ describe('cy.origin Cypress API', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.Cookies.preserveOnce('') }) }) @@ -235,7 +235,7 @@ describe('cy.origin Cypress API', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.session.clearAllSavedSessions() }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.jsx b/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.jsx index c542249196bf..309e4fb43ad9 100644 --- a/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.jsx +++ b/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.jsx @@ -5,7 +5,7 @@ describe('cy.origin dependencies - jsx', () => { }) it('works with a jsx file', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const lodash = Cypress.require('lodash') expect(lodash.get({ foo: 'foo' }, 'foo')).to.equal('foo') diff --git a/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.ts b/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.ts index 687a38e992ce..860af3a5f930 100644 --- a/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/dependencies.cy.ts @@ -5,7 +5,7 @@ describe('cy.origin dependencies', () => { }) it('works with an arrow function', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const lodash = Cypress.require('lodash') const dayjs = Cypress.require('dayjs') @@ -17,7 +17,7 @@ describe('cy.origin dependencies', () => { }) it('works with a function expression', () => { - cy.origin('http://foobar.com:3500', function () { + cy.origin('http://www.foobar.com:3500', function () { const lodash = Cypress.require('lodash') expect(lodash.get({ foo: 'foo' }, 'foo')).to.equal('foo') @@ -25,7 +25,7 @@ describe('cy.origin dependencies', () => { }) it('works with options object + args', () => { - cy.origin('http://foobar.com:3500', { args: ['arg1'] }, ([arg1]) => { + cy.origin('http://www.foobar.com:3500', { args: ['arg1'] }, ([arg1]) => { const lodash = Cypress.require('lodash') expect(lodash.get({ foo: 'foo' }, 'foo')).to.equal('foo') @@ -34,7 +34,7 @@ describe('cy.origin dependencies', () => { }) it('works with a yielded value', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const lodash = Cypress.require('lodash') expect(lodash.get({ foo: 'foo' }, 'foo')).to.equal('foo') @@ -45,7 +45,7 @@ describe('cy.origin dependencies', () => { }) it('works with a returned value', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const lodash = Cypress.require('lodash') expect(lodash.get({ foo: 'foo' }, 'foo')).to.equal('foo') @@ -56,7 +56,7 @@ describe('cy.origin dependencies', () => { }) it('works with multiple cy.origin calls', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const lodash = Cypress.require('lodash') expect(lodash.get({ foo: 'foo' }, 'foo')).to.equal('foo') @@ -64,7 +64,7 @@ describe('cy.origin dependencies', () => { cy.get('[data-cy="cross-origin-tertiary-link"]').click() }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { const dayjs = Cypress.require('dayjs') expect(dayjs('2022-07-29 12:00:00').format('MMMM D, YYYY')).to.equal('July 29, 2022') @@ -72,7 +72,7 @@ describe('cy.origin dependencies', () => { }) it('works with a relative esm dependency', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const { add } = Cypress.require('./dependencies.support-esm') expect(add(1, 2)).to.equal(3) @@ -80,7 +80,7 @@ describe('cy.origin dependencies', () => { }) it('works with a relative commonjs dependency', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const { add } = Cypress.require('./dependencies.support-commonjs') expect(add(1, 2)).to.equal(3) @@ -90,7 +90,7 @@ describe('cy.origin dependencies', () => { it('works with args passed to require result', () => { const args = ['some string'] - cy.origin('http://foobar.com:3500', { args }, ([arg1]) => { + cy.origin('http://www.foobar.com:3500', { args }, ([arg1]) => { const result = Cypress.require('./dependencies.support-commonjs')(arg1) expect(result).to.equal('some_string') @@ -98,13 +98,13 @@ describe('cy.origin dependencies', () => { }) it('works in support file', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { expect(cy.getAll).to.be.undefined }) - cy.originLoadUtils('http://foobar.com:3500') + cy.originLoadUtils('http://www.foobar.com:3500') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { expect(cy.getAll).to.be.a('function') }) }) @@ -115,7 +115,7 @@ describe('cy.origin dependencies', () => { expect(err.message).to.include('Cannot find module') }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Cypress.require('./does-not-exist') }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/events.cy.ts b/packages/driver/cypress/e2e/e2e/origin/events.cy.ts index d8e44d89275e..4889eb7ea7ea 100644 --- a/packages/driver/cypress/e2e/e2e/origin/events.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/events.cy.ts @@ -8,14 +8,14 @@ describe('cy.origin', () => { cy.window().its('testPrimaryOriginBeforeLoad').should('be.true') // Needs to be declared before the visit - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.on('window:before:load', (win: {testSecondaryWindowBeforeLoad: boolean}) => { win.testSecondaryWindowBeforeLoad = true }) }) cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.window().its('testSecondaryWindowBeforeLoad').should('be.true') cy.window().its('testPrimaryOriginBeforeLoad').should('be.undefined') cy @@ -37,7 +37,7 @@ describe('cy.origin', () => { }) it('form:submitted', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterFormSubmitted = new Promise((resolve) => { Cypress.once('form:submitted', (e) => { const $form = cy.$$('form') @@ -56,7 +56,7 @@ describe('cy.origin', () => { cy.origin('http://www.foobar.com:3500', () => { const afterWindowBeforeUnload = new Promise((resolve) => { Cypress.once('window:before:unload', () => { - expect(location.host).to.equal('foobar.com:3500') + expect(location.host).to.equal('www.foobar.com:3500') resolve() }) }) @@ -71,7 +71,7 @@ describe('cy.origin', () => { cy.origin('http://www.foobar.com:3500', () => { const afterWindowUnload = new Promise((resolve) => { Cypress.once('window:unload', () => { - expect(location.host).to.equal('foobar.com:3500') + expect(location.host).to.equal('www.foobar.com:3500') resolve() }) }) @@ -83,10 +83,10 @@ describe('cy.origin', () => { }) it('window:alert', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterWindowAlert = new Promise((resolve) => { Cypress.once('window:alert', (text) => { - expect(location.host).to.equal('foobar.com:3500') + expect(location.host).to.equal('www.foobar.com:3500') expect(`window:alert ${text}`).to.equal('window:alert the alert text') resolve() }) @@ -98,10 +98,10 @@ describe('cy.origin', () => { }) it('window:confirm', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterWindowConfirm = new Promise((resolve) => { Cypress.once('window:confirm', (text) => { - expect(location.host).to.equal('foobar.com:3500') + expect(location.host).to.equal('www.foobar.com:3500') expect(`window:confirm ${text}`).to.equal('window:confirm the confirm text') resolve() }) @@ -113,10 +113,10 @@ describe('cy.origin', () => { }) it('window:confirmed - true when no window:confirm listeners return false', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterWindowConfirmed = new Promise((resolve) => { Cypress.once('window:confirmed', (text, returnedFalse) => { - expect(location.host).to.equal('foobar.com:3500') + expect(location.host).to.equal('www.foobar.com:3500') expect(`window:confirmed ${text} - ${returnedFalse}`).to.equal('window:confirmed the confirm text - true') resolve() }) @@ -133,10 +133,10 @@ describe('cy.origin', () => { }) it('window:confirmed - false when any window:confirm listeners return false', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterWindowConfirmed = new Promise((resolve) => { Cypress.once('window:confirmed', (text, returnedFalse) => { - expect(location.host).to.equal('foobar.com:3500') + expect(location.host).to.equal('www.foobar.com:3500') expect(`window:confirmed ${text} - ${returnedFalse}`).to.equal('window:confirmed the confirm text - false') resolve() }) diff --git a/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts b/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts index 69fe86d8e31b..bb1f048eefe5 100644 --- a/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/integrity.cy.ts @@ -62,7 +62,7 @@ describe('Integrity Preservation', () => { cy.visit('fixtures/primary-origin.html') cy.get('[data-cy="integrity-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // The added script, if integrity matches, should execute and // add a

element with 'integrity script loaded' as the text cy.get('#integrity', { @@ -85,7 +85,7 @@ describe('Integrity Preservation', () => { cy.visit('fixtures/primary-origin.html') cy.get('[data-cy="integrity-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // The added script, if integrity matches, should execute and // add a

element with 'integrity script loaded' as the text cy.get('#integrity', { @@ -112,7 +112,7 @@ describe('Integrity Preservation', () => { cy.visit('fixtures/primary-origin.html') cy.get('[data-cy="integrity-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="integrity-header"]', { timeout: 1000, }).then((integrityHeader) => { @@ -137,7 +137,7 @@ describe('Integrity Preservation', () => { cy.visit('fixtures/primary-origin.html') cy.get('[data-cy="integrity-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="integrity-header"]', { timeout: 1000, }).then((integrityHeader) => { diff --git a/packages/driver/cypress/e2e/e2e/origin/logging.cy.ts b/packages/driver/cypress/e2e/e2e/origin/logging.cy.ts index 0f7ece507a0f..7e0214dd563f 100644 --- a/packages/driver/cypress/e2e/e2e/origin/logging.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/logging.cy.ts @@ -11,7 +11,7 @@ describe('cy.origin logging', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]').invoke('text') }) @@ -70,7 +70,7 @@ describe('cy.origin logging', () => { const options = { args: { div: Cypress.$('div') } } - cy.origin('http://foobar.com:3500', options, () => {}) + cy.origin('http://www.foobar.com:3500', options, () => {}) }) it('groups callback commands when failing with inner command failure', (done) => { @@ -99,7 +99,7 @@ describe('cy.origin logging', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]').invoke('text') cy.get('#does-not-exist', { timeout: 1 }) }) @@ -131,7 +131,7 @@ describe('cy.origin logging', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]').invoke('text').then(() => { setTimeout(() => { throw new Error('async error') diff --git a/packages/driver/cypress/e2e/e2e/origin/navigation.cy.ts b/packages/driver/cypress/e2e/e2e/origin/navigation.cy.ts index 3a0ecb5fb231..8d12f03066e3 100644 --- a/packages/driver/cypress/e2e/e2e/origin/navigation.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/navigation.cy.ts @@ -27,7 +27,7 @@ describe('navigation events', () => { describe('navigation:changed', () => { it('navigation:changed via hashChange', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterNavigationChanged = new Promise((resolve) => { const listener = () => { const loc = cy.getRemoteLocation() @@ -48,7 +48,7 @@ describe('navigation events', () => { }) it('navigates forward and back using history', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const onLoad = (cb) => { const onNavChanged = (event) => { if (event === 'page navigation event (load)') { @@ -80,7 +80,7 @@ describe('navigation events', () => { describe('window:load', () => { it('reloads', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const logs: any[] = [] cy.on('log:added', (attrs, log) => { @@ -111,7 +111,7 @@ describe('navigation events', () => { }) it('navigates to a new page', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const logs: any[] = [] cy.on('log:added', (attrs, log) => { @@ -144,7 +144,7 @@ describe('navigation events', () => { describe('url:changed', () => { it('reloads', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterUrlChanged = new Promise((resolve) => { cy.once('url:changed', (url) => { expect(url).to.equal('http://www.foobar.com:3500/fixtures/secondary-origin.html') @@ -158,7 +158,7 @@ describe('navigation events', () => { }) it('navigates to a new page', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const afterUrlChanged = new Promise((resolve) => { const listener = (url) => { cy.removeListener('url:changed', listener) @@ -177,7 +177,7 @@ describe('navigation events', () => { // TODO: this test should re revisited with the cypress in cypress tests available in 10.0 // https://github.com/cypress-io/cypress/issues/20973 it.skip('the runner url updates appropriately', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('a[data-cy="cross-origin-page"]').click() }) }) @@ -190,7 +190,7 @@ describe('event timing', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.log('inside cy.origin foobar') }) @@ -199,7 +199,7 @@ describe('event timing', () => { win.location.href = 'http://www.idp.com:3500/fixtures/primary-origin.html' }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.log('inside cy.origin idp') }) }) @@ -216,14 +216,14 @@ describe('delayed navigation', { defaultCommandTimeout: 2000 }, () => { it('localhost -> foobar, delay in', () => { cy.visit('/fixtures/auth/delayedNavigate.html') cy.get('[data-cy="to-foobar"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="login-idp"]') }) }) it('foobar -> localhost, delay out', () => { cy.visit('/fixtures/auth/index.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/auth/delayedNavigate.html') cy.get('[data-cy="to-localhost"]').click() }) @@ -233,12 +233,12 @@ describe('delayed navigation', { defaultCommandTimeout: 2000 }, () => { it('foobar -> idp, delay out', () => { cy.visit('/fixtures/auth/index.html') - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/auth/delayedNavigate.html') cy.get('[data-cy="to-idp"]').click() }) - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="login-idp"]') }) }) @@ -249,7 +249,7 @@ describe('errors', () => { it('never calls cy.origin', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -265,7 +265,7 @@ describe('errors', () => { it('never redirects to the cross-origin', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://idp.com:3500\` but the application is at origin \`http://localhost:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://www.idp.com:3500\` but the application is at origin \`http://localhost:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -275,7 +275,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]') - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') // Timeout here on command, cannot find element cy.get('[data-cy="login"]').click() }) @@ -288,7 +288,7 @@ describe('errors', () => { it('redirects to the wrong cross-origin', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://idp.com:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://www.idp.com:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) expect(err.message).to.include(`This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.`) // 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`) @@ -298,7 +298,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-foobar"]').click() // Timeout on page load here, we never reach the expected origin - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.get('[data-cy="login"]').click() }) @@ -312,7 +312,7 @@ describe('errors', () => { it('never returns to the primary origin', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://idp.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.idp.com:3500\`.`) // 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`) @@ -321,7 +321,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]').click() - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') }) // cy.origin is stable so the command exits @@ -334,7 +334,7 @@ describe('errors', () => { it('redirects to an unexpected cross-origin', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) // 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`) @@ -343,7 +343,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]').click() - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.window().then((win) => { win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html' @@ -359,7 +359,7 @@ describe('errors', () => { it('redirects to an unexpected cross-origin and calls another command in the cy.origin command', { pageLoadTimeout: 5000, defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://idp.com:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://www.idp.com:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) // 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`) @@ -368,7 +368,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]').click() - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.window().then((win) => { win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html' @@ -387,7 +387,7 @@ describe('errors', () => { it.skip('fails in cy.origin when a command is run after we return to localhost', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://idp.com:3500\` but the application is at origin \`http://localhost:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://www.idp.com:3500\` but the application is at origin \`http://localhost:3500\`.`) // 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`) @@ -396,7 +396,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') // Establishes primary origin cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.get('[data-cy="login"]').click() cy.get('[data-cy="cannot_find"]') // Timeout here on command stability achieved by primary origin, this command times out. @@ -420,7 +420,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') // Establishes primary origin cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="cannot_find"]') // Timeout here on command stability achieved by primary origin, this command times out. }) }) @@ -431,7 +431,7 @@ describe('errors', () => { it('times out in cy.origin with foobar spec bridge undefined', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) // 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`) @@ -439,13 +439,13 @@ describe('errors', () => { }) cy.visit('/fixtures/auth/index.html') // Establishes primary origin - cy.origin('http://foobar.com:3500', () => {}).then(() => { + cy.origin('http://www.foobar.com:3500', () => {}).then(() => { // Force remove the spec bridge - window?.top?.document.getElementById('Spec Bridge: http://foobar.com:3500')?.remove() + window?.top?.document.getElementById('Spec Bridge: http://www.foobar.com:3500')?.remove() }) cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.window().then((win) => { win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html' @@ -462,7 +462,7 @@ describe('errors', () => { it('establishes foobar spec bridge', () => { cy.visit('/fixtures/auth/index.html') // Establishes primary origin cy.get('[data-cy="login-foobar"]').click() // Takes you to idp.com - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.get('[data-cy="login"]').click() }) @@ -478,7 +478,7 @@ describe('errors', () => { it('times out in cy.origin with foobar spec bridge defined', { defaultCommandTimeout: 50 }, (done) => { cy.on('fail', (err) => { expect(err.message).to.include(`Timed out retrying after 50ms:`) - expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://foobar.com:3500\`.`) + expect(err.message).to.include(`The command was expected to run against origin \`http://localhost:3500\` but the application is at origin \`http://www.foobar.com:3500\`.`) // 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`) @@ -487,7 +487,7 @@ describe('errors', () => { cy.visit('/fixtures/auth/index.html') // Establishes primary origin cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.window().then((win) => { win.location.href = 'http://www.foobar.com:3500/fixtures/auth/index.html' diff --git a/packages/driver/cypress/e2e/e2e/origin/origin.cy.ts b/packages/driver/cypress/e2e/e2e/origin/origin.cy.ts index d9e79698ae3a..aa696056f255 100644 --- a/packages/driver/cypress/e2e/e2e/origin/origin.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/origin.cy.ts @@ -11,7 +11,7 @@ describe('cy.origin', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', { args: expectedViewport }, (expectedViewport) => { + cy.origin('http://www.foobar.com:3500', { args: expectedViewport }, (expectedViewport) => { const secondaryViewport = [cy.state('viewportWidth'), cy.state('viewportHeight')] expect(secondaryViewport).to.deep.equal(expectedViewport) @@ -22,7 +22,7 @@ describe('cy.origin', () => { it('executes quickly', () => { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { expect(true).to.equal(true) }) }) @@ -50,7 +50,7 @@ describe('cy.origin', () => { expect(err.message).to.include(`\`cy.visit()\` was called to visit a cross origin site with an \`onLoad\` callback. \`onLoad\` callbacks can only be used with same origin sites. If you wish to specify an \`onLoad\` callback please use the \`cy.origin\` command to setup a \`window:load\` event prior to visiting the cross origin site.`) - expect(err.message).to.include(`\`cy.origin('http://idp.com:3500', () => {\``) + expect(err.message).to.include(`\`cy.origin('http://www.idp.com:3500', () => {\``) expect(err.message).to.include(`\` cy.on('window:load', () => {\``) expect(err.message).to.include(` \` \``) expect(err.message).to.include(` \`cy.visit('http://www.idp.com:3500/fixtures/auth/index.html')\``) @@ -71,7 +71,7 @@ describe('cy.origin', () => { expect(err.message).to.include(`\`cy.visit()\` was called to visit a cross origin site with an \`onBeforeLoad\` callback. \`onBeforeLoad\` callbacks can only be used with same origin sites. If you wish to specify an \`onBeforeLoad\` callback please use the \`cy.origin\` command to setup a \`window:before:load\` event prior to visiting the cross origin site.`) - expect(err.message).to.include(`\`cy.origin('http://idp.com:3500', () => {\``) + expect(err.message).to.include(`\`cy.origin('http://www.idp.com:3500', () => {\``) expect(err.message).to.include(`\` cy.on('window:before:load', () => {\``) expect(err.message).to.include(` \` \``) expect(err.message).to.include(` \`cy.visit('http://www.idp.com:3500/fixtures/auth/index.html')\``) @@ -95,7 +95,7 @@ describe('cy.origin', () => { }) it('runs commands in secondary origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy .get('[data-cy="dom-check"]') .invoke('text') @@ -141,7 +141,7 @@ describe('cy.origin', () => { ctx: {}, } - cy.origin('http://foobar.com:3500', { args: expectedRunnable }, (expectedRunnable) => { + cy.origin('http://www.foobar.com:3500', { args: expectedRunnable }, (expectedRunnable) => { const actualRunnable = cy.state('runnable') expect(actualRunnable.titlePath()).to.deep.equal(expectedRunnable.titlePath) @@ -160,7 +160,7 @@ describe('cy.origin', () => { }) it('handles querying nested elements', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy .get('form button') .invoke('text') @@ -171,7 +171,7 @@ describe('cy.origin', () => { }) it('sets up window.Cypress in secondary origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy .get('[data-cy="cypress-check"]') .invoke('text') @@ -181,39 +181,39 @@ describe('cy.origin', () => { describe('data argument', () => { it('passes object to callback function', () => { - cy.origin('http://foobar.com:3500', { args: { foo: 'foo', bar: 'bar' } }, ({ foo, bar }) => { + cy.origin('http://www.foobar.com:3500', { args: { foo: 'foo', bar: 'bar' } }, ({ foo, bar }) => { expect(foo).to.equal('foo') expect(bar).to.equal('bar') }) }) it('passes array to callback function', () => { - cy.origin('http://foobar.com:3500', { args: ['foo', 'bar'] }, ([foo, bar]) => { + cy.origin('http://www.foobar.com:3500', { args: ['foo', 'bar'] }, ([foo, bar]) => { expect(foo).to.equal('foo') expect(bar).to.equal('bar') }) }) it('passes string to callback function', () => { - cy.origin('http://foobar.com:3500', { args: 'foo' }, (foo) => { + cy.origin('http://www.foobar.com:3500', { args: 'foo' }, (foo) => { expect(foo).to.equal('foo') }) }) it('passes number to callback function', () => { - cy.origin('http://foobar.com:3500', { args: 1 }, (num) => { + cy.origin('http://www.foobar.com:3500', { args: 1 }, (num) => { expect(num).to.equal(1) }) }) it('passes boolean to callback function', () => { - cy.origin('http://foobar.com:3500', { args: true }, (bool) => { + cy.origin('http://www.foobar.com:3500', { args: true }, (bool) => { expect(bool).to.be.true }) }) it('passes mixed types to callback function', () => { - cy.origin('http://foobar.com:3500', { args: { foo: 'foo', num: 1, bool: true } }, ({ foo, num, bool }) => { + cy.origin('http://www.foobar.com:3500', { args: { foo: 'foo', num: 1, bool: true } }, ({ foo, num, bool }) => { expect(foo).to.equal('foo') expect(num).to.equal(1) expect(bool).to.be.true @@ -237,7 +237,7 @@ describe('cy.origin', () => { const variable = 'string' - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.log(variable) }) }) @@ -248,7 +248,7 @@ describe('cy.origin', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw 'oops' }) }) @@ -260,7 +260,7 @@ describe('cy.origin', () => { resolve(undefined) }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw 'oops' }) }) @@ -277,7 +277,7 @@ describe('cy.origin', () => { done() }) - cy.origin('http://foobar.com:3500', { args: timeout }, (timeout) => { + cy.origin('http://www.foobar.com:3500', { args: timeout }, (timeout) => { cy.get('#doesnt-exist', { timeout, }) @@ -293,7 +293,7 @@ describe('cy.origin', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('#doesnt-exist') }) }) @@ -313,7 +313,7 @@ describe('cy.origin', () => { const variable = () => {} - cy.origin('http://foobar.com:3500', { args: variable }, (variable) => { + cy.origin('http://www.foobar.com:3500', { args: variable }, (variable) => { variable() }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/rerun.cy.ts b/packages/driver/cypress/e2e/e2e/origin/rerun.cy.ts index de020668585a..75a0e5e2bdd8 100644 --- a/packages/driver/cypress/e2e/e2e/origin/rerun.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/rerun.cy.ts @@ -7,7 +7,7 @@ describe('cy.origin - rerun', { }, () => { it('successfully reruns tests', () => { // @ts-ignore - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]') }) .then(() => { diff --git a/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts b/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts index a9dd06757337..957fc57b0d3d 100644 --- a/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/snapshots.cy.ts @@ -28,11 +28,11 @@ describe('cy.origin - snapshots', () => { // TODO: the xhr event is showing up twice in the log, which is wrong and causing flake. skipping until: https://github.com/cypress-io/cypress/issues/23840 is addressed. it.skip('verifies XHR requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js // @ts-ignore Cypress.config('isInteractive', true) - cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-onload.html') + cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') cy.get(`[data-cy="assertion-header"]`).should('exist') cy.wait('@fooBarBaz') }) @@ -54,11 +54,11 @@ describe('cy.origin - snapshots', () => { // TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23437 it.skip('verifies fetch requests made while a secondary origin is active eventually update with snapshots of the secondary origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js // @ts-ignore Cypress.config('isInteractive', true) - cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-onload.html') + cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') cy.get(`[data-cy="assertion-header"]`).should('exist') cy.wait('@fooBarBaz') }) @@ -94,9 +94,9 @@ describe('cy.origin - snapshots', () => { done() }) - cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-onload.html') + cy.visit('http://www.foobar.com:3500/fixtures/xhr-fetch-requests.html') - cy.origin('http://barbaz.com:3500', () => { + cy.origin('http://www.barbaz.com:3500', () => { // need to set isInteractive in the spec bridge in order to take xhr snapshots in run mode, similar to how isInteractive is set within support/defaults.js // @ts-ignore Cypress.config('isInteractive', true) diff --git a/packages/driver/cypress/e2e/e2e/origin/spec_bridge.cy.ts b/packages/driver/cypress/e2e/e2e/origin/spec_bridge.cy.ts index 5f7f8ee12f4c..5c885b25bb04 100644 --- a/packages/driver/cypress/e2e/e2e/origin/spec_bridge.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/spec_bridge.cy.ts @@ -2,7 +2,7 @@ it('visits foobar.com and types foobar inside an input', () => { cy.visit('/fixtures/primary-origin.html') cy.get('[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="text-input"]').type('foobar') }) .then(() => { diff --git a/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts b/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts index 7b21cc087c00..6efefc99b559 100644 --- a/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/uncaught_errors.cy.ts @@ -12,7 +12,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.then(() => { expect(true).to.be.false }) @@ -42,7 +42,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('.trigger-sync-error').click() }) }) @@ -55,7 +55,7 @@ describe('cy.origin - uncaught errors', () => { cy.on('fail', failureSpy) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.on('uncaught:exception', () => false) cy.get('.trigger-sync-error').click() }).then(() => { @@ -75,7 +75,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.once('uncaught:exception', () => true) cy.get('.trigger-sync-error').click() }) @@ -84,7 +84,7 @@ describe('cy.origin - uncaught errors', () => { // if we mutate the error, the app's listeners for 'error' or // 'unhandledrejection' will have our wrapped error instead of the original it('original error is not mutated for "error" in the origin', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.once('uncaught:exception', () => false) cy.get('.trigger-sync-error').click() @@ -105,7 +105,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { setTimeout(() => { throw new Error('setTimeout error') }, 50) @@ -137,7 +137,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('.trigger-async-error').click() // add the cy.wait here to keep commands streaming in, @@ -154,7 +154,7 @@ describe('cy.origin - uncaught errors', () => { cy.on('fail', failureSpy) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { // the async error here should be thrown AFTER the current command and test has finished, resulting in a passed test with no fail being triggered in the primary cy.get('.trigger-async-error').click() }).then(() => { @@ -173,7 +173,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { setTimeout(() => { throw new Error('setTimeout error') }, 50) @@ -185,7 +185,7 @@ describe('cy.origin - uncaught errors', () => { describe('unhandled rejections', () => { it('unhandled rejection triggers uncaught:exception and has promise as third argument', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { const r = cy.state('runnable') const afterUncaughtException = new Promise((resolve) => { @@ -209,7 +209,7 @@ describe('cy.origin - uncaught errors', () => { }) it('original error is not mutated for "unhandledrejection"', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.once('uncaught:exception', () => false) cy.get('.trigger-unhandled-rejection').click() @@ -228,7 +228,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Promise.reject(new Error('rejected promise')) // add the cy.wait here to keep commands streaming in, forcing the @@ -248,7 +248,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { Promise.reject(new Error('rejected promise')) }) @@ -264,7 +264,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw document.createElement('h1') }) }) @@ -276,7 +276,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw () => undefined }) }) @@ -288,7 +288,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw Symbol('foo') }) }) @@ -300,7 +300,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw new Promise(() => {}) }) }) @@ -308,9 +308,9 @@ describe('cy.origin - uncaught errors', () => { describe('serializable errors', () => { it('errors thrown prior to attaching are forwarded to top', (done) => { - cy.origin('http://foobar.com:3500', () => {}).then(() => { + cy.origin('http://www.foobar.com:3500', () => {}).then(() => { // Force remove the spec bridge - window?.top?.document.getElementById('Spec Bridge: http://foobar.com:3500')?.remove() + window?.top?.document.getElementById('Spec Bridge: http://www.foobar.com:3500')?.remove() }) cy.on('fail', (err) => { @@ -318,7 +318,7 @@ describe('cy.origin - uncaught errors', () => { expect(err.message).to.include('this is the message') expect(err.message).to.include('The following error originated from your application code, not from Cypress.') expect(err.message).to.include('this is the message') - expect(err.message).to.include('\`cy.origin(\'http://foobar.com:3500\', () => {\`') + expect(err.message).to.include('\`cy.origin(\'http://www.foobar.com:3500\', () => {\`') expect(err.message).to.include('\`cy.visit(\'http://www.foobar.com:3500/fixtures/auth/error-on-load.html\')\`') expect(err.docsUrl).to.deep.eq(['https://on.cypress.io/uncaught-exception-from-application', 'https://on.cypress.io/origin']) @@ -338,7 +338,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.visit('http://www.foobar.com:3500/fixtures/auth/error-on-load.html') }) }) @@ -357,7 +357,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { class CustomError extends Error { private _name = 'CustomError' get name () { @@ -393,7 +393,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { class FooBar { private _metasyntaticList = ['foo'] get metasyntaticList (): string[] { @@ -421,7 +421,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw 'oops' }) }) @@ -433,7 +433,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw ['why would anyone do this?', 'this is odd'] }) }) @@ -445,7 +445,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw 2 }) }) @@ -457,7 +457,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw true }) }) @@ -469,7 +469,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw null }) }) @@ -481,7 +481,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw undefined }) }) @@ -493,7 +493,7 @@ describe('cy.origin - uncaught errors', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { throw new Date() }) }) diff --git a/packages/driver/cypress/e2e/e2e/origin/user_agent_override.cy.ts b/packages/driver/cypress/e2e/e2e/origin/user_agent_override.cy.ts index 539ccb61fabf..5148ca08d765 100644 --- a/packages/driver/cypress/e2e/e2e/origin/user_agent_override.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/user_agent_override.cy.ts @@ -29,7 +29,7 @@ describe('user agent override', { cy.visit('/fixtures/primary-origin.html') cy.get('a[data-cy="cross-origin-secondary-link"]').click() - cy.origin('http://foobar.com:3500', { + cy.origin('http://www.foobar.com:3500', { args: { userAgentBefore: window.navigator.userAgent, }, diff --git a/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts b/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts index 2de82525ca1d..ef571f78ac8e 100644 --- a/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts @@ -1,5 +1,11 @@ describe('cy.origin', () => { describe('successes', () => { + beforeEach(() => { + // TODO: There seems to be a limit of 15 active spec bridges during a given test. How common is this? + // @ts-ignore + [...window.top?.document.getElementsByClassName('spec-bridge-iframe')].forEach((el) => el.remove()) + }) + it('succeeds on a localhost domain name', () => { cy.origin('localhost', () => undefined) cy.then(() => { @@ -53,10 +59,10 @@ describe('cy.origin', () => { }) it('succeeds on a complete origin using https', () => { - cy.origin('https://foobar2.com:3500', () => undefined) + cy.origin('https://www.foobar2.com:3500', () => undefined) cy.then(() => { - const expectedSrc = `https://foobar2.com:3500/__cypress/spec-bridge-iframes` - const iframe = window.top?.document.getElementById('Spec\ Bridge:\ https://foobar2.com:3500') as HTMLIFrameElement + const expectedSrc = `https://www.foobar2.com:3500/__cypress/spec-bridge-iframes` + const iframe = window.top?.document.getElementById('Spec\ Bridge:\ https://www.foobar2.com:3500') as HTMLIFrameElement expect(iframe.src).to.equal(expectedSrc) }) @@ -85,8 +91,8 @@ describe('cy.origin', () => { it('succeeds on a subdomain', () => { cy.origin('app.foobar5.com', () => undefined) cy.then(() => { - const expectedSrc = `https://foobar5.com/__cypress/spec-bridge-iframes` - const iframe = window.top?.document.getElementById('Spec\ Bridge:\ https://foobar5.com') as HTMLIFrameElement + const expectedSrc = `https://app.foobar5.com/__cypress/spec-bridge-iframes` + const iframe = window.top?.document.getElementById('Spec\ Bridge:\ https://app.foobar5.com') as HTMLIFrameElement expect(iframe.src).to.equal(expectedSrc) }) @@ -105,8 +111,8 @@ describe('cy.origin', () => { it('succeeds on a url with path', () => { cy.origin('http://www.foobar7.com/login', () => undefined) cy.then(() => { - const expectedSrc = `http://foobar7.com/__cypress/spec-bridge-iframes` - const iframe = window.top?.document.getElementById('Spec\ Bridge:\ http://foobar7.com') as HTMLIFrameElement + const expectedSrc = `http://www.foobar7.com/__cypress/spec-bridge-iframes` + const iframe = window.top?.document.getElementById('Spec\ Bridge:\ http://www.foobar7.com') as HTMLIFrameElement expect(iframe.src).to.equal(expectedSrc) }) @@ -115,8 +121,8 @@ describe('cy.origin', () => { it('succeeds on a url with a hash', () => { cy.origin('http://www.foobar8.com/#hash', () => undefined) cy.then(() => { - const expectedSrc = `http://foobar8.com/__cypress/spec-bridge-iframes` - const iframe = window.top?.document.getElementById('Spec\ Bridge:\ http://foobar8.com') as HTMLIFrameElement + const expectedSrc = `http://www.foobar8.com/__cypress/spec-bridge-iframes` + const iframe = window.top?.document.getElementById('Spec\ Bridge:\ http://www.foobar8.com') as HTMLIFrameElement expect(iframe.src).to.equal(expectedSrc) }) @@ -125,8 +131,8 @@ describe('cy.origin', () => { it('succeeds on a url with a path and hash', () => { cy.origin('http://www.foobar9.com/login/#hash', () => undefined) cy.then(() => { - const expectedSrc = `http://foobar9.com/__cypress/spec-bridge-iframes` - const iframe = window.top?.document.getElementById('Spec\ Bridge:\ http://foobar9.com') as HTMLIFrameElement + const expectedSrc = `http://www.foobar9.com/__cypress/spec-bridge-iframes` + const iframe = window.top?.document.getElementById('Spec\ Bridge:\ http://www.foobar9.com') as HTMLIFrameElement expect(iframe.src).to.equal(expectedSrc) }) @@ -165,8 +171,8 @@ describe('cy.origin', () => { it('succeeds on a public suffix with a subdomain', () => { cy.origin('app.foobar.herokuapp.com', () => undefined) cy.then(() => { - const expectedSrc = `https://foobar.herokuapp.com/__cypress/spec-bridge-iframes` - const iframe = window.top?.document.getElementById('Spec\ Bridge:\ https://foobar.herokuapp.com') as HTMLIFrameElement + const expectedSrc = `https://app.foobar.herokuapp.com/__cypress/spec-bridge-iframes` + const iframe = window.top?.document.getElementById('Spec\ Bridge:\ https://app.foobar.herokuapp.com') as HTMLIFrameElement expect(iframe.src).to.equal(expectedSrc) }) @@ -188,7 +194,7 @@ describe('cy.origin', () => { win.location.href = 'http://baz.foobar.com:3500/fixtures/auth/idp.html' }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://baz.foobar.com:3500', () => { cy.get('[data-cy="username"]').type('TJohnson') cy.get('[data-cy="login"]').click() }) @@ -211,7 +217,7 @@ describe('cy.origin', () => { it.skip('uses cy.origin twice', () => { cy.visit('/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]').click() - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.get('[data-cy="username"]').type('BJohnson') cy.get('[data-cy="login"]').click() }) @@ -226,7 +232,7 @@ describe('cy.origin', () => { win.location.href = 'http://baz.foobar.com:3500/fixtures/auth/idp.html' }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="username"]').type('TJohnson') cy.get('[data-cy="login"]').click() }) @@ -238,15 +244,15 @@ describe('cy.origin', () => { it('creates a spec bridge for https://idp.com:3502', () => { cy.visit('/fixtures/auth/index.html') - cy.origin('idp.com:3502', () => { + cy.origin('www.idp.com:3502', () => { cy.visit('https://www.idp.com:3502/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]').invoke('text').should('equal', 'Login IDP') }) }) - it('creates a spec bridge for http://idp.com:3500', () => { + it('creates a spec bridge for http://www.idp.com:3500', () => { cy.visit('/fixtures/auth/index.html') - cy.origin('http://idp.com:3500', () => { + cy.origin('http://www.idp.com:3500', () => { cy.visit('http://www.idp.com:3500/fixtures/auth/index.html') cy.get('[data-cy="login-idp"]').invoke('text').should('equal', 'Login IDP') }) diff --git a/packages/driver/cypress/e2e/e2e/origin/yield.cy.ts b/packages/driver/cypress/e2e/e2e/origin/yield.cy.ts index 745e8d7c3c8b..953bade551bf 100644 --- a/packages/driver/cypress/e2e/e2e/origin/yield.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/yield.cy.ts @@ -15,7 +15,7 @@ describe('cy.origin yields', () => { }) it('yields a value', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy .get('[data-cy="dom-check"]') .invoke('text') @@ -23,7 +23,7 @@ describe('cy.origin yields', () => { }) it('yields the cy value even if a return is present', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy .get('[data-cy="dom-check"]') .invoke('text') @@ -45,7 +45,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy .get('[data-cy="dom-check"]') .invoke('text') @@ -55,13 +55,13 @@ describe('cy.origin yields', () => { }) it('yields synchronously', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { return 'From a secondary origin' }).should('equal', 'From a secondary origin') }) it('yields asynchronously', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { return new Promise((resolve: (val: string) => any, reject) => { setTimeout(() => { resolve('From a secondary origin') @@ -71,7 +71,7 @@ describe('cy.origin yields', () => { }) it('succeeds if subject cannot be serialized and is not accessed synchronously', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { return { symbol: Symbol(''), } @@ -89,7 +89,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { return { symbol: Symbol(''), } @@ -100,7 +100,7 @@ describe('cy.origin yields', () => { }) it('succeeds if subject cannot be serialized and is not accessed', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]') }) .then(() => { @@ -118,7 +118,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.get('[data-cy="dom-check"]') }) .then((subject) => subject.text()) @@ -134,7 +134,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin<{ key: Function }>('http://foobar.com:3500', () => { + cy.origin<{ key: Function }>('http://www.foobar.com:3500', () => { cy.wrap({ key: () => { return 'whoops' @@ -154,7 +154,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap({ key: Symbol('whoops'), }) @@ -171,7 +171,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap(() => { return 'text' }) @@ -191,7 +191,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap(Symbol('symbol')) }) .should('equal', 'symbol') @@ -211,7 +211,7 @@ describe('cy.origin yields', () => { done() }) - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap({ key: new Error('Boom goes the dynamite'), }) @@ -223,7 +223,7 @@ describe('cy.origin yields', () => { }) it('yields an object containing valid types', () => { - cy.origin('http://foobar.com:3500', () => { + cy.origin('http://www.foobar.com:3500', () => { cy.wrap({ array: [ 1, diff --git a/packages/driver/cypress/fixtures/auth/index.html b/packages/driver/cypress/fixtures/auth/index.html index bc7f2327ab10..c2406435849a 100644 --- a/packages/driver/cypress/fixtures/auth/index.html +++ b/packages/driver/cypress/fixtures/auth/index.html @@ -64,7 +64,7 @@ loginWithApprovalBtn.innerHTML = "Login With Approval" loginWithApprovalBtn.dataset.cy = "login-with-approval" loginWithApprovalBtn.onclick = function () { - window.location.href = `http://wwww.foobar.com:3500/fixtures/auth/approval.html?redirect=${encodeURIComponent(window.location.href)}` + window.location.href = `http://www.foobar.com:3500/fixtures/auth/approval.html?redirect=${encodeURIComponent(window.location.href)}` }; document.body.appendChild(loginWithApprovalBtn); diff --git a/packages/driver/cypress/plugins/server.js b/packages/driver/cypress/plugins/server.js index 989a08cae61f..70b356b18234 100644 --- a/packages/driver/cypress/plugins/server.js +++ b/packages/driver/cypress/plugins/server.js @@ -8,6 +8,7 @@ const path = require('path') const Promise = require('bluebird') const multer = require('multer') const upload = multer({ dest: 'cypress/_test-output/' }) +const { cors } = require('@packages/network') const PATH_TO_SERVER_PKG = path.dirname(require.resolve('@packages/server')) @@ -296,17 +297,20 @@ const createApp = (port) => { }) app.get('/test-request-credentials', (req, res) => { + const origin = cors.getOrigin(req['headers']['referer']) + res - .setHeader('Access-Control-Allow-Origin', req['headers']['origin']) + .setHeader('Access-Control-Allow-Origin', origin) .setHeader('Access-Control-Allow-Credentials', 'true') .sendStatus(200) }) app.get('/set-cookie-credentials', (req, res) => { const { cookie } = req.query + const origin = cors.getOrigin(req['headers']['referer']) res - .setHeader('Access-Control-Allow-Origin', req['headers']['origin']) + .setHeader('Access-Control-Allow-Origin', origin) .setHeader('Access-Control-Allow-Credentials', 'true') .append('Set-Cookie', cookie) .sendStatus(200) diff --git a/packages/driver/src/cross-origin/communicator.ts b/packages/driver/src/cross-origin/communicator.ts index edf377ad1f9f..ae7ec206983d 100644 --- a/packages/driver/src/cross-origin/communicator.ts +++ b/packages/driver/src/cross-origin/communicator.ts @@ -88,7 +88,7 @@ export class PrimaryOriginCommunicator extends EventEmitter { // where we need to set the crossOriginDriverWindows to source to // communicate back to the iframe if (messageName === 'bridge:ready' && source) { - this.crossOriginDriverWindows[data.superDomainOrigin] = source as Window + this.crossOriginDriverWindows[data.origin] = source as Window } // reify any logs coming back from the cross-origin spec bridges to serialize snapshot/consoleProp DOM elements as well as select functions. @@ -105,7 +105,7 @@ export class PrimaryOriginCommunicator extends EventEmitter { data.data.err = reifySerializedError(data.data.err, this.userInvocationStack as string) } - this.emit(messageName, data.data, data.superDomainOrigin, source) + this.emit(messageName, data.data, data.origin, source) return } @@ -137,8 +137,8 @@ export class PrimaryOriginCommunicator extends EventEmitter { }) } - toSpecBridge (superDomainOrigin: string, event: string, data?: any) { - debug('=> to spec bridge', superDomainOrigin, event, data) + toSpecBridge (origin: string, event: string, data?: any) { + debug('=> to spec bridge', origin, event, data) const preprocessedData = preprocessForSerialization(data) @@ -148,7 +148,7 @@ export class PrimaryOriginCommunicator extends EventEmitter { } // If there is no crossOriginDriverWindows, there is no need to send the message. - this.crossOriginDriverWindows[superDomainOrigin]?.postMessage({ + this.crossOriginDriverWindows[origin]?.postMessage({ event, data: preprocessedData, }, '*') @@ -161,18 +161,18 @@ export class PrimaryOriginCommunicator extends EventEmitter { * @param options - contains boolean to sync globals * @returns the response from primary of the event with the same name. */ - toSpecBridgePromise (superDomainOrigin: string, event: string, data?: any) { + toSpecBridgePromise (origin: string, event: string, data?: any) { return new Promise((resolve, reject) => { const dataToSend = sharedPromiseSetup({ resolve, reject, data, event, - specBridgeName: superDomainOrigin, + specBridgeName: origin, communicator: this, }) - this.toSpecBridge(superDomainOrigin, event, dataToSend) + this.toSpecBridge(origin, event, dataToSend) }) } } @@ -251,7 +251,7 @@ export class SpecBridgeCommunicator extends EventEmitter { * @param {Cypress.ObjectLike} data - any meta data to be sent with the event. */ toPrimary (event: string, data?: Cypress.ObjectLike, options: { syncGlobals: boolean } = { syncGlobals: false }) { - const { superDomainOrigin } = $Location.create(window.location.href) + const { origin } = $Location.create(window.location.href) const eventName = `${CROSS_ORIGIN_PREFIX}${event}` // Preprocess logs before sending through postMessage() to attempt to serialize some DOM nodes and functions. @@ -265,14 +265,14 @@ export class SpecBridgeCommunicator extends EventEmitter { data = preprocessSnapshotForSerialization(data as any) } - debug('<= to Primary ', event, data, superDomainOrigin) + debug('<= to Primary ', event, data, origin) if (options.syncGlobals) this.syncGlobalsToPrimary() this.handleSubjectAndErr(data, (data: Cypress.ObjectLike) => { window.top?.postMessage({ event: eventName, data, - superDomainOrigin, + origin, }, '*') }) } diff --git a/packages/driver/src/cross-origin/cypress.ts b/packages/driver/src/cross-origin/cypress.ts index f5164d402ca5..801a4e2970d7 100644 --- a/packages/driver/src/cross-origin/cypress.ts +++ b/packages/driver/src/cross-origin/cypress.ts @@ -25,7 +25,6 @@ import { patchFetch } from './patches/fetch' import { patchXmlHttpRequest } from './patches/xmlHttpRequest' import $errUtils from '../cypress/error_utils' import $Mocha from '../cypress/mocha' -import * as cors from '@packages/network/lib/cors' const createCypress = () => { // @ts-ignore @@ -44,8 +43,8 @@ const createCypress = () => { const frame = window.parent.frames[index] try { - // the AUT would be the frame with a matching super domain origin, but not the same exact href. - if (window.location.origin === cors.getSuperDomainOrigin(frame.location.origin) + // the AUT would be the frame with a matching origin, but not the same exact href. + if (window.location.origin === frame.location.origin && window.location.href !== frame.location.href) { return frame } @@ -68,10 +67,10 @@ const createCypress = () => { }) Cypress.specBridgeCommunicator.on('generate:final:snapshot', (snapshotUrl: string) => { - const currentAutSuperDomainOrigin = cy.state('autLocation').superDomainOrigin + const currentAutOrigin = cy.state('autLocation').origin const requestedSnapshotUrlLocation = $Location.create(snapshotUrl) - if (requestedSnapshotUrlLocation.superDomainOrigin === currentAutSuperDomainOrigin) { + if (requestedSnapshotUrlLocation.origin === currentAutOrigin) { // if true, this is the correct spec bridge to take the snapshot and send it back const finalSnapshot = cy.createSnapshot(FINAL_SNAPSHOT_NAME) diff --git a/packages/driver/src/cross-origin/events/misc.ts b/packages/driver/src/cross-origin/events/misc.ts index 585e8e2c28f1..32dc51a2730a 100644 --- a/packages/driver/src/cross-origin/events/misc.ts +++ b/packages/driver/src/cross-origin/events/misc.ts @@ -1,6 +1,5 @@ import type { $Cy } from '../../cypress/cy' import { $Location } from '../../cypress/location' -import * as cors from '@packages/network/lib/cors' export const handleMiscEvents = (Cypress: Cypress.Cypress, cy: $Cy) => { Cypress.on('viewport:changed', (viewport, callbackFn) => { @@ -24,7 +23,7 @@ export const handleMiscEvents = (Cypress: Cypress.Cypress, cy: $Cy) => { // Listen for any unload events in other origins, if any have unloaded we should also become unstable. Cypress.specBridgeCommunicator.on('before:unload', (origin) => { // If the unload event originated from this spec bridge, isStable is already being handled. - if (window.location.origin !== cors.getSuperDomainOrigin(origin)) { + if (window.location.origin !== origin) { cy.state('isStable', false) } }) diff --git a/packages/driver/src/cy/commands/navigation.ts b/packages/driver/src/cy/commands/navigation.ts index 9ee3dd204f22..5e1aec95db4a 100644 --- a/packages/driver/src/cy/commands/navigation.ts +++ b/packages/driver/src/cy/commands/navigation.ts @@ -312,7 +312,7 @@ const stabilityChanged = async (Cypress, state, config, stable) => { const onPageLoadErr = (err) => { state('onPageLoadErr', null) - const { superDomainOrigin } = $Location.create(window.location.href) + const { origin } = $Location.create(window.location.href) try { $errUtils.throwErrByPath('navigation.cross_origin', { @@ -320,7 +320,7 @@ const stabilityChanged = async (Cypress, state, config, stable) => { args: { configFile: Cypress.config('configFile'), message: err.message, - superDomainOrigin, + origin, }, }) } catch (error) { @@ -1087,7 +1087,7 @@ export default (Commands, Cypress, cy, state, config) => { // if the super domain origin currently matches // or if we have previously visited a location or are a spec bridge // then go ahead and change the iframe's src - // we use the superDomainOrigin policy as we can interact with subdomains based document.domain set to the superdomain + // we use the super domain origin as we can interact with subdomains based document.domain set to the super domain origin if (remote.superDomainOrigin === existing.superDomainOrigin || ((previouslyVisitedLocation || Cypress.isCrossOriginSpecBridge) && Cypress.config('experimentalSessionAndOrigin')) ) { diff --git a/packages/driver/src/cy/commands/origin/index.ts b/packages/driver/src/cy/commands/origin/index.ts index c4f1f2050d90..d9dc6ed4f9bc 100644 --- a/packages/driver/src/cy/commands/origin/index.ts +++ b/packages/driver/src/cy/commands/origin/index.ts @@ -85,14 +85,14 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State validator.validateLocation(location, urlOrDomain) - const superDomainOrigin = location.superDomainOrigin + const origin = location.origin // This is set while IN the cy.origin command. - cy.state('currentActiveSuperDomainOrigin', superDomainOrigin) + cy.state('currentActiveOrigin', origin) return new Bluebird((resolve, reject, onCancel) => { const cleanup = ({ readyForOriginFailed }: {readyForOriginFailed?: boolean} = {}): void => { - cy.state('currentActiveSuperDomainOrigin', undefined) + cy.state('currentActiveOrigin', undefined) communicator.off('queue:finished', onQueueFinished) communicator.off('sync:globals', onSyncGlobals) @@ -168,23 +168,23 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State } // fired once the spec bridge is set up and ready to receive messages - communicator.once('bridge:ready', async (_data, specBridgeSuperDomainOrigin) => { - if (specBridgeSuperDomainOrigin === superDomainOrigin) { + communicator.once('bridge:ready', async (_data, specBridgeOrigin) => { + if (specBridgeOrigin === origin) { // now that the spec bridge is ready, instantiate Cypress with the current app config and environment variables for initial sync when creating the instance - communicator.toSpecBridge(superDomainOrigin, 'initialize:cypress', { + communicator.toSpecBridge(origin, 'initialize:cypress', { config: preprocessConfig(Cypress.config()), env: preprocessEnv(Cypress.env()), }) // Attach the spec bridge to the window to be tested. - communicator.toSpecBridge(superDomainOrigin, 'attach:to:window') - const fn = _.isFunction(callbackFn) ? callbackFn.toString() : callbackFn + communicator.toSpecBridge(origin, 'attach:to:window') + // once the secondary origin page loads, send along the // user-specified callback to run in that origin try { - communicator.toSpecBridge(superDomainOrigin, 'run:origin:fn', { + communicator.toSpecBridge(origin, 'run:origin:fn', { args: options?.args || undefined, fn, // let the spec bridge version of Cypress know if config read-only values can be overwritten since window.top cannot be accessed in cross-origin iframes @@ -236,7 +236,7 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State } }) - // this signals to the runner to create the spec bridge for the specified origin policy + // this signals to the runner to create the spec bridge for the specified origin communicator.emit('expect:origin', location) }) }, diff --git a/packages/driver/src/cy/commands/waiting.ts b/packages/driver/src/cy/commands/waiting.ts index 82bbd4dda7d8..964723af5a57 100644 --- a/packages/driver/src/cy/commands/waiting.ts +++ b/packages/driver/src/cy/commands/waiting.ts @@ -282,14 +282,14 @@ export default (Commands, Cypress, cy, state) => { }) } - Cypress.primaryOriginCommunicator.on('wait:for:xhr', ({ args: [str, options] }, superDomainOrigin) => { + Cypress.primaryOriginCommunicator.on('wait:for:xhr', ({ args: [str, options] }, origin) => { options.isCrossOriginSpecBridge = true waitString(null, str, options).then((responses) => { - Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, 'wait:for:xhr:end', responses) + Cypress.primaryOriginCommunicator.toSpecBridge(origin, 'wait:for:xhr:end', responses) }).catch((err) => { options._log?.error(err) err.hasSpecBridgeError = true - Cypress.primaryOriginCommunicator.toSpecBridge(superDomainOrigin, 'wait:for:xhr:end', err) + Cypress.primaryOriginCommunicator.toSpecBridge(origin, 'wait:for:xhr:end', err) }) }) diff --git a/packages/driver/src/cy/ensures.ts b/packages/driver/src/cy/ensures.ts index 7d6c5e8dbd02..107541854512 100644 --- a/packages/driver/src/cy/ensures.ts +++ b/packages/driver/src/cy/ensures.ts @@ -395,7 +395,7 @@ export const create = (state: StateFunc, expect: $Cy['expect']) => { if (!isRunnerAbleToCommunicateWithAut()) { const crossOriginCommandError = $errUtils.errByPath('miscellaneous.cross_origin_command', { commandOrigin: window.location.origin, - autSuperDomainOrigin: state('autLocation').superDomainOrigin, + autOrigin: state('autLocation').origin, }) if (err) { diff --git a/packages/driver/src/cypress/error_messages.ts b/packages/driver/src/cypress/error_messages.ts index 4911ed578204..0bf0366a21e0 100644 --- a/packages/driver/src/cypress/error_messages.ts +++ b/packages/driver/src/cypress/error_messages.ts @@ -914,9 +914,9 @@ export default { return `Timed out retrying after ${ms}ms: ` }, test_stopped: 'Cypress test was stopped while running this command.', - cross_origin_command ({ commandOrigin, autSuperDomainOrigin }) { + cross_origin_command ({ commandOrigin, autOrigin }) { return stripIndent`\ - The command was expected to run against origin \`${commandOrigin }\` but the application is at origin \`${autSuperDomainOrigin}\`. + The command was expected to run against origin \`${commandOrigin }\` but the application is at origin \`${autOrigin}\`. This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.` }, @@ -980,20 +980,20 @@ export default { }, navigation: { - cross_origin ({ message, superDomainOrigin, configFile, projectRoot }) { + cross_origin ({ message, origin, configFile, projectRoot }) { return { message: stripIndent`\ Cypress detected a cross origin error happened on page load: > ${message} - Before the page load, you were bound to the origin policy: + Before the page load, you were bound to the origin: - > ${superDomainOrigin} + > ${origin} - A cross origin error happens when your application navigates to a new URL which does not match the origin policy above. + A cross origin error happens when your application navigates to a new URL which does not match the origin 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. + A new URL does not match the origin if the 'protocol', 'port' (if specified), and/or 'host' are different. Cypress does not allow you to navigate to a different origin URL within a single test. @@ -1259,7 +1259,7 @@ export default { This error was thrown by a cross origin page. If you wish to suppress this error you will have to use the cy.origin command to handle the error prior to visiting the page. - \`cy.origin('${autLocation.superDomainOrigin}', () => {\` + \`cy.origin('${autLocation.origin}', () => {\` \` cy.on('uncaught:exception', (e) => {\` \` if (e.message.includes('Things went bad')) {\` \` // we expected this error, so let's ignore it\` @@ -2177,7 +2177,7 @@ export default { message: stripIndent`${cmd('visit')} was called to visit a cross origin site with an \`onLoad\` callback. \`onLoad\` callbacks can only be used with same origin sites. If you wish to specify an \`onLoad\` callback please use the \`cy.origin\` command to setup a \`window:load\` event prior to visiting the cross origin site. - \`cy.origin('${args.autLocation.superDomainOrigin}', () => {\` + \`cy.origin('${args.autLocation.origin}', () => {\` \` cy.on('window:load', () => {\` \` \` \` })\` @@ -2192,7 +2192,7 @@ export default { message: stripIndent`${cmd('visit')} was called to visit a cross origin site with an \`onBeforeLoad\` callback. \`onBeforeLoad\` callbacks can only be used with same origin sites. If you wish to specify an \`onBeforeLoad\` callback please use the \`cy.origin\` command to setup a \`window:before:load\` event prior to visiting the cross origin site. - \`cy.origin('${args.autLocation.superDomainOrigin}', () => {\` + \`cy.origin('${args.autLocation.origin}', () => {\` \` cy.on('window:before:load', () => {\` \` \` \` })\` @@ -2217,7 +2217,7 @@ export default { ${args.experimentalSessionAndOrigin ? `You likely forgot to use ${cmd('origin')}:` : `In order to visit a different origin, you can enable the \`experimentalSessionAndOrigin\` flag and use ${cmd('origin')}:` } ${args.isCrossOriginSpecBridge ? - `\`cy.origin('${args.previousUrl.superDomainOrigin}', () => {\` + `\`cy.origin('${args.previousUrl.origin}', () => {\` \` cy.visit('${args.previousUrl}')\` \` \` \`})\`` : @@ -2225,7 +2225,7 @@ export default { \`\`` } - \`cy.origin('${args.attemptedUrl.superDomainOrigin}', () => {\` + \`cy.origin('${args.attemptedUrl.origin}', () => {\` \` cy.visit('${args.originalUrl}')\` \` \` \`})\` diff --git a/packages/driver/src/cypress/log.ts b/packages/driver/src/cypress/log.ts index 5b356188bd92..564002f9bb9c 100644 --- a/packages/driver/src/cypress/log.ts +++ b/packages/driver/src/cypress/log.ts @@ -374,16 +374,16 @@ export class Log { } if (this.config('experimentalSessionAndOrigin') && !Cypress.isCrossOriginSpecBridge) { - const activeSpecBridgeSuperDomainOriginIfApplicable = this.state('currentActiveSuperDomainOrigin') || undefined + const activeSpecBridgeOriginIfApplicable = this.state('currentActiveOrigin') || undefined // @ts-ignore - const { superDomainOrigin: superDomainOriginThatIsSoonToBeOrIsActive } = Cypress.Location.create(this.state('url')) + const { origin: originThatIsSoonToBeOrIsActive } = Cypress.Location.create(this.state('url')) - if (activeSpecBridgeSuperDomainOriginIfApplicable && activeSpecBridgeSuperDomainOriginIfApplicable === superDomainOriginThatIsSoonToBeOrIsActive) { + if (activeSpecBridgeOriginIfApplicable && activeSpecBridgeOriginIfApplicable === originThatIsSoonToBeOrIsActive) { Cypress.emit('request:snapshot:from:spec:bridge', { log: this, name, options, - specBridge: activeSpecBridgeSuperDomainOriginIfApplicable, + specBridge: activeSpecBridgeOriginIfApplicable, addSnapshot: this.addSnapshot, }) diff --git a/packages/driver/src/cypress/state.ts b/packages/driver/src/cypress/state.ts index 5a438139d273..d417a72d39c2 100644 --- a/packages/driver/src/cypress/state.ts +++ b/packages/driver/src/cypress/state.ts @@ -23,7 +23,7 @@ export interface StateFunc { (k: 'logGroupIds', v?: Array): Array (k: 'autLocation', v?: LocationObject): LocationObject (k: 'originCommandBaseUrl', v?: string): string - (k: 'currentActiveSuperDomainOrigin', v?: string): string + (k: 'currentActiveOrigin', v?: string): string (k: 'duringUserTestExecution', v?: boolean): boolean (k: 'onQueueEnd', v?: () => void): () => void (k: 'onFail', v?: (err: Error) => void): (err: Error) => void diff --git a/packages/network/lib/cors.ts b/packages/network/lib/cors.ts index 08abc5363149..2e4eab92f248 100644 --- a/packages/network/lib/cors.ts +++ b/packages/network/lib/cors.ts @@ -205,23 +205,23 @@ export function getOrigin (url: string) { // @ts-ignore const { origin } = new URL(url) - // origin policy is comprised of: + // origin is comprised of: // protocol + subdomain + superdomain + port return origin } /** - * We use the super domain origin policy in the driver to determine whether or not we need to reload/interact with the AUT, and + * We use the super domain origin in the driver to determine whether or not we need to reload/interact with the AUT, and * currently in the spec bridge to interact with the AUT frame, which uses document.domain set to the super domain * @param url - the full absolute url - * @returns the super domain origin policy - + * @returns the super domain origin - * ex: http://www.example.com:8081/my/path -> http://example.com:8081/my/path */ export function getSuperDomainOrigin (url: string) { // @ts-ignore const { port, protocol } = new URL(url) - // super domain origin policy is comprised of: + // super domain origin is comprised of: // protocol + superdomain + port (subdomain is not factored in) return _.compact([`${protocol}//${getSuperDomain(url)}`, port]).join(':') } diff --git a/packages/proxy/lib/http/request-middleware.ts b/packages/proxy/lib/http/request-middleware.ts index de8b93ff00fb..63bff1b259af 100644 --- a/packages/proxy/lib/http/request-middleware.ts +++ b/packages/proxy/lib/http/request-middleware.ts @@ -157,7 +157,9 @@ const MaybeEndRequestWithBufferedResponse: RequestMiddleware = function () { if (buffer) { this.debug('ending request with buffered response') - this.res.wantsInjection = this.config.experimentalSessionAndOrigin && buffer.isCrossOrigin ? 'fullCrossOrigin' : 'full' + // NOTE: Only inject fullCrossOrigin here if experimental is on and + // the super domain origins do not match in order to keep parity with cypress application reloads + this.res.wantsInjection = this.config.experimentalSessionAndOrigin && buffer.isCrossSuperDomainOrigin ? 'fullCrossOrigin' : 'full' return this.onResponse(buffer.response, buffer.stream) } diff --git a/packages/proxy/lib/http/response-middleware.ts b/packages/proxy/lib/http/response-middleware.ts index 230f828ea469..ea3613dc86c3 100644 --- a/packages/proxy/lib/http/response-middleware.ts +++ b/packages/proxy/lib/http/response-middleware.ts @@ -257,10 +257,11 @@ const SetInjectionLevel: ResponseMiddleware = function () { return 'partial' } - const isCrossOrigin = !reqMatchesSuperDomainOrigin(this.req, this.remoteStates.getPrimary()) + // NOTE: Only inject fullCrossOrigin if the super domain origins do not match in order to keep parity with cypress application reloads + const isCrossSuperDomainOrigin = !reqMatchesSuperDomainOrigin(this.req, this.remoteStates.getPrimary()) const isAUTFrame = this.req.isAUTFrame - if (this.config.experimentalSessionAndOrigin && isCrossOrigin && isAUTFrame && (isHTML || isRenderedHTML)) { + if (this.config.experimentalSessionAndOrigin && isCrossSuperDomainOrigin && isAUTFrame && (isHTML || isRenderedHTML)) { this.debug('- cross origin injection') return 'fullCrossOrigin' @@ -519,7 +520,7 @@ const MaybeInjectHtml: ResponseMiddleware = function () { wantsSecurityRemoved: this.res.wantsSecurityRemoved, isHtml: isHtml(this.incomingRes), useAstSourceRewriting: this.config.experimentalSourceRewriting, - modifyObstructiveThirdPartyCode: this.config.experimentalModifyObstructiveThirdPartyCode && !this.remoteStates.isPrimaryOrigin(this.req.proxiedUrl), + modifyObstructiveThirdPartyCode: this.config.experimentalModifyObstructiveThirdPartyCode && !this.remoteStates.isPrimarySuperDomainOrigin(this.req.proxiedUrl), modifyObstructiveCode: this.config.modifyObstructiveCode, url: this.req.proxiedUrl, deferSourceMapRewrite: this.deferSourceMapRewrite, @@ -549,7 +550,7 @@ const MaybeRemoveSecurity: ResponseMiddleware = function () { this.incomingResStream = this.incomingResStream.pipe(rewriter.security({ isHtml: isHtml(this.incomingRes), useAstSourceRewriting: this.config.experimentalSourceRewriting, - modifyObstructiveThirdPartyCode: this.config.experimentalModifyObstructiveThirdPartyCode && !this.remoteStates.isPrimaryOrigin(this.req.proxiedUrl), + modifyObstructiveThirdPartyCode: this.config.experimentalModifyObstructiveThirdPartyCode && !this.remoteStates.isPrimarySuperDomainOrigin(this.req.proxiedUrl), modifyObstructiveCode: this.config.modifyObstructiveCode, url: this.req.proxiedUrl, deferSourceMapRewrite: this.deferSourceMapRewrite, diff --git a/packages/proxy/lib/http/util/buffers.ts b/packages/proxy/lib/http/util/buffers.ts index 4c285143e727..afaa8f01da03 100644 --- a/packages/proxy/lib/http/util/buffers.ts +++ b/packages/proxy/lib/http/util/buffers.ts @@ -12,7 +12,7 @@ export type HttpBuffer = { response: IncomingMessage stream: Readable url: string - isCrossOrigin: boolean + isCrossSuperDomainOrigin: boolean } const stripPort = (url) => { diff --git a/packages/proxy/lib/http/util/top-simulation.ts b/packages/proxy/lib/http/util/top-simulation.ts index dc0676e1ac3f..36e1384b2413 100644 --- a/packages/proxy/lib/http/util/top-simulation.ts +++ b/packages/proxy/lib/http/util/top-simulation.ts @@ -8,7 +8,7 @@ export const doesTopNeedToBeSimulated = (ctx: HttpMiddlewareThis): boolean return false } - // only simulate top if the AUT is NOT the primary origin, meaning that we should treat the AUT as top + // only simulate top if the AUT is NOT the primary super domain origin, meaning that we should treat the AUT as top // or the request is the AUT frame, which is common for redirects and navigations. - return !ctx.remoteStates.isPrimaryOrigin(currentAUTUrl) || ctx.req.isAUTFrame + return !ctx.remoteStates.isPrimarySuperDomainOrigin(currentAUTUrl) || ctx.req.isAUTFrame } diff --git a/packages/proxy/test/unit/http/request-middleware.spec.ts b/packages/proxy/test/unit/http/request-middleware.spec.ts index 67ca0442534f..d3f1faf68095 100644 --- a/packages/proxy/test/unit/http/request-middleware.spec.ts +++ b/packages/proxy/test/unit/http/request-middleware.spec.ts @@ -135,7 +135,7 @@ describe('http/request-middleware', () => { }, getAUTUrl: sinon.stub().returns('http://localhost:8080'), remoteStates: { - isPrimaryOrigin: sinon.stub().returns(false), + isPrimarySuperDomainOrigin: sinon.stub().returns(false), }, req: { headers: { @@ -159,7 +159,7 @@ describe('http/request-middleware', () => { }, getAUTUrl: sinon.stub().returns('http://localhost:8080'), remoteStates: { - isPrimaryOrigin: sinon.stub().returns(false), + isPrimarySuperDomainOrigin: sinon.stub().returns(false), }, resourceTypeAndCredentialManager: { get: sinon.stub().returns({}), @@ -186,7 +186,7 @@ describe('http/request-middleware', () => { }, getAUTUrl: sinon.stub().returns('http://localhost:8080'), remoteStates: { - isPrimaryOrigin: sinon.stub().returns(false), + isPrimarySuperDomainOrigin: sinon.stub().returns(false), }, resourceTypeAndCredentialManager: { get: sinon.stub().returns({}), @@ -212,7 +212,7 @@ describe('http/request-middleware', () => { }, getAUTUrl: sinon.stub().returns('http://localhost:8080'), remoteStates: { - isPrimaryOrigin: sinon.stub().returns(false), + isPrimarySuperDomainOrigin: sinon.stub().returns(false), }, resourceTypeAndCredentialManager: { get: sinon.stub().returns({ @@ -338,7 +338,7 @@ describe('http/request-middleware', () => { const ctx = await getContext() ctx.req.isAUTFrame = false - ctx.remoteStates.isPrimaryOrigin.returns(true), + ctx.remoteStates.isPrimarySuperDomainOrigin.returns(true), await testMiddleware([MaybeAttachCrossOriginCookies], ctx) @@ -529,7 +529,7 @@ describe('http/request-middleware', () => { getAUTUrl: () => autUrl, getCookieJar: () => cookieJar, remoteStates: { - isPrimaryOrigin: sinon.stub().returns(false), + isPrimarySuperDomainOrigin: sinon.stub().returns(false), }, config: { experimentalSessionAndOrigin: true }, req: { @@ -548,7 +548,7 @@ describe('http/request-middleware', () => { it('sets wantsInjection to full when a request is buffered', async () => { const buffers = new HttpBuffers() - const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: false } as HttpBuffer + const buffer = { url: 'https://www.cypress.io/', isCrossSuperDomainOrigin: false } as HttpBuffer buffers.set(buffer) @@ -568,7 +568,7 @@ describe('http/request-middleware', () => { it('sets wantsInjection to fullCrossOrigin when a cross origin request is buffered and experimentalSessionAndOrigin=true', async () => { const buffers = new HttpBuffers() - const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: true } as HttpBuffer + const buffer = { url: 'https://www.cypress.io/', isCrossSuperDomainOrigin: true } as HttpBuffer buffers.set(buffer) @@ -591,7 +591,7 @@ describe('http/request-middleware', () => { it('sets wantsInjection to full when a cross origin request is buffered and experimentalSessionAndOrigin=false', async () => { const buffers = new HttpBuffers() - const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: true } as HttpBuffer + const buffer = { url: 'https://www.cypress.io/', isCrossSuperDomainOrigin: true } as HttpBuffer buffers.set(buffer) @@ -614,7 +614,7 @@ describe('http/request-middleware', () => { it('wantsInjection is not set when the request is not buffered', async () => { const buffers = new HttpBuffers() - const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: true } as HttpBuffer + const buffer = { url: 'https://www.cypress.io/', isCrossSuperDomainOrigin: true } as HttpBuffer buffers.set(buffer) diff --git a/packages/proxy/test/unit/http/response-middleware.spec.ts b/packages/proxy/test/unit/http/response-middleware.spec.ts index 9f476139dd4f..43ee7b0936c5 100644 --- a/packages/proxy/test/unit/http/response-middleware.spec.ts +++ b/packages/proxy/test/unit/http/response-middleware.spec.ts @@ -647,7 +647,7 @@ describe('http/response-middleware', function () { ctx.getAUTUrl = () => 'http://www.foobar.com/index.html' // set the primaryOrigin to true to signal we do NOT need to simulate top - ctx.remoteStates.isPrimaryOrigin = () => true + ctx.remoteStates.isPrimarySuperDomainOrigin = () => true await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -679,7 +679,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated, but the experimental flag is off ctx.getAUTUrl = () => 'http://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -717,7 +717,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -777,7 +777,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -836,7 +836,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -897,7 +897,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -955,7 +955,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1014,7 +1014,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1058,7 +1058,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1114,7 +1114,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1153,7 +1153,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1208,7 +1208,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'http://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1247,7 +1247,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1283,7 +1283,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1322,7 +1322,7 @@ describe('http/response-middleware', function () { // a case where top would need to be simulated ctx.getAUTUrl = () => 'https://www.foobar.com/index.html' - ctx.remoteStates.isPrimaryOrigin = () => false + ctx.remoteStates.isPrimarySuperDomainOrigin = () => false await testMiddleware([MaybeCopyCookiesFromIncomingRes], ctx) @@ -1401,7 +1401,7 @@ describe('http/response-middleware', function () { remoteStates.set(origin, {}, false) }) - remoteStates.isPrimaryOrigin = () => false + remoteStates.isPrimarySuperDomainOrigin = () => false const cookieJar = props.cookieJar || { getAllCookies: () => [], @@ -1465,7 +1465,7 @@ describe('http/response-middleware', function () { }, }) - ctx.remoteStates.isPrimaryOrigin = () => true + ctx.remoteStates.isPrimarySuperDomainOrigin = () => true return { appendStub, ctx } } diff --git a/packages/proxy/test/unit/http/util/top-simulation.spec.ts b/packages/proxy/test/unit/http/util/top-simulation.spec.ts index cb29a6fd4b8a..acf251e1f22d 100644 --- a/packages/proxy/test/unit/http/util/top-simulation.spec.ts +++ b/packages/proxy/test/unit/http/util/top-simulation.spec.ts @@ -6,14 +6,14 @@ import { doesTopNeedToBeSimulated } from '../../../../lib/http/util/top-simulati context('.doesTopNeedToBeSimulated', () => { const autUrl = 'http://localhost:8080' - it('returns false when URL matches the AUT Url origin policy and the AUT Url exists and is NOT the AUT frame', () => { + it('returns false when URL matches the AUT Url origin and the AUT Url exists and is NOT the AUT frame', () => { const mockCtx: HttpMiddlewareThis = { getAUTUrl: sinon.stub().returns(autUrl), req: { isAUTFrame: false, }, remoteStates: { - isPrimaryOrigin: sinon.stub().returns(true), + isPrimarySuperDomainOrigin: sinon.stub().returns(true), }, } @@ -26,14 +26,14 @@ context('.doesTopNeedToBeSimulated', () => { * If this proves problematic in the future, we can likely leverage the sec-fetch-mode header for requests and 3xx status for responses to determine * whether or not cookies need to be attached from the jar or set into the jar */ - it('returns true when URL matches the AUT Url origin policy and the AUT Url exists and is the AUT frame', () => { + it('returns true when URL matches the AUT Url origin and the AUT Url exists and is the AUT frame', () => { const mockCtx: HttpMiddlewareThis = { getAUTUrl: sinon.stub().returns(autUrl), req: { isAUTFrame: true, }, remoteStates: { - isPrimaryOrigin: sinon.stub().returns(true), + isPrimarySuperDomainOrigin: sinon.stub().returns(true), }, } @@ -52,7 +52,7 @@ context('.doesTopNeedToBeSimulated', () => { const mockCtx: HttpMiddlewareThis = { getAUTUrl: sinon.stub().returns(autUrl), remoteStates: { - isPrimaryOrigin: sinon.stub().returns(false), + isPrimarySuperDomainOrigin: sinon.stub().returns(false), }, } diff --git a/packages/runner/injection/cross-origin.js b/packages/runner/injection/cross-origin.js index 8481248d72fb..c3bcaaea22d0 100644 --- a/packages/runner/injection/cross-origin.js +++ b/packages/runner/injection/cross-origin.js @@ -25,7 +25,7 @@ const findCypress = () => { // eslint-disable-next-line no-useless-concat const frameHostRegex = new RegExp(`(^|\\.)${ frame.location.host.replaceAll('.', '\\.') }` + '$') - // Compare the locations origin policy without pulling in more dependencies. + // Compare the locations origins without pulling in more dependencies. // Compare host, protocol and test that the window's host ends with the frame's host. // This works because the spec bridge's host is always created without a sub domain. if (window.location.port === frame.location.port diff --git a/packages/server/lib/remote_states.ts b/packages/server/lib/remote_states.ts index 397dfd459376..e2ba2bca6dd1 100644 --- a/packages/server/lib/remote_states.ts +++ b/packages/server/lib/remote_states.ts @@ -68,7 +68,7 @@ export class RemoteStates { return state } - isPrimaryOrigin (url: string): boolean { + isPrimarySuperDomainOrigin (url: string): boolean { return this.primaryOriginKey === cors.getSuperDomainOrigin(url) } @@ -86,7 +86,7 @@ export class RemoteStates { return this.get(this.currentOriginKey) as Cypress.RemoteState } - set (urlOrState: string | Cypress.RemoteState, options: { auth?: {} } = {}, isPrimaryOrigin: boolean = true): Cypress.RemoteState { + set (urlOrState: string | Cypress.RemoteState, options: { auth?: {} } = {}, isPrimarySuperDomainOrigin: boolean = true): Cypress.RemoteState { let state if (_.isString(urlOrState)) { @@ -120,7 +120,7 @@ export class RemoteStates { this.currentOriginKey = remoteOrigin - if (isPrimaryOrigin) { + if (isPrimarySuperDomainOrigin) { // convert map to array const stateArray = Array.from(this.remoteStates.entries()) diff --git a/packages/server/lib/server-e2e.ts b/packages/server/lib/server-e2e.ts index 74438f30c536..b1afcde27400 100644 --- a/packages/server/lib/server-e2e.ts +++ b/packages/server/lib/server-e2e.ts @@ -166,7 +166,7 @@ export class ServerE2E extends ServerBase { let handlingLocalFile = false const previousRemoteState = this._remoteStates.current() - const previousRemoteStateIsPrimary = this._remoteStates.isPrimaryOrigin(previousRemoteState.origin) + const previousRemoteStateIsPrimary = this._remoteStates.isPrimarySuperDomainOrigin(previousRemoteState.origin) const primaryRemoteState = this._remoteStates.getPrimary() // nuke any hashes from our url since @@ -307,10 +307,10 @@ export class ServerE2E extends ServerBase { // TODO: think about moving this logic back into the frontend so that the driver can be in control // of when to buffer and set the remote state if (isOk && details.isHtml) { - const isCrossOrigin = options.hasAlreadyVisitedUrl && !cors.urlsSuperDomainOriginMatch(primaryRemoteState.origin, newUrl || '') || options.isFromSpecBridge + const isCrossSuperDomainOrigin = options.hasAlreadyVisitedUrl && !cors.urlsSuperDomainOriginMatch(primaryRemoteState.origin, newUrl || '') || options.isFromSpecBridge if (!handlingLocalFile) { - this._remoteStates.set(newUrl as string, options, !isCrossOrigin) + this._remoteStates.set(newUrl as string, options, !isCrossSuperDomainOrigin) } const responseBufferStream = new stream.PassThrough({ @@ -325,7 +325,7 @@ export class ServerE2E extends ServerBase { details, originalUrl, response: incomingRes, - isCrossOrigin, + isCrossSuperDomainOrigin, }) } else { // TODO: move this logic to the driver too for @@ -333,7 +333,7 @@ export class ServerE2E extends ServerBase { restorePreviousRemoteState(previousRemoteState, previousRemoteStateIsPrimary) } - details.isPrimaryOrigin = this._remoteStates.isPrimaryOrigin(newUrl!) + details.isPrimarySuperDomainOrigin = this._remoteStates.isPrimarySuperDomainOrigin(newUrl!) return resolve(details) }) diff --git a/packages/server/test/integration/server_spec.js b/packages/server/test/integration/server_spec.js index 22daf4c01105..cc313586e7ec 100644 --- a/packages/server/test/integration/server_spec.js +++ b/packages/server/test/integration/server_spec.js @@ -144,7 +144,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -176,7 +176,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: false, contentType: 'application/json', url: 'http://localhost:2000/assets/foo.json', @@ -197,7 +197,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -215,7 +215,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -247,7 +247,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/sub/', @@ -280,7 +280,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: false, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/does-not-exist', @@ -308,7 +308,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -391,7 +391,7 @@ describe('Server', () => { }).then((obj) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: `http://localhost:${this.httpPort}/${path}/100`, @@ -438,7 +438,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://getbootstrap.com/', @@ -473,7 +473,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: false, + isPrimarySuperDomainOrigin: false, isHtml: false, contentType: 'application/json', url: 'http://getbootstrap.com/user.json', @@ -518,7 +518,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: undefined, url: 'http://example.com/', @@ -540,7 +540,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: false, + isPrimarySuperDomainOrigin: false, isHtml: false, contentType: undefined, url: 'http://example.com/', @@ -574,7 +574,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://espn.go.com/', @@ -639,7 +639,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://espn.go.com/', @@ -659,7 +659,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://espn.go.com/', @@ -714,7 +714,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: false, - isPrimaryOrigin: false, + isPrimarySuperDomainOrigin: false, isHtml: false, contentType: undefined, url: 'http://espn.com/', @@ -729,7 +729,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://espn.go.com/', @@ -765,7 +765,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: false, - isPrimaryOrigin: false, + isPrimarySuperDomainOrigin: false, isHtml: true, contentType: 'text/html', url: 'http://mlb.mlb.com/', @@ -799,7 +799,7 @@ describe('Server', () => { .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://getbootstrap.com/', @@ -840,7 +840,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://google.com/foo', @@ -897,7 +897,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://google.com/index', @@ -962,13 +962,13 @@ describe('Server', () => { fileServer: null, }) - expect(this.server.remoteStates.isPrimaryOrigin('http://cypress.io')).to.be.false + expect(this.server.remoteStates.isPrimarySuperDomainOrigin('http://cypress.io')).to.be.false return this.server._onResolveUrl('http://www.cypress.io/', {}, this.automationRequest, { isFromSpecBridge: true }) .then((obj = {}) => { expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: false, + isPrimarySuperDomainOrigin: false, isHtml: true, contentType: 'text/html', url: 'http://www.cypress.io/', @@ -983,7 +983,7 @@ describe('Server', () => { const buffer = this.buffers.take('http://www.cypress.io/') expect(buffer).to.not.be.empty - expect(buffer.isCrossOrigin).to.be.true + expect(buffer.isCrossSuperDomainOrigin).to.be.true // Verify the secondary remote state is returned expect(this.server.remoteStates.current()).to.deep.eq({ @@ -1135,7 +1135,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -1156,7 +1156,7 @@ describe('Server', () => { }).then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://www.google.com/', @@ -1190,7 +1190,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -1234,7 +1234,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://www.google.com/', @@ -1273,7 +1273,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -1308,7 +1308,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://www.google.com/', @@ -1353,7 +1353,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'https://www.foobar.com:8443/', @@ -1392,7 +1392,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -1427,7 +1427,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'https://www.foobar.com:8443/', @@ -1472,7 +1472,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: s3StaticHtmlUrl, @@ -1519,7 +1519,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: 'http://localhost:2000/index.html', @@ -1554,7 +1554,7 @@ describe('Server', () => { .then((obj = {}) => { return expectToEqDetails(obj, { isOkStatusCode: true, - isPrimaryOrigin: true, + isPrimarySuperDomainOrigin: true, isHtml: true, contentType: 'text/html', url: s3StaticHtmlUrl, diff --git a/packages/server/test/unit/remote_states.spec.ts b/packages/server/test/unit/remote_states.spec.ts index 84195ad93809..64420a358154 100644 --- a/packages/server/test/unit/remote_states.spec.ts +++ b/packages/server/test/unit/remote_states.spec.ts @@ -117,18 +117,18 @@ describe('remote states', () => { }) }) - context('#isPrimaryOrigin', () => { + context('#isPrimarySuperDomainOrigin', () => { it('returns true when the requested url is the primary origin', function () { - const isPrimaryOrigin = this.remoteStates.isPrimaryOrigin('http://localhost:3500') + const isPrimarySuperDomainOrigin = this.remoteStates.isPrimarySuperDomainOrigin('http://localhost:3500') - expect(isPrimaryOrigin).to.be.true + expect(isPrimarySuperDomainOrigin).to.be.true }) it('returns false when the requested url is not the primary origin', function () { this.remoteStates.set('https://google.com', {}, false) - const isPrimaryOrigin = this.remoteStates.isPrimaryOrigin('http://google.com') + const isPrimarySuperDomainOrigin = this.remoteStates.isPrimarySuperDomainOrigin('http://google.com') - expect(isPrimaryOrigin).to.be.false + expect(isPrimarySuperDomainOrigin).to.be.false }) }) @@ -168,8 +168,8 @@ describe('remote states', () => { }) context('#set', () => { - it('sets primary state and origin when isPrimaryOrigin is true', function () { - expect(this.remoteStates.isPrimaryOrigin('http://localhost:3500')).to.be.true + it('sets primary state and origin when isPrimarySuperDomainOrigin is true', function () { + expect(this.remoteStates.isPrimarySuperDomainOrigin('http://localhost:3500')).to.be.true const state = this.remoteStates.set('https://staging.google.com/foo/bar', {}, true) @@ -189,11 +189,11 @@ describe('remote states', () => { expect(this.remoteStates.get('https://staging.google.com')).to.deep.equal(state) - expect(this.remoteStates.isPrimaryOrigin('https://staging.google.com')).to.be.true + expect(this.remoteStates.isPrimarySuperDomainOrigin('https://staging.google.com')).to.be.true }) - it('sets a secondary state when isPrimaryOrigin is false', function () { - expect(this.remoteStates.isPrimaryOrigin('http://localhost:3500')).to.be.true + it('sets a secondary state when isPrimarySuperDomainOrigin is false', function () { + expect(this.remoteStates.isPrimarySuperDomainOrigin('http://localhost:3500')).to.be.true const state = this.remoteStates.set('https://staging.google.com/foo/bar', {}, false) @@ -213,8 +213,8 @@ describe('remote states', () => { expect(this.remoteStates.get('https://staging.google.com')).to.deep.equal(state) - expect(this.remoteStates.isPrimaryOrigin('http://localhost:3500')).to.be.true - expect(this.remoteStates.isPrimaryOrigin('https://staging.google.com')).to.be.false + expect(this.remoteStates.isPrimarySuperDomainOrigin('http://localhost:3500')).to.be.true + expect(this.remoteStates.isPrimarySuperDomainOrigin('https://staging.google.com')).to.be.false }) it('overrides the existing state', function () { diff --git a/system-tests/__snapshots__/web_security_spec.js b/system-tests/__snapshots__/web_security_spec.js index 4ed1c41dd823..63a1685e4a69 100644 --- a/system-tests/__snapshots__/web_security_spec.js +++ b/system-tests/__snapshots__/web_security_spec.js @@ -35,13 +35,13 @@ exports['e2e web security / when enabled / fails'] = ` > [Cross origin error message] -Before the page load, you were bound to the origin policy: +Before the page load, you were bound to the origin: > http://localhost:4466 -A cross origin error happens when your application navigates to a new URL which does not match the origin policy above. +A cross origin error happens when your application navigates to a new URL which does not match the origin 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. +A new URL does not match the origin if the 'protocol', 'port' (if specified), and/or 'host' are different. Cypress does not allow you to navigate to a different origin URL within a single test. @@ -58,13 +58,13 @@ https://on.cypress.io/cross-origin-violation > [Cross origin error message] -Before the page load, you were bound to the origin policy: +Before the page load, you were bound to the origin: > http://localhost:4466 -A cross origin error happens when your application navigates to a new URL which does not match the origin policy above. +A cross origin error happens when your application navigates to a new URL which does not match the origin 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. +A new URL does not match the origin if the 'protocol', 'port' (if specified), and/or 'host' are different. Cypress does not allow you to navigate to a different origin URL within a single test. @@ -81,13 +81,13 @@ https://on.cypress.io/cross-origin-violation > [Cross origin error message] -Before the page load, you were bound to the origin policy: +Before the page load, you were bound to the origin: > http://localhost:4466 -A cross origin error happens when your application navigates to a new URL which does not match the origin policy above. +A cross origin error happens when your application navigates to a new URL which does not match the origin 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. +A new URL does not match the origin if the 'protocol', 'port' (if specified), and/or 'host' are different. Cypress does not allow you to navigate to a different origin URL within a single test. diff --git a/system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts b/system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts index 361325608234..e3dda2e01045 100644 --- a/system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts +++ b/system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts @@ -5,7 +5,7 @@ describe('cy.origin', () => { }) it('tries to find an element that doesn\'t exist and fails', () => { - cy.origin('http://foobar.com:4466', () => { + cy.origin('http://www.foobar.com:4466', () => { cy.get('#doesnotexist', { timeout: 1000, }) From 99e44f5153f2389d4da465305fa2dbecfcb6d3b7 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Wed, 28 Sep 2022 17:23:07 -0400 Subject: [PATCH 2/5] fix: do NOT set the initial cypress cookie inside the spec bridge as it is sending unecessary cookies --- packages/driver/src/cross-origin/cypress.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/driver/src/cross-origin/cypress.ts b/packages/driver/src/cross-origin/cypress.ts index 801a4e2970d7..69bb62fa33ea 100644 --- a/packages/driver/src/cross-origin/cypress.ts +++ b/packages/driver/src/cross-origin/cypress.ts @@ -206,7 +206,7 @@ const attachToWindow = (autWindow: Window) => { cy.isStable(false, 'beforeunload') - cy.Cookies.setInitial() + // NOTE: we intentionally do not set the cy.Cookies.setInitial() inside the spec bridge as we are not doing full injection and this leads to cookie side effects cy.resetTimer() From 5c5dd142f46209e6cbd9e8bc1c147f7a314e69e8 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Mon, 3 Oct 2022 16:42:21 -0400 Subject: [PATCH 3/5] chore: simplify the finding cypress in the injection code --- packages/runner/injection/cross-origin.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/runner/injection/cross-origin.js b/packages/runner/injection/cross-origin.js index c3bcaaea22d0..fe8c062133cf 100644 --- a/packages/runner/injection/cross-origin.js +++ b/packages/runner/injection/cross-origin.js @@ -19,20 +19,10 @@ const findCypress = () => { const frame = window.parent.frames[index] try { - // If Cypress is defined and we haven't gotten a cross origin error we have found the correct bridge. - if (frame.Cypress) { - // If the ending $ is included in the template string, it breaks transpilation - // eslint-disable-next-line no-useless-concat - const frameHostRegex = new RegExp(`(^|\\.)${ frame.location.host.replaceAll('.', '\\.') }` + '$') - - // Compare the locations origins without pulling in more dependencies. - // Compare host, protocol and test that the window's host ends with the frame's host. - // This works because the spec bridge's host is always created without a sub domain. - if (window.location.port === frame.location.port - && window.location.protocol === frame.location.protocol - && frameHostRegex.test(window.location.host)) { - return frame.Cypress - } + // If Cypress is defined and we haven't gotten a cross origin error + // and the origins match, we have found the correct bridge. + if (frame.Cypress && window.location.origin === frame.location.origin) { + return frame.Cypress } } catch (error) { // Catch DOMException: Blocked a frame from accessing a cross-origin frame. From aeb98075be14b506e9a7e6c5feca8bb3df048435 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Tue, 4 Oct 2022 11:11:10 -0400 Subject: [PATCH 4/5] chore: change order in which callback fn is declared --- packages/driver/src/cy/commands/origin/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/driver/src/cy/commands/origin/index.ts b/packages/driver/src/cy/commands/origin/index.ts index d9dc6ed4f9bc..990659f32fae 100644 --- a/packages/driver/src/cy/commands/origin/index.ts +++ b/packages/driver/src/cy/commands/origin/index.ts @@ -177,10 +177,10 @@ export default (Commands, Cypress: Cypress.Cypress, cy: Cypress.cy, state: State }) // Attach the spec bridge to the window to be tested. - const fn = _.isFunction(callbackFn) ? callbackFn.toString() : callbackFn - communicator.toSpecBridge(origin, 'attach:to:window') + const fn = _.isFunction(callbackFn) ? callbackFn.toString() : callbackFn + // once the secondary origin page loads, send along the // user-specified callback to run in that origin try { From e59e508716f49198f9e406f801b42cb564ec86cd Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Tue, 4 Oct 2022 14:51:24 -0400 Subject: [PATCH 5/5] chore: add spec bridge performance issue to validation tests --- packages/driver/cypress/e2e/e2e/origin/validation.cy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts b/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts index ef571f78ac8e..58e32b1368b1 100644 --- a/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts +++ b/packages/driver/cypress/e2e/e2e/origin/validation.cy.ts @@ -1,7 +1,8 @@ describe('cy.origin', () => { describe('successes', () => { beforeEach(() => { - // TODO: There seems to be a limit of 15 active spec bridges during a given test. How common is this? + // TODO: There seems to be a limit of 15 active spec bridges during a given test. + // Needs to be fixed with https://github.com/cypress-io/cypress/issues/22874 // @ts-ignore [...window.top?.document.getElementsByClassName('spec-bridge-iframe')].forEach((el) => el.remove()) })