Repository: facebook/react
File: packages/react-devtools-extensions/src/main.js (JavaScript)

Code before:
        });

        store = new Store(bridge, {
          isProfiling,
          supportsReloadAndProfile: IS_CHROME || IS_EDGE,
          supportsProfiling,
          // At this time, the timeline can only parse Chrome performance profiles.
          supportsTimeline: IS_CHROME,
          supportsTraceUpdates: true,
        });
        if (!isProfiling) {
          store.profilerStore.profilingData = profilingData;
        }

        // Initialize the backend only once the Store has been initialized.
        // Otherwise the Store may miss important initial tree op codes.
        if (IS_CHROME | IS_EDGE) {
          chrome.runtime.sendMessage({
            source: 'react-devtools-main',
            payload: {
              type: 'react-devtools-inject-backend',
              tabId,
            },
          });
        } else {
          // Firefox does not support executing script in MAIN wolrd from content script.
          // see prepareInjection.js
          chrome.devtools.inspectedWindow.eval(
            `window.postMessage({ source: 'react-devtools-inject-backend' }, '*');`,
            function (response, evalError) {
              if (evalError) {
                console.error(evalError);
              }
            },
          );
        }

        const viewAttributeSourceFunction = (id, path) => {
          const rendererID = store.getRendererIDForElement(id);
          if (rendererID != null) {
            // Ask the renderer interface to find the specified attribute,
            // and store it as a global variable on the window.
            bridge.send('viewAttributeSource', {id, path, rendererID});

            setTimeout(() => {
              // Ask Chrome to display the location of the attribute,
              // assuming the renderer found a match.
              chrome.devtools.inspectedWindow.eval(`
                if (window.$attribute != null) {
                  inspect(window.$attribute);
                }

Review comment (suggestion):
```suggestion
          // Firefox does not support executing script in ExecutionWorld.MAIN from content script.
```

Code after:
        });

        store = new Store(bridge, {
          isProfiling,
          supportsReloadAndProfile: IS_CHROME || IS_EDGE,
          supportsProfiling,
          // At this time, the timeline can only parse Chrome performance profiles.
          supportsTimeline: IS_CHROME,
          supportsTraceUpdates: true,
        });
        if (!isProfiling) {
          store.profilerStore.profilingData = profilingData;
        }

        // Initialize the backend only once the Store has been initialized.
        // Otherwise the Store may miss important initial tree op codes.
        if (IS_CHROME || IS_EDGE) {
          chrome.runtime.sendMessage({
            source: 'react-devtools-main',
            payload: {
              type: 'react-devtools-inject-backend',
              tabId,
            },
          });
        } else {
          // Firefox does not support executing script in ExecutionWorld.MAIN from content script.
          // see prepareInjection.js
          chrome.devtools.inspectedWindow.eval(
            `window.postMessage({ source: 'react-devtools-inject-backend' }, '*');`,
            function (response, evalError) {
              if (evalError) {
                console.error(evalError);
              }
            },
          );
        }

        const viewAttributeSourceFunction = (id, path) => {
          const rendererID = store.getRendererIDForElement(id);
          if (rendererID != null) {
            // Ask the renderer interface to find the specified attribute,
            // and store it as a global variable on the window.
            bridge.send('viewAttributeSource', {id, path, rendererID});

            setTimeout(() => {
              // Ask Chrome to display the location of the attribute,
              // assuming the renderer found a match.
              chrome.devtools.inspectedWindow.eval(`
                if (window.$attribute != null) {
                  inspect(window.$attribute);
                }