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

Add the Sandbox for the iFrame #189

Closed
wants to merge 16 commits into from

Conversation

KambleSonam
Copy link
Collaborator

@KambleSonam KambleSonam commented Feb 9, 2024

  • Add the sandbox for the iframe created for Web Popup and Exit Intents
  • Pass html directly as srcdoc to iframe

@KambleSonam KambleSonam changed the title iframe sandbox Add the Sandbox for the iFrame Feb 12, 2024
@PraveenCTzen PraveenCTzen marked this pull request as draft March 1, 2024 09:54
src/util/tr.js Outdated Show resolved Hide resolved
src/util/tr.js Outdated Show resolved Hide resolved
src/util/tr.js Outdated Show resolved Hide resolved
src/util/tr.js Outdated Show resolved Hide resolved
src/util/tr.js Outdated Show resolved Hide resolved
src/util/tr.js Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

please delete all the commented out code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@AmeeParsania AmeeParsania left a comment

Choose a reason for hiding this comment

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

Please update the description with relevant details.


iframe.setAttribute('style', 'z-index: 2147483647; display:block; width: 100% !important; border:0px !important; border-color:none !important;')
// made height : 100% which will help in adjustIframe height
iframe.setAttribute('style', 'z-index: 2147483647; display:block; width: 100% !important; height:100%; border:0px !important; border-color:none !important;')
Copy link
Contributor

Choose a reason for hiding this comment

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

check for regressions

src/util/tr.js Outdated
@@ -436,6 +436,9 @@ const _tr = (msg, {
iframe.marginwidth = '0px'
iframe.scrolling = 'no'
iframe.id = 'wiz-iframe'
if (displayObj['custom-editor']) { // sandboxing the iframe only for custom html
iframe.sandbox = 'allow-scripts allow-popups allow-popups-to-escape-sandbox' // allow popup to open url in new page
Copy link
Contributor

Choose a reason for hiding this comment

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

src/util/tr.js Outdated
adjustIFrameHeight()
const contentDiv = document.getElementById('wiz-iframe').contentDocument.getElementById('contentDiv')
setupClickUrl(onClick, targetingMsgJson, contentDiv, divId, legacy)
if (displayObj['custom-editor']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

with your current changes looks like we are not calling adjustIFrameHeight() fn for form based templates. Is that the case ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Added support for form based templates

src/util/tr.js Outdated
const contentDiv = document.getElementById('wiz-iframe').contentDocument.getElementById('contentDiv')
setupClickUrl(onClick, targetingMsgJson, contentDiv, divId, legacy)
iframe.onload = () => {
if (displayObj['custom-editor']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

lot of code duplication. please optimise

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes done!

src/util/tr.js Outdated
contentDiv = document.getElementById('contentDiv')
let contentHeight = contentDiv.scrollHeight
contentDiv.style.height = '100%'
// if (displayObj['custom-editor'] !== true && !isBanner) { //It will always be custom-editor.
Copy link
Contributor

Choose a reason for hiding this comment

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

remove commented code

Copy link
Contributor

Choose a reason for hiding this comment

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

Done!

src/util/tr.js Outdated Show resolved Hide resolved
src/util/tr.js Outdated
}
})
}
setupClickUrl(onClick, targetingMsgJson, '', divId, legacy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you verified if the clicks get tracked correctly for form based templates? I think it might break coz we are passing an empty string as a part of contentDiv

Copy link
Contributor

Choose a reason for hiding this comment

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

Added support for form based templates as well

src/util/tr.js Outdated
const contentDiv = document.getElementById('wiz-iframe-intent').contentDocument.getElementById('contentDiv')
setupClickUrl(onClick, targetingMsgJson, contentDiv, 'intentPreview', legacy)
iframe.onload = () => {
window.addEventListener('message', event => {
Copy link
Contributor

Choose a reason for hiding this comment

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

If multiple custom html campaigns are rendered on a page, by doing the above, wouldn't we end up adding multiple message listeners on the page, in turn raising duplicate notification clicked events??

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed duplicate notification clicked events issue!

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.

4 participants