-
Notifications
You must be signed in to change notification settings - Fork 46.4k
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
DevTools: Improve browser extension iframe support #19854
Conversation
DevTools: Iframe support
if (canAccessParentWindow(target) && !isMainWindow(target)) { | ||
hook = getMainWindow(target).__REACT_DEVTOOLS_GLOBAL_HOOK__; | ||
} | ||
if (!hook) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I handle now the case if we don't have __REACT_DEVTOOLS_GLOBAL_HOOK__
in the parent window
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ae0bd28:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these changes fix the dev shell regression 👍
So I guess they're good to move forward with.
Thank you @bvaughn ! |
@omarsy I've built the extension from master |
@StanislavMayorov No you need any extra configuration. Can I see your code ? What kind of iframe do you use (sandbox or not) ? |
Your previous devtool work with iframe if you add if you add this code in your iframe
|
I don't have a demo that I can share right now. That's sandbox attr.
|
No, It didn't work for my app. |
In the case of the sandbox we cannot always access the parent's window (blocked by the browser for security reasons), that's why it doesn't work. My fix allows this script
to be done automatically. But this does not solve the problem of the sandbox. Maybe we can solve the case of sandboxed iframes but I think it is necessary to make a big refactoring and at the security level it remains a big question mark. |
Perhaps you have an iframe or ( main window) element in your props ? In this case, when we try to dehydrate the props, it causes this issue.
|
@bvaughn I think it’s not related to my merge. I can reproduce it. |
I don't have crash in this demo.
I'll check props as I know there is no element. |
@omarsy I just open your app and see error, even without react devtools. But I have following steps in my app:
result: it fails with error. |
Yes, normally if it was due to my change it would have crashed before the inspect (because we do several treatments with the window). I think you have a window in one of your props. I think i can have a PR for this issue |
If you are confident that the crash is not related to the previous iframe change, then you can submit a PR that reverts my revert. |
I can check current version with reverted PR. |
@StanislavMayorov You good to build and test this locally? (Let me know if you need me to build and attach a version here.) |
With the reverted PR you cannot inspect 'iframe react component' I think. We need to give you a quick fix for the window security crash + iframe support |
Couldn't you add the pass through (like in our fixtures) to test with the reverted DT? react/fixtures/devtools/regression/16.7.html Lines 8 to 12 in 6eca8ef
|
@bvaughn for this issue https://codesandbox.io/s/modest-moser-jg9x9?file=/src/index.js. Can I submit a PR ? |
Sorry @omarsy but I don't have time to dig into this at the moment. Please feel free to submit a PR if you think it's appropriate :) |
Okay, I have this changes in my app. I will test it. Should I use this version?
I have already built it using these steps https://github.com/facebook/react/tree/master/packages/react-devtools-extensions#build-from-source |
Yes I think you can use it |
I tested this version and added There's no error on inspector click, but react inspector doesn't work. It throw only an error on start: |
|
Iframe app doesn't have access to
|
What you say : |
What I'm saying is in the stacktrace, you can see that we have the issue when trying to desyhdrate props. So my understanding is that you should have a window element in your props because of this but maybe I'm wrong that's why I asked you to put in a debugger to see which props were causing the issue Well I'll stop investigating as I can see I'm not getting anywhere. |
You are right. There are two errors. I missed the error on start in console because react-error-overlay doesn't work at this stage. I update my comment about the test result. The fix adds script |
I will try to reproduce and debug props soon. Is it enough just to use |
That's fine. If you're testing in Chrome, the fastest way would be to run either yarn build:chrome && yarn test:chrome --url=<url-of-your-sandbox> |
Co-authored-by: Joel DSouza <joel.dsouza@kapturecrm.com> Co-authored-by: Damien Maillard <damien.maillard@dailymotion.com> Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
…19854)" (facebook#19959) This reverts commit a99bf5c.
Fixes #18945
Summary
Correct the issue caused by this PR #19827
Test Plan