question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DevTools: Improve browser extension iframe support

See original GitHub issue

When react is inside an iframe, chrome extension for react devtools fails to detect react.

This is because the extension sets __REACT_DEVTOOLS_GLOBAL_HOOK__ only on the top level window. Apparently it’s possible to have __REACT_DEVTOOLS_GLOBAL_HOOK__ on iframes too by adding all_frames: true in extension manifest.json. It was done by redux devtools extension in https://github.com/zalmoxisus/redux-devtools-extension/pull/56.

Have you considered adding all_frames: true to chrome extension ?

Steps To Reproduce

  1. Create a file react-main.html
<!DOCTYPE html>
<html>
  <head>
    <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  </head>
  <body></body>
</html>

  1. Create a file react-iframe.html
<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <iframe src="./react-main.html" />
  </body>
</html>
  1. Open react-iframe.html in chrome

The current behavior

react-devtools-not-detected

The expected behavior

react-devtools-detected

Pull request: https://github.com/facebook/react/pull/18952

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:42
  • Comments:53 (13 by maintainers)

github_iconTop GitHub Comments

6reactions
bvaughncommented, May 18, 2020

The frame limitation is mentioned in the docs, FWIW: https://github.com/facebook/react/tree/master/packages/react-devtools

It’s not a bug, just a known limitation. We currently suggest using the standalone version (as linked above) or (if you also control the iframe) passing the hook through from the parent: https://github.com/facebook/react/blob/d897c35ecfb7471b55e41933fd4d993b98dbf600/fixtures/devtools/regression/14.9.html#L9-L11

I don’t think that adding the Manifest setting you mentioned would be enough on its own to make the React DevTools extension detect and support versions of React running inside of iframes.

I’d be happy for you to take a shot at implementing it though if you’d like. We have a regression test that you could use to verify this:

./fixtures/devtools/regression/server.js
# Open localhost:3000 and see if DevTools detects React
5reactions
bvaughncommented, Jan 3, 2021

That’s why the issue is still open, @alleksei37.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using react dev tools inside iframe [In Chrome] - Stack Overflow
Solution suggested by the dev tools team: https://github.com/zalmoxisus/redux-devtools-extension/pull/56. "Adds the 'all_frames' option to the ...
Read more >
Extending DevTools with Chrome Extensions
A DevTools extension adds functionality to the Chrome DevTools. It can add new UI panels and sidebars, interact with the inspected page, ...
Read more >
45 Browser Extensions to Perform Accessibility Testing ...
Accessible Web Helper for Google Chrome is a powerful (and free) Google Chrome extension built to help you test your website's accessibility and...
Read more >
Set Chrome policies for users or browsers - Google Support
Tip: Many admins leave the default settings and only configure settings, such as startup pages, new tab pages, apps and extensions, and themes....
Read more >
A New Programmable Playground for Web Application Security
On the other hand, client-side defenses, especially in the form of modi- fied browsers or browser extensions, require constant vendor support or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found