Skip to content

Failed to read the 'contentDocument' property on older browsers => broken page #14313

Closed
getsentry/rrweb
#222
@jlowcs

Description

@jlowcs

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

8.36.0

Framework Version

react 18.3.1

Link to Sentry event

https://changeorg.sentry.io/issues/6048039184/events/9fa3cc0ed21f4efab1dd24971ce140b0/

Reproduction Example/SDK Setup

No response

Steps to Reproduce

Hard to say.

We are noticing some Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "..." errors coming from older browsers. This results in a broken page for us.

My guess is that those older browsers are throwing a SecurityError instead of returning null when accessing a iframe.contentDocument on an iframe that is hiding its content to Sentry (in this case a Stripe iframe).

This specific error is coming from this line, but there might be other instances of this accessor within the Sentry code.

Image

Expected Result

Sentry should catch that error instead of letting it bubble.

Something like this:

function getIframeContentDocument(n) {
  try {
    return n.contentDocument;
  } catch (e) {
    return null;
  }
}
const iframeDoc = getIframeContentDocument(n)

Actual Result

Error is thrown and is breaking the page.

Metadata

Metadata

Assignees

Labels

Package: reactIssues related to the Sentry React SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions