Bug 147097 - Web Inspector: add protocol test for existing error handling performed by the backend
Summary: Web Inspector: add protocol test for existing error handling performed by the...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: BJ Burg
URL:
Keywords: InRadar
Depends on: 147096
Blocks: InspectorProtocol 146466
  Show dependency treegraph
 
Reported: 2015-07-19 15:01 PDT by Brian Burg
Modified: 2022-03-01 02:46 PST (History)
8 users (show)

See Also:


Attachments
Proposed Fix (30.62 KB, patch)
2015-08-24 16:29 PDT, BJ Burg
joepeck: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Burg 2015-07-19 15:01:22 PDT
Prior to refactoring the error handling, I'd like to get some test coverage.
Comment 1 Radar WebKit Bug Importer 2015-07-19 15:01:54 PDT
<rdar://problem/21892877>
Comment 2 BJ Burg 2015-08-24 16:29:14 PDT
Created attachment 259790 [details]
Proposed Fix
Comment 3 Joseph Pecoraro 2015-08-24 16:46:00 PDT
Comment on attachment 259790 [details]
Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=259790&action=review

Nice!

> LayoutTests/inspector/protocol/backend-dispatcher-argument-errors.html:71
> +        name : "RequiredParameterWrongType",
> +        description: "The backend should return an error if a message has an optional parameter with wrong type.",

The name here should be "OptionalParameterWrongType".

> LayoutTests/inspector/protocol/backend-dispatcher-malformed-message-errors.html:17
> +    let errorCodes = {
> +        ParseError: -32700,
> +        InvalidRequest: -32600,
> +        MethodNotFound: -32601,
> +        InvalidParams: -32602,
> +        InternalError: -32603,
> +        ServerError: -32000,
> +    };

Should InspectorBackend expose these? Currently it only checks for -32000 but it could expose these constants. Then we wouldn't need to duplicate it in these tests.

> LayoutTests/inspector/protocol/backend-dispatcher-malformed-message-errors.html:39
> +                })

Style: semicolon? I'm normally very lax about commenting on style of tests, but seeing a they are getting rather clean / uniform now.

> LayoutTests/inspector/protocol/backend-dispatcher-malformed-message-errors.html:46
> +        name : "UnparseableStringMessage",

Style: "name :" => "name:" (for all of these in both tests)

> LayoutTests/inspector/protocol/backend-dispatcher-malformed-message-errors.html:141
> +    addErrorResponseTestCase({
> +        name : "MethodFieldWithBadFormatting5",
> +        description: "The backend should return an error if a message has a 'method' field not formatted as 'Domain.Methodname'.",
> +        message: {id: 123, method: ".FooBar."},
> +        expectedError: "InvalidRequest"
> +    });

Another similar one would be Foo.bar.baz. Both covered by the same condition here, but might be good to test separately.
Comment 4 BJ Burg 2015-08-24 16:55:55 PDT
Comment on attachment 259790 [details]
Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=259790&action=review

>> LayoutTests/inspector/protocol/backend-dispatcher-malformed-message-errors.html:17
>> +    };
> 
> Should InspectorBackend expose these? Currently it only checks for -32000 but it could expose these constants. Then we wouldn't need to duplicate it in these tests.

Meh, they are part of the JSON-RPC specification.

Besides, this test doesn't cover InspetorBackend.js, which should be a separate test (focused on correct resolve/reject/callback args).

>> LayoutTests/inspector/protocol/backend-dispatcher-malformed-message-errors.html:39
>> +                })
> 
> Style: semicolon? I'm normally very lax about commenting on style of tests, but seeing a they are getting rather clean / uniform now.

It's a promise chain.
Comment 5 BJ Burg 2015-08-24 16:58:56 PDT
Committed r188897: <http://trac.webkit.org/changeset/188897>