Title: [92122] trunk
Revision
92122
Author
yu...@chromium.org
Date
2011-08-01 04:42:43 -0700 (Mon, 01 Aug 2011)

Log Message

Web Inspector: typing an _expression_ in an iframe leads to multiple "Unsafe _javascript_ attempt to access frame..." errors
https://bugs.webkit.org/show_bug.cgi?id=65457

Source/WebCore:

Console completions are now done using evaluation which returns a JSON object with all property names rather than a remote
object. Also Runtime.evaluate and Runtime.callFunctionOn commands were extended with an optional parameter that allows to
get result as JSON value.

Reviewed by Pavel Feldman.

Test: http/tests/inspector/console-cd-completions.html

* inspector/InjectedScript.cpp:
(WebCore::InjectedScript::evaluate):
(WebCore::InjectedScript::callFunctionOn):
* inspector/InjectedScript.h:
* inspector/InjectedScriptSource.js:
(.):
():
* inspector/Inspector.json:
* inspector/InspectorRuntimeAgent.cpp:
(WebCore::asBool):
(WebCore::InspectorRuntimeAgent::evaluate):
(WebCore::InspectorRuntimeAgent::callFunctionOn):
* inspector/InspectorRuntimeAgent.h:
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype._completions.evaluated.getCompletions):
(WebInspector.ConsoleView.prototype._completions.evaluated):
(WebInspector.ConsoleView.prototype._completions.receivedPropertySet):
(WebInspector.ConsoleView.prototype._completions):
(WebInspector.ConsoleView.prototype.evalInInspectedWindow):
* inspector/front-end/RemoteObject.js:
(WebInspector.RemoteObject):
(WebInspector.RemoteObject.prototype.callFunction):
(WebInspector.RemoteObject.prototype.callFunctionJSON):
* inspector/front-end/WatchExpressionsSidebarPane.js:
(WebInspector.WatchExpressionsSection.prototype.update):

LayoutTests:

Reviewed by Pavel Feldman.

* http/tests/inspector/console-cd-completions-expected.txt: Added.
* http/tests/inspector/console-cd-completions.html: Added.
* http/tests/inspector/resources/console-cd-completions-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (92121 => 92122)


--- trunk/LayoutTests/ChangeLog	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/LayoutTests/ChangeLog	2011-08-01 11:42:43 UTC (rev 92122)
@@ -1,3 +1,14 @@
+2011-08-01  Yury Semikhatsky  <yu...@chromium.org>
+
+        Web Inspector: typing an _expression_ in an iframe leads to multiple "Unsafe _javascript_ attempt to access frame..." errors
+        https://bugs.webkit.org/show_bug.cgi?id=65457
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/console-cd-completions-expected.txt: Added.
+        * http/tests/inspector/console-cd-completions.html: Added.
+        * http/tests/inspector/resources/console-cd-completions-iframe.html: Added.
+
 2011-08-01  Tony Gentilcore  <to...@chromium.org>
 
         [chromium] http/tests/inspector/resource-tree/resource-tree-document-url.html occasionally times out

Added: trunk/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt (0 => 92122)


--- trunk/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt	2011-08-01 11:42:43 UTC (rev 92122)
@@ -0,0 +1,6 @@
+Test that completions in the context of an iframe with a different origin will result in names of its global variables. Test passes if all global variables are found among completions AND there are NO console messages. Bug 65457.
+
+
+myGlobalVar
+myGlobalFunction
+
Property changes on: trunk/LayoutTests/http/tests/inspector/console-cd-completions-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/http/tests/inspector/console-cd-completions.html (0 => 92122)


--- trunk/LayoutTests/http/tests/inspector/console-cd-completions.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/console-cd-completions.html	2011-08-01 11:42:43 UTC (rev 92122)
@@ -0,0 +1,53 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    InspectorTest.showConsolePanel();
+    var selector = WebInspector.console._contextSelectElement;
+    var option = selector.firstChild;
+    while (option) {
+        if (option.textContent && option.textContent.indexOf("myIFrame") === 0)
+            break;
+        option = option.nextSibling;
+    }
+    if (!option) {
+        InspectorTest.addResult("FAILED: myIFrame not found in the context list");
+        InspectorTest.completeTest();
+        return;
+    }
+    option.selected = true;
+
+
+    WebInspector.console._completions("", "myGlob", false, checkCompletions.bind(this));
+    function checkCompletions(completions)
+    {
+        var expected = ["myGlobalVar", "myGlobalFunction"];
+        for (var i = 0; i < expected.length; ++i) {
+            if (completions.indexOf(expected[i]) !== -1)
+                InspectorTest.addResult(expected[i]);
+            else
+                InspectorTest.addResult("NOT FOUND: " + expected[i]);
+        }
+        InspectorTest.dumpConsoleMessages();
+        InspectorTest.completeTest();
+    }
+}
+
+</script>
+</head>
+
+<body>
+<p>
+Test that completions in the context of an iframe with a different origin will
+result in names of its global variables. Test passes if all global variables
+are found among completions AND there are NO console messages.
+<a href="" 65457.</a>
+</p>
+<iframe name="myIFrame" src="" _onload_="runTest()"></iframe>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/console-cd-completions.html
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/http/tests/inspector/resources/console-cd-completions-iframe.html (0 => 92122)


--- trunk/LayoutTests/http/tests/inspector/resources/console-cd-completions-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resources/console-cd-completions-iframe.html	2011-08-01 11:42:43 UTC (rev 92122)
@@ -0,0 +1,4 @@
+<script>
+var myGlobalVar = 2011;
+function myGlobalFunction() { }
+</script>
Property changes on: trunk/LayoutTests/http/tests/inspector/resources/console-cd-completions-iframe.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (92121 => 92122)


--- trunk/Source/WebCore/ChangeLog	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/ChangeLog	2011-08-01 11:42:43 UTC (rev 92122)
@@ -1,3 +1,42 @@
+2011-08-01  Yury Semikhatsky  <yu...@chromium.org>
+
+        Web Inspector: typing an _expression_ in an iframe leads to multiple "Unsafe _javascript_ attempt to access frame..." errors
+        https://bugs.webkit.org/show_bug.cgi?id=65457
+
+        Console completions are now done using evaluation which returns a JSON object with all property names rather than a remote
+        object. Also Runtime.evaluate and Runtime.callFunctionOn commands were extended with an optional parameter that allows to
+        get result as JSON value.
+
+        Reviewed by Pavel Feldman.
+
+        Test: http/tests/inspector/console-cd-completions.html
+
+        * inspector/InjectedScript.cpp:
+        (WebCore::InjectedScript::evaluate):
+        (WebCore::InjectedScript::callFunctionOn):
+        * inspector/InjectedScript.h:
+        * inspector/InjectedScriptSource.js:
+        (.):
+        ():
+        * inspector/Inspector.json:
+        * inspector/InspectorRuntimeAgent.cpp:
+        (WebCore::asBool):
+        (WebCore::InspectorRuntimeAgent::evaluate):
+        (WebCore::InspectorRuntimeAgent::callFunctionOn):
+        * inspector/InspectorRuntimeAgent.h:
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype._completions.evaluated.getCompletions):
+        (WebInspector.ConsoleView.prototype._completions.evaluated):
+        (WebInspector.ConsoleView.prototype._completions.receivedPropertySet):
+        (WebInspector.ConsoleView.prototype._completions):
+        (WebInspector.ConsoleView.prototype.evalInInspectedWindow):
+        * inspector/front-end/RemoteObject.js:
+        (WebInspector.RemoteObject):
+        (WebInspector.RemoteObject.prototype.callFunction):
+        (WebInspector.RemoteObject.prototype.callFunctionJSON):
+        * inspector/front-end/WatchExpressionsSidebarPane.js:
+        (WebInspector.WatchExpressionsSection.prototype.update):
+
 2011-08-01  Mihnea Ovidenie  <mih...@adobe.com>
 
         BORDER attribute with the object tag, using percentage values not working.

Modified: trunk/Source/WebCore/inspector/InjectedScript.cpp (92121 => 92122)


--- trunk/Source/WebCore/inspector/InjectedScript.cpp	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/InjectedScript.cpp	2011-08-01 11:42:43 UTC (rev 92122)
@@ -54,21 +54,23 @@
 {
 }
 
-void InjectedScript::evaluate(ErrorString* errorString, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown)
+void InjectedScript::evaluate(ErrorString* errorString, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, bool sendResultByValue, RefPtr<InspectorObject>* result, bool* wasThrown)
 {
     ScriptFunctionCall function(m_injectedScriptObject, "evaluate");
     function.appendArgument(_expression_);
     function.appendArgument(objectGroup);
     function.appendArgument(includeCommandLineAPI);
+    function.appendArgument(sendResultByValue);
     makeEvalCall(errorString, function, result, wasThrown);
 }
 
-void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& _expression_, const String& arguments, RefPtr<InspectorObject>* result, bool* wasThrown)
+void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& _expression_, const String& arguments, bool sendResultByValue, RefPtr<InspectorObject>* result, bool* wasThrown)
 {
     ScriptFunctionCall function(m_injectedScriptObject, "callFunctionOn");
     function.appendArgument(objectId);
     function.appendArgument(_expression_);
     function.appendArgument(arguments);
+    function.appendArgument(sendResultByValue);
     makeEvalCall(errorString, function, result, wasThrown);
 }
 

Modified: trunk/Source/WebCore/inspector/InjectedScript.h (92121 => 92122)


--- trunk/Source/WebCore/inspector/InjectedScript.h	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/InjectedScript.h	2011-08-01 11:42:43 UTC (rev 92122)
@@ -55,8 +55,20 @@
 
     bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
 
-    void evaluate(ErrorString*, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
-    void callFunctionOn(ErrorString*, const String& objectId, const String& _expression_, const String& arguments, RefPtr<InspectorObject>* result, bool* wasThrown);
+    void evaluate(ErrorString*,
+                  const String& _expression_,
+                  const String& objectGroup,
+                  bool includeCommandLineAPI,
+                  bool sendResultByValue,
+                  RefPtr<InspectorObject>* result,
+                  bool* wasThrown);
+    void callFunctionOn(ErrorString*,
+                        const String& objectId,
+                        const String& _expression_,
+                        const String& arguments,
+                        bool sendResultByValue,
+                        RefPtr<InspectorObject>* result,
+                        bool* wasThrown);
     void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
     void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
     Node* nodeForObjectId(const String& objectId);

Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (92121 => 92122)


--- trunk/Source/WebCore/inspector/InjectedScriptSource.js	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js	2011-08-01 11:42:43 UTC (rev 92122)
@@ -108,10 +108,10 @@
     },
 
     // This method cannot throw.
-    _wrapObject: function(object, objectGroupName)
+    _wrapObject: function(object, objectGroupName, forceValueType)
     {
         try {
-            return new InjectedScript.RemoteObject(object, objectGroupName);
+            return new InjectedScript.RemoteObject(object, objectGroupName, forceValueType);
         } catch (e) {
             try {
                 var description = injectedScript._describe(e);
@@ -183,8 +183,8 @@
         for (var i = 0; i < propertyNames.length; ++i) {
             var propertyName = propertyNames[i];
 
-            var getter = object["__lookupGetter__"] && object.__lookupGetter__(propertyName);
-            var setter = object["__lookupSetter__"] && object.__lookupSetter__(propertyName);
+            var getter = (typeof object["__lookupGetter__"] === "function") && object.__lookupGetter__(propertyName);
+            var setter = (typeof object["__lookupSetter__"] === "function") && object.__lookupSetter__(propertyName);
             if (getter || setter) {
                 if (getter) {
                     var property = {};
@@ -246,12 +246,12 @@
         return Object.keys(propertyNameSet);
     },
 
-    evaluate: function(_expression_, objectGroup, injectCommandLineAPI)
+    evaluate: function(_expression_, objectGroup, injectCommandLineAPI, sendResultByValue)
     {
-        return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, _expression_, objectGroup, false, injectCommandLineAPI);
+        return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, _expression_, objectGroup, false, injectCommandLineAPI, sendResultByValue);
     },
 
-    callFunctionOn: function(objectId, _expression_, args)
+    callFunctionOn: function(objectId, _expression_, args, sendResultByValue)
     {
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
@@ -287,18 +287,18 @@
                 return "Given _expression_ does not evaluate to a function";
 
             return { wasThrown: false,
-                     result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup) };
+                     result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, sendResultByValue) };
         } catch (e) {
             return { wasThrown: true,
                      result: this._wrapObject(e, objectGroup) };
         }
     },
 
-    _evaluateAndWrap: function(evalFunction, object, _expression_, objectGroup, isEvalOnCallFrame, injectCommandLineAPI)
+    _evaluateAndWrap: function(evalFunction, object, _expression_, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, sendResultByValue)
     {
         try {
             return { wasThrown: false,
-                     result: this._wrapObject(this._evaluateOn(evalFunction, object, _expression_, isEvalOnCallFrame, injectCommandLineAPI), objectGroup) };
+                     result: this._wrapObject(this._evaluateOn(evalFunction, object, _expression_, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, sendResultByValue) };
         } catch (e) {
             return { wasThrown: true,
                      result: this._wrapObject(e, objectGroup) };
@@ -450,10 +450,10 @@
 
 var injectedScript = new InjectedScript();
 
-InjectedScript.RemoteObject = function(object, objectGroupName)
+InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType)
 {
     this.type = typeof object;
-    if (injectedScript.isPrimitiveValue(object) || object === null) {
+    if (injectedScript.isPrimitiveValue(object) || object === null || forceValueType) {
 
         // We don't send undefined values over JSON.
         if (typeof object !== "undefined")

Modified: trunk/Source/WebCore/inspector/Inspector.json (92121 => 92122)


--- trunk/Source/WebCore/inspector/Inspector.json	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/Inspector.json	2011-08-01 11:42:43 UTC (rev 92122)
@@ -230,7 +230,7 @@
                     { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean"], "description": "Object type." },
                     { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                     { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for <code>object</code> type values only." },
-                    { "name": "value", "type": "any", "optional": true, "description": "Remote object value (in case of primitive values)." },
+                    { "name": "value", "type": "any", "optional": true, "description": "Remote object value (in case of primitive values or JSON values if it was requested)." },
                     { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
                     { "name": "objectId", "$ref": "RemoteObjectId", "optional": true, "description": "Unique object identifier (for non-primitive values)." }
                 ]
@@ -263,7 +263,8 @@
                     { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." },
                     { "name": "includeCommandLineAPI", "type": "boolean", "optional": true, "description": "Determines whether Command Line API should be available during the evaluation." },
                     { "name": "doNotPauseOnExceptions", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions. Overrides setPauseOnException state." },
-                    { "name": "frameId", "type": "string", "optional": true, "description": "Specifies in which frame to perform evaluation." }
+                    { "name": "frameId", "type": "string", "optional": true, "description": "Specifies in which frame to perform evaluation." },
+                    { "name": "sendResultByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }
                 ],
                 "returns": [
                     { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },
@@ -276,7 +277,8 @@
                 "parameters": [
                     { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to call function on." },
                     { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." },
-                    { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same _javascript_ world as the target object." }
+                    { "name": "arguments", "type": "array", "items": { "$ref": "CallArgument", "description": "Call argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same _javascript_ world as the target object." },
+                    { "name": "sendResultByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object which should be sent by value." }
                 ],
                 "returns": [
                     { "name": "result", "$ref": "RemoteObject", "description": "Call result." },

Modified: trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp (92121 => 92122)


--- trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp	2011-08-01 11:42:43 UTC (rev 92122)
@@ -45,6 +45,11 @@
 
 namespace WebCore {
 
+static bool asBool(const bool* const b)
+{
+    return b ? *b : false;
+}
+
 InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager)
     : m_injectedScriptManager(injectedScriptManager)
 #if ENABLE(_javascript__DEBUGGER)
@@ -57,7 +62,7 @@
 {
 }
 
-void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, RefPtr<InspectorObject>* result, bool* wasThrown)
+void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, const bool* const sendResultByValue, RefPtr<InspectorObject>* result, bool* wasThrown)
 {
     ScriptState* scriptState = 0;
     if (frameId) {
@@ -77,13 +82,13 @@
     ASSERT(m_scriptDebugServer);
     bool pauseStateChanged = false;
     ScriptDebugServer::PauseOnExceptionsState presentState = m_scriptDebugServer->pauseOnExceptionsState();
-    if (doNotPauseOnExceptions && *doNotPauseOnExceptions && presentState != ScriptDebugServer::DontPauseOnExceptions) {
+    if (asBool(doNotPauseOnExceptions) && presentState != ScriptDebugServer::DontPauseOnExceptions) {
         m_scriptDebugServer->setPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions);
         pauseStateChanged = true;
     }
 #endif
 
-    injectedScript.evaluate(errorString, _expression_, objectGroup ? *objectGroup : "", includeCommandLineAPI ? *includeCommandLineAPI : false, result, wasThrown);
+    injectedScript.evaluate(errorString, _expression_, objectGroup ? *objectGroup : "", asBool(includeCommandLineAPI), asBool(sendResultByValue), result, wasThrown);
 
 #if ENABLE(_javascript__DEBUGGER)
     if (pauseStateChanged)
@@ -91,7 +96,7 @@
 #endif
 }
 
-void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& _expression_, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown)
+void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& _expression_, const RefPtr<InspectorArray>* const optionalArguments, const bool* const sendResultByValue, RefPtr<InspectorObject>* result, bool* wasThrown)
 {
     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
@@ -101,7 +106,7 @@
     String arguments;
     if (optionalArguments)
         arguments = (*optionalArguments)->toJSONString();
-    injectedScript.callFunctionOn(errorString, objectId, _expression_, arguments, result, wasThrown);
+    injectedScript.callFunctionOn(errorString, objectId, _expression_, arguments, asBool(sendResultByValue), result, wasThrown);
 }
 
 void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result)

Modified: trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h (92121 => 92122)


--- trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h	2011-08-01 11:42:43 UTC (rev 92122)
@@ -53,8 +53,22 @@
     virtual ~InspectorRuntimeAgent();
 
     // Part of the protocol.
-    void evaluate(ErrorString*, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, const String* const frameId, RefPtr<InspectorObject>* result, bool* wasThrown);
-    void callFunctionOn(ErrorString*, const String& objectId, const String& _expression_, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown);
+    void evaluate(ErrorString*,
+                  const String& _expression_,
+                  const String* const objectGroup,
+                  const bool* const includeCommandLineAPI,
+                  const bool* const doNotPauseOnExceptions,
+                  const String* const frameId,
+                  const bool* const sendResultByValue,
+                  RefPtr<InspectorObject>* result,
+                  bool* wasThrown);
+    void callFunctionOn(ErrorString*,
+                        const String& objectId,
+                        const String& _expression_,
+                        const RefPtr<InspectorArray>* const optionalArguments,
+                        const bool* const sendResultByValue,
+                        RefPtr<InspectorObject>* result,
+                        bool* wasThrown);
     void releaseObject(ErrorString*, const String& objectId);
     void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
     void releaseObjectGroup(ErrorString*, const String& objectGroup);

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleView.js (92121 => 92122)


--- trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleView.js	2011-08-01 11:42:43 UTC (rev 92122)
@@ -408,26 +408,33 @@
         if (!expressionString && WebInspector.panels.scripts.paused)
             WebInspector.panels.scripts.getSelectedCallFrameVariables(reportCompletions.bind(this));
         else
-            this.evalInInspectedWindow(expressionString, "completion", true, true, evaluated.bind(this));
+            this.evalInInspectedWindow(expressionString, "completion", true, true, undefined, evaluated.bind(this));
 
         function evaluated(result, wasThrown)
         {
             if (wasThrown)
                 return;
-            result.getAllProperties(evaluatedProperties.bind(this));
+            var getCompletions = function()
+            {
+                var resultSet = {};
+                for (var o = this; o; o = o.__proto__) {
+                    try {
+                        var names = Object.getOwnPropertyNames(o);
+                        for (var i = 0; i < names.length; ++i)
+                            resultSet[names[i]] = true;
+                    } catch (e) {
+                    }
+                }
+                return resultSet;
+            }
+            result.callFunctionJSON(getCompletions, receivedPropertyNames.bind(this));
         }
 
-        function evaluatedProperties(properties)
+        function receivedPropertyNames(propertyNames)
         {
             RuntimeAgent.releaseObjectGroup("completion");
-            var propertyNames = {};
-            for (var i = 0; properties && i < properties.length; ++i)
-                propertyNames[properties[i].name] = true;
-            reportCompletions.call(this, propertyNames);
-        }
-
-        function reportCompletions(propertyNames)
-        {
+            if (!propertyNames)
+                return;
             var includeCommandLineAPI = (!dotNotation && !bracketNotation);
             if (includeCommandLineAPI) {
                 const commandLineAPI = ["dir", "dirxml", "keys", "values", "profile", "profileEnd", "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear"];
@@ -595,7 +602,7 @@
         }
     },
 
-    evalInInspectedWindow: function(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, callback)
+    evalInInspectedWindow: function(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, evalAsJSONValue, callback)
     {
         if (WebInspector.panels.scripts && WebInspector.panels.scripts.paused) {
             WebInspector.panels.scripts.evaluateInSelectedCallFrame(_expression_, objectGroup, includeCommandLineAPI, callback);
@@ -612,7 +619,7 @@
             if (!error)
                 callback(WebInspector.RemoteObject.fromPayload(result), wasThrown);
         }
-        RuntimeAgent.evaluate(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, this._currentEvaluationContextId(), evalCallback);
+        RuntimeAgent.evaluate(_expression_, objectGroup, includeCommandLineAPI, doNotPauseOnExceptions, this._currentEvaluationContextId(), evalAsJSONValue, evalCallback);
     },
 
     _enterKeyPressed: function(event)
@@ -643,7 +650,7 @@
 
             self.addMessage(new WebInspector.ConsoleCommandResult(result, wasThrown, commandMessage));
         }
-        this.evalInInspectedWindow(str, "console", true, undefined, printResult);
+        this.evalInInspectedWindow(str, "console", true, undefined, undefined, printResult);
 
         WebInspector.userMetrics.ConsoleEvaluated.record();
     },

Modified: trunk/Source/WebCore/inspector/front-end/RemoteObject.js (92121 => 92122)


--- trunk/Source/WebCore/inspector/front-end/RemoteObject.js	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/front-end/RemoteObject.js	2011-08-01 11:42:43 UTC (rev 92122)
@@ -194,9 +194,19 @@
             callback((error || wasThrown) ? null : WebInspector.RemoteObject.fromPayload(result));
         }
 
-        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), undefined, mycallback);
+        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), undefined, undefined, mycallback);
     },
 
+    callFunctionJSON: function(functionDeclaration, callback)
+    {
+        function mycallback(error, result, wasThrown)
+        {
+            callback((error || wasThrown) ? null : result.value);
+        }
+
+        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), undefined, true, mycallback);
+    },
+
     release: function()
     {
         RuntimeAgent.releaseObject(this._objectId);

Modified: trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js (92121 => 92122)


--- trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js	2011-08-01 11:38:59 UTC (rev 92121)
+++ trunk/Source/WebCore/inspector/front-end/WatchExpressionsSidebarPane.js	2011-08-01 11:42:43 UTC (rev 92122)
@@ -159,7 +159,7 @@
             if (!_expression_)
                 continue;
 
-            WebInspector.console.evalInInspectedWindow(_expression_, this._watchObjectGroupId, false, true, appendResult.bind(this, _expression_, i));
+            WebInspector.console.evalInInspectedWindow(_expression_, this._watchObjectGroupId, false, true, undefined, appendResult.bind(this, _expression_, i));
         }
 
         if (!propertyCount) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to