Changeset 85319 in webkit


Ignore:
Timestamp:
Apr 29, 2011 5:36:51 AM (13 years ago)
Author:
yurys@chromium.org
Message:

2011-04-28 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: [protocol] Evaluate should expose thrown exception value
https://bugs.webkit.org/show_bug.cgi?id=59000

  • inspector/console/console-dir-expected.txt:
  • inspector/console/console-eval-global-expected.txt:
  • inspector/console/console-format-expected.txt:
  • inspector/extensions/extensions-eval-expected.txt:
  • inspector/protocol/console-agent-expected.txt:
  • inspector/protocol/runtime-agent-expected.txt:

2011-04-28 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: [protocol] Evaluate should expose thrown exception value
https://bugs.webkit.org/show_bug.cgi?id=59000

Each evaluation command may have either thrown or returned result. This is indicated
by wasThrown property in the protocol.

  • inspector/InjectedScript.cpp: (WebCore::InjectedScript::evaluate): (WebCore::InjectedScript::evaluateOn): (WebCore::InjectedScript::evaluateOnCallFrame): (WebCore::InjectedScript::getProperties): (WebCore::InjectedScript::makeEvalCall):
  • inspector/InjectedScript.h:
  • inspector/InjectedScriptSource.js:
  • inspector/Inspector.json: Removed "error" remote object type, added "wasThrown" property to the evaluation results.
  • inspector/InspectorDebuggerAgent.cpp: (WebCore::InspectorDebuggerAgent::evaluateOnCallFrame):
  • inspector/InspectorDebuggerAgent.h:
  • inspector/InspectorRuntimeAgent.cpp: (WebCore::InspectorRuntimeAgent::evaluate): (WebCore::InspectorRuntimeAgent::evaluateOn): (WebCore::InspectorRuntimeAgent::getProperties):
  • inspector/InspectorRuntimeAgent.h:
  • inspector/front-end/ConsoleView.js: (WebInspector.ConsoleView.prototype.completions.evaluated): (WebInspector.ConsoleView.prototype.evalInInspectedWindow): (WebInspector.ConsoleView.prototype._enterKeyPressed.printResult): (WebInspector.ConsoleView.prototype._enterKeyPressed): (WebInspector.ConsoleCommandResult):
  • inspector/front-end/DebuggerPresentationModel.js: (WebInspector.PresenationCallFrame.prototype.evaluate):
  • inspector/front-end/ElementsTreeOutline.js: (WebInspector.ElementsTreeElement.prototype._createTooltipForNode.setTooltip):
  • inspector/front-end/ExtensionPanel.js: (WebInspector.ExtensionSidebarPane.prototype._onEvaluate):
  • inspector/front-end/ExtensionServer.js: (WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage):
  • inspector/front-end/ObjectPropertiesSection.js: (WebInspector.ObjectPropertyTreeElement.prototype.update):
  • inspector/front-end/PropertiesSidebarPane.js: (WebInspector.PropertiesSidebarPane.prototype.update.nodePrototypesReady):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype._showPopup.showObjectPopup): (WebInspector.SourceFrame.prototype._showPopup):
Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85317 r85319  
     12011-04-28  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: [protocol] Evaluate should expose thrown exception value
     6        https://bugs.webkit.org/show_bug.cgi?id=59000
     7
     8        * inspector/console/console-dir-expected.txt:
     9        * inspector/console/console-eval-global-expected.txt:
     10        * inspector/console/console-format-expected.txt:
     11        * inspector/extensions/extensions-eval-expected.txt:
     12        * inspector/protocol/console-agent-expected.txt:
     13        * inspector/protocol/runtime-agent-expected.txt:
     14
    1152011-04-29  Sheriff Bot  <webkit.review.bot@gmail.com>
    216
  • trunk/LayoutTests/http/tests/inspector/inspector-test.js

    r85317 r85319  
    4949    callback = InspectorTest.safeWrap(callback);
    5050
    51     function mycallback(error, result)
     51    function mycallback(error, result, wasThrown)
    5252    {
    5353        if (!error)
    54             callback(WebInspector.RemoteObject.fromPayload(result));
     54            callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
    5555    }
    5656    RuntimeAgent.evaluate(code, "console", false, mycallback);
  • trunk/LayoutTests/inspector/console/console-dir-expected.txt

    r85063 r85319  
    1919
    2020console-dir.html:11XPathResult
    21     booleanValue: XPathException
     21    booleanValue: [Exception: XPathException]
    2222    constructor: XPathResultConstructor
    2323    invalidIteratorState: false
    24     numberValue: XPathException
     24    numberValue: [Exception: XPathException]
    2525    resultType: 4
    26     singleNodeValue: XPathException
    27     snapshotLength: XPathException
    28     stringValue: XPathException
     26    singleNodeValue: [Exception: XPathException]
     27    snapshotLength: [Exception: XPathException]
     28    stringValue: [Exception: XPathException]
    2929    __proto__: XPathResultPrototype
    3030
  • trunk/LayoutTests/inspector/console/console-eval-global-expected.txt

    r78535 r85319  
    44"fooValue"
    55bar1
    6 ReferenceError: Can't find variable: bar1
     6Error
    77
  • trunk/LayoutTests/inspector/console/console-format-expected.txt

    r80628 r85319  
    6565globals[3]
    6666"test named "test""
    67 console-format.html:53Error:
    68 console-format.html:54[Error: ]
     67console-format.html:53Error
     68console-format.html:54[Error]
    6969globals[4]
    70 Error:
     70Error
    7171console-format.html:53<body onload="onload()">…</body>
    7272console-format.html:54[<body onload="onload()">…</body>]
  • trunk/LayoutTests/inspector/extensions/extensions-eval-expected.txt

    r78535 r85319  
    88Evaluate: {"func":"function","variable":42} (exception: undefined)
    99RUNNING TEST: extension_testEvalFailed
    10 Evaluate: "TypeError: JSON.stringify cannot serialize cyclic structures." (exception: true)
     10Evaluate: "Error" (exception: true)
    1111RUNNING TEST: extension_testEvalOk
    1212Evaluate: {"str":"foo","num":42} (exception: undefined)
  • trunk/LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt

    r85073 r85319  
    1818
    1919console-dir.html:11XPathResult
    20     booleanValue: XPathException
     20    booleanValue: [Exception: XPathException]
    2121    invalidIteratorState: false
    22     numberValue: XPathException
     22    numberValue: [Exception: XPathException]
    2323    resultType: 4
    24     singleNodeValue: XPathException
    25     snapshotLength: XPathException
    26     stringValue: XPathException
     24    singleNodeValue: [Exception: XPathException]
     25    snapshotLength: [Exception: XPathException]
     26    stringValue: [Exception: XPathException]
    2727    __proto__: XPathResult
    2828
  • trunk/LayoutTests/platform/chromium/inspector/console/console-eval-global-expected.txt

    r82713 r85319  
    44"fooValue"
    55bar1
    6 ReferenceError: bar1 is not defined
     6ReferenceError
    77
  • trunk/Source/WebCore/ChangeLog

    r85317 r85319  
     12011-04-28  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: [protocol] Evaluate should expose thrown exception value
     6        https://bugs.webkit.org/show_bug.cgi?id=59000
     7
     8        Each evaluation command may have either thrown or returned result. This is indicated
     9        by wasThrown property in the protocol.
     10
     11        * inspector/InjectedScript.cpp:
     12        (WebCore::InjectedScript::evaluate):
     13        (WebCore::InjectedScript::evaluateOn):
     14        (WebCore::InjectedScript::evaluateOnCallFrame):
     15        (WebCore::InjectedScript::getProperties):
     16        (WebCore::InjectedScript::makeEvalCall):
     17        * inspector/InjectedScript.h:
     18        * inspector/InjectedScriptSource.js:
     19        * inspector/Inspector.json: Removed "error" remote object type, added "wasThrown" property to
     20        the evaluation results.
     21        * inspector/InspectorDebuggerAgent.cpp:
     22        (WebCore::InspectorDebuggerAgent::evaluateOnCallFrame):
     23        * inspector/InspectorDebuggerAgent.h:
     24        * inspector/InspectorRuntimeAgent.cpp:
     25        (WebCore::InspectorRuntimeAgent::evaluate):
     26        (WebCore::InspectorRuntimeAgent::evaluateOn):
     27        (WebCore::InspectorRuntimeAgent::getProperties):
     28        * inspector/InspectorRuntimeAgent.h:
     29        * inspector/front-end/ConsoleView.js:
     30        (WebInspector.ConsoleView.prototype.completions.evaluated):
     31        (WebInspector.ConsoleView.prototype.evalInInspectedWindow):
     32        (WebInspector.ConsoleView.prototype._enterKeyPressed.printResult):
     33        (WebInspector.ConsoleView.prototype._enterKeyPressed):
     34        (WebInspector.ConsoleCommandResult):
     35        * inspector/front-end/DebuggerPresentationModel.js:
     36        (WebInspector.PresenationCallFrame.prototype.evaluate):
     37        * inspector/front-end/ElementsTreeOutline.js:
     38        (WebInspector.ElementsTreeElement.prototype._createTooltipForNode.setTooltip):
     39        * inspector/front-end/ExtensionPanel.js:
     40        (WebInspector.ExtensionSidebarPane.prototype._onEvaluate):
     41        * inspector/front-end/ExtensionServer.js:
     42        (WebInspector.ExtensionServer.prototype._onEvaluateOnInspectedPage):
     43        * inspector/front-end/ObjectPropertiesSection.js:
     44        (WebInspector.ObjectPropertyTreeElement.prototype.update):
     45        * inspector/front-end/PropertiesSidebarPane.js:
     46        (WebInspector.PropertiesSidebarPane.prototype.update.nodePrototypesReady):
     47        * inspector/front-end/SourceFrame.js:
     48        (WebInspector.SourceFrame.prototype._showPopup.showObjectPopup):
     49        (WebInspector.SourceFrame.prototype._showPopup):
     50
    1512011-04-29  Sheriff Bot  <webkit.review.bot@gmail.com>
    252
  • trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm

    r84780 r85319  
    491491    push(@function, "    RefPtr<InspectorObject> responseMessage = InspectorObject::create();");
    492492    push(@function, "    RefPtr<InspectorObject> result = InspectorObject::create();");
    493     push(@function, map("        result->set" . typeTraits($_->type, "JSONType") . "(\"" . $_->name . "\", out_" . $_->name . ");", @outArgs));
     493    foreach my $parameter (@outArgs) {
     494        my $offset = "        ";
     495        # Don't add optional boolean parameter to the result unless it is "true"
     496        if ($parameter->extendedAttributes->{"optional"} && $parameter->type eq "boolean") {
     497            push(@function, $offset . "if (out_" . $parameter->name . ")");
     498            $offset .= "    ";
     499        }
     500        push(@function, $offset . "result->set" . typeTraits($parameter->type, "JSONType") . "(\"" . $parameter->name . "\", out_" . $parameter->name . ");");
     501    }
    494502    push(@function, "    responseMessage->setObject(\"result\", result);");
    495503    push(@function, "");
  • trunk/Source/WebCore/inspector/InjectedScript.cpp

    r85035 r85319  
    11/*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
     2 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5555}
    5656
    57 void InjectedScript::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result)
     57void InjectedScript::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown)
    5858{
    5959    ScriptFunctionCall function(m_injectedScriptObject, "evaluate");
     
    6161    function.appendArgument(objectGroup);
    6262    function.appendArgument(includeCommandLineAPI);
    63     makeObjectCall(errorString, function, result);
    64 }
    65 
    66 void InjectedScript::evaluateOn(ErrorString* errorString, const String& objectId, const String& expression, RefPtr<InspectorObject>* result)
     63    makeEvalCall(errorString, function, result, wasThrown);
     64}
     65
     66void InjectedScript::evaluateOn(ErrorString* errorString, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown)
    6767{
    6868    ScriptFunctionCall function(m_injectedScriptObject, "evaluateOn");
    6969    function.appendArgument(objectId);
    7070    function.appendArgument(expression);
    71     makeObjectCall(errorString, function, result);
    72 }
    73 
    74 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result)
     71    makeEvalCall(errorString, function, result, wasThrown);
     72}
     73
     74void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown)
    7575{
    7676    ScriptFunctionCall function(m_injectedScriptObject, "evaluateOnCallFrame");
     
    8080    function.appendArgument(objectGroup);
    8181    function.appendArgument(includeCommandLineAPI);
    82     makeObjectCall(errorString, function, result);
     82    makeEvalCall(errorString, function, result, wasThrown);
    8383}
    8484
     
    8989    function.appendArgument(ignoreHasOwnProperty);
    9090
    91     RefPtr<InspectorValue> result; 
     91    RefPtr<InspectorValue> result;
    9292    makeCall(function, &result);
    9393    if (!result || result->type() != InspectorValue::TypeArray) {
     
    207207}
    208208
    209 void InjectedScript::makeObjectCall(ErrorString* errorString, ScriptFunctionCall& function, RefPtr<InspectorObject>* objectResult)
    210 {
    211     RefPtr<InspectorValue> result;
    212     makeCall(function, &result);
    213     if (result && result->type() == InspectorValue::TypeString) {
     209void InjectedScript::makeEvalCall(ErrorString* errorString, ScriptFunctionCall& function, RefPtr<InspectorObject>* objectResult, bool* wasThrown)
     210{
     211    RefPtr<InspectorValue> result;
     212    makeCall(function, &result);
     213    if (!result) {
     214        *errorString = "Internal error: result value is empty";
     215        return;
     216    }
     217    if (result->type() == InspectorValue::TypeString) {
    214218        result->asString(errorString);
    215219        return;
    216220    }
    217 
    218     if (!result || result->type() != InspectorValue::TypeObject) {
    219         *errorString = "Internal error";
    220         return;
    221     }
    222     *objectResult = result->asObject();
     221    RefPtr<InspectorObject> resultPair = result->asObject();
     222    if (!resultPair) {
     223        *errorString = "Internal error: result is not an Object";
     224        return;
     225    }
     226    RefPtr<InspectorObject> resultObj = resultPair->getObject("result");
     227    bool wasThrownVal = false;
     228    if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) {
     229        *errorString = "Internal error: result is not a pair of value and wasThrown flag";
     230        return;
     231    }
     232    *objectResult = resultObj;
     233    *wasThrown = wasThrownVal;
    223234}
    224235
  • trunk/Source/WebCore/inspector/InjectedScript.h

    r85035 r85319  
    11/*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
     2 * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5656    bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
    5757
    58     void evaluate(ErrorString*, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result);
    59     void evaluateOn(ErrorString*, const String& objectId, const String& expression, RefPtr<InspectorObject>* result);
    60     void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result);
     58    void evaluate(ErrorString*, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
     59    void evaluateOn(ErrorString*, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown);
     60    void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
    6161    void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
    6262    Node* nodeForObjectId(const String& objectId);
     
    8181    bool canAccessInspectedWindow();
    8282    void makeCall(ScriptFunctionCall&, RefPtr<InspectorValue>* result);
    83     void makeObjectCall(ErrorString*, ScriptFunctionCall&, RefPtr<InspectorObject>* result);
     83    void makeEvalCall(ErrorString*, ScriptFunctionCall&, RefPtr<InspectorObject>* result, bool* wasThrown);
    8484    ScriptValue nodeAsScriptValue(Node*);
    8585
  • trunk/Source/WebCore/inspector/InjectedScriptSource.js

    r85054 r85319  
    9191    },
    9292
     93    // This method cannot throw.
    9394    _wrapObject: function(object, objectGroupName)
    9495    {
     
    9798                var id = this._lastBoundObjectId++;
    9899                this._idToWrappedObject[id] = object;
    99                 var objectId = "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":" + id + "}";   
     100                var objectId = "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":" + id + "}";
    100101                if (objectGroupName) {
    101102                    var group = this._objectGroups[objectGroupName];
     
    110111            return InjectedScript.RemoteObject.fromObject(object, objectId);
    111112        } catch (e) {
    112             return InjectedScript.RemoteObject.fromObject("[ Exception: " + e.toString() + " ]");
     113            return InjectedScript.RemoteObject.fromException(e);
    113114        }
    114115    },
     
    153154        if (!ignoreHasOwnProperty && object.__proto__)
    154155            propertyNames.push("__proto__");
    155    
     156
    156157        // Go over properties, prepare results.
    157158        for (var i = 0; i < propertyNames.length; ++i) {
    158159            var propertyName = propertyNames[i];
    159    
     160
    160161            var property = {};
    161162            property.name = propertyName + "";
     
    163164            if (!isGetter) {
    164165                try {
    165                     property.value = this._wrapObject(object[propertyName], objectGroupName);
     166                    var value = object[propertyName];
    166167                } catch(e) {
    167                     property.value = new InjectedScript.RemoteObject.fromException(e);
     168                    var value = e;
     169                    property.wasThrown = true;
    168170                }
     171                property.value = this._wrapObject(value, objectGroupName);
    169172            } else {
    170173                // FIXME: this should show something like "getter" (bug 16734).
    171                 property.value = new InjectedScript.RemoteObject.fromObject("\u2014"); // em dash
     174                property.value = InjectedScript.RemoteObject.fromObject("\u2014"); // em dash
    172175                property.isGetter = true;
    173176            }
     
    183186        if (!this._isDefined(object))
    184187            return "Object with given id not found";
    185    
     188
    186189        var expressionLength = expression.length;
    187190        if (!expressionLength) {
     
    189192            return propertyName in object ? "Cound not delete property." : undefined;
    190193        }
    191    
     194
    192195        try {
    193196            // Surround the expression in parenthesis so the result of the eval is the result
    194197            // of the whole expression not the last potential sub-expression.
    195    
     198
    196199            // There is a regression introduced here: eval is now happening against global object,
    197200            // not call frame while on a breakpoint.
     
    263266    {
    264267        try {
    265             return this._wrapObject(this._evaluateOn(evalFunction, object, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup);
     268            return { wasThrown: false,
     269                     result: this._wrapObject(this._evaluateOn(evalFunction, object, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup) };
    266270        } catch (e) {
    267             return InjectedScript.RemoteObject.fromException(e);
     271            return { wasThrown: true,
     272                     result: this._wrapObject(e, objectGroup) };
    268273        }
    269274    },
     
    280285                expression = "with ((window && window.console && window.console._commandLineAPI) || {}) {\n" + expression + "\n}";
    281286            }
    282 
    283             var value = evalFunction.call(object, expression);
    284 
    285             // When evaluating on call frame error is not thrown, but returned as a value.
    286             if (this._type(value) === "error")
    287                 throw value.toString();
    288 
    289             return value;
     287            return evalFunction.call(object, expression);
    290288        } finally {
    291289            if (injectCommandLineAPI && inspectedWindow.console)
     
    298296        if (!callFrame)
    299297            return false;
    300    
     298
    301299        var result = [];
    302300        var depth = 0;
     
    396394        if (obj instanceof inspectedWindow.HTMLCollection)
    397395            return "array";
    398         if (obj instanceof inspectedWindow.Error)
    399             return "error";
    400396        return type;
    401397    },
     
    458454        var description = "<failed to convert exception to string>";
    459455    }
    460     return new InjectedScript.RemoteObject(null, "error", description);
    461 }
    462 
     456    return new InjectedScript.RemoteObject(null, "string", "[ Exception: " + description + " ]");
     457}
     458
     459// This method may throw
    463460InjectedScript.RemoteObject.fromObject = function(object, objectId)
    464461{
     
    467464    var hasChildren = (rawType === "object" && object !== null && (!!Object.getOwnPropertyNames(object).length || !!object.__proto__)) || rawType === "function";
    468465    var description = "";
    469     try {
    470         var description = injectedScript._describe(object);
    471         return new InjectedScript.RemoteObject(objectId, type, description, hasChildren);
    472     } catch (e) {
    473         return InjectedScript.RemoteObject.fromException(e);
    474     }
     466    var description = injectedScript._describe(object);
     467    return new InjectedScript.RemoteObject(objectId, type, description, hasChildren);
    475468}
    476469
  • trunk/Source/WebCore/inspector/Inspector.json

    r85035 r85319  
    202202                    { "name": "hasChildren", "type": "boolean", "optional": true, "description": "True when this object can be queried for children." },
    203203                    { "name": "objectId", "type": "string", "optional": true, "description": "Unique object identifier (for non-primitive values)." },
    204                     { "name": "type", "type": "string", "enum": ["object", "array", "function", "null", "node", "undefined", "string", "number", "boolean", "error", "regexp", "date"], "description": "Object type." }
     204                    { "name": "type", "type": "string", "enum": ["object", "array", "function", "null", "node", "undefined", "string", "number", "boolean", "regexp", "date"], "description": "Object type." }
    205205                ]
    206206            },
     
    212212                    { "name": "name", "type": "string", "description": "Property name." },
    213213                    { "name": "value", "$ref": "RemoteObject", "description": "Property value." },
     214                    { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if exception was thrown on attempt to get the property value, in that case the value propery will contain thrown value." },
    214215                    { "name": "isGetter", "type": "boolean", "optional": true, "description": "True if this property is getter." }
    215216                ]
     
    225226                ],
    226227                "returns": [
    227                     { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." }
     228                    { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },
     229                    { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True iff the result was thrown during the evaluation." }
    228230                ],
    229231                "description": "Evaluate expression on global object."
     
    236238                ],
    237239                "returns": [
    238                     { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." }
     240                    { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },
     241                    { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True iff the result was thrown during the evaluation." }
    239242                ],
    240243                "description": "Evaluate expression on given object using it as <code>this</code>."
     
    14501453                ],
    14511454                "returns": [
    1452                     { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." }
     1455                    { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." },
     1456                    { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True iff the result was thrown during the evaluation." }
    14531457                ],
    14541458                "description": "Evaluates expression on a given call frame."
  • trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp

    r85035 r85319  
    353353}
    354354
    355 void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result)
     355void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString* errorString, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown)
    356356{
    357357    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(callFrameId);
    358     if (!injectedScript.hasNoValue())
    359         injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, result);
     358    if (injectedScript.hasNoValue()) {
     359        *errorString = "Inspected frame has gone";
     360        return;
     361    }
     362    injectedScript.evaluateOnCallFrame(errorString, m_currentCallStack, callFrameId, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, result, wasThrown);
    360363}
    361364
  • trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h

    r85035 r85319  
    9898    void stepOut(ErrorString*);
    9999    void setPauseOnExceptions(ErrorString*, const String& pauseState);
    100     void evaluateOnCallFrame(ErrorString*, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result);
     100    void evaluateOnCallFrame(ErrorString*, const String& callFrameId, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
    101101
    102102    class Listener {
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp

    r83706 r85319  
    5050}
    5151
    52 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result)
     52void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown)
    5353{
    5454    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(getDefaultInspectedState());
    55     if (!injectedScript.hasNoValue())
    56         injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, result);
     55    if (injectedScript.hasNoValue()) {
     56        *errorString = "Inspected frame has gone";
     57        return;
     58    }
     59    injectedScript.evaluate(errorString, expression, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, result, wasThrown);
    5760}
    5861
    59 void InspectorRuntimeAgent::evaluateOn(ErrorString* errorString, const String& objectId, const String& expression, RefPtr<InspectorObject>* result)
     62void InspectorRuntimeAgent::evaluateOn(ErrorString* errorString, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown)
    6063{
    6164    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
    62     if (!injectedScript.hasNoValue())
    63         injectedScript.evaluateOn(errorString, objectId, expression, result);
     65    if (injectedScript.hasNoValue()) {
     66        *errorString = "Inspected frame has gone";
     67        return;
     68    }
     69    injectedScript.evaluateOn(errorString, objectId, expression, result, wasThrown);
    6470}
    6571
     
    6773{
    6874    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
    69     if (!injectedScript.hasNoValue())
    70         injectedScript.getProperties(errorString, objectId, ignoreHasOwnProperty, result);
     75    if (injectedScript.hasNoValue()) {
     76        *errorString = "Inspected frame has gone";
     77        return;
     78    }
     79    injectedScript.getProperties(errorString, objectId, ignoreHasOwnProperty, result);
    7180}
    7281
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h

    r83706 r85319  
    5353
    5454    // Part of the protocol.
    55     void evaluate(ErrorString*, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result);
    56     void evaluateOn(ErrorString*, const String& objectId, const String& expression, RefPtr<InspectorObject>* result);
     55    void evaluate(ErrorString*, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
     56    void evaluateOn(ErrorString*, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown);
    5757    void releaseObject(ErrorString*, const String& objectId);
    5858    void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
  • trunk/Source/WebCore/inspector/front-end/ConsoleView.js

    r85312 r85319  
    359359        this.evalInInspectedWindow(expressionString, "completion", true, evaluated.bind(this));
    360360
    361         function evaluated(result)
     361        function evaluated(result, wasThrown)
    362362        {
    363             if (!result)
     363            if (wasThrown)
    364364                return;
    365365            result.getAllProperties(evaluatedProperties.bind(this));
     
    535535        }
    536536
    537         function evalCallback(error, result)
     537        function evalCallback(error, result, wasThrown)
    538538        {
    539539            if (!error)
    540                 callback(WebInspector.RemoteObject.fromPayload(result));
     540                callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
    541541        }
    542542        RuntimeAgent.evaluate(expression, objectGroup, includeCommandLineAPI, evalCallback);
     
    561561
    562562        var self = this;
    563         function printResult(result)
     563        function printResult(result, wasThrown)
    564564        {
    565565            self.prompt.history.push(str);
     
    569569            WebInspector.settings.consoleHistory = self.prompt.history.slice(-30);
    570570
    571             self.addMessage(new WebInspector.ConsoleCommandResult(result, commandMessage));
     571            self.addMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, commandMessage));
    572572        }
    573573        this.evalInInspectedWindow(str, "console", true, printResult);
     
    10941094}
    10951095
    1096 WebInspector.ConsoleCommandResult = function(result, originatingCommand)
     1096WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingCommand)
    10971097{
    1098     var level = (result.isError() ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
     1098    var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
    10991099    this.originatingCommand = originatingCommand;
    11001100    WebInspector.ConsoleMessage.call(this, WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageType.Result, level, -1, null, 1, null, [result]);
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r85317 r85319  
    685685    evaluate: function(code, objectGroup, includeCommandLineAPI, callback)
    686686    {
    687         function didEvaluateOnCallFrame(error, result)
    688         {
    689             callback(WebInspector.RemoteObject.fromPayload(result));
     687        function didEvaluateOnCallFrame(error, result, wasThrown)
     688        {
     689            callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
    690690        }
    691691        DebuggerAgent.evaluateOnCallFrame(this._callFrame.id, code, objectGroup, includeCommandLineAPI, didEvaluateOnCallFrame.bind(this));
  • trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js

    r85312 r85319  
    407407            return;
    408408
    409         function setTooltip(error, result)
    410         {
    411             if (error || !result || result.type !== "string")
     409        function setTooltip(error, result, wasThrown)
     410        {
     411            if (error || wasThrown || result.type !== "string")
    412412                return;
    413413
  • trunk/Source/WebCore/inspector/front-end/ExtensionPanel.js

    r84624 r85319  
    107107    },
    108108
    109     _onEvaluate: function(title, error, result)
     109    _onEvaluate: function(title, error, result, wasThrown)
    110110    {
    111111        if (!error)
  • trunk/Source/WebCore/inspector/front-end/ExtensionServer.js

    r84904 r85319  
    265265    _onEvaluateOnInspectedPage: function(message, port)
    266266    {
    267         function callback(error, resultPayload)
     267        function callback(error, resultPayload, wasThrown)
    268268        {
    269269            if (error)
     
    271271            var resultObject = WebInspector.RemoteObject.fromPayload(resultPayload);
    272272            var result = {};
    273             if (resultObject.isError())
     273            if (wasThrown)
    274274                result.isException = true;
    275275            result.value = resultObject.description;
  • trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js

    r82609 r85319  
    188188        var description = this.property.value.description;
    189189        // Render \n as a nice unicode cr symbol.
    190         if (this.property.value.type === "string" && typeof description === "string") {
     190        if (this.property.wasThrown)
     191            this.valueElement.textContent = "[Exception: " + description + "]";
     192        else if (this.property.value.type === "string" && typeof description === "string") {
    191193            this.valueElement.textContent = "\"" + description.replace(/\n/g, "\u21B5") + "\"";
    192194            this.valueElement._originalTextContent = "\"" + description + "\"";
     
    199201        if (this.property.isGetter)
    200202            this.valueElement.addStyleClass("dimmed");
    201         if (this.property.value.isError())
     203        if (this.property.wasThrown)
    202204            this.valueElement.addStyleClass("error");
    203205        if (this.property.value.type)
     
    211213        this.listItemElement.appendChild(separatorElement);
    212214        this.listItemElement.appendChild(this.valueElement);
    213         this.hasChildren = this.property.value.hasChildren;
     215        this.hasChildren = this.property.value.hasChildren && !this.property.wasThrown;
    214216    },
    215217
  • trunk/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js

    r82609 r85319  
    5353        }
    5454
    55         function nodePrototypesReady(error, objectPayload)
     55        function nodePrototypesReady(error, objectPayload, wasThrown)
    5656        {
    57             if (error || !objectPayload)
     57            if (error || wasThrown)
    5858                return;
    5959            var object = WebInspector.RemoteObject.fromPayload(objectPayload);
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r85312 r85319  
    794794        }
    795795
    796         function showObjectPopup(result)
     796        function showObjectPopup(result, wasThrown)
    797797        {
    798             if (result.isError() || !this._delegate.debuggerPaused())
     798            if (wasThrown || !this._delegate.debuggerPaused())
    799799                return;
    800800
  • trunk/Source/WebCore/inspector/generate-inspector-idl

    r84773 r85319  
    134134            if ("returns" in command):
    135135                for out_param in command["returns"]:
    136                     params.append("out %s %s" % (param_type(domain_name, out_param), out_param["name"]))
     136                    if ("optional" in out_param):
     137                        optional = " [optional]"
     138                    else:
     139                        optional = ""
     140                    params.append("out%s %s %s" % (optional, param_type(domain_name, out_param), out_param["name"]))
    137141            output_file.write("\n        void %s(%s);" % (command["name"], ", ".join(params)))
    138142
Note: See TracChangeset for help on using the changeset viewer.