Changeset 147356 in webkit


Ignore:
Timestamp:
Apr 1, 2013 1:33:04 PM (11 years ago)
Author:
timothy@apple.com
Message:

Make 'this' evaluate to the correct object when paused in the Debugger.

https://webkit.org/b/113607
rdar://problem/13538351

Reviewed by Joseph Pecoraro.

Source/WebCore:

  • inspector/InjectedScriptSource.js:

(InjectedScript.prototype._evaluateOn): Bind 'this' to the expression function.

LayoutTests:

  • platform/mac/http/tests/inspector/console-resource-errors-expected.txt:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r147355 r147356  
     12013-04-01  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make 'this' evaluate to the correct object when paused in the Debugger.
     4
     5        https://webkit.org/b/113607
     6        rdar://problem/13538351
     7
     8        Reviewed by Joseph Pecoraro.
     9
     10        * platform/mac/http/tests/inspector/console-resource-errors-expected.txt:
     11
    1122013-04-01  Victor Carbune  <vcarbune@chromium.org>
    213
  • trunk/LayoutTests/platform/mac/http/tests/inspector/console-resource-errors-expected.txt

    r146840 r147356  
    55GET http://127.0.0.1:8000/inspector/non-existent-iframe.html 404 (Not Found) non-existent-iframe.html:1 console-message console-error-level
    66GET http://127.0.0.1:8000/inspector/non-existent-script.js 404 (Not Found) console-resource-errors-iframe.html:4 console-message console-error-level
    7 GET http://127.0.0.1:8000/inspector/non-existent-xhr 404 (Not Found) [native code]:1send [native code]:1loadXHR console-resource-errors.html:18performActions console-resource-errors.html:10eval codeeval [native code]:1(anonymous function)_evaluateOn_evaluateAndWrapevaluate console-message console-error-level
     7GET http://127.0.0.1:8000/inspector/non-existent-xhr 404 (Not Found) [native code]:1send [native code]:1loadXHR console-resource-errors.html:18performActions console-resource-errors.html:10eval codeeval [native code]:1(anonymous function)(anonymous function)_evaluateOn_evaluateAndWrapevaluate console-message console-error-level
    88
  • trunk/Source/WebCore/ChangeLog

    r147355 r147356  
     12013-04-01  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make 'this' evaluate to the correct object when paused in the Debugger.
     4
     5        https://webkit.org/b/113607
     6        rdar://problem/13538351
     7
     8        Reviewed by Joseph Pecoraro.
     9
     10        * inspector/InjectedScriptSource.js:
     11        (InjectedScript.prototype._evaluateOn): Bind 'this' to the expression function.
     12
    1132013-04-01  Victor Carbune  <vcarbune@chromium.org>
    214
  • trunk/Source/WebCore/inspector/InjectedScriptSource.js

    r147221 r147356  
    556556            // create that provides the command line APIs.
    557557
    558             var thisObject = isEvalOnCallFrame ? object : null;
    559558            var parameters = [InjectedScriptHost.evaluate, expression];
    560559            var expressionFunctionBody = "var __originalEval = window.eval; window.eval = __eval; try { return eval(__currentExpression); } finally { window.eval = __originalEval; }";
     
    567566                // expressions with 'use strict';.
    568567
    569                 var commandLineAPI = new CommandLineAPI(this._commandLineAPIImpl, thisObject);
     568                var commandLineAPI = new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null);
    570569                var parameterNames = Object.getOwnPropertyNames(commandLineAPI);
    571 
    572570                for (var i = 0; i < parameterNames.length; ++i)
    573571                    parameters.push(commandLineAPI[parameterNames[i]]);
     
    580578            }
    581579
    582             var expressionFunction = evalFunction.call(thisObject, expressionFunctionString);
    583             var result = expressionFunction.apply(thisObject, parameters);
     580            // Bind 'this' to the function expression using another closure instead of Function.prototype.bind. This ensures things will work if the page replaces bind.
     581            var boundExpressionFunctionString = "(function(__function, __thisObject) { return function() { return __function.apply(__thisObject, arguments) }; })(" + expressionFunctionString + ", this)";
     582            var expressionFunction = evalFunction.call(object, boundExpressionFunctionString);
     583            var result = expressionFunction.apply(null, parameters);
    584584
    585585            if (objectGroup === "console")
Note: See TracChangeset for help on using the changeset viewer.