Skip to content

Commit b1457f7

Browse files
committed
Loading a cross domain page won't happen until the spec bridge is active (or a timeout will happen)
1 parent 85f6d6a commit b1457f7

File tree

4 files changed

+2
-44
lines changed

4 files changed

+2
-44
lines changed

packages/driver/cypress/integration/e2e/multi-domain/navigation_spec.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -237,27 +237,3 @@ describe('delayed navigation', { experimentalSessionSupport: true, defaultComman
237237
})
238238
})
239239
})
240-
241-
// @ts-ignore / session support is needed for visiting about:blank between tests
242-
describe('sub domain window loads before multi-domain command', { experimentalSessionSupport: true }, () => {
243-
beforeEach(() => {
244-
cy.visit('/fixtures/multi-domain.html')
245-
cy.get('a[data-cy="multi-domain-secondary-link"]').click()
246-
})
247-
248-
it('establish a foobar spec bridge', () => {
249-
cy.switchToDomain('http://foobar.com:3500', () => {
250-
cy.get('a[data-cy="multi-domain-page"]')
251-
})
252-
})
253-
254-
it('page load before switchToDomain command when spec bridge is already established', () => {
255-
return new Promise<void>((resolve) => {
256-
setTimeout(() => {
257-
cy.switchToDomain('http://foobar.com:3500', () => {
258-
cy.get('a[data-cy="multi-domain-page"]')
259-
}).then(resolve)
260-
}, 2100)// this number should be larger than the delay cross origin domains.
261-
})
262-
})
263-
})

packages/driver/src/multi-domain/cypress.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ const onBeforeAppWindowLoad = (Cypress: Cypress.Cypress, cy: $Cy) => (autWindow:
100100
cy.overrides.wrapNativeMethods(autWindow)
101101

102102
const onWindowLoadPrimary = ({ url }) => {
103-
// If the primary domain has indicated a load event, set stability to undefined, not true since the load happened in another domain.
104-
cy.isStable(undefined, 'primary onload')
103+
cy.isStable(true, 'primary onload')
105104
Cypress.emit('internal:window:load', { type: 'cross:domain', url })
106105
}
107106

packages/driver/src/multi-domain/domain_fn.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,6 @@ const rehydrateRunnable = (data: serializedRunnable): Runnable|Test => {
5555

5656
export const handleDomainFn = (Cypress: Cypress.Cypress, cy: $Cy) => {
5757
const reset = (state) => {
58-
// If stability is true in this domain, that means this domain has loaded itself, in that case trust the domain and run the next command.
59-
// We also wish to preserve the stability state through the state refresh.
60-
if (cy.state('isStable')) {
61-
// If this state is stable there is a good chance that the primary domain was not listening, resend the load event.
62-
Cypress.specBridgeCommunicator.toPrimary('window:load', { url: cy.getRemoteLocation('href') })
63-
64-
state.isStable = true
65-
} else {
66-
// We specifically don't call 'cy.isStable' here because we don't want to inject another load event.
67-
if (state.isStable) {
68-
// If stability is established in a different domain, set this domain to undefined
69-
state.isStable = undefined
70-
}
71-
}
72-
7358
cy.reset({})
7459

7560
const stateUpdates = {

packages/runner-shared/src/event-manager.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,7 @@ export const eventManager = {
532532
// Only listen to window load events from the most recent secondary domain, This prevents nondeterminism in the case where we redirect to an already
533533
// established spec bridge, but one that is not the current or next switchToDomain command.
534534
if (cy.state('latestActiveDomain') === domain) {
535-
// Since stability was established in another domain set stable to undefined, not true. Undefined and true are treated the same stability.ts, but
536-
// it allows us to distinguish between a load event that ocurred in this domain and some that didn't (or the initial state)
537-
cy.isStable(undefined, 'load')
535+
cy.isStable(true, 'load')
538536
// Prints out the newly loaded URL
539537
Cypress.emit('internal:window:load', { type: 'cross:domain', url })
540538
}

0 commit comments

Comments
 (0)