Bug 138221 - Web Inspector: ObjC Protocol Interfaces should throw exceptions for nil arguments
Summary: Web Inspector: ObjC Protocol Interfaces should throw exceptions for nil argum...
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: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-10-30 12:18 PDT by Joseph Pecoraro
Modified: 2014-11-03 11:36 PST (History)
6 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (23.71 KB, patch)
2014-10-31 16:40 PDT, Joseph Pecoraro
timothy: review+
timothy: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2014-10-30 12:18:48 PDT
* SUMMARY
Improved type checking and enforcement of correct inspector protocol types by throwing exceptions if required ObjC protocol objects are nil.
Comment 1 Radar WebKit Bug Importer 2014-10-30 12:19:01 PDT
<rdar://problem/18827853>
Comment 2 Joseph Pecoraro 2014-10-31 16:40:42 PDT
Created attachment 240769 [details]
[PATCH] Proposed Fix

The following convenience macros are defined in RWIProtocolJSONInternal.h, which these files include.

> #define THROW_EXCEPTION_FOR_NIL_KEY(expr) \
>     if (!expr)                            \
>         [NSException raise:NSInvalidArgumentException format:@"cannot set property with nil key"];
> 
> #define THROW_EXCEPTION_FOR_NIL_VALUE(expr) \
>     if (!expr)                              \
>         [NSException raise:NSInvalidArgumentException format:@"cannot set property to nil value"];
> 
> #define THROW_EXCEPTION_FOR_REQUIRED_PROPERTY(expr, propertyName) \
>     if (!expr)                                                    \
>         [NSException raise:NSInvalidArgumentException format:@"required property '%@' cannot be nil", propertyName];
> 
> #define THROW_EXCEPTION_FOR_REQUIRED_PARAMETER(expr, parameterName) \
>     if (!expr)                                                      \
>         [NSException raise:NSInvalidArgumentException format:@"required parameter '%@' cannot be nil", parameterName];
> 
> #define THROW_EXCEPTION_FOR_BAD_OPTIONAL_PARAMETER(expr, parameterName) \
>     if (expr && !*expr)                                                 \
>         [NSException raise:NSInvalidArgumentException format:@"optional parameter '%@' cannot be nil", parameterName];

The top ones are only used by RWIProtocolJSON for generic methods like -setString:forKey, -setObject:forKey:, ...
Comment 3 WebKit Commit Bot 2014-10-31 16:42:38 PDT
This patch modifies the inspector protocol generator. Please ensure that you have rebaselined any generator test results (i.e., by running `Tools/Scripts/run-inspector-generator-tests --reset-results`)
Comment 4 Joseph Pecoraro 2014-11-03 11:36:49 PST
https://trac.webkit.org/r175479