Bug 138221

Summary: Web Inspector: ObjC Protocol Interfaces should throw exceptions for nil arguments
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: burg, commit-queue, graouts, joepeck, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix timothy: review+, timothy: commit-queue-

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