Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: ensure multi domain passivity #20442

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/driver/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"retries": {
"runMode": 2,
"openMode": 0
}
},
"experimentalMultiDomain": true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also be setting experimentalSessionSupport here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mschile sorry I missed this comment! I don't think we need to because it likely would impact the cookie_spec. We can get away with setting experimentalSessionSupport as an override because the server doesn't need the value, which is nice!

}
28 changes: 0 additions & 28 deletions packages/driver/cypress/integration/commands/navigation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2134,34 +2134,6 @@ describe('src/cy/commands/navigation', () => {
.get('#does-not-exist', { timeout: 200 }).should('have.class', 'foo')
})

// TODO: This test is currently being skipped for multidomain and needs to be fixed. See issue #19632.
it.skip('captures cross origin failures', function (done) {
cy.once('fail', (err) => {
const { lastLog } = this

assertLogLength(this.logs, 2)
expect(err.message).to.include('Cypress detected a cross origin error happened on page load')
expect(err.docsUrl).to.eq('https://on.cypress.io/cross-origin-violation')
expect(lastLog.get('name')).to.eq('page load')
expect(lastLog.get('state')).to.eq('failed')
expect(lastLog.get('error')).to.eq(err)
expect(cy.state('onPageLoadErr')).to.be.null

done()
})

cy
.visit('/fixtures/jquery.html')
.window({ log: false }).then((win) => {
const url = 'http://localhost:3501/fixtures/generic.html'

const $a = win.$(`<a href='${url}'>jquery</a>`)
.appendTo(win.document.body)

causeSynchronousBeforeUnload($a)
})
})

return null
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck / session support is needed for visiting about:blank between tests
describe('basic login', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('basic login', { experimentalSessionSupport: true }, () => {
// Scenario, Token based auth. Visit site, redirect to IDP hosted on secondary domain, login and redirect back to site.
describe('visit primary first', () => {
it('logs in with idp redirect', () => {
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('basic login', { experimentalSessionSupport: true, experimentalMultiDom
})

// session support is needed for visiting about:blank between tests
describe('Multi-step Auth', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('Multi-step Auth', { experimentalSessionSupport: true }, () => {
// TODO: Switch to domain does not work in switch to domain yet.
it.skip('final auth redirects back to localhost - nested', () => {
cy.visit('/fixtures/auth/index.html')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain actions', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain actions', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain aliasing', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain aliasing', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain assertions', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain assertions', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain connectors', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain connectors', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain cookies', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain cookies', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain files', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain files', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain local storage', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain local storage', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain location', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain location', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain misc', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain misc', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain navigation', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain navigation', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
// FIXME: received cross-origin errors
context.skip('multi-domain network requests', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context.skip('multi-domain network requests', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="request-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain querying', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain querying', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain shadow dom', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain shadow dom', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="shadow-dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain screenshot', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain screenshot', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
this.serverResult = {
path: '/path/to/screenshot',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// You must enable the experimentalSessionSupport flag in order to use Cypress session commands
// at throwIfNoSessionSupport(webpack:///../driver/src/cy/commands/sessions.ts?:287:76)
// at session(webpack:///../driver/src/cy/commands/sessions.ts?:516:7)
context.skip('multi-domain session', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context.skip('multi-domain session', { experimentalSessionSupport: true }, () => {
before(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain spies, stubs, and clock', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain spies, stubs, and clock', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain traversal', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain traversal', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain unsupported commands', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain unsupported commands', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain viewport', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain viewport', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain waiting', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain waiting', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
context('multi-domain window', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
context('multi-domain window', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
['config', 'env'].forEach((fnName) => {
// @ts-ignore
describe(`multi-domain - Cypress.${fnName}()`, { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe(`multi-domain - Cypress.${fnName}()`, { experimentalSessionSupport: true }, () => {
const USED_KEYS = {
foo: 'multi-domain-foo',
bar: 'multi-domain-bar',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests+
describe('multi-domain Cypress API', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('multi-domain Cypress API', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
describe('multi-domain', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('multi-domain', { experimentalSessionSupport: true }, () => {
it('window:before:load event', () => {
cy.visit('/fixtures/multi-domain.html')
cy.on('window:before:load', (win: {testPrimaryDomainBeforeLoad: boolean}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore
describe('multi-domain - rerun', { experimentalMultiDomain: true }, () => {
describe('multi-domain - rerun', { }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
describe('multi-domain', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('multi-domain', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('multi-domain', { experimentalSessionSupport: true, experimentalMultiDo
})

// @ts-ignore
describe('domain validation', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('domain validation', { experimentalSessionSupport: true }, () => {
it('finds the right spec bridge with a subdomain', () => {
cy.visit('/fixtures/auth/index.html') // Establishes Primary Domain
cy.window().then((win) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
describe('multi-domain - uncaught errors', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('multi-domain - uncaught errors', { experimentalSessionSupport: true }, () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="errors-link"]').click()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-ignore / session support is needed for visiting about:blank between tests
describe('multi-domain', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('multi-domain', { experimentalSessionSupport: true }, () => {
describe('successes', () => {
it('succeeds on a localhost domain name', () => {
cy.switchToDomain('localhost', () => undefined)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertLogLength } from '../../../support/utils'

// @ts-ignore / session support is needed for visiting about:blank between tests
describe('multi-domain yields', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('multi-domain yields', { experimentalSessionSupport: true }, () => {
let logs: any = []

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const reifyLogs = (logs) => {
}

// @ts-ignore / session support is needed for visiting about:blank between tests
describe('navigation events', { experimentalSessionSupport: true, experimentalMultiDomain: true }, () => {
describe('navigation events', { experimentalSessionSupport: true }, () => {
let logs: any = []

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/proxy/lib/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const defaultMiddleware = {
}

export type ServerCtx = Readonly<{
config: CyServer.Config
config: CyServer.Config & Cypress.Config
shouldCorrelatePreRequests?: () => boolean
getFileServerToken: () => string
getRemoteState: CyServer.getRemoteState
Expand Down
4 changes: 2 additions & 2 deletions packages/proxy/lib/http/response-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const MaybeDelayForMultiDomain: ResponseMiddleware = function () {
const isRenderedHTML = reqWillRenderHtml(this.req)
const isAUTFrame = this.req.isAUTFrame

if (isCrossDomain && isAUTFrame && (isHTML || isRenderedHTML)) {
if (this.config.experimentalMultiDomain && isCrossDomain && isAUTFrame && (isHTML || isRenderedHTML)) {
this.debug('is cross-domain, delay until domain:ready event')

this.serverBus.once('ready:for:domain', () => {
Expand Down Expand Up @@ -272,7 +272,7 @@ const SetInjectionLevel: ResponseMiddleware = function () {
const isHTML = resContentTypeIs(this.incomingRes, 'text/html')
const isAUTFrame = this.req.isAUTFrame

if (!isReqMatchOriginPolicy && isAUTFrame && (isHTML || isRenderedHTML)) {
if (this.config.experimentalMultiDomain && !isReqMatchOriginPolicy && isAUTFrame && (isHTML || isRenderedHTML)) {
this.debug('- multi-domain injection')

return 'fullMultiDomain'
Expand Down
Loading