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

Use window.top and window.top.document #294

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link
Contributor

This pull request is to break out of simple same-domain <iframe>s, i.e. when rrweb.js is loaded from within the iframe.

This is the case for GoDaddy.

I'm not sure whether this is generally a good idea for all of rrweb's users, so maybe it needs further consideration before being accepted?

@Juice10
Copy link
Contributor

Juice10 commented Aug 20, 2020

Great work eoghanmurray!
I’m wondering if this could potentially work cross-domain, for example in electron if rrweb is injected in all the iframes.

@eoghanmurray eoghanmurray force-pushed the window-top branch 3 times, most recently from 136f8df to c42cfb5 Compare August 21, 2020 13:12
@eoghanmurray
Copy link
Contributor Author

@Juice10 I hadn't envisioned that usecase and haven't tested that.

I just came across this since reading your comment:
rrweb-io/rrweb-snapshot#10
Maybe that is unrelated?

Do you have a chance to test out what would happen with multiple iframes in the same document?

@Juice10
Copy link
Contributor

Juice10 commented Aug 25, 2020

I just came across this since reading your comment:
rrweb-io/rrweb-snapshot#10
Maybe that is unrelated?

@eoghanmurray I'm not sure to be honest.

Do you have a chance to test out what would happen with multiple iframes in the same document?

Yes I'd be happy to, anything specific you'd like me to do? Just do a recording with this branch? Any specific pages you'd like me to try out?

One thing that might make electron based recording a little trickier is that every iframe/browser-window has its own rrweb.record({ emit(event) { /* send to central location */ } }); so electron receives events from multiple pages at the same time without knowing which one is which.

@eoghanmurray
Copy link
Contributor Author

The electron (https://www.electronjs.org/ ?) application of rrweb is definitely not on my radar, I was only thinking of the web; so I guess a run through it's paces would be great to make sure this change doesn't break things there.

@eoghanmurray
Copy link
Contributor Author

Should this be a configuration option for it to be accepted?

@eoghanmurray
Copy link
Contributor Author

Does #481 change it so that it starts with the top level document, or is it just in whatever document that rrweb is initiated?

rrweb/src/record/index.ts

Lines 439 to 442 in 1dd91f0

const init = () => {
takeFullSnapshot();
handlers.push(observe(document));
};

I think the latter is the case so maybe this pull request is still relevant?

@eoghanmurray
Copy link
Contributor Author

eoghanmurray commented Sep 29, 2021

I've done a full rework as this PR was originally authored before we had nested iframe support (#481)

This is also based on #716, although that is still in progress, as they are related.

Now with a working test!

…rent environments (I can't see how the `positions` attribute is normalised away in record.test.ts if indeed it is)
@vlazdimir vlazdimir mentioned this pull request Jul 28, 2022
@samber
Copy link
Contributor

samber commented Oct 10, 2022

Any update regarding this PR?

How can we move things forward?

I wonder if it would be better to add window as a property of recordOptions? 🤔 It would let the developer pick the right window: window, window.parent, window.top or child iframe.

@eoghanmurray
Copy link
Contributor Author

I wonder if it would be better to add window as a property of recordOptions? thinking It would let the developer pick the right window: window, window.parent, window.top or child iframe.

I think both will be good, but I think it should default to the highest window it can find

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.

3 participants