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: avoid focusing already removed iframe(closes #2178) #2750

Merged
merged 1 commit into from Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/client/sandbox/event/focus-blur.ts
Expand Up @@ -291,6 +291,11 @@ export default class FocusBlurSandbox extends SandboxBase {
!styleUtils.isElementInInvisibleIframe(el);
const elDocument = (el[INTERNAL_PROPS.processedContext] || this.window).document;

// NOTE: In some cases focus event can be raised for the element in the iframe at the moment when the iframe is removed from the document.
// For example, in React application by its internal mechanism: https://github.com/DevExpress/testcafe-hammerhead/issues/2178
if(!elDocument.defaultView)
return null;

if (!raiseEventInIframe || isNativeFocus && !styleUtils.isElementVisible(el, elDocument))
return null;

Expand Down