| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 * @return {!Object} | 611 * @return {!Object} |
| 612 */ | 612 */ |
| 613 installCommandLineAPI: function(nativeCommandLineAPI) | 613 installCommandLineAPI: function(nativeCommandLineAPI) |
| 614 { | 614 { |
| 615 // NOTE: This list contains only not native Command Line API methods. Fo
r full list: V8Console. | 615 // NOTE: This list contains only not native Command Line API methods. Fo
r full list: V8Console. |
| 616 // NOTE: Argument names of these methods will be printed in the console,
so use pretty names! | 616 // NOTE: Argument names of these methods will be printed in the console,
so use pretty names! |
| 617 var members = [ "$", "$$", "$x", "monitorEvents", "unmonitorEvents", "in
spect", "copy", "getEventListeners" ]; | 617 var members = [ "$", "$$", "$x", "monitorEvents", "unmonitorEvents", "in
spect", "copy", "getEventListeners" ]; |
| 618 var commandLineAPIImpl = this._commandLineAPIImpl; | 618 var commandLineAPIImpl = this._commandLineAPIImpl; |
| 619 for (var member of members) | 619 for (var member of members) |
| 620 nativeCommandLineAPI[member] = bind(commandLineAPIImpl[member], comm
andLineAPIImpl); | 620 nativeCommandLineAPI[member] = bind(commandLineAPIImpl[member], comm
andLineAPIImpl); |
| 621 for (var i = 0; i < 5; ++i) { | |
| 622 var member = "$" + i; | |
| 623 nativeCommandLineAPI[member] = bind(commandLineAPIImpl._inspectedObj
ect, commandLineAPIImpl, i); | |
| 624 } | |
| 625 var functionToStringMap = new Map([ | 621 var functionToStringMap = new Map([ |
| 626 ["$", "function $(selector, [startNode]) { [Command Line AP
I] }"], | 622 ["$", "function $(selector, [startNode]) { [Command Line AP
I] }"], |
| 627 ["$$", "function $$(selector, [startNode]) { [Command Line A
PI] }"], | 623 ["$$", "function $$(selector, [startNode]) { [Command Line A
PI] }"], |
| 628 ["$x", "function $x(xpath, [startNode]) { [Command Line API]
}"], | 624 ["$x", "function $x(xpath, [startNode]) { [Command Line API]
}"], |
| 629 ["dir", "function dir(value) { [Command Line API] }"], | 625 ["dir", "function dir(value) { [Command Line API] }"], |
| 630 ["dirxml", "function dirxml(value) { [Command Line API] }"], | 626 ["dirxml", "function dirxml(value) { [Command Line API] }"], |
| 631 ["keys", "function keys(object) { [Command Line API] }"], | 627 ["keys", "function keys(object) { [Command Line API] }"], |
| 632 ["values", "function values(object) { [Command Line API] }"], | 628 ["values", "function values(object) { [Command Line API] }"], |
| 633 ["inspect", "function inspect(object) { [Command Line API] }"], | 629 ["inspect", "function inspect(object) { [Command Line API] }"], |
| 634 ["copy", "function copy(value) { [Command Line API] }"], | 630 ["copy", "function copy(value) { [Command Line API] }"], |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 var listeners = result[type]; | 1331 var listeners = result[type]; |
| 1336 for (var i = 0, listener; listener = listeners[i]; ++i) { | 1332 for (var i = 0, listener; listener = listeners[i]; ++i) { |
| 1337 listener["type"] = type; | 1333 listener["type"] = type; |
| 1338 listener["remove"] = removeFunc; | 1334 listener["remove"] = removeFunc; |
| 1339 } | 1335 } |
| 1340 } | 1336 } |
| 1341 return result; | 1337 return result; |
| 1342 }, | 1338 }, |
| 1343 | 1339 |
| 1344 /** | 1340 /** |
| 1345 * @param {number} num | |
| 1346 */ | |
| 1347 _inspectedObject: function(num) | |
| 1348 { | |
| 1349 return InjectedScriptHost.inspectedObject(num); | |
| 1350 }, | |
| 1351 | |
| 1352 /** | |
| 1353 * @param {!Array.<string>|string=} types | 1341 * @param {!Array.<string>|string=} types |
| 1354 * @return {!Array.<string>} | 1342 * @return {!Array.<string>} |
| 1355 */ | 1343 */ |
| 1356 _normalizeEventTypes: function(types) | 1344 _normalizeEventTypes: function(types) |
| 1357 { | 1345 { |
| 1358 if (typeof types === "undefined") | 1346 if (typeof types === "undefined") |
| 1359 types = ["mouse", "key", "touch", "pointer", "control", "load", "unl
oad", "abort", "error", "select", "input", "change", "submit", "reset", "focus",
"blur", "resize", "scroll", "search", "devicemotion", "deviceorientation"]; | 1347 types = ["mouse", "key", "touch", "pointer", "control", "load", "unl
oad", "abort", "error", "select", "input", "change", "submit", "reset", "focus",
"blur", "resize", "scroll", "search", "devicemotion", "deviceorientation"]; |
| 1360 else if (typeof types === "string") | 1348 else if (typeof types === "string") |
| 1361 types = [types]; | 1349 types = [types]; |
| 1362 | 1350 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1383 */ | 1371 */ |
| 1384 _logEvent: function(event) | 1372 _logEvent: function(event) |
| 1385 { | 1373 { |
| 1386 inspectedGlobalObject.console.log(event.type, event); | 1374 inspectedGlobalObject.console.log(event.type, event); |
| 1387 } | 1375 } |
| 1388 } | 1376 } |
| 1389 | 1377 |
| 1390 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1378 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1391 return injectedScript; | 1379 return injectedScript; |
| 1392 }) | 1380 }) |
| OLD | NEW |