Skip to content

Commit

Permalink
fix: firefox 93 error issues (#20695)
Browse files Browse the repository at this point in the history
* don't fail serialization in cases properties are inaccessable due to implementation contraints

* gracefully fail element lookups in case of cross origin stale documents to prevent unwanted failures

* reset window and document when spec bridge exits

* test in firefox

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

Co-authored-by: mjhenkes <mjhenkes@gmail.com>
  • Loading branch information
AtofStryker and mjhenkes authored Mar 22, 2022
1 parent f638ba7 commit 89c0091
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ describe('errors', { experimentalSessionSupport: true }, () => {
.should('equal', 'Welcome BJohnson')
})

// TODO: run in firefox too after we fix error serialization for firefox.
it('fails in switchToDomain when a command is run after we return to localhost', { browser: '!firefox', defaultCommandTimeout: 50 }, (done) => {
it('fails in switchToDomain 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: Expected to find element: \`[data-cy="cannot_find"]\`, but never found it`)
// make sure that the secondary domain failures do NOT show up as spec failures or AUT failures
Expand Down
2 changes: 2 additions & 0 deletions packages/driver/src/multi-domain/cypress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ const onBeforeAppWindowLoad = (Cypress: Cypress.Cypress, cy: $Cy) => (autWindow:
Cypress.specBridgeCommunicator.off('window:load', onWindowLoadPrimary)
},
onUnload (e) {
cy.state('window', undefined)
cy.state('document', undefined)
// We only need to listen to this if we've started an unload event and the load happens in another spec bridge.
Cypress.specBridgeCommunicator.once('window:load', onWindowLoadPrimary)

Expand Down
17 changes: 15 additions & 2 deletions packages/driver/src/util/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,21 @@ const convertObjectToSerializableLiteral = (obj): typeof obj => {
const props = Object.getOwnPropertyNames(currentObjectRef)

props.forEach((prop: string) => {
if (!allProps.includes(prop) && isSerializableInCurrentBrowser(currentObjectRef[prop])) {
allProps.push(prop)
try {
if (!allProps.includes(prop) && isSerializableInCurrentBrowser(currentObjectRef[prop])) {
allProps.push(prop)
}
} catch (err) {
/**
* In some browsers, properties of objects on the prototype chain point to the implementation object.
* Depending on implementation constraints, these properties may throw an error when accessed.
*
* ex: DOMException's prototype is Error, and calling the 'name' getter on DOMException's prototype
* throws a TypeError since Error does not implement the DOMException interface.
*/
if (err?.name !== 'TypeError') {
throw err
}
}
})

Expand Down

0 comments on commit 89c0091

Please sign in to comment.