Files
react-native-devtools-frontend/test/webtests/http/tests/devtools/sources
Tim van der Lippe 6ba009e8ab Fix side-effect instance constructions during module loading
While working on the linear memory inspector component
(https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2501301)
we discovered that both snippets and quick_open were side-effect
instantiating instances during module loading. This caused issues
when trying to write isolated unittests for other components, if
they were (transitively) importing these modules.

To resolve these issues, we defer creation to the appropriate time.
In the case of CommandMenu, this was a small refactoring to use
the instance-singleton-pattern we have been using throughout the
codebase.

For Snippets, it was less obvious. In the end, we realized that
the singleton instances that snippets/ was relying on were constructed
in `Main.MainImpl.MainImpl._createAppUI`. More specifically,
the instantiation of `self.Persistence.isolatedFileSystemManager`
right at the top of `_createAppUI` was implicitly required for
snippets/.

This wasn't a problem when loading DevTools, as we lazy-load snippets/
after we instantiate `MainImpl`. Hence, the singletons were in place
and the code would correctly function. However, that assumption is
invalid when loading `snippets/` in isolation, which was the case
when writing the unit test.

The same treatment was necessary for `Snippets.project`, which has
been moved to a lazily-computed function.

R=aerotwist@chromium.org,jacktfranklin@chromium.org,kimanh@chromium.org

Fixed: 1143170
Change-Id: I28d3bbbc428f0316ca89453f98331b7479711c87
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2503953
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Kim-Anh Tran <kimanh@chromium.org>
2020-11-02 11:47:22 +00:00
..