Commit Graph
15 Commits
Author SHA1 Message Date
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
Tim van der Lippe 4a8441c385 Port license header check to ESLint
This improves the PRESUBMIT performance as we can rely on the AST
parsing of ESLint, meaning we don't have to parse AST twice.

It also allows us to use the nice `--fix` solution to insert the proper
license header in the files.

This shaves an expected 5 seconds of the presubmit time
(non-scientifically computed based on 2 uploads).

Change-Id: I5c53e9b232585f9ec46f86b36557c50bf80f7add
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2097992
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-03-12 16:08:22 +00:00
Jack Franklin 8297869795 Generate protocol.d.ts files in devtools-frontend
We need this to be able to migrate parts of the frontend over to
TypeScript that use the Protocol.

We can generate this automatically via a script [1] from the
devtools-protocol repository on GitHub that we've pulled into our repo
and tweaked slightly.

The files are commited and can be easily re-generated should the PDL
files be updated.

DISABLE_THIRD_PARTY_CHECK=expected ts_library changes

[1]: https://github.com/ChromeDevTools/devtools-protocol/tree/master/scripts

Change-Id: I7115fdf109487a82edcaaf7f9984e8ec587d8b04
Bug: 1011811
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2096703
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2020-03-12 15:18:42 +00:00