Skip to content

Conversation

@igobranco
Copy link
Member

@igobranco igobranco commented Dec 12, 2025

Cherry pick from upstream of the commit be5a625e64570eb083483bd530462598fca4e891.

Fixed a SecurityError that occurred when Google Tag Manager was enabled
and the Authoring MFE embedded Studio content in an iframe.

The bug was in cms/templates/container_chromeless.html where the resize
script used window.parent[0].offsetHeight to get initial dimensions.
When GTM is present, window.parent[0] references GTM's cross-origin
iframe instead of the parent window, causing a cross-origin security
error: "Failed to read a named property 'offsetHeight' from 'Window'".

Changed to use document.documentElement.scrollHeight and
document.documentElement.scrollWidth to get the current document's
dimensions directly, avoiding cross-origin frame access entirely.

This allows the Authoring MFE to function correctly with Google Tag
Manager and other third-party scripts that inject iframes.

- It's related previous PR: https://github.com/openedx/edx-platform/pull/36643/files.
- This time followed LMS template(https://github.com/openedx/edx-platform/blob/5b3caa93e218e38e7459bdc1ff99ee175e93a22b/lms/templates/courseware/courseware-chromeless.html#L126C7-L127C42) as we are not getting any error on LMS.

Attaching error for context:
`Uncaught SecurityError: Failed to read a named property 'offsetHeight' from 'Window': Blocked a frame with origin "https://studio.stage.edx.org/" from accessing a cross-origin frame.`
@igobranco igobranco force-pushed the igobranco/issues/661/fix-studio-embed-content-tag-manager branch from b670341 to a03c986 Compare December 12, 2025 17:06
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.

2 participants