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: firefox 93 error issues #20695

Merged
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