Chromium Code Reviews| Index: third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js |
| diff --git a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js |
| index 3673b57bbdabec1e0d932aed839e62ad907dfd11..1eb6125b31f66b5d87a3279e2be0c8e9a77f970b 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/InjectedScriptSource.js |
| @@ -607,11 +607,45 @@ InjectedScript.prototype = { |
| }, |
| /** |
| - * @return {!CommandLineAPI} |
| + * @param {!Object} nativeCommandLineAPI |
| + * @return {!Object} |
| */ |
| - commandLineAPI: function() |
| + installCommandLineAPI: function(nativeCommandLineAPI) |
| { |
| - return new CommandLineAPI(this._commandLineAPIImpl); |
| + var commandLineAPIImpl = this._commandLineAPIImpl; |
| + /** |
| + * @param {string} name The name of the method for which a toString method should be generated. |
| + * @return {function():string} |
| + */ |
| + function customToStringMethod(name) |
|
dgozman
2016/04/25 18:09:50
Let's have a big map {method -> toString} for all
kozy
2016/04/25 19:31:06
Done.
|
| + { |
| + return function() |
| + { |
| + var funcArgsSyntax = ""; |
| + try { |
| + var funcSyntax = "" + commandLineAPIImpl[name]; |
| + funcSyntax = funcSyntax.replace(/\n/g, " "); |
| + funcSyntax = funcSyntax.replace(/^function[^\(]*\(([^\)]*)\).*$/, "$1"); |
| + funcSyntax = funcSyntax.replace(/\s*,\s*/g, ", "); |
| + funcSyntax = funcSyntax.replace(/\bopt_(\w+)\b/g, "[$1]"); |
| + funcArgsSyntax = funcSyntax.trim(); |
| + } catch (e) { |
| + } |
| + return "function " + name + "(" + funcArgsSyntax + ") { [Command Line API] }"; |
| + }; |
| + } |
| + |
| + for (var i = 0; i < CommandLineAPIImpl.members_.length; ++i) { |
| + var member = CommandLineAPIImpl.members_[i]; |
| + nativeCommandLineAPI[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl); |
| + nativeCommandLineAPI[member].toString = customToStringMethod(member); |
| + } |
| + |
| + for (var i = 0; i < 5; ++i) { |
| + var member = "$" + i; |
| + nativeCommandLineAPI[member] = bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i); |
| + } |
| + return nativeCommandLineAPI; |
| }, |
| /** |
| @@ -1136,65 +1170,21 @@ InjectedScript.RemoteObject.prototype = { |
| /** |
| * @constructor |
| - * @param {!CommandLineAPIImpl} commandLineAPIImpl |
| */ |
| -function CommandLineAPI(commandLineAPIImpl) |
| +function CommandLineAPIImpl() |
| { |
| - /** |
| - * @param {string} name The name of the method for which a toString method should be generated. |
| - * @return {function():string} |
| - */ |
| - function customToStringMethod(name) |
| - { |
| - return function() |
| - { |
| - var funcArgsSyntax = ""; |
| - try { |
| - var funcSyntax = "" + commandLineAPIImpl[name]; |
| - funcSyntax = funcSyntax.replace(/\n/g, " "); |
| - funcSyntax = funcSyntax.replace(/^function[^\(]*\(([^\)]*)\).*$/, "$1"); |
| - funcSyntax = funcSyntax.replace(/\s*,\s*/g, ", "); |
| - funcSyntax = funcSyntax.replace(/\bopt_(\w+)\b/g, "[$1]"); |
| - funcArgsSyntax = funcSyntax.trim(); |
| - } catch (e) { |
| - } |
| - return "function " + name + "(" + funcArgsSyntax + ") { [Command Line API] }"; |
| - }; |
| - } |
| - |
| - for (var i = 0; i < CommandLineAPI.members_.length; ++i) { |
| - var member = CommandLineAPI.members_[i]; |
| - this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl); |
| - this[member].toString = customToStringMethod(member); |
| - } |
| - |
| - for (var i = 0; i < 5; ++i) { |
| - var member = "$" + i; |
| - this[member] = bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i); |
| - } |
| - this.__proto__ = null; |
| } |
| -// NOTE: Please keep the list of API methods below synchronized to that in WebInspector.RuntimeModel |
| -// and V8InjectedScriptHost! |
| +// NOTE: This list contains only not native Command Line API methods. For full list: V8InjectedScriptHost. |
| // NOTE: Argument names of these methods will be printed in the console, so use pretty names! |
| /** |
| * @type {!Array.<string>} |
| * @const |
| */ |
| -CommandLineAPI.members_ = [ |
| - "$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd", |
| - "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventListeners", |
| - "debug", "undebug", "monitor", "unmonitor", "table" |
| +CommandLineAPIImpl.members_ = [ |
| + "$", "$$", "$x", "monitorEvents", "unmonitorEvents", "inspect", "copy", "getEventListeners" |
| ]; |
| -/** |
| - * @constructor |
| - */ |
| -function CommandLineAPIImpl() |
| -{ |
| -} |
| - |
| CommandLineAPIImpl.prototype = { |
| /** |
| * @param {string} selector |
| @@ -1256,57 +1246,6 @@ CommandLineAPIImpl.prototype = { |
| }, |
| /** |
| - * @return {*} |
| - */ |
| - dir: function(var_args) |
| - { |
| - return InjectedScriptHost.callFunction(inspectedGlobalObject.console.dir, inspectedGlobalObject.console, slice(arguments)); |
| - }, |
| - |
| - /** |
| - * @return {*} |
| - */ |
| - dirxml: function(var_args) |
| - { |
| - return InjectedScriptHost.callFunction(inspectedGlobalObject.console.dirxml, inspectedGlobalObject.console, slice(arguments)); |
| - }, |
| - |
| - /** |
| - * @return {!Array.<string>} |
| - */ |
| - keys: function(object) |
| - { |
| - return Object.keys(object); |
| - }, |
| - |
| - /** |
| - * @return {!Array.<*>} |
| - */ |
| - values: function(object) |
| - { |
| - var result = []; |
| - for (var key in object) |
| - push(result, object[key]); |
| - return result; |
| - }, |
| - |
| - /** |
| - * @return {*} |
| - */ |
| - profile: function(opt_title) |
| - { |
| - return InjectedScriptHost.callFunction(inspectedGlobalObject.console.profile, inspectedGlobalObject.console, slice(arguments)); |
| - }, |
| - |
| - /** |
| - * @return {*} |
| - */ |
| - profileEnd: function(opt_title) |
| - { |
| - return InjectedScriptHost.callFunction(inspectedGlobalObject.console.profileEnd, inspectedGlobalObject.console, slice(arguments)); |
| - }, |
| - |
| - /** |
| * @param {!Object} object |
| * @param {!Array.<string>|string=} opt_types |
| */ |
| @@ -1363,11 +1302,6 @@ CommandLineAPIImpl.prototype = { |
| InjectedScriptHost.inspect(remoteObject, hints); |
| }, |
| - clear: function() |
| - { |
| - InjectedScriptHost.clearConsoleMessages(); |
| - }, |
| - |
| /** |
| * @param {!Node} node |
| * @return {!Object|undefined} |
| @@ -1416,31 +1350,6 @@ CommandLineAPIImpl.prototype = { |
| return result; |
| }, |
| - debug: function(fn) |
| - { |
| - InjectedScriptHost.debugFunction(fn); |
| - }, |
| - |
| - undebug: function(fn) |
| - { |
| - InjectedScriptHost.undebugFunction(fn); |
| - }, |
| - |
| - monitor: function(fn) |
| - { |
| - InjectedScriptHost.monitorFunction(fn); |
| - }, |
| - |
| - unmonitor: function(fn) |
| - { |
| - InjectedScriptHost.unmonitorFunction(fn); |
| - }, |
| - |
| - table: function(data, opt_columns) |
| - { |
| - InjectedScriptHost.callFunction(inspectedGlobalObject.console.table, inspectedGlobalObject.console, slice(arguments)); |
| - }, |
| - |
| /** |
| * @param {number} num |
| */ |