|
| 1 | +# DevTools-on-DevTools (aka Debugging the Debugger) |
| 2 | + |
| 3 | +[goo.gle/devtools-on-devtools][self-link] |
| 4 | + |
| 5 | +The Chromium DevTools front-end is a web application (with some special powers), |
| 6 | +and can therefore be debugged like any other web application (using Chromium |
| 7 | +DevTools itself). |
| 8 | + |
| 9 | +## Inspecting the inspector |
| 10 | + |
| 11 | +You don't need a special build of Chromium or DevTools, you can try this with |
| 12 | +any Chrome or Chromium build. Open DevTools on any page, e.g. |
| 13 | +`http://www.example.com`, and undock DevTools into a dedicated window. |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +Then in the undocked DevTools window press Cmd+Shift+I (on macOS) or |
| 18 | +Ctrl+Shift+I (on Windows, Linux, or Chrome OS), and a new DevTools window will |
| 19 | +open, that is debugging the actual DevTools window. You can tell them apart |
| 20 | +based on their window titles, the original one says *"DevTools - |
| 21 | +www.example.com"*, while the DevTools-on-DevTools says something like |
| 22 | +*"DevTools - devtools://devtools/bundled/devtools_app.html"*. |
| 23 | + |
| 24 | +**Pro-Tip**: Set a different color theme for the DevTools-on-DevTools to be able |
| 25 | +to tell them apart more easily. For example, use light theme for actual DevTools |
| 26 | +and dark theme for DevTools-on-DevTools. |
| 27 | + |
| 28 | +When using `--custom-devtools-frontend`, you can also right-click anywhere in |
| 29 | +the regular DevTools and select *Inspect* from the context menu to open a |
| 30 | +DevTools-on-DevTools window, even when the regular DevTools window is docked. |
| 31 | + |
| 32 | +## Using Automatic Workspace folders |
| 33 | + |
| 34 | +The [Workspace][workspace-documentation] feature is a powerful tool for working |
| 35 | +on DevTools, as it allows you preview changes to styles instantly, even while |
| 36 | +editing in your IDE (e.g. VS Code or Cider-G). With M-135, a new feature called |
| 37 | +[Automatic Workspace folders][automatic-workspace-folders-documentation] was |
| 38 | +introduced, which can be used to make debugging and developing DevTools easier. |
| 39 | + |
| 40 | +Follow the steps [here](../ecosystem/automatic_workspace_folders.md#setup) to |
| 41 | +set up your Chrome or Chromium instance. Then in your `devtools-frontend` |
| 42 | +checkout, use |
| 43 | + |
| 44 | +``` |
| 45 | +./third_party/chrome/chrome-linux/chrome \ |
| 46 | + --disable-infobars \ |
| 47 | + --custom-devtools-frontend=file://$(realpath out/Default/gen/front_end) |
| 48 | +``` |
| 49 | + |
| 50 | +on Linux or |
| 51 | + |
| 52 | +``` |
| 53 | +./third_party/chrome/chrome-mac/Google\ Chrome\ for\ Testing.app/Contents/MacOS/Google\ Chrome\ for\ Testing \ |
| 54 | + --disable-infobars \ |
| 55 | + --disable-features=MediaRouter \ |
| 56 | + --custom-devtools-frontend=file://$(realpath out/Default/gen/front_end) \ |
| 57 | + --use-mock-keychain |
| 58 | +``` |
| 59 | + |
| 60 | +on macOS to start. The first time you do this, you'll need to connect the folder |
| 61 | +to your workspace. |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +Afterwards you can immediately access the DevTools source code from within your |
| 66 | +DevTools-on-DevTools, and for example work on CSS changes in real time, without |
| 67 | +having to worry about extracting them out of DevTools-on-DevTools later. This |
| 68 | +even works from within your IDE or editor: As long as the (automatic) workspace |
| 69 | +folder is connected and DevTools-on-DevTools is open, it'll listen for changes |
| 70 | +to these files on disk, and automatically pick up any CSS changes and apply |
| 71 | +them. |
| 72 | + |
| 73 | +[self-link]: http://goo.gle/devtools-on-devtools |
| 74 | +[workspace-documentation]: https://developer.chrome.com/docs/devtools/workspaces |
| 75 | +[automatic-workspace-folders-documentation]: http://goo.gle/devtools-automatic-workspace-folders |
0 commit comments