| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 columns = [columns]; | 359 columns = [columns]; |
| 360 if (InjectedScriptHost.subtype(columns) === "array") { | 360 if (InjectedScriptHost.subtype(columns) === "array") { |
| 361 columnNames = []; | 361 columnNames = []; |
| 362 for (var i = 0; i < columns.length; ++i) | 362 for (var i = 0; i < columns.length; ++i) |
| 363 columnNames[i] = toString(columns[i]); | 363 columnNames[i] = toString(columns[i]); |
| 364 } | 364 } |
| 365 return this._wrapObject(table, "console", false, true, columnNames, true
); | 365 return this._wrapObject(table, "console", false, true, columnNames, true
); |
| 366 }, | 366 }, |
| 367 | 367 |
| 368 /** | 368 /** |
| 369 * @param {*} object | |
| 370 * @return {*} | |
| 371 */ | |
| 372 _inspect: function(object) | |
| 373 { | |
| 374 if (arguments.length === 0) | |
| 375 return; | |
| 376 | |
| 377 var objectId = this._wrapObject(object, ""); | |
| 378 var hints = { __proto__: null }; | |
| 379 | |
| 380 InjectedScriptHost.inspect(objectId, hints); | |
| 381 return object; | |
| 382 }, | |
| 383 | |
| 384 /** | |
| 385 * This method cannot throw. | 369 * This method cannot throw. |
| 386 * @param {*} object | 370 * @param {*} object |
| 387 * @param {string=} objectGroupName | 371 * @param {string=} objectGroupName |
| 388 * @param {boolean=} forceValueType | 372 * @param {boolean=} forceValueType |
| 389 * @param {boolean=} generatePreview | 373 * @param {boolean=} generatePreview |
| 390 * @param {?Array.<string>=} columnNames | 374 * @param {?Array.<string>=} columnNames |
| 391 * @param {boolean=} isTable | 375 * @param {boolean=} isTable |
| 392 * @param {boolean=} doNotBind | 376 * @param {boolean=} doNotBind |
| 393 * @param {*=} customObjectConfig | 377 * @param {*=} customObjectConfig |
| 394 * @return {!RuntimeAgent.RemoteObject} | 378 * @return {!RuntimeAgent.RemoteObject} |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 }, | 591 }, |
| 608 | 592 |
| 609 /** | 593 /** |
| 610 * @param {!Object} nativeCommandLineAPI | 594 * @param {!Object} nativeCommandLineAPI |
| 611 * @return {!Object} | 595 * @return {!Object} |
| 612 */ | 596 */ |
| 613 installCommandLineAPI: function(nativeCommandLineAPI) | 597 installCommandLineAPI: function(nativeCommandLineAPI) |
| 614 { | 598 { |
| 615 // NOTE: This list contains only not native Command Line API methods. Fo
r full list: V8Console. | 599 // 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! | 600 // 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" ]; | 601 var members = [ "$", "$$", "$x", "monitorEvents", "unmonitorEvents", "ge
tEventListeners" ]; |
| 618 var commandLineAPIImpl = this._commandLineAPIImpl; | 602 var commandLineAPIImpl = this._commandLineAPIImpl; |
| 619 for (var member of members) | 603 for (var member of members) |
| 620 nativeCommandLineAPI[member] = bind(commandLineAPIImpl[member], comm
andLineAPIImpl); | 604 nativeCommandLineAPI[member] = bind(commandLineAPIImpl[member], comm
andLineAPIImpl); |
| 621 var functionToStringMap = new Map([ | 605 var functionToStringMap = new Map([ |
| 622 ["$", "function $(selector, [startNode]) { [Command Line AP
I] }"], | 606 ["$", "function $(selector, [startNode]) { [Command Line AP
I] }"], |
| 623 ["$$", "function $$(selector, [startNode]) { [Command Line A
PI] }"], | 607 ["$$", "function $$(selector, [startNode]) { [Command Line A
PI] }"], |
| 624 ["$x", "function $x(xpath, [startNode]) { [Command Line API]
}"], | 608 ["$x", "function $x(xpath, [startNode]) { [Command Line API]
}"], |
| 625 ["dir", "function dir(value) { [Command Line API] }"], | 609 ["dir", "function dir(value) { [Command Line API] }"], |
| 626 ["dirxml", "function dirxml(value) { [Command Line API] }"], | 610 ["dirxml", "function dirxml(value) { [Command Line API] }"], |
| 627 ["keys", "function keys(object) { [Command Line API] }"], | 611 ["keys", "function keys(object) { [Command Line API] }"], |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 unmonitorEvents: function(object, opt_types) | 1238 unmonitorEvents: function(object, opt_types) |
| 1255 { | 1239 { |
| 1256 if (!object || !object.addEventListener || !object.removeEventListener) | 1240 if (!object || !object.addEventListener || !object.removeEventListener) |
| 1257 return; | 1241 return; |
| 1258 var types = this._normalizeEventTypes(opt_types); | 1242 var types = this._normalizeEventTypes(opt_types); |
| 1259 for (var i = 0; i < types.length; ++i) | 1243 for (var i = 0; i < types.length; ++i) |
| 1260 object.removeEventListener(types[i], this._logEvent, false); | 1244 object.removeEventListener(types[i], this._logEvent, false); |
| 1261 }, | 1245 }, |
| 1262 | 1246 |
| 1263 /** | 1247 /** |
| 1264 * @param {*} object | |
| 1265 * @return {*} | |
| 1266 */ | |
| 1267 inspect: function(object) | |
| 1268 { | |
| 1269 return injectedScript._inspect(object); | |
| 1270 }, | |
| 1271 | |
| 1272 copy: function(object) | |
| 1273 { | |
| 1274 var string; | |
| 1275 if (injectedScript._subtype(object) === "node") { | |
| 1276 string = object.outerHTML; | |
| 1277 } else if (injectedScript.isPrimitiveValue(object)) { | |
| 1278 string = toString(object); | |
| 1279 } else { | |
| 1280 try { | |
| 1281 string = JSON.stringify(object, null, " "); | |
| 1282 } catch (e) { | |
| 1283 string = toString(object); | |
| 1284 } | |
| 1285 } | |
| 1286 | |
| 1287 var hints = { copyToClipboard: true, __proto__: null }; | |
| 1288 var remoteObject = injectedScript._wrapObject(string, "") | |
| 1289 InjectedScriptHost.inspect(remoteObject, hints); | |
| 1290 }, | |
| 1291 | |
| 1292 /** | |
| 1293 * @param {!Node} node | 1248 * @param {!Node} node |
| 1294 * @return {!Object|undefined} | 1249 * @return {!Object|undefined} |
| 1295 */ | 1250 */ |
| 1296 getEventListeners: function(node) | 1251 getEventListeners: function(node) |
| 1297 { | 1252 { |
| 1298 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod
e)); | 1253 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod
e)); |
| 1299 if (!result) | 1254 if (!result) |
| 1300 return; | 1255 return; |
| 1301 | 1256 |
| 1302 // TODO(dtapuska): Remove this one closure compiler is updated | 1257 // TODO(dtapuska): Remove this one closure compiler is updated |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 */ | 1326 */ |
| 1372 _logEvent: function(event) | 1327 _logEvent: function(event) |
| 1373 { | 1328 { |
| 1374 inspectedGlobalObject.console.log(event.type, event); | 1329 inspectedGlobalObject.console.log(event.type, event); |
| 1375 } | 1330 } |
| 1376 } | 1331 } |
| 1377 | 1332 |
| 1378 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1333 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1379 return injectedScript; | 1334 return injectedScript; |
| 1380 }) | 1335 }) |
| OLD | NEW |