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

Wrap getContainerRenderWindow loop in try/catch #801

Closed
wants to merge 1 commit into from
Closed

Wrap getContainerRenderWindow loop in try/catch #801

wants to merge 1 commit into from

Conversation

itsjoekent
Copy link

Fixes #798

@casesandberg Can you merge + publish this? This is causing our application to fail in production

Comment on lines +23 to +27
try {
while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
renderWindow = renderWindow.parent
}
} catch (error) {}
Copy link

@lixun910 lixun910 Oct 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@casesandberg @itsjoekent For cross-domain error, the renderWindow.document will raise DOMException. At this point, is the renderWindow already an invalid object, which can not be returned?

This works on my test:

    let renderWindow = window
    let lastRenderWindow = window
    try {
        while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
          lastRenderWindow = renderWindow
          renderWindow = renderWindow.parent
        }
      } catch(error) {
        // handle possible cross-origin error, if happens then use current window in frame
      }
      return lastRenderWindow

#806

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For cross-domain error , it's cannot access renderWindow.document when renderWindow is parent iframe

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue #806 , Request resolution

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use it in inner iframe, when cross-domain, 'renderWindow.document' will throw error, please reconfirm and repair

@jdsxzhao
Copy link

When can this pr be merged? The problem mentioned in the issue #806 is still causing crashes!

@itsjoekent itsjoekent closed this by deleting the head repository Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: A security error occurred and caused a crash when used in a different source iframe
4 participants