Add emitFromIframe option to support iframe in iframe#1726
Add emitFromIframe option to support iframe in iframe#1726ppsreejith wants to merge 1 commit intorrweb-io:masterfrom
Conversation
|
512f809 to
bbb0aaf
Compare
bbb0aaf to
3328fcf
Compare
| recordDOM = true, | ||
| recordCanvas = false, | ||
| recordCrossOriginIframes = false, | ||
| emitFromIframe = false, |
There was a problem hiding this comment.
since you could have more than one nested iframe that you want to record but will only ever have one parent, i wonder if it makes more sense to have a isParentIframe or isRootIframe instead
config then gets slightly simpler
pauldambra
left a comment
There was a problem hiding this comment.
i don't know if there are already tests on the iframe behaviour but since this would let us break the behaviour we should probably add some tests that when "i am a parent" config is set it emits and when "i am an iframe" config is set it passes the message up to the parent
|
I think this is a great idea! Thank you for contributing.
Yes I'd like to echo @pauldambra's comments about tests, they are really important in this situation. Also I'm not sure about the naming of these things at the moment, might have to think some more about this. Thanks for contributing though, I definitely think this should be part of rrweb |
Thank you for maintaining rrweb and supporting the modern web dev tooling ecosystem
Description
This PR introduces a new
emitFromIframeboolean in rrweb'srecordOptionsthat allows iframe-in-iframe monitoring when hosted in a parent that doesn't have rrweb.Problem
Consider a "host website" (which doesn't have rrweb) which hosts a "parent iframe" (which has rrweb) which nests another "child iframe" (which also has rrweb).
Currently, the
recordCrossOriginIframesoption would need to be enabled in rrweb in both parent and child iframes in order to monitor iframe-in-iframe traffic correctly. However we cannot monitor the parent iframe as therecordCrossOriginIframesoption is ALSO used to pass all events to the host website since the parent iframe is not the top level page. i.e: TherecordCrossOriginIframesis used for both receiving events from a child iframe and passing those events without recording, to the host website.Thus the parent iframe will emit events to the host website since
recordCrossOriginIframesis true and the host website will ignore these events as it doesn't have rrweb.Solution
Adding a
emitFromIframeoption allows the parent iframe to record events directly without passing events to the host website while usingrecordCrossOriginIframesto collect events from child iframes.Status
This is a proof-of-concept but it should already work in production. I would like to get feedback on whether this is something that aligns with the rrweb team's roadmap before investing more effort in adding documentation and tests.