mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-25 00:19:11 -05:00
chore: [Multi-domain] Rename isMultiDomain for the driver and the server (#20947)
* chore: [Multi-domain] Rename isMultiDomain for the driver and the server * A couple more changes * Update packages/driver/src/cy/commands/navigation.ts Co-authored-by: Matt Schile <mschile@gmail.com> Co-authored-by: Matt Schile <mschile@gmail.com>
This commit is contained in:
@@ -65,8 +65,8 @@ const timedOutWaitingForPageLoad = (ms, log) => {
|
||||
if (currentCommand?.get('name') === 'origin') {
|
||||
// If the current command is a cy.origin command, we should have gotten a request on the origin it expects.
|
||||
originPolicies = [cy.state('latestActiveOriginPolicy')]
|
||||
} else if (Cypress.isMultiDomain && cy.queue.isOnLastCommand()) {
|
||||
// If this is multi-domain and the we're on the last command, we should have gotten a request on the origin of one of the parents.
|
||||
} else if (Cypress.isCrossOriginSpecBridge && cy.queue.isOnLastCommand()) {
|
||||
// If this is a cross origin spec bridge and we're on the last command, we should have gotten a request on the origin of one of the parents.
|
||||
originPolicies = cy.state('parentOriginPolicies')
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ const timedOutWaitingForPageLoad = (ms, log) => {
|
||||
}
|
||||
}
|
||||
|
||||
const cannotVisitDifferentOrigin = ({ remote, existing, previousUrlVisited, log, isMultiDomain = false }) => {
|
||||
const cannotVisitDifferentOrigin = ({ remote, existing, previousUrlVisited, log, isCrossOriginSpecBridge = false }) => {
|
||||
const differences: string[] = []
|
||||
|
||||
if (remote.protocol !== existing.protocol) {
|
||||
@@ -111,7 +111,7 @@ const cannotVisitDifferentOrigin = ({ remote, existing, previousUrlVisited, log,
|
||||
differences: differences.join(', '),
|
||||
previousUrl: previousUrlVisited,
|
||||
attemptedUrl: remote.origin,
|
||||
isMultiDomain,
|
||||
isCrossOriginSpecBridge,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ const stabilityChanged = (Cypress, state, config, stable) => {
|
||||
}
|
||||
|
||||
// filter the options to only the REQUEST_URL_OPTS options, normalize the timeout
|
||||
// value to the responseTimeout, and add the isMultiDomain value.
|
||||
// value to the responseTimeout, and add the isCrossOriginSpecBridge value.
|
||||
//
|
||||
// there are really two timeout values - pageLoadTimeout
|
||||
// and the underlying responseTimeout. for the purposes
|
||||
@@ -489,7 +489,7 @@ const normalizeOptions = (options) => {
|
||||
.pick(REQUEST_URL_OPTS)
|
||||
.extend({
|
||||
timeout: options.responseTimeout,
|
||||
isMultiDomain: Cypress.isMultiDomain,
|
||||
isCrossOrigin: Cypress.isCrossOriginSpecBridge,
|
||||
})
|
||||
.value()
|
||||
}
|
||||
@@ -869,7 +869,7 @@ export default (Commands, Cypress, cy, state, config) => {
|
||||
|
||||
url = $Location.normalize(url)
|
||||
|
||||
if (Cypress.isMultiDomain) {
|
||||
if (Cypress.isCrossOriginSpecBridge) {
|
||||
url = $Location.qualifyWithBaseUrl(Cypress.state('originCommandBaseUrl'), url)
|
||||
} else {
|
||||
const baseUrl = config('baseUrl')
|
||||
@@ -950,9 +950,9 @@ export default (Commands, Cypress, cy, state, config) => {
|
||||
|
||||
knownCommandCausedInstability = true
|
||||
|
||||
// if this is multi-domain, we need to tell the primary to change
|
||||
// if this is a cross origin spec bridge, we need to tell the primary to change
|
||||
// the AUT iframe since we don't have access to it
|
||||
if (Cypress.isMultiDomain) {
|
||||
if (Cypress.isCrossOriginSpecBridge) {
|
||||
return Cypress.specBridgeCommunicator.toPrimary('visit:url', { url })
|
||||
}
|
||||
|
||||
@@ -1033,7 +1033,7 @@ export default (Commands, Cypress, cy, state, config) => {
|
||||
return cannotVisitDifferentOrigin(params)
|
||||
}
|
||||
|
||||
// in multi-domain, the window may not have been set yet if nothing has been loaded in the secondary origin,
|
||||
// in a cross origin spec bridge, the window may not have been set yet if nothing has been loaded in the secondary origin,
|
||||
// it's also possible for a new test to start and for a cross-origin failure to occur if the win is set but
|
||||
// the AUT hasn't yet navigated to the secondary origin
|
||||
if (win) {
|
||||
@@ -1122,12 +1122,12 @@ export default (Commands, Cypress, cy, state, config) => {
|
||||
})
|
||||
}
|
||||
|
||||
// if we are in multi-domain and the origin policies weren't the same,
|
||||
// if we are in a cross origin spec bridge and the origin policies weren't the same,
|
||||
// we need to throw an error since the user tried to visit a new
|
||||
// domain which isn't allowed within a multi-domain block
|
||||
if (Cypress.isMultiDomain && win) {
|
||||
// origin which isn't allowed within a cy.origin block
|
||||
if (Cypress.isCrossOriginSpecBridge && win) {
|
||||
const existingAutOrigin = $Location.create(win.location.href).origin
|
||||
const params = { remote, existing, previousUrlVisited: existingAutOrigin, log: options._log, isMultiDomain: true }
|
||||
const params = { remote, existing, previousUrlVisited: existingAutOrigin, log: options._log, isCrossOriginSpecBridge: true }
|
||||
|
||||
// TODO: need a better error message
|
||||
return cannotVisitDifferentOrigin(params)
|
||||
@@ -1250,10 +1250,10 @@ export default (Commands, Cypress, cy, state, config) => {
|
||||
// so that we nuke the previous state. subsequent
|
||||
// visits will not navigate to about:blank so that
|
||||
// our history entries are intact
|
||||
// skip for multi-domain since multi-domain requires
|
||||
// skip for cross origin spec bridges since they require
|
||||
// session support which already visits
|
||||
// about:blank between tests
|
||||
if (!hasVisitedAboutBlank && !Cypress.isMultiDomain) {
|
||||
if (!hasVisitedAboutBlank && !Cypress.isCrossOriginSpecBridge) {
|
||||
hasVisitedAboutBlank = true
|
||||
currentlyVisitingAboutBlank = true
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class $Cypress {
|
||||
emitMap: any
|
||||
primaryOriginCommunicator: PrimaryOriginCommunicator
|
||||
specBridgeCommunicator: SpecBridgeCommunicator
|
||||
isMultiDomain: boolean
|
||||
isCrossOriginSpecBridge: boolean
|
||||
|
||||
// attach to $Cypress to access
|
||||
// all of the constructors
|
||||
@@ -156,7 +156,7 @@ class $Cypress {
|
||||
this.onSpecReady = null
|
||||
this.primaryOriginCommunicator = new PrimaryOriginCommunicator()
|
||||
this.specBridgeCommunicator = new SpecBridgeCommunicator()
|
||||
this.isMultiDomain = false
|
||||
this.isCrossOriginSpecBridge = false
|
||||
|
||||
this.events = $Events.extend(this)
|
||||
this.$ = jqueryProxyFn.bind(this)
|
||||
@@ -189,8 +189,8 @@ class $Cypress {
|
||||
// slice up the behavior
|
||||
config.isInteractive = !config.isTextTerminal
|
||||
|
||||
// true if this Cypress belongs to multi-domain
|
||||
this.isMultiDomain = config.isMultiDomain || false
|
||||
// true if this Cypress belongs to a cross origin spec bridge
|
||||
this.isCrossOriginSpecBridge = config.isCrossOriginSpecBridge || false
|
||||
|
||||
// enable long stack traces when
|
||||
// we not are running headlessly
|
||||
@@ -206,14 +206,14 @@ class $Cypress {
|
||||
// change this in the NEXT_BREAKING
|
||||
const { env } = config
|
||||
|
||||
config = _.omit(config, 'env', 'remote', 'resolved', 'scaffoldedFiles', 'state', 'testingType', 'isMultiDomain')
|
||||
config = _.omit(config, 'env', 'remote', 'resolved', 'scaffoldedFiles', 'state', 'testingType', 'isCrossOriginSpecBridge')
|
||||
|
||||
_.extend(this, browserInfo(config))
|
||||
|
||||
this.state = $SetterGetter.create({})
|
||||
this.originalConfig = _.cloneDeep(config)
|
||||
this.config = $SetterGetter.create(config, (config) => {
|
||||
if (this.isMultiDomain ? !window.__cySkipValidateConfig : !window.top!.__cySkipValidateConfig) {
|
||||
if (this.isCrossOriginSpecBridge ? !window.__cySkipValidateConfig : !window.top!.__cySkipValidateConfig) {
|
||||
validateNoReadOnlyConfig(config, (errProperty) => {
|
||||
const errPath = this.state('runnable')
|
||||
? 'config.invalid_cypress_config_override'
|
||||
|
||||
@@ -2099,7 +2099,7 @@ export default {
|
||||
|
||||
> {{differences}}
|
||||
|
||||
You may only ${cmd('visit')} same-origin URLs within ${args.isMultiDomain ? cmd('origin') : 'a single test'}.
|
||||
You may only ${cmd('visit')} same-origin URLs within ${args.isCrossOriginSpecBridge ? cmd('origin') : 'a single test'}.
|
||||
|
||||
The previous URL you visited was:
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ const setup = (cypressConfig: Cypress.Config, env: Cypress.ObjectLike) => {
|
||||
Cypress.configure({
|
||||
...cypressConfig,
|
||||
env,
|
||||
// never turn on video for multi-domain when syncing the config. This is handled in the primary.
|
||||
// never turn on video for a spec bridge when syncing the config. This is handled in the primary.
|
||||
video: false,
|
||||
isMultiDomain: true,
|
||||
// multi-domain cannot be used in component testing and is only valid for e2e.
|
||||
isCrossOriginSpecBridge: true,
|
||||
// cross origin spec bridges cannot be used in component testing and is only valid for e2e.
|
||||
// This value is not synced with the config because it is omitted on big Cypress creation, as well as a few other key properties
|
||||
testingType: 'e2e',
|
||||
})
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ declare namespace Cypress {
|
||||
specBridgeCommunicator: import('../src/multi-domain/communicator').SpecBridgeCommunicator
|
||||
mocha: $Mocha
|
||||
configure: (config: Cypress.ObjectLike) => void
|
||||
isMultiDomain: boolean
|
||||
isCrossOriginSpecBridge: boolean
|
||||
originalConfig: Cypress.ObjectLike
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ const MaybeEndRequestWithBufferedResponse: RequestMiddleware = function () {
|
||||
|
||||
if (buffer) {
|
||||
this.debug('ending request with buffered response')
|
||||
this.res.wantsInjection = buffer.isMultiDomain ? 'fullMultiDomain' : 'full'
|
||||
this.res.wantsInjection = buffer.isCrossOrigin ? 'fullCrossOrigin' : 'full'
|
||||
|
||||
return this.onResponse(buffer.response, buffer.stream)
|
||||
}
|
||||
|
||||
@@ -229,15 +229,15 @@ const PatchExpressSetHeader: ResponseMiddleware = function () {
|
||||
this.next()
|
||||
}
|
||||
|
||||
const MaybeDelayForMultiDomain: ResponseMiddleware = function () {
|
||||
const isCrossDomain = !reqMatchesOriginPolicy(this.req, this.remoteStates.current())
|
||||
const MaybeDelayForCrossOrigin: ResponseMiddleware = function () {
|
||||
const isCrossOrigin = !reqMatchesOriginPolicy(this.req, this.remoteStates.current())
|
||||
const isPreviousOrigin = this.remoteStates.isInOriginStack(this.req.proxiedUrl)
|
||||
const isHTML = resContentTypeIs(this.incomingRes, 'text/html')
|
||||
const isRenderedHTML = reqWillRenderHtml(this.req)
|
||||
const isAUTFrame = this.req.isAUTFrame
|
||||
|
||||
// delay the response if this is a cross-origin (and not returning to a previous origin) html request from the AUT iframe
|
||||
if (this.config.experimentalLoginFlows && isCrossDomain && !isPreviousOrigin && isAUTFrame && (isHTML || isRenderedHTML)) {
|
||||
if (this.config.experimentalLoginFlows && isCrossOrigin && !isPreviousOrigin && isAUTFrame && (isHTML || isRenderedHTML)) {
|
||||
this.debug('is cross-origin, delay until ready:for:origin event')
|
||||
|
||||
this.serverBus.once('ready:for:origin', ({ failed }) => {
|
||||
@@ -282,9 +282,9 @@ const SetInjectionLevel: ResponseMiddleware = function () {
|
||||
const isAUTFrame = this.req.isAUTFrame
|
||||
|
||||
if (this.config.experimentalLoginFlows && isSecondaryOrigin && isAUTFrame && (isHTML || isRenderedHTML)) {
|
||||
this.debug('- multi-domain injection')
|
||||
this.debug('- cross origin injection')
|
||||
|
||||
return 'fullMultiDomain'
|
||||
return 'fullCrossOrigin'
|
||||
}
|
||||
|
||||
if (!isHTML || (!isReqMatchOriginPolicy && !isAUTFrame)) {
|
||||
@@ -388,13 +388,13 @@ const MaybePreventCaching: ResponseMiddleware = function () {
|
||||
this.next()
|
||||
}
|
||||
|
||||
const determineIfNeedsMultiDomainHandling = (ctx: HttpMiddlewareThis<ResponseMiddlewareProps>) => {
|
||||
const determineIfNeedsCrossOriginHandling = (ctx: HttpMiddlewareThis<ResponseMiddlewareProps>) => {
|
||||
const previousAUTRequestUrl = ctx.getPreviousAUTRequestUrl()
|
||||
|
||||
// A cookie needs multi-domain handling if it's an AUT request and
|
||||
// A cookie needs cross origin handling if it's an AUT request and
|
||||
// either the request itself is cross-origin or the origins between
|
||||
// requests don't match, since the browser won't set them in that
|
||||
// case and if it's secondary-domain -> primary-domain, we don't
|
||||
// case and if it's secondary-origin -> primary-origin, we don't
|
||||
// recognize the request as cross-origin
|
||||
return (
|
||||
!!ctx.req.isAUTFrame &&
|
||||
@@ -456,18 +456,18 @@ const CopyCookiesFromIncomingRes: ResponseMiddleware = function () {
|
||||
const cookies: string | string[] | undefined = this.incomingRes.headers['set-cookie']
|
||||
|
||||
if (cookies) {
|
||||
const needsMultiDomainHandling = (
|
||||
const needsCrossOriginHandling = (
|
||||
this.config.experimentalLoginFlows
|
||||
&& determineIfNeedsMultiDomainHandling(this)
|
||||
&& determineIfNeedsCrossOriginHandling(this)
|
||||
)
|
||||
const browser = this.getCurrentBrowser() || { family: null }
|
||||
const url = new URL(this.req.proxiedUrl)
|
||||
const isLocalhost = uri.isLocalhost(url)
|
||||
|
||||
debug('force SameSite=None?', needsMultiDomainHandling)
|
||||
debug('force SameSite=None?', needsCrossOriginHandling)
|
||||
|
||||
;([] as string[]).concat(cookies).forEach((cookie) => {
|
||||
if (needsMultiDomainHandling) {
|
||||
if (needsCrossOriginHandling) {
|
||||
cookie = ensureSameSiteNone({ cookie, browser, isLocalhost, url })
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ export default {
|
||||
AttachPlainTextStreamFn,
|
||||
InterceptResponse,
|
||||
PatchExpressSetHeader,
|
||||
MaybeDelayForMultiDomain,
|
||||
MaybeDelayForCrossOrigin,
|
||||
SetInjectionLevel,
|
||||
OmitProblematicHeaders,
|
||||
MaybePreventCaching,
|
||||
|
||||
@@ -12,7 +12,7 @@ export type HttpBuffer = {
|
||||
response: IncomingMessage
|
||||
stream: Readable
|
||||
url: string
|
||||
isMultiDomain: boolean
|
||||
isCrossOrigin: boolean
|
||||
}
|
||||
|
||||
const stripPort = (url) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { oneLine } from 'common-tags'
|
||||
import { getRunnerInjectionContents, getRunnerMultiDomainInjectionContents } from '@packages/resolve-dist'
|
||||
import { getRunnerInjectionContents, getRunnerCrossOriginInjectionContents } from '@packages/resolve-dist'
|
||||
|
||||
export function partial (domain) {
|
||||
return oneLine`
|
||||
@@ -21,8 +21,8 @@ export function full (domain) {
|
||||
})
|
||||
}
|
||||
|
||||
export function fullMultiDomain (domain) {
|
||||
return getRunnerMultiDomainInjectionContents().then((contents) => {
|
||||
export function fullCrossOrigin (domain) {
|
||||
return getRunnerCrossOriginInjectionContents().then((contents) => {
|
||||
return oneLine`
|
||||
<script type='text/javascript'>
|
||||
document.domain = '${domain}';
|
||||
|
||||
@@ -29,8 +29,8 @@ function getHtmlToInject ({ domainName, wantsInjection }: InjectionOpts) {
|
||||
switch (wantsInjection) {
|
||||
case 'full':
|
||||
return inject.full(domainName)
|
||||
case 'fullMultiDomain':
|
||||
return inject.fullMultiDomain(domainName)
|
||||
case 'fullCrossOrigin':
|
||||
return inject.fullCrossOrigin(domainName)
|
||||
case 'partial':
|
||||
return inject.partial(domainName)
|
||||
default:
|
||||
|
||||
@@ -15,7 +15,7 @@ export type CypressIncomingRequest = Request & {
|
||||
isAUTFrame: boolean
|
||||
}
|
||||
|
||||
export type CypressWantsInjection = 'full' | 'fullMultiDomain' | 'partial' | false
|
||||
export type CypressWantsInjection = 'full' | 'fullCrossOrigin' | 'partial' | false
|
||||
|
||||
/**
|
||||
* An outgoing response to an incoming request to the Cypress web server.
|
||||
|
||||
@@ -62,7 +62,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/', isMultiDomain: false } as HttpBuffer
|
||||
const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: false } as HttpBuffer
|
||||
|
||||
buffers.set(buffer)
|
||||
|
||||
@@ -80,9 +80,9 @@ describe('http/request-middleware', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('sets wantsInjection to fullMultiDomain when a multi-domain request is buffered', async () => {
|
||||
it('sets wantsInjection to fullCrossOrigin when a cross origin request is buffered', async () => {
|
||||
const buffers = new HttpBuffers()
|
||||
const buffer = { url: 'https://www.cypress.io/', isMultiDomain: true } as HttpBuffer
|
||||
const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: true } as HttpBuffer
|
||||
|
||||
buffers.set(buffer)
|
||||
|
||||
@@ -96,13 +96,13 @@ describe('http/request-middleware', () => {
|
||||
|
||||
await testMiddleware([MaybeEndRequestWithBufferedResponse], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.res.wantsInjection).to.equal('fullMultiDomain')
|
||||
expect(ctx.res.wantsInjection).to.equal('fullCrossOrigin')
|
||||
})
|
||||
})
|
||||
|
||||
it('wantsInjection is not set when the request is not buffered', async () => {
|
||||
const buffers = new HttpBuffers()
|
||||
const buffer = { url: 'https://www.cypress.io/', isMultiDomain: true } as HttpBuffer
|
||||
const buffer = { url: 'https://www.cypress.io/', isCrossOrigin: true } as HttpBuffer
|
||||
|
||||
buffers.set(buffer)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('http/response-middleware', function () {
|
||||
'AttachPlainTextStreamFn',
|
||||
'InterceptResponse',
|
||||
'PatchExpressSetHeader',
|
||||
'MaybeDelayForMultiDomain',
|
||||
'MaybeDelayForCrossOrigin',
|
||||
'SetInjectionLevel',
|
||||
'OmitProblematicHeaders',
|
||||
'MaybePreventCaching',
|
||||
@@ -130,14 +130,14 @@ describe('http/response-middleware', function () {
|
||||
}
|
||||
})
|
||||
|
||||
describe('MaybeDelayForMultiDomain', function () {
|
||||
const { MaybeDelayForMultiDomain } = ResponseMiddleware
|
||||
describe('MaybeDelayForCrossOrigin', function () {
|
||||
const { MaybeDelayForCrossOrigin } = ResponseMiddleware
|
||||
let ctx
|
||||
|
||||
it('doesn\'t do anything when not html or rendered html', function () {
|
||||
prepareContext({})
|
||||
|
||||
return testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
return testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.serverBus.emit).not.to.be.called
|
||||
})
|
||||
@@ -152,7 +152,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
return testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
return testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.serverBus.emit).not.to.be.called
|
||||
})
|
||||
@@ -167,7 +167,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
return testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
return testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.serverBus.emit).not.to.be.called
|
||||
})
|
||||
@@ -190,7 +190,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
return testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
return testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.serverBus.emit).not.to.be.called
|
||||
})
|
||||
@@ -213,7 +213,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
const promise = testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
const promise = testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
|
||||
expect(ctx.serverBus.emit).to.be.calledWith('cross:origin:delaying:html', { href: 'http://www.idp.com/test' })
|
||||
|
||||
@@ -238,7 +238,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
const promise = testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
const promise = testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
|
||||
expect(ctx.serverBus.emit).to.be.calledWith('cross:origin:delaying:html', { href: 'http://www.foobar.com/test' })
|
||||
|
||||
@@ -264,7 +264,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
const promise = testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
const promise = testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
|
||||
expect(ctx.serverBus.emit).to.be.calledWith('cross:origin:delaying:html', { href: 'http://www.foobar.com/test' })
|
||||
|
||||
@@ -290,7 +290,7 @@ describe('http/response-middleware', function () {
|
||||
},
|
||||
})
|
||||
|
||||
const promise = testMiddleware([MaybeDelayForMultiDomain], ctx)
|
||||
const promise = testMiddleware([MaybeDelayForCrossOrigin], ctx)
|
||||
|
||||
expect(ctx.serverBus.emit).to.be.calledWith('cross:origin:delaying:html', { href: 'http://www.idp.com/test' })
|
||||
|
||||
@@ -421,7 +421,7 @@ describe('http/response-middleware', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('injects "fullMultiDomain" when "experimentalLoginFlows" config flag is set to true for cross-domain html"', function () {
|
||||
it('injects "fullCrossOrigin" when "experimentalLoginFlows" config flag is set to true for cross-origin html"', function () {
|
||||
prepareContext({
|
||||
req: {
|
||||
proxiedUrl: 'http://foobar.com',
|
||||
@@ -442,11 +442,11 @@ describe('http/response-middleware', function () {
|
||||
|
||||
return testMiddleware([SetInjectionLevel], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.res.wantsInjection).to.equal('fullMultiDomain')
|
||||
expect(ctx.res.wantsInjection).to.equal('fullCrossOrigin')
|
||||
})
|
||||
})
|
||||
|
||||
it('injects "fullMultiDomain" when request is in origin stack for cross-domain html"', function () {
|
||||
it('injects "fullCrossOrigin" when request is in origin stack for cross-origin html"', function () {
|
||||
prepareContext({
|
||||
req: {
|
||||
proxiedUrl: 'http://example.com',
|
||||
@@ -467,7 +467,7 @@ describe('http/response-middleware', function () {
|
||||
|
||||
return testMiddleware([SetInjectionLevel], ctx)
|
||||
.then(() => {
|
||||
expect(ctx.res.wantsInjection).to.equal('fullMultiDomain')
|
||||
expect(ctx.res.wantsInjection).to.equal('fullCrossOrigin')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export const getRunnerInjectionContents = () => {
|
||||
return getRunnerContents('injection.js')
|
||||
}
|
||||
|
||||
export const getRunnerMultiDomainInjectionContents = () => {
|
||||
export const getRunnerCrossOriginInjectionContents = () => {
|
||||
return getRunnerContents('injection_multi_domain.js')
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ mainConfig.resolve = {
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const multiDomainConfig: webpack.Configuration = {
|
||||
const crossOriginConfig: webpack.Configuration = {
|
||||
mode: 'development',
|
||||
...getSimpleConfig(),
|
||||
entry: {
|
||||
@@ -110,7 +110,7 @@ const mainInjectionConfig: webpack.Configuration = {
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
const multiDomainInjectionConfig: webpack.Configuration = {
|
||||
const crossOriginInjectionConfig: webpack.Configuration = {
|
||||
...getSimpleConfig(),
|
||||
mode: 'production',
|
||||
entry: {
|
||||
@@ -125,6 +125,6 @@ const multiDomainInjectionConfig: webpack.Configuration = {
|
||||
export default [
|
||||
mainConfig,
|
||||
mainInjectionConfig,
|
||||
multiDomainConfig,
|
||||
multiDomainInjectionConfig,
|
||||
crossOriginConfig,
|
||||
crossOriginInjectionConfig,
|
||||
]
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
handleMultiDomainIframe (req, res) {
|
||||
handleCrossOriginIframe (req, res) {
|
||||
const iframePath = cwd('lib', 'html', 'multi-domain-iframe.html')
|
||||
const domain = req.hostname
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ export class RemoteStates {
|
||||
return this.get(this.originStack[this.originStack.length - 1]) as Cypress.RemoteState
|
||||
}
|
||||
|
||||
set (urlOrState: string | Cypress.RemoteState, options: { auth?: {}, isMultiDomain?: boolean } = {}): Cypress.RemoteState {
|
||||
set (urlOrState: string | Cypress.RemoteState, options: { auth?: {}, isCrossOrigin?: boolean } = {}): Cypress.RemoteState {
|
||||
let state
|
||||
|
||||
if (_.isString(urlOrState)) {
|
||||
@@ -119,7 +119,7 @@ export class RemoteStates {
|
||||
|
||||
const remoteOriginPolicy = cors.getOriginPolicy(state.origin)
|
||||
|
||||
if (options.isMultiDomain) {
|
||||
if (options.isCrossOrigin) {
|
||||
this.remoteStates.set(remoteOriginPolicy, state)
|
||||
} else {
|
||||
// convert map to array
|
||||
@@ -153,7 +153,7 @@ export class RemoteStates {
|
||||
// since this is just the cy.origin starting, we don't want to override
|
||||
// the existing origin if it already exists
|
||||
if (!existingOrigin) {
|
||||
this.set(originPolicy, { isMultiDomain: true })
|
||||
this.set(originPolicy, { isCrossOrigin: true })
|
||||
}
|
||||
|
||||
this.addOrigin(originPolicy)
|
||||
|
||||
@@ -132,7 +132,7 @@ export const createRoutesE2E = ({
|
||||
routesE2E.get('/__cypress/multi-domain-iframes', (req, res) => {
|
||||
debug('handling multi-domain iframe for domain: %s', req.hostname)
|
||||
|
||||
files.handleMultiDomainIframe(req, res)
|
||||
files.handleCrossOriginIframe(req, res)
|
||||
})
|
||||
|
||||
return routesE2E
|
||||
|
||||
@@ -313,7 +313,7 @@ export class ServerE2E extends ServerBase<SocketE2E> {
|
||||
details,
|
||||
originalUrl,
|
||||
response: incomingRes,
|
||||
isMultiDomain: options.isMultiDomain,
|
||||
isCrossOrigin: options.isCrossOrigin,
|
||||
})
|
||||
} else {
|
||||
// TODO: move this logic to the driver too for
|
||||
@@ -331,7 +331,7 @@ export class ServerE2E extends ServerBase<SocketE2E> {
|
||||
}
|
||||
|
||||
const restorePreviousRemoteState = (previousRemoteState: Cypress.RemoteState, previousRemoteStateIsPrimary: boolean) => {
|
||||
this.remoteStates.set(previousRemoteState, { isMultiDomain: !previousRemoteStateIsPrimary })
|
||||
this.remoteStates.set(previousRemoteState, { isCrossOrigin: !previousRemoteStateIsPrimary })
|
||||
}
|
||||
|
||||
// if they're POSTing an object, querystringify their POST body
|
||||
|
||||
@@ -906,7 +906,7 @@ describe('Server', () => {
|
||||
})
|
||||
})
|
||||
|
||||
context('multi-domain', () => {
|
||||
context('cross-origin', () => {
|
||||
it('adds a secondary remote state', function () {
|
||||
nock('http://www.cypress.io/')
|
||||
.get('/')
|
||||
@@ -940,7 +940,7 @@ describe('Server', () => {
|
||||
|
||||
expect(this.server.remoteStates.isSecondaryOrigin('http://cypress.io')).to.be.true
|
||||
|
||||
return this.server._onResolveUrl('http://www.cypress.io/', {}, this.automationRequest, { isMultiDomain: true })
|
||||
return this.server._onResolveUrl('http://www.cypress.io/', {}, this.automationRequest, { isCrossOrigin: true })
|
||||
.then((obj = {}) => {
|
||||
expectToEqDetails(obj, {
|
||||
isOkStatusCode: true,
|
||||
@@ -954,11 +954,11 @@ describe('Server', () => {
|
||||
redirects: [],
|
||||
})
|
||||
|
||||
// Verify the multi-domain request was buffered
|
||||
// Verify the cross origin request was buffered
|
||||
const buffer = this.buffers.take('http://www.cypress.io/')
|
||||
|
||||
expect(buffer).to.not.be.empty
|
||||
expect(buffer.isMultiDomain).to.be.true
|
||||
expect(buffer.isCrossOrigin).to.be.true
|
||||
|
||||
// Verify the secondary remote state is returned
|
||||
expect(this.server.remoteStates.current()).to.deep.eq({
|
||||
@@ -999,7 +999,7 @@ describe('Server', () => {
|
||||
|
||||
this.server.socket.localBus.emit('ready:for:origin', { originPolicy: 'http://cypress.io' })
|
||||
|
||||
return this.server._onResolveUrl('http://www.cypress.io/', {}, this.automationRequest, { isMultiDomain: true })
|
||||
return this.server._onResolveUrl('http://www.cypress.io/', {}, this.automationRequest, { isCrossOrigin: true })
|
||||
.then(() => {
|
||||
// Verify the secondary remote state is returned
|
||||
expect(this.server.remoteStates.current()).to.deep.eq({
|
||||
@@ -1041,7 +1041,7 @@ describe('Server', () => {
|
||||
})
|
||||
|
||||
it('returns primary remote state', function () {
|
||||
this.server.remoteStates.set('http://www.cypress.io/', { isMultiDomain: true })
|
||||
this.server.remoteStates.set('http://www.cypress.io/', { isCrossOrigin: true })
|
||||
|
||||
expect(this.server.remoteStates.get('http://localhost:2000')).to.deep.eq({
|
||||
auth: undefined,
|
||||
@@ -1054,7 +1054,7 @@ describe('Server', () => {
|
||||
})
|
||||
|
||||
it('returns secondary remote state', function () {
|
||||
this.server.remoteStates.set('http://www.cypress.io/', { isMultiDomain: true })
|
||||
this.server.remoteStates.set('http://www.cypress.io/', { isCrossOrigin: true })
|
||||
|
||||
expect(this.server.remoteStates.get('http://cypress.io')).to.deep.eq({
|
||||
auth: undefined,
|
||||
|
||||
@@ -165,7 +165,7 @@ describe('remote states', () => {
|
||||
context('#current', () => {
|
||||
it('returns the remote state for the current origin in the stack', function () {
|
||||
this.eventEmitter.emit('ready:for:origin', { originPolicy: 'https://google.com' })
|
||||
this.remoteStates.set('https://staging.google.com/foo/bar', { isMultiDomain: true })
|
||||
this.remoteStates.set('https://staging.google.com/foo/bar', { isCrossOrigin: true })
|
||||
|
||||
const state = this.remoteStates.current()
|
||||
|
||||
@@ -185,10 +185,10 @@ describe('remote states', () => {
|
||||
})
|
||||
|
||||
context('#set', () => {
|
||||
it('sets primary state and origin when isMultiDomain is false', function () {
|
||||
it('sets primary state and origin when isCrossOrigin is false', function () {
|
||||
expect(this.remoteStates.isPrimaryOrigin('http://localhost:3500')).to.be.true
|
||||
|
||||
const state = this.remoteStates.set('https://staging.google.com/foo/bar', { isMultiDomain: false })
|
||||
const state = this.remoteStates.set('https://staging.google.com/foo/bar', { isCrossOrigin: false })
|
||||
|
||||
expect(state).to.deep.equal({
|
||||
auth: undefined,
|
||||
@@ -206,10 +206,10 @@ describe('remote states', () => {
|
||||
expect(this.remoteStates.isPrimaryOrigin('https://staging.google.com')).to.be.true
|
||||
})
|
||||
|
||||
it('sets a secondary state when isMultiDomain is true', function () {
|
||||
it('sets a secondary state when isCrossOrigin is true', function () {
|
||||
expect(this.remoteStates.isPrimaryOrigin('http://localhost:3500')).to.be.true
|
||||
|
||||
const state = this.remoteStates.set('https://staging.google.com/foo/bar', { isMultiDomain: true })
|
||||
const state = this.remoteStates.set('https://staging.google.com/foo/bar', { isCrossOrigin: true })
|
||||
|
||||
this.remoteStates.addOrigin('https://staging.google.com')
|
||||
|
||||
@@ -414,7 +414,7 @@ describe('remote states', () => {
|
||||
// simulate a cy.origin by calling ready:for:origin followed by setting
|
||||
// the origin with specific auth options and finally calling cross:origin:finished
|
||||
this.eventEmitter.emit('ready:for:origin', { originPolicy: 'http://cypress.io' })
|
||||
this.remoteStates.set('http://cypress.io', { auth: { username: 'u', password: 'p' }, isMultiDomain: true })
|
||||
this.remoteStates.set('http://cypress.io', { auth: { username: 'u', password: 'p' }, isCrossOrigin: true })
|
||||
currentState = this.remoteStates.current()
|
||||
expect(currentState.origin).to.equal('http://cypress.io')
|
||||
expect(currentState.auth).to.deep.equal({ username: 'u', password: 'p' })
|
||||
|
||||
Reference in New Issue
Block a user