Skip to content

Commit

Permalink
don't signal stable if cross-origin w/o multi-domain api use
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Jan 3, 2022
1 parent e2d7113 commit c9c963d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/driver/src/cypress/cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ export class $Cy implements ITimeouts, IStability, IAssertions, IRetries, IJQuer
}

initialize ($autIframe) {
const signalStable = () => {
this.isStable(true, 'load')
}

this.state('$autIframe', $autIframe)

// dont need to worry about a try/catch here
Expand Down Expand Up @@ -504,20 +508,23 @@ export class $Cy implements ITimeouts, IStability, IAssertions, IRetries, IJQuer
// about:blank in a visit, we do need these
this.contentWindowListeners(autWindow)

// stability is signalled after the window:load event to give event
// listeners time to be invoked prior to moving on, but not if
// there is cross-origin error and the multi-domain APIs are
// not utilized
try {
this.Cypress.action('app:window:load', this.state('window'))

signalStable()
} catch (err) {
// this catches errors thrown by user-registered event handlers
// for `window:load`. this is used in the `catch` below so they
// aren't mistaken as cross-origin errors
err.isFromWindowLoadEvent = true

signalStable()

throw err
} finally {
// we are now stable again which is purposefully
// the last event we call here, to give our event
// listeners time to be invoked prior to moving on
this.isStable(true, 'load')
}
} catch (err) {
if (err.isFromWindowLoadEvent) {
Expand Down Expand Up @@ -546,7 +553,7 @@ export class $Cy implements ITimeouts, IStability, IAssertions, IRetries, IJQuer
// elsewhere to handle running cross-domain, so don't fail
// because of it
if (this.state('readyForMultidomain')) {
this.isStable(true, 'load')
signalStable()

return
}
Expand Down

0 comments on commit c9c963d

Please sign in to comment.