52 Commits
Author SHA1 Message Date
Jack Franklin c10b497bff ESLint: lint *.d.ts files
Bug: none
Change-Id: Ie91dbdc6ed1533c2c58cdb2eafa6d5f23632d243
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6311457
Reviewed-by: Nikolay Vitkov <nvitkov@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
2025-02-28 11:35:14 -08:00
Nikolay Vitkov d36860c0b4 [eslint] Enable useful rules
@typescript-eslint/no-inferrable-types Simplifies the code and makes
type be more specific.

@typescript-eslint/return-await In theory more performant, but also
provides better debugging experience.

@typescript-eslint/ban-ts-comment Disallow all but ts-expect-error, as
else the error may get fixed not remove and later mask unrelated issues

Bug: 397260638
Change-Id: I09f268eb9157336635c378fa76546a4196e448e9
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6281149
Reviewed-by: Victor Porof <victorporof@chromium.org>
Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org>
Auto-Submit: Nikolay Vitkov <nvitkov@chromium.org>
2025-02-19 10:49:41 -08:00
Danil Somsikov 6806877859 Use type-only import where possible.
Not only this is shorter, it also allows having a side-effect import in addition to the type-only
import and is properly understood by lit-analyzer.

No-Presubmit: true
Bug: 370734442
Change-Id: I32f0a6198e8de8175201d8ce576a63a9ce25806f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5921081
Commit-Queue: Danil Somsikov <dsv@chromium.org>
Reviewed-by: Paul Irish <paulirish@chromium.org>
Commit-Queue: Paul Irish <paulirish@chromium.org>
Auto-Submit: Danil Somsikov <dsv@chromium.org>
2024-10-11 20:29:33 +00:00
Jack Franklin 3a80260722 Inline type imports in front_end
This CL enables the `inline_type_imports` rule for devtools-frontend,
and is the result of running the auto-fixer to update all imports
accordingly.

Bug: 1319340
Change-Id: I303256476fd4e94f4505bbf4355c0070ac101aa9
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3752799
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2022-07-13 09:26:00 +00:00
Takuto Ikuta f342a5145f replace protocol.d.ts with protocol.ts
This is to make const enum in protocol.d.ts works with esbuild in
unittest.

Without this, const enum usage from protocol.d.ts is not replaced with
esbuild. So I need to make protocol.d.ts actual TypeScript file and make
it has corresponding JavaScript file with defined enums.

I also need to tweak how protocol.js is imported to make build/test pass
in both tsc and esbuild with child CL.

Bug: 1278663
DISABLE_THIRD_PARTY_CHECK=change generated/ and importing files
Change-Id: Ic5f27633c85bbfe8647636beef9b8625f33eabdd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3367593
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
2022-01-24 01:35:02 +00:00
Sigurd Schneider 49556e02b5 Heuristically identify identifier types in CDP
This CL uses a heuristic to classify identifier types:
If the type ends with Id or ID it is considered an
identifier type. The CL also introduces an override
in protocol_dts_generator.ts which can be used to
add more types, or disable the heuristic for specific
types.

DISABLE_THIRD_PARTY_CHECK=disable

Fixed: chromium:1226471
Change-Id: I4696463622ef026c48e1abeefd48aa438f9d11f6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3110425
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-20 13:12:48 +00:00
Sigurd Schneider 76240a3faa Type annotate IO.StreamHandle
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: Id7479a3d8d371bf5dbaac02a89d0d49de9ae0983
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3109532
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-20 12:18:58 +00:00
Sigurd Schneider 8cdc7310d3 Type annotate Runtime.RemoteObjectId
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: If9c171471a6b7320fbc2c09764b44faa5502d74c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3104558
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-19 14:23:34 +00:00
Sigurd Schneider 676c94480d Type annotate HeapProfiler.HeapSnapshotObjectId
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I4aa826df54644ded10c65d7ec80234826947455c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3104554
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-19 13:47:54 +00:00
Sigurd Schneider 14953ec447 Type annotate Debugger.CallFrameId
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I3c0ea9a7c6d500b66a274218a097a03151fdfd5e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3104551
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-19 10:35:31 +00:00
Sigurd Schneider 1259c0f055 Type annotate more protocol identifiers
This CL type annotates
  Debugger.BreakpointId
  LayerTree.SnapshotId
  Page.ScriptIdentifier

DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I307a6a6705653c18ca2f5b4afa2ce83fe3ca9049
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3104549
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-19 10:17:43 +00:00
Sigurd Schneider 2a3e642670 Type annotate more protocol identifiers
This CL adds type annotations for
  DOM.SnapshotId
  Runtime.ExecutionContextId
  Runtime.UniqueDebuggerId

DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I41ca383b6145351d238ba9ae7bf9a4182f502e84
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3103787
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-19 05:56:11 +00:00
Sigurd Schneider 171b7961d5 Type annotate ScriptId
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I22b69f920789a9eb0516de2bc86d0e05dd0454da
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3103235
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-18 15:40:31 +00:00
Sigurd Schneider a5dcab9a8e Type annotate Database.DatabaseId
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I3e03fdbf5de9e78135a90c07b9029735997011fb
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3103233
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-18 11:55:54 +00:00
Sigurd Schneider 19b55237a3 Type annotate with Page.FrameId consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I76ece085a7e448558f1f2553179c42b1188888d6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3083710
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-13 17:28:44 +00:00
Sigurd Schneider b5657ef670 Type annotate with CSS.StyleSheetId consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I1ad6cf3c9d21251b8719010319f6b4e1ba8f24f9
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3080313
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-10 06:15:19 +00:00
Sigurd Schneider 02626e4afc Type-annotate ServiceWorker.RegistrationID consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I0b0cfe44753123be4a4baa6142724d56b8166655
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3080315
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-09 15:15:47 +00:00
Sigurd Schneider 16cc89e295 Consistently type Target.{SessionID,TargetID}
This uncovered a bug where we used a targetID to as a sessionID,
which is fixed in this CL. The bug caused target information to
not get updated and the fix should increase target information
accuracy.

DISABLE_THIRD_PARTY_CHECK=<reason>

Bug: chromium:1226471
Change-Id: I89e461381443617d96ae06d5775038cd32ad8dd1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3080308
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-09 11:42:37 +00:00
Sigurd Schneider e195fd2829 Consistently type several protocol identifier types
This CL ensures consistent typing for the following protocol
types:
  Browser.BrowserContextID
  Browser.WindowID
  LayerTree.LayerId
  Security.CertificateId

DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I42f27da00d20b428cce3ff1a7a53a3a397f36f39
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3080301
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-09 10:38:47 +00:00
Sigurd Schneider 65937eaa4e Type-annotate WebAudio.GraphObjectId consistently
DISABLE_THIRD_PARTY_CHECK=disable

Drive-by: Ensure type for Media.PlayerId (no change required)

Bug: chromium:1226471
Change-Id: Ifbc6c451d57a58fec1e500f23a155a3fbc48ba58
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3077880
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-09 07:40:38 +00:00
Sigurd Schneider e863836967 Type-annotate WebAuthn.AuthenticatorId consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: If65fe3aa2aa8e21ba3e09242495d3deb25a7a415
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3077879
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-06 10:25:56 +00:00
Sigurd Schneider e0890db2bd Type-annotate Network.{LoaderId,InterceptionId} consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I76f69be43970a5ad5fc4784e678edc7d843c9071
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3074612
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-05 12:41:29 +00:00
Sigurd Schneider 4c29a69985 Ensure P.Audits.IssueId is type-annotated consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: Ic9d3352c7ce348aa180b0b110208e5aefb9bdf8a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3074606
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-08-05 11:44:39 +00:00
Kriti Sapra 56daf78ddb Updated no-multiple-empty-lines to only have 1 as max
DISABLE_THIRD_PARTY_CHECK=updated linting formatting
Bug: 1106746
Change-Id: I371bca95b7cf1e8b7eaa4f9e7c3860af4eedee3e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3057042
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-28 14:10:15 +00:00
Sigurd Schneider 3d756d2481 Ensure consistent usage of Protocol.Network.RequestId
This uncovered the fact that NetworkRequests really have two
request ids: One that is a string used in the front-end that
doesn't always have a corresponding request in the back-end,
and one that is always a back-end id. This CL makes this
explit in the types.

DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I894d6ab4d14099b9793c5e1c1a2863d2ec9c2548
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3014857
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-07-09 12:06:52 +00:00
Sigurd Schneider 30b3bd549e Ensure Fetch.RequestId is type-annotated consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I02a33641e5a792e198611c43e511882c82486378
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3009827
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-07-07 13:58:18 +00:00
Sigurd Schneider c67d1d0cc3 Ensure Accessibility.AXNodeId is type-annotated consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: Id731a0226ecff428e62482cdb16be9d08b0e2ed1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3009825
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2021-07-07 13:37:59 +00:00
Sigurd Schneider baf3960471 Improve types of Dispatchers in InspectorBackend
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1172300
Change-Id: I99837d4d0b459f00084d8b44aa3008d61a6655ee
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3009814
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-07-07 08:22:27 +00:00
Sigurd Schneider e18ce8ea87 Ensure DOM.BackendNodeId is type-annotated consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I8ce305dfcefcd81b93c3decf931b747da160c7ca
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3003253
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
2021-07-06 09:40:16 +00:00
Sigurd Schneider 73d92ec33f Ensure DOM.NodeId is type-annotated consistently
DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: I6ce261be75eec735d818cdf258cfa484b7e82dc5
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3003252
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
2021-07-06 09:30:46 +00:00
Sigurd Schneider 8d9cf0d99e Ensure CacheId is treated opaquely via type system
CacheIds must be treated opaquely by the front-end (they shouldn't be
analyzed or cooked up). This CL modifies the type emitted for CacheId
such that this is checked by the type system.

DISABLE_THIRD_PARTY_CHECK=disable

Bug: chromium:1226471
Change-Id: Id3188bbaabf1d6554e8c412ab42f4877e262a173
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3003251
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
2021-07-06 08:36:36 +00:00
Tim van der Lippe 7330337eda Remove protocol definitions from global file
DISABLE_THIRD_PARTY_CHECK=Protocol removal
R=jacktfranklin@chromium.org

Fixed: 1208357
Change-Id: I7439947b8ee4573acc0baa930fc1a5b6018b082f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2897519
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-05-17 13:18:32 +00:00
Tim van der Lippe eb876c6b1e Generate const enums in protocol.d.ts
Some files currently rely on the Protocol to be available on the
global scope. However, the Protocol definitions are defined in
a .d.ts file, which isn't available on runtime. Therefore,
attempting to import Protocol with non-type imports would retain
the imports in the `.js` files and break on runtime.

Since the only usages of the Protocol on runtime are the enums,
we can make them const, such that they get inlined as intended.
Then, `import * as` will work again, as the enums are inlined and
the import is removed from the `.js` file.

DISABLE_THIRD_PARTY_CHECK=Protocol update
R=jacktfranklin@chromium.org

Bug: 1208357
Change-Id: I749e57c9f51596866b61cab686c59f00bc8a8eb4
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2897277
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-05-14 15:51:00 +00:00
Tim van der Lippe 2a1eac282b Remove leftover from protocol-proxy-api global removal
This should have been included in https://crrev.com/c/2891760

R=jacktfranklin@chromium.org

Bug: 1208357
Change-Id: I27c9bbadad03a20f62bb2fdd97f844dc4852096f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2894392
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-05-13 16:22:04 +00:00
Tim van der Lippe 5bf64b9856 Make the Protocol definitions importable
Currently, all Protocol type definitions live on the global scope.
Additionally, the protocol files are included in all ts_library
targets. However, we don't want the protocol definitions to be
available in, for example, reusable UI components.

Therefore, we should move to a system where all files that want
to refer to the protocol types should import them instead.
However, doing so in 1 large CL will be problematic, which is
why it should be both globally available and importable as an
interim step.

To do so, we augment the existing protocol definitions to export
them as namespace and regular export. Then, we introduce a separate
file that imports the protocol types and augments the global scope
with the definitions. Now, protocol is both importable and remains
available on the global scope.

The reason that we need a separate file is that TypeScript disallows
you to augment the global scope in a file that also exports types.
Therefore, the global scope augmentation happens in protocol-globals.d.ts,
which will be removed once all Protocol type usages are imported.

To verify that this approach works, ProtocolClient imports the
required types, while SDK only imports it in AccessibilityModel.
All other files in SDK still refer to the global type.
In follow-up CLs, all pre-existing usages of Protocol will use
the import style.

DISABLE_THIRD_PARTY_CHECK=Updating protocol type format
R=szuend@chromium.org,jacktfranklin@chromium.org

Bug: 1208357
Change-Id: I1d75949b9cd3e37989c6cddf79ac849f5664a1e3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2891756
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-05-13 09:48:18 +00:00
Jack Franklin a75ae7cbb3 Enforce import type when importing TS types.
Bug: none
Change-Id: I02ef1182143b7fe091ce92d59f04ac2188903e0d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2886925
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
2021-05-11 14:00:22 +00:00
Tim van der Lippe 40755599ae Enable no-implicit-coercion for all files
R=mathias@chromium.org,jacktfranklin@chromium.org

