(data: $FlowFixMe)
| 17 | |
| 18 | function startActivation(contentWindow: any, bridge: BackendBridge) { |
| 19 | const onSavedPreferences = (data: $FlowFixMe) => { |
| 20 | // This is the only message we're listening for, |
| 21 | // so it's safe to cleanup after we've received it. |
| 22 | bridge.removeListener('savedPreferences', onSavedPreferences); |
| 23 | |
| 24 | const { |
| 25 | appendComponentStack, |
| 26 | breakOnConsoleErrors, |
| 27 | componentFilters, |
| 28 | showInlineWarningsAndErrors, |
| 29 | hideConsoleLogsInStrictMode, |
| 30 | } = data; |
| 31 | |
| 32 | contentWindow.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = |
| 33 | appendComponentStack; |
| 34 | contentWindow.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = |
| 35 | breakOnConsoleErrors; |
| 36 | contentWindow.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters; |
| 37 | contentWindow.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = |
| 38 | showInlineWarningsAndErrors; |
| 39 | contentWindow.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ = |
| 40 | hideConsoleLogsInStrictMode; |
| 41 | |
| 42 | // TRICKY |
| 43 | // The backend entry point may be required in the context of an iframe or the parent window. |
| 44 | // If it's required within the parent window, store the saved values on it as well, |
| 45 | // since the injected renderer interface will read from window. |
| 46 | // Technically we don't need to store them on the contentWindow in this case, |
| 47 | // but it doesn't really hurt anything to store them there too. |
| 48 | if (contentWindow !== window) { |
| 49 | window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = appendComponentStack; |
| 50 | window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = breakOnConsoleErrors; |
| 51 | window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters; |
| 52 | window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = |
| 53 | showInlineWarningsAndErrors; |
| 54 | window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ = |
| 55 | hideConsoleLogsInStrictMode; |
| 56 | } |
| 57 | |
| 58 | finishActivation(contentWindow, bridge); |
| 59 | }; |
| 60 | |
| 61 | bridge.addListener('savedPreferences', onSavedPreferences); |
| 62 |
nothing calls this directly
no test coverage detected