Skip to content

Commit b77dc15

Browse files
Muhammad Faraz  MaqsoodMuhammad Faraz  Maqsood
authored andcommitted
fix: security issue
- 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.`
1 parent 5b3caa9 commit b77dc15

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

cms/templates/container_chromeless.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@
215215
// it will report the height of its contents to the parent window when the
216216
// document loads, window resizes, or DOM mutates.
217217
if (window !== window.parent) {
218-
var lastHeight = window.parent[0].offsetHeight;
219-
var lastWidth = window.parent[0].offsetWidth;
218+
var lastHeight = window.offsetHeight;
219+
var lastWidth = window.offsetWidth;
220220
var contentElement = document.getElementById('content');
221221

222222
function dispatchResizeMessage(event) {

common/templates/xblock_v2/xblock_iframe.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@
455455
// it will report the height of its contents to the parent window when the
456456
// document loads, window resizes, or DOM mutates.
457457
if (window !== window.parent) {
458+
var lastHeight = window.offsetHeight;
459+
var lastWidth = window.offsetWidth;
460+
458461
function dispatchResizeMessage(event) {
459462
// Note: event is actually an Array of MutationRecord objects when fired from the MutationObserver
460463
var newHeight = rootNode.scrollHeight;
@@ -469,6 +472,10 @@
469472
}
470473
}, document.referrer
471474
);
475+
476+
lastHeight = newHeight;
477+
lastWidth = newWidth;
478+
472479
// Within the authoring microfrontend the iframe resizes to match the
473480
// height of this document and it should never scroll. It does scroll
474481
// ocassionally when javascript is used to focus elements on the page

0 commit comments

Comments
 (0)