Skip to content

Console error in Email preview in the Magento admin #37820

Open
@bosskar231

Description

@bosskar231

Summary

Preconditions and environment
Getting a console error in all magento environment in version 2.4.6

Steps to reproduce
Fresh Install of M2.4.6 in environment as above
Login to backend

Nav to Admin>Marketing>Email Templates>click preview
Open developer options and you can able to find a error in the console.

Bocked script execution in 'http://localmagento/index.php/admin/admin/email_template/popup/key/53379463b63d4ed7911eaf8d8aa133d7f186826b20ecfbf01cf5d5ec5c8e349f/' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

2023-08-01_12-12

Examples

We checked the code and found this phtml under the path

vendor/magento/module-email/view/adminhtml/templates/preview/iframeswitcher.phtml

Proposed solution

<iframe name="preview_iframe"
           id="preview_iframe"
           frameborder="0"
           title="<?= $block->escapeHtmlAttr(__('Preview')) ?>"
           width="100%"
           sandbox="allow-same-origin allow-pointer-lock"
   ></iframe>

In the above code snippet you can find sandbox attribute, In which if we add allow-scripts value with other allow-same-origin and allow-pointer-lock. After adding the allow scripts the console error is not occuring in the preview templates.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Labels

Area: Other Developer ToolsComponent: EmailIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: PR in progressReported on 2.4.6Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions