| Index: Source/core/inspector/InjectedScriptSource.js
 | 
| diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
 | 
| index 717f581cf9e22c54523bbce8bc3f230548dabcf5..5e9c2b5a012dbcef7cb08fafe69604fe68190812 100644
 | 
| --- a/Source/core/inspector/InjectedScriptSource.js
 | 
| +++ b/Source/core/inspector/InjectedScriptSource.js
 | 
| @@ -616,7 +616,7 @@ InjectedScript.prototype = {
 | 
|       */
 | 
|      evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview)
 | 
|      {
 | 
| -        return this._evaluateAndWrap(null, null, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview);
 | 
| +        return this._evaluateAndWrap(null, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview);
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| @@ -689,20 +689,18 @@ InjectedScript.prototype = {
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {?function(string):*} evalFunction
 | 
| -     * @param {?Object} object
 | 
| +     * @param {?JavaScriptCallFrame} callFrame
 | 
|       * @param {string} expression
 | 
|       * @param {string} objectGroup
 | 
| -     * @param {boolean} isEvalOnCallFrame
 | 
|       * @param {boolean} injectCommandLineAPI
 | 
|       * @param {boolean} returnByValue
 | 
|       * @param {boolean} generatePreview
 | 
|       * @param {!Array.<!Object>=} scopeChain
 | 
|       * @return {!Object}
 | 
|       */
 | 
| -    _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, scopeChain)
 | 
| +    _evaluateAndWrap: function(callFrame, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, scopeChain)
 | 
|      {
 | 
| -        var wrappedResult = this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, scopeChain);
 | 
| +        var wrappedResult = this._evaluateOn(callFrame, objectGroup, expression, injectCommandLineAPI, scopeChain);
 | 
|          if (!wrappedResult.exceptionDetails) {
 | 
|              return { wasThrown: false,
 | 
|                       result: this._wrapObject(wrappedResult.result, objectGroup, returnByValue, generatePreview),
 | 
| @@ -730,36 +728,36 @@ InjectedScript.prototype = {
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {?function(string):*} evalFunction
 | 
| -     * @param {?Object} object
 | 
| +     * @param {?JavaScriptCallFrame} callFrame
 | 
|       * @param {string} objectGroup
 | 
|       * @param {string} expression
 | 
| -     * @param {boolean} isEvalOnCallFrame
 | 
|       * @param {boolean} injectCommandLineAPI
 | 
|       * @param {!Array.<!Object>=} scopeChain
 | 
|       * @return {*}
 | 
|       */
 | 
| -    _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, scopeChain)
 | 
| +    _evaluateOn: function(callFrame, objectGroup, expression, injectCommandLineAPI, scopeChain)
 | 
|      {
 | 
|          // Only install command line api object for the time of evaluation.
 | 
|          // Surround the expression in with statements to inject our command line API so that
 | 
|          // the window object properties still take more precedent than our API functions.
 | 
|  
 | 
| -        injectCommandLineAPI = injectCommandLineAPI && !("__commandLineAPI" in inspectedWindow);
 | 
| +        var scopeExtensionForEval = (callFrame && injectCommandLineAPI) ? new CommandLineAPI(this._commandLineAPIImpl, callFrame) : undefined;
 | 
| +
 | 
| +        injectCommandLineAPI = !scopeExtensionForEval && !callFrame && injectCommandLineAPI && !("__commandLineAPI" in inspectedWindow);
 | 
|          var injectScopeChain = scopeChain && scopeChain.length && !("__scopeChainForEval" in inspectedWindow);
 | 
|  
 | 
|          try {
 | 
|              var prefix = "";
 | 
|              var suffix = "";
 | 
|              if (injectCommandLineAPI) {
 | 
| -                InjectedScriptHost.setNonEnumProperty(inspectedWindow, "__commandLineAPI", new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null));
 | 
| -                prefix = "with (__commandLineAPI || { __proto__: null }) {";
 | 
| +                InjectedScriptHost.setNonEnumProperty(inspectedWindow, "__commandLineAPI", new CommandLineAPI(this._commandLineAPIImpl, callFrame));
 | 
| +                prefix = "with (typeof __commandLineAPI !== 'undefined' ? __commandLineAPI : { __proto__: null }) {";
 | 
|                  suffix = "}";
 | 
|              }
 | 
|              if (injectScopeChain) {
 | 
|                  InjectedScriptHost.setNonEnumProperty(inspectedWindow, "__scopeChainForEval", scopeChain);
 | 
|                  for (var i = 0; i < scopeChain.length; ++i) {
 | 
| -                    prefix = "with (__scopeChainForEval[" + i + "] || { __proto__: null }) {" + (suffix ? " " : "") + prefix;
 | 
| +                    prefix = "with (typeof __scopeChainForEval !== 'undefined' ? __scopeChainForEval[" + i + "] : { __proto__: null }) {" + (suffix ? " " : "") + prefix;
 | 
|                      if (suffix)
 | 
|                          suffix += " }";
 | 
|                      else
 | 
| @@ -769,7 +767,7 @@ InjectedScript.prototype = {
 | 
|  
 | 
|              if (prefix)
 | 
|                  expression = prefix + "\n" + expression + "\n" + suffix;
 | 
| -            var wrappedResult = evalFunction ? InjectedScriptHost.callFunction(evalFunction, object, [expression]) : InjectedScriptHost.evaluateWithExceptionDetails(expression);
 | 
| +            var wrappedResult = callFrame ? callFrame.evaluateWithExceptionDetails(expression, scopeExtensionForEval) : InjectedScriptHost.evaluateWithExceptionDetails(expression);
 | 
|              if (objectGroup === "console" && !wrappedResult.exceptionDetails)
 | 
|                  this._lastResult = wrappedResult.result;
 | 
|              return wrappedResult;
 | 
| @@ -802,8 +800,8 @@ InjectedScript.prototype = {
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {!Object} topCallFrame
 | 
| -     * @param {!Array.<!Object>} asyncCallStacks
 | 
| +     * @param {!JavaScriptCallFrame} topCallFrame
 | 
| +     * @param {!Array.<!JavaScriptCallFrame>} asyncCallStacks
 | 
|       * @param {string} callFrameId
 | 
|       * @param {string} expression
 | 
|       * @param {string} objectGroup
 | 
| @@ -819,12 +817,12 @@ InjectedScript.prototype = {
 | 
|          if (!callFrame)
 | 
|              return "Could not find call frame with given id";
 | 
|          if (parsedCallFrameId["asyncOrdinal"])
 | 
| -            return this._evaluateAndWrap(null, null, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview, callFrame.scopeChain);
 | 
| -        return this._evaluateAndWrap(callFrame.evaluateWithExceptionDetails, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview);
 | 
| +            return this._evaluateAndWrap(null, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview, callFrame.scopeChain);
 | 
| +        return this._evaluateAndWrap(callFrame, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview);
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {!Object} topCallFrame
 | 
| +     * @param {!JavaScriptCallFrame} topCallFrame
 | 
|       * @param {string} callFrameId
 | 
|       * @return {*}
 | 
|       */
 | 
| @@ -840,7 +838,7 @@ InjectedScript.prototype = {
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {!Object} topCallFrame
 | 
| +     * @param {!JavaScriptCallFrame} topCallFrame
 | 
|       * @param {string} callFrameId
 | 
|       * @return {*} a stepIn position array ready for protocol JSON or a string error
 | 
|       */
 | 
| @@ -857,7 +855,7 @@ InjectedScript.prototype = {
 | 
|  
 | 
|      /**
 | 
|       * Either callFrameId or functionObjectId must be specified.
 | 
| -     * @param {!Object} topCallFrame
 | 
| +     * @param {!JavaScriptCallFrame} topCallFrame
 | 
|       * @param {string|boolean} callFrameId or false
 | 
|       * @param {string|boolean} functionObjectId or false
 | 
|       * @param {number} scopeNumber
 | 
| @@ -889,9 +887,9 @@ InjectedScript.prototype = {
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {!Object} topCallFrame
 | 
| +     * @param {!JavaScriptCallFrame} topCallFrame
 | 
|       * @param {string} callFrameId
 | 
| -     * @return {?Object}
 | 
| +     * @return {?JavaScriptCallFrame}
 | 
|       */
 | 
|      _callFrameForId: function(topCallFrame, callFrameId)
 | 
|      {
 | 
| @@ -900,10 +898,10 @@ InjectedScript.prototype = {
 | 
|      },
 | 
|  
 | 
|      /**
 | 
| -     * @param {!Object} topCallFrame
 | 
| +     * @param {!JavaScriptCallFrame} topCallFrame
 | 
|       * @param {!Object} parsedCallFrameId
 | 
| -     * @param {!Array.<!Object>} asyncCallStacks
 | 
| -     * @return {?Object}
 | 
| +     * @param {!Array.<!JavaScriptCallFrame>} asyncCallStacks
 | 
| +     * @return {?JavaScriptCallFrame}
 | 
|       */
 | 
|      _callFrameForParsedId: function(topCallFrame, parsedCallFrameId, asyncCallStacks)
 | 
|      {
 | 
| @@ -1448,7 +1446,7 @@ InjectedScript.CallFrameProxy._createScopeJson = function(scopeTypeCode, scopeOb
 | 
|  /**
 | 
|   * @constructor
 | 
|   * @param {!CommandLineAPIImpl} commandLineAPIImpl
 | 
| - * @param {?Object} callFrame
 | 
| + * @param {?JavaScriptCallFrame} callFrame
 | 
|   */
 | 
|  function CommandLineAPI(commandLineAPIImpl, callFrame)
 | 
|  {
 | 
| @@ -1459,7 +1457,7 @@ function CommandLineAPI(commandLineAPIImpl, callFrame)
 | 
|      function inScopeVariables(member)
 | 
|      {
 | 
|          if (!callFrame)
 | 
| -            return false;
 | 
| +            return (member in inspectedWindow);
 | 
|  
 | 
|          var scopeChain = callFrame.scopeChain;
 | 
|          for (var i = 0; i < scopeChain.length; ++i) {
 | 
| @@ -1493,7 +1491,7 @@ function CommandLineAPI(commandLineAPIImpl, callFrame)
 | 
|  
 | 
|      for (var i = 0; i < CommandLineAPI.members_.length; ++i) {
 | 
|          var member = CommandLineAPI.members_[i];
 | 
| -        if (member in inspectedWindow || inScopeVariables(member))
 | 
| +        if (inScopeVariables(member))
 | 
|              continue;
 | 
|  
 | 
|          this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl);
 | 
| @@ -1502,7 +1500,7 @@ function CommandLineAPI(commandLineAPIImpl, callFrame)
 | 
|  
 | 
|      for (var i = 0; i < 5; ++i) {
 | 
|          var member = "$" + i;
 | 
| -        if (member in inspectedWindow || inScopeVariables(member))
 | 
| +        if (inScopeVariables(member))
 | 
|              continue;
 | 
|  
 | 
|          this.__defineGetter__("$" + i, bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i));
 | 
| 
 |