Lexical declarations in `case` and `default` clauses are a footgun,
since they are visible in the entire switch block, but they only
get initialized upon assignment, which only happens if the relevant
`case` is actually reached.
To ensure that such lexical declarations only apply to the current
`case` (which is usually the intention), `case` clauses containing
them should be wrapped in curly braces to create an explicit block.
More information:
https://eslint.org/docs/rules/no-case-declarations
Change-Id: I63d9341fcd76d4b9ce8281bd0e6573b886577f08
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2119685
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
This CL changes references to self.Common.settings (the global
instance of SDK.Common.Settings) over to
Common.Settings.Settings.instance(). To keep both TypeScript and
Closure happy we must make a method on the Settings class itself,
since it only allows private constructors to be accessed by static
methods on the class.
Bug: 1058320
Change-Id: I04afc8caf64acf29cdda13ef03ad05cfff4786a1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2091450
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
The Chromium/Google style guides does not enforce curly braces for
single-line if-statements, but does strongly recommend doing so. Adding
braces will improve code readability, by visually separating code
blocks. This will also prevent issues where accidental additions are
pushed to the "else"-clause instead of in the if-block.
This CL also updates the presubmit `eslint` to run the fix with the
correct configuration. It will now fix all issues it can fix.
Change-Id: I4b616f21a99393f168dec743c0bcbdc7f5db04a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821526
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jeff Fisher <jeffish@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#701070}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 7e0bdbe2d7f9fc2386bfaefda3cc29c66ccc18f9
This change adds 4 new performance histograms for the DevTools using the
prefix 'DevTools.Launch':
- DevTools.Launch.Console
- DevTools.Launch.Elements
- DevTools.Launch.Network
- DevTools.Launch.Sources
These histograms measure the time between the DevTools window being
shown during 'DevToolsWindow::ToggleDevToolsWindow' and a point in each
tool that corresponds to the 'ready' state as seen by a user. These end
points are unique to each tool but are as follows:
- Console: At the end of the ConsolePrompt constructor
- Elements: At the end of _updateMetrics when the styles panel has
been populated for the initially selected node
- Network: After the panel is shown
- Sources: After the NetworkNavigatorView has been loaded
These tools were chosen as they represent the most popular in terms of
usage and will allow us to identify any significant performance impact
in the time taken to launch the DevTools when these panels open by
default.
To see time captured by the histograms in terms of a perf trace for
each tool please take a look at the following screenshots:
https://imgur.com/a/rcAgQ8h
In the traces you can see that the end marker for each load is at the
end of the trace near first meaningful paint, and just as the user
will see the content of the tool render fully.
To accomplish the histograms, a new native function has been added to
the DevTools ui bindings/embedder classes called
'recordPerformanceHistogram'. Along with the plumbing and a new helper
function in the frontend javascript Host.UserMetrics file called
'panelLoaded'
When the frontend javascript loads, it will store the initial panel to
be loaded from the preferences. Once that panel has been created and
the appropriate loaded marker has been hit, the duration of the launch
will be calculated using performance.now(). That duration is then sent
to the native code which will fire the appropriate histogram via the
'UMA_HISTOGRAM_TIMES' macros.
The mechanism is similar to the existing one used for enumerated
histograms and can be expanded to fire additional performance histograms
in the future.
Also added a new test for user-metrics to ensure that the panelLoaded
function will correctly record the histograms.
Change-Id: Ib9f0bf80c651231d6d2e308bee36c1a1223f04db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1506388
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Commit-Queue: James Lissiak <jalissia@microsoft.com>
Cr-Original-Commit-Position: refs/heads/master@{#644407}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 296f6b12650bd5e38eaf1fe0987c46910fe2d6eb
Fixes 2 stick to bottom cases
- Prompt has text, but is scrolled out of view. User presses 'Enter'.
Browsers usually scroll an field into view on input events, but
Console preventsDefault to avoid adding a newline. Now, we will
emulate the scroll.
- Page logs a ton of messages, Console opened for the first time.
CodeMirror asynchronously resized prompt height on load, which
broke stick to bottom. This CL changes layout so that prompt
height does not grow on editor load.
Bug: 863664
Change-Id: Ia25a71100d9a895d4c8c710b36ba1d8b76d76990
Reviewed-on: https://chromium-review.googlesource.com/c/1321575
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#605936}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 60802eced856d89133f211ef29df6124f29401bd
- Console prompt is cleared when text is pinned
- Pins persist across refresh
- Newly created pin runs with side effects until text differs
or new expression is committed (on blur)
- Ctrl-Enter moves focus from Pin to Console prompt
- Added command menu option to create new pin
- Pressing Tab indents, moves focus iff pin is empty
(same logic as Console prompt)
- Pins producing errors show error message on red background
- Pin text is trimmed upon blur/commit
Bug: 849875
Change-Id: I641abb6b5e19a84c17b1a6cd3e50ca7b459f2015
Reviewed-on: https://chromium-review.googlesource.com/1141096
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#586108}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 811a4303b8b973d61567d61372ec8e1d692037c0
- Splits out prompt styles into consolePrompt.css
- Do not show background/border on matching brackets if the
CodeMirror container is not focused
Bug: none
Change-Id: I1955e07ca3289a6781097d0c99467c51336403b9
Reviewed-on: https://chromium-review.googlesource.com/1153468
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#579136}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 60fc08c17da4f858739220886c4899ef846cc4bc
Introduces JavaScriptREPL, a utility that includes
- Logic used by EagerEval for building side-effect-free previews
- Console prompt's preprocessing logic
(object literal wrapping and top level await)
Bug: 849875
Change-Id: Ie8146435fced9ebf440b43c225d25ef145416247
Reviewed-on: https://chromium-review.googlesource.com/1145911
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#577341}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: f8ffab5d79243cb7de978d17669e8decdb9141df
Part 1: introduce pins behind an experiment.
- Prompt has 'pin' button to add current expression to pins
- Pin pane sticks to the top of the Console, with max height
- Pins have multiline editors and a value preview that shows
"not available" when there is an error
Screenshot: https://imgur.com/a/Ahdtosa
Bug: 849875
Change-Id: Ib0b8bafd97551f823ff8b64d13c5259f42328994
Reviewed-on: https://chromium-review.googlesource.com/1087509
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#574740}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 589cdcb33ef96770a2c3e4a9c76ee439d1e2e56e
Turns the console below-prompt UI experiment from hidden to
visible.
Clicking on the preview element will now focus the prompt
editor, unless it has a selection.
Bug: 810176
Change-Id: I28cb5fa9c375ab4ae5cbfdf5043d03c7d8c71057
Reviewed-on: https://chromium-review.googlesource.com/1043464
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#556316}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 65f577c90e5521bc91afd2aa25c2fa84d630a49b
* Enter accepts the current suggestion in the console.
* History suggestions are not auto-selected. The user must use the
arrow keys or manually click to select them now.
Previously we worried about that the user would accidentally select a
suggestion in the console when they actually wanted to run the command
as is. Due to recent improvements in autocomplete, this is less of a
problem. Autocomplete showing up on an already complete expression
should be extremely rare. The only exception is history completions,
which are no longer autoselected.
Change-Id: Id9d567ae69f4c29c63e875a1f3285448adbd7ce3
Reviewed-on: https://chromium-review.googlesource.com/1026838
Reviewed-by: Erik Luo <luoe@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Joel Einbinder <einbinder@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#555609}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ca3ac226e566791986bb6451bdfcb02d661c6eb8
This reverts commit fcaafdd756b1aef4f8244474e37be9ee12c75284.
Reason for revert: we'd like to be more strict about side effects
Original change's description:
> DevTools: use autocomplete's possibleSideEffect to bypass throwOnSideEffect
>
> Allow Console to evaluate without throwOnSideEffect when the entire
> expression meets the same strict conditions used by JSAutocomplete.
>
> Bug: 810176
> Change-Id: If5c80250cd75d81eec1e495d0414903213fac930
> Reviewed-on: https://chromium-review.googlesource.com/1028934
> Commit-Queue: Erik Luo <luoe@chromium.org>
> Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
> Reviewed-by: Joel Einbinder <einbinder@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#555142}
TBR=dgozman@chromium.org,einbinder@chromium.org,luoe@chromium.org
Change-Id: Iec31996445e98945a0a9a9b67e572d17bafdcbeb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 810176
Reviewed-on: https://chromium-review.googlesource.com/1039063
Reviewed-by: Erik Luo <luoe@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#555269}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 67c4b089fbb62cc5986b98129dadfab5f69fcc97
- Adds an empty 15px space directly below the Console
prompt's editor.
- Updates "isScrolledToBottom" logic in Console to account
for the new space. Without this update, typing on the
prompt's last line will not "jump + stick to bottom"
as expected.
With this CL, overlay scrollbars (e.g. on Mac), should
never cover the prompt's editor.
Bug: 725249
Change-Id: Ib0167f6919d5b9942e7f2dc4d8cf0c15fc9368df
Reviewed-on: https://chromium-review.googlesource.com/965020
Commit-Queue: Erik Luo <luoe@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Joel Einbinder <einbinder@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#551222}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 06e046ba940fb6dffe3bbed45b85fb840b4a9194