Bug 136032 - Web Inspector: check and cast InspectorObjects before passing to InspectorAgents
Summary: Web Inspector: check and cast InspectorObjects before passing to InspectorAgents
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: InspectorProtocol
  Show dependency treegraph
 
Reported: 2014-08-17 15:04 PDT by Brian Burg
Modified: 2016-12-13 15:38 PST (History)
3 users (show)

See Also:


Attachments
WIP (527.74 KB, patch)
2014-11-12 13:32 PST, Brian Burg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Burg 2014-08-17 15:04:32 PDT
All in parameters for commands use raw InspectorObjects and do ad-hoc shape checking.

I think we can just generate assertValueHasExpectedType for all types and add accessors to the checked InspectorObject wrappers. Inside the dispatcher functions, all the argument shapes are asserted and casted in debug builds.

-- Original code from InspectorDebuggerAgent::setBreakpoint --

    RefPtr<InspectorObject> options = ...;
    String condition = emptyString();
    bool autoContinue = false;
    RefPtr<InspectorArray> actions;
    if (options) {
        (*options)->getString(ASCIILiteral("condition"), &condition);
        (*options)->getBoolean(ASCIILiteral("autoContinue"), &autoContinue);
        actions = (*options)->getArray(ASCIILiteral("actions"));
    }

-- Proposed refactor --

    RefPtr<Protocol::Debugger::Options> options = ...;
    String condition = emptyString();
    bool autoContinue = false;
    RefPtr<Protocol::Array<Protocol::Debugger::BreakpointAction>> actions;
    if (options) {
        options->getCondition(condition);
        options->getAutoContinue(autoContinue);
        options->getActions(actions);
    }


This would require the getters to take the argument by reference if the parameter is optional.
Comment 1 Brian Burg 2014-11-12 13:32:55 PST
Created attachment 241438 [details]
WIP
Comment 2 Radar WebKit Bug Importer 2014-11-12 13:33:10 PST
<rdar://problem/18960076>
Comment 3 Radar WebKit Bug Importer 2014-11-12 13:33:11 PST
<rdar://problem/18960075>