Fixed: 1082789
Change-Id: I2cf3c221e748654c296f35c3f149b1f76684f4a3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2612903
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
2021-01-07 14:54:36 +00:00
Sigurd Schneider c870c46ba4 Don't generate types for deprecated Console domain
The runtime definitions are explicitly skipped here:
https://source.chromium.org/chromium/chromium/src/+/master:third_party/devtools-frontend/src/scripts/build/code_generator_frontend.py;l=202;drc=8e12f92229028121fd0cfa1a3c39825a228f341c

This means that if someone tries to access the values at runtime,
an error occurs. Removing the definition altogether is the
safest option.

Bug: chromium:1153099
Change-Id: Icc17caa99ebc68e4466ea309bf2a06b4c8cd71fe
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2575092
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
2020-12-07 12:20:01 +00:00
Tim van der Lippe 3c7eedcd60 Remove all definitions of usesObjectNotation
This was a temporary method, used during the migration to use
objects in dispatcher callbacks. Since all dispatchers now receive
the event as an object, we can remove these temporary methods.

R=aerotwist@chromium.org

Fixed: 1138492
Bug: 1011811
Change-Id: Ib7fbfae567ebc9b2be0a5d760458e5b0c7edc12e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2484723
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2020-10-20 10:59:51 +00:00
Tim van der Lippe 662c01bba2 Remove ProtocolProxyApiWorkaround
The upstream issue has been fixed in TypeScript 4 and therefore this workaround
is no longer necessary.

R=sigurds@chromium.org

Change-Id: I4a831566f3a7f7756f8938668c38e5fabe2ca14c
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2367947
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
2020-08-21 14:10:19 +00:00
Tim van der Lippe 719446c0db Include workaround for TypeScript compiler bug
The TypeScript compiler has a bug where, when you implement an
interface in JSDoc which is defined in a `.d.ts` file which
uses a namespace, it generates an invalid declaration file [1].

To workaround this bug, we have to add global interfaces that
are essentially aliases of the actual interfaces. As a result,
the TypeScript compiler no longer fails with resolving.

Update Closure accordingly such that we can use the correct
type to work in both Closure and TypeScript.

[1]: https://github.com/microsoft/TypeScript/issues/38640

R=jacktfranklin@chromium.org,aerotwist@chromium.org
CC=sigurds@chromium.org,janscheffler@chromium.org

Bug: 1081686, 1011811
Change-Id: I088a4520c90ce0873cf9850a8ed65f9c8dd896ef
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2208978
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
2020-05-19 14:06:46 +00:00
Tim van der Lippe 3e704e9618 Add Dispatcher base-interface to enforce type-safety
To make sure that typescriptified dispatchers use the object
notation, we have to signal to the InspectorBackend that
we use the object notation. As such, add a base interface
with an interface method called `usesObjectNotation` to make
sure that all dispatcher implementations use this method.

A follow-up CL will make the required changes to the
InspectorBackend to call the dispatcher with the correct
method arguments.

R=jacktfranklin@chromium.org,aerotwist@chromium.org
CC=sigurds@chromium.org,janscheffler@chromium.org

Bug: 1081686
Change-Id: I1fa9338afa44d26cc63dce84b9d88a936c4f35e4
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2207236
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
2020-05-19 10:02:16 +00:00
Tim van der Lippe 4833536c81 Fix return type for "void" CDP methods
Even though some CDP methods are typed as void, they can still
error and therefore `getError()` would return the error.

R=sigurds@chromium.org

Fixed: 1081724
Bug: 1011811
Change-Id: Id7b2712808745c30756e3ebb532a8d6ef38003a9
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2196388
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
2020-05-12 15:49:24 +00:00
Tim van der Lippe d1c8d6c721 Fix protocol dispatcher type generation
The dispatchers must be separate types, as they are implemented
in the SDK models. These models can't implement the *Api interface,
as these are auto-generated in the InspectorBackend.

A follow-up CL will change the Closure type generator to also
understand the new ProtocolProxyApi dispatcher interfaces, to
unblock further typescriptification of the SDK models.

R=jacktfranklin@chromium.org
CC=janscheffler@chromium.org,sigurds@chromium.org

Bug: 1081686, 1011811
Change-Id: Id193def28c426bdce17b9f72c65ccba21efd474e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2196386
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-05-12 15:10:34 +00:00
Tim van der Lippe 96de606848 Start with typechecking sdk/NetworkManager.js
Throughout this process we learned the following:
- The magically generated agents need to be properly exposed
on the target, rather than setting them on the TargetBase prototype.
- We need to rename the protocol proxy api definitions to use
the invoke_ naming, such that we can use structured request bodies.
This will allow us to no longer rely on parameter ordering and
does not require additional changes to the underlying Closure
generated code.
- Instead of using a symbol as an index on a different class, use
a WeakMap to keep track of the link between the NetworkRequest
and the NetworkManager. This breaks the circular dependency and
allows us to remove the lookup with the symbol

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

Bug: 1011811
Change-Id: I6cf25533b32793636d970b0a6c108f739d4e757e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2167868
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
2020-04-28 13:37:23 +00:00
Tim van der Lippe fcf8179a6a Fix issues with SDK compilation
Even though we were using the SDK files in the unittests for SDK,
not all files were included. A CL which attempts to use sdk.js (e.g.
https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2165757)
would then fail on several generated .d.ts issues.

Issues fixed:
- Usage of `Object` instead of `Map` causing issues with a type
alias of `string`, since TypeScript object notation only allows
primitives to be used as indices.
- Missing return types for function types
- A reference to `Protocol.NetworkAgent` which does not exist on
the protocol. Instead, that is part of the protocol-proxy-api.
Therefore, we must include the declaration file in the ts_library.
This also showed that the `ProtocolApi` needs to be exported
instead of declared.

This means that for any future reference to any Protocol type
that is actually an agent, we should be using the
`ProtocolProxyApi` definitions instead. To make sure Closure
understands that type, I aliased it in the externs.

R=jacktfranklin@chromium.org
CC=​sigurds@chromium.org,szuend@chromium.org
DISABLE_THIRD_PARTY_CHECK=Typescript fixes

No-Presubmit: true
Bug: 1011811
Change-Id: I4f5a488edb2d5fa6c5ed12d33411efb5f7fb8133
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2165795
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-04-27 14:22:46 +00:00
Tim van der Lippe b0f499fbae Fix eslint import rules to warn on test import extensions
Tests should also use imports that end with an extension, particularly
as it can silently fail in Karma.

We discovered this issue in
https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2144163/4/test/e2e/application/cookies.ts#10

R=janscheffler@chromium.org

Change-Id: Ic379cb90b8e201b55a24010dc45565f6f45d910e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2150450
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
2020-04-15 14:02:58 +00:00
Simon Zünd f69667700c Emit real TypeScript enums for inline declared protocol enum types
Commands, Events and Object types can declare "inline enums" to
restrict the possible values of a 'string' field.

Example field:

  referrerPolicy: ('unsafe-url'|'...'|'...')

To enable type-checking with TypeScript and stay compatible with
existing code, we now generate explicit enums. The naming scheme
for the enum names is adapted from code_generator_frontend.py
and needs to always match.

Example generated enum for the above code:

  export enum RequestReferrerPolicy {
    UnsafeUrl = 'unsafe-url',
    NoReferrerWhenDowngrade = 'no-referrer-when-downgrade',
    NoReferrer = 'no-referrer',
    Origin = 'origin',
    OriginWhenCrossOrigin = 'origin-when-cross-origin',
    SameOrigin = 'same-origin',
    StrictOrigin = 'strict-origin',
    StrictOriginWhenCrossOrigin = 'strict-origin-when-cross-origin',
  }

This is necessary as we didn't had any type for this enum before
but existing code was using

  Protocol.Network.RequestReferrerPolicy

as a type in JSDoc.

R=tvanderlippe@chromium.org

Bug: chromium:1011811
Change-Id: I4b4aa04b69fa4d7bf3b79ad97d61d4e3bfb7e228
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2113374
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2020-03-23 15:47:21 +00:00
Simon Zünd c385b48e5d Emit TypeScript enums in protocol.d.ts for Protocol enums
Instead of

    export type MixedContentType = ('blockable'|'...'|'none');

we know emit

    export enum MixedContentType {
      Blockable = 'blockable',
      OptionallyBlockable = 'optionally-blockable',
      None = 'none',
    }

This is necessary as existing JavaScript code accesses these
enums using

   Protocol.Security.MixedContentType.None

R=tvanderlippe@chromium.org

Bug: chromium:1011811
Change-Id: Id4bf2c1333affcdc4df37a43bf95379700e3e9d0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2113373
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2020-03-23 15:17:31 +00:00
Tim van der Lippe c19ea32ca5 Fix protocol generator formats
- The protocol files were generated without license headers
- There were whitespace issues in the .d.ts files

Change-Id: I19572989360a4a537fdfe829f212587ae70e180f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2107217
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Philip Pfaffe <pfaffe@chromium.org>
2020-03-17 12:34:08 +00:00