| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 function toStringDescription(obj) | 98 function toStringDescription(obj) |
| 99 { | 99 { |
| 100 if (typeof obj === "number" && obj === 0 && 1 / obj < 0) | 100 if (typeof obj === "number" && obj === 0 && 1 / obj < 0) |
| 101 return "-0"; // Negative zero. | 101 return "-0"; // Negative zero. |
| 102 return "" + obj; | 102 return "" + obj; |
| 103 } | 103 } |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Please use this bind, not the one from Function.prototype | 106 * Please use this bind, not the one from Function.prototype |
| 107 * @param {function(...)} func | 107 * @param {function(...)} func |
| 108 * @param {Object} thisObject | 108 * @param {?Object} thisObject |
| 109 * @param {...} var_args | 109 * @param {...} var_args |
| 110 * @return {function(...)} |
| 110 */ | 111 */ |
| 111 function bind(func, thisObject, var_args) | 112 function bind(func, thisObject, var_args) |
| 112 { | 113 { |
| 113 var args = slice(arguments, 2); | 114 var args = slice(arguments, 2); |
| 114 | 115 |
| 115 /** | 116 /** |
| 116 * @param {...} var_args | 117 * @param {...} var_args |
| 117 */ | 118 */ |
| 118 function bound(var_args) | 119 function bound(var_args) |
| 119 { | 120 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return a > b ? a : b; | 173 return a > b ? a : b; |
| 173 } | 174 } |
| 174 | 175 |
| 175 /** | 176 /** |
| 176 * @constructor | 177 * @constructor |
| 177 */ | 178 */ |
| 178 var InjectedScript = function() | 179 var InjectedScript = function() |
| 179 { | 180 { |
| 180 /** @type {number} */ | 181 /** @type {number} */ |
| 181 this._lastBoundObjectId = 1; | 182 this._lastBoundObjectId = 1; |
| 182 /** @type {!Object.<number, Object>} */ | 183 /** @type {!Object.<number, !Object>} */ |
| 183 this._idToWrappedObject = { __proto__: null }; | 184 this._idToWrappedObject = { __proto__: null }; |
| 184 /** @type {!Object.<number, string>} */ | 185 /** @type {!Object.<number, string>} */ |
| 185 this._idToObjectGroupName = { __proto__: null }; | 186 this._idToObjectGroupName = { __proto__: null }; |
| 186 /** @type {!Object.<string, Array.<number>>} */ | 187 /** @type {!Object.<string, !Array.<number>>} */ |
| 187 this._objectGroups = { __proto__: null }; | 188 this._objectGroups = { __proto__: null }; |
| 188 /** @type {!Object.<string, Object>} */ | 189 /** @type {!Object.<string, !Object>} */ |
| 189 this._modules = { __proto__: null }; | 190 this._modules = { __proto__: null }; |
| 190 } | 191 } |
| 191 | 192 |
| 192 /** | 193 /** |
| 193 * @type {!Object.<string, boolean>} | 194 * @type {!Object.<string, boolean>} |
| 194 * @const | 195 * @const |
| 195 */ | 196 */ |
| 196 InjectedScript.primitiveTypes = { | 197 InjectedScript.primitiveTypes = { |
| 197 "undefined": true, | 198 "undefined": true, |
| 198 "boolean": true, | 199 "boolean": true, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 result.type = typeof object; | 237 result.type = typeof object; |
| 237 if (this.isPrimitiveValue(object)) | 238 if (this.isPrimitiveValue(object)) |
| 238 result.value = object; | 239 result.value = object; |
| 239 else | 240 else |
| 240 result.description = toString(object); | 241 result.description = toString(object); |
| 241 return /** @type {!RuntimeAgent.RemoteObject} */ (result); | 242 return /** @type {!RuntimeAgent.RemoteObject} */ (result); |
| 242 }, | 243 }, |
| 243 | 244 |
| 244 /** | 245 /** |
| 245 * @param {boolean} canAccessInspectedWindow | 246 * @param {boolean} canAccessInspectedWindow |
| 246 * @param {Object} table | 247 * @param {!Object} table |
| 247 * @param {Array.<string>|string|boolean} columns | 248 * @param {!Array.<string>|string|boolean} columns |
| 248 * @return {!RuntimeAgent.RemoteObject} | 249 * @return {!RuntimeAgent.RemoteObject} |
| 249 */ | 250 */ |
| 250 wrapTable: function(canAccessInspectedWindow, table, columns) | 251 wrapTable: function(canAccessInspectedWindow, table, columns) |
| 251 { | 252 { |
| 252 if (!canAccessInspectedWindow) | 253 if (!canAccessInspectedWindow) |
| 253 return this._fallbackWrapper(table); | 254 return this._fallbackWrapper(table); |
| 254 var columnNames = null; | 255 var columnNames = null; |
| 255 if (typeof columns === "string") | 256 if (typeof columns === "string") |
| 256 columns = [columns]; | 257 columns = [columns]; |
| 257 if (InjectedScriptHost.type(columns) == "array") { | 258 if (InjectedScriptHost.type(columns) == "array") { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 try { | 306 try { |
| 306 var description = injectedScript._describe(e); | 307 var description = injectedScript._describe(e); |
| 307 } catch (ex) { | 308 } catch (ex) { |
| 308 var description = "<failed to convert exception to string>"; | 309 var description = "<failed to convert exception to string>"; |
| 309 } | 310 } |
| 310 return new InjectedScript.RemoteObject(description); | 311 return new InjectedScript.RemoteObject(description); |
| 311 } | 312 } |
| 312 }, | 313 }, |
| 313 | 314 |
| 314 /** | 315 /** |
| 315 * @param {Object} object | 316 * @param {!Object} object |
| 316 * @param {string=} objectGroupName | 317 * @param {string=} objectGroupName |
| 317 * @return {string} | 318 * @return {string} |
| 318 */ | 319 */ |
| 319 _bind: function(object, objectGroupName) | 320 _bind: function(object, objectGroupName) |
| 320 { | 321 { |
| 321 var id = this._lastBoundObjectId++; | 322 var id = this._lastBoundObjectId++; |
| 322 this._idToWrappedObject[id] = object; | 323 this._idToWrappedObject[id] = object; |
| 323 var objectId = "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":"
+ id + "}"; | 324 var objectId = "{\"injectedScriptId\":" + injectedScriptId + ",\"id\":"
+ id + "}"; |
| 324 if (objectGroupName) { | 325 if (objectGroupName) { |
| 325 var group = this._objectGroups[objectGroupName]; | 326 var group = this._objectGroups[objectGroupName]; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 inspectedWindow.console.error("Web Inspector error: InjectedScript.%
s returns undefined", methodName); | 369 inspectedWindow.console.error("Web Inspector error: InjectedScript.%
s returns undefined", methodName); |
| 369 result = null; | 370 result = null; |
| 370 } | 371 } |
| 371 return result; | 372 return result; |
| 372 }, | 373 }, |
| 373 | 374 |
| 374 /** | 375 /** |
| 375 * @param {string} objectId | 376 * @param {string} objectId |
| 376 * @param {boolean} ownProperties | 377 * @param {boolean} ownProperties |
| 377 * @param {boolean} accessorPropertiesOnly | 378 * @param {boolean} accessorPropertiesOnly |
| 378 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean} | 379 * @return {!Array.<!RuntimeAgent.PropertyDescriptor>|boolean} |
| 379 */ | 380 */ |
| 380 getProperties: function(objectId, ownProperties, accessorPropertiesOnly) | 381 getProperties: function(objectId, ownProperties, accessorPropertiesOnly) |
| 381 { | 382 { |
| 382 var parsedObjectId = this._parseObjectId(objectId); | 383 var parsedObjectId = this._parseObjectId(objectId); |
| 383 var object = this._objectForId(parsedObjectId); | 384 var object = this._objectForId(parsedObjectId); |
| 384 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; | 385 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; |
| 385 | 386 |
| 386 if (!this._isDefined(object)) | 387 if (!this._isDefined(object)) |
| 387 return false; | 388 return false; |
| 388 var descriptors = this._propertyDescriptors(object, ownProperties, acces
sorPropertiesOnly); | 389 var descriptors = this._propertyDescriptors(object, ownProperties, acces
sorPropertiesOnly); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 401 if (!("enumerable" in descriptor)) | 402 if (!("enumerable" in descriptor)) |
| 402 descriptor.enumerable = false; | 403 descriptor.enumerable = false; |
| 403 if ("symbol" in descriptor) | 404 if ("symbol" in descriptor) |
| 404 descriptor.symbol = this._wrapObject(descriptor.symbol, objectGr
oupName); | 405 descriptor.symbol = this._wrapObject(descriptor.symbol, objectGr
oupName); |
| 405 } | 406 } |
| 406 return descriptors; | 407 return descriptors; |
| 407 }, | 408 }, |
| 408 | 409 |
| 409 /** | 410 /** |
| 410 * @param {string} objectId | 411 * @param {string} objectId |
| 411 * @return {Array.<Object>|boolean} | 412 * @return {!Array.<!Object>|boolean} |
| 412 */ | 413 */ |
| 413 getInternalProperties: function(objectId, ownProperties) | 414 getInternalProperties: function(objectId) |
| 414 { | 415 { |
| 415 var parsedObjectId = this._parseObjectId(objectId); | 416 var parsedObjectId = this._parseObjectId(objectId); |
| 416 var object = this._objectForId(parsedObjectId); | 417 var object = this._objectForId(parsedObjectId); |
| 417 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; | 418 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; |
| 418 if (!this._isDefined(object)) | 419 if (!this._isDefined(object)) |
| 419 return false; | 420 return false; |
| 420 var descriptors = []; | 421 var descriptors = []; |
| 421 var internalProperties = InjectedScriptHost.getInternalProperties(object
); | 422 var internalProperties = InjectedScriptHost.getInternalProperties(object
); |
| 422 if (internalProperties) { | 423 if (internalProperties) { |
| 423 for (var i = 0; i < internalProperties.length; i++) { | 424 for (var i = 0; i < internalProperties.length; i++) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 /** | 469 /** |
| 469 * @param {number} id | 470 * @param {number} id |
| 470 */ | 471 */ |
| 471 _releaseObject: function(id) | 472 _releaseObject: function(id) |
| 472 { | 473 { |
| 473 delete this._idToWrappedObject[id]; | 474 delete this._idToWrappedObject[id]; |
| 474 delete this._idToObjectGroupName[id]; | 475 delete this._idToObjectGroupName[id]; |
| 475 }, | 476 }, |
| 476 | 477 |
| 477 /** | 478 /** |
| 478 * @param {Object} object | 479 * @param {!Object} object |
| 479 * @param {boolean=} ownProperties | 480 * @param {boolean=} ownProperties |
| 480 * @param {boolean=} accessorPropertiesOnly | 481 * @param {boolean=} accessorPropertiesOnly |
| 481 * @return {Array.<Object>} | 482 * @return {!Array.<!Object>} |
| 482 */ | 483 */ |
| 483 _propertyDescriptors: function(object, ownProperties, accessorPropertiesOnly
) | 484 _propertyDescriptors: function(object, ownProperties, accessorPropertiesOnly
) |
| 484 { | 485 { |
| 485 var descriptors = []; | 486 var descriptors = []; |
| 486 var propertyProcessed = { __proto__: null }; | 487 var propertyProcessed = { __proto__: null }; |
| 487 | 488 |
| 488 /** | 489 /** |
| 489 * @param {Object} o | 490 * @param {?Object} o |
| 490 * @param {!Array.<string|symbol>} properties | 491 * @param {!Array.<string|symbol>} properties |
| 491 */ | 492 */ |
| 492 function process(o, properties) | 493 function process(o, properties) |
| 493 { | 494 { |
| 494 for (var i = 0; i < properties.length; ++i) { | 495 for (var i = 0; i < properties.length; ++i) { |
| 495 var property = properties[i]; | 496 var property = properties[i]; |
| 496 if (propertyProcessed[property]) | 497 if (propertyProcessed[property]) |
| 497 continue; | 498 continue; |
| 498 | 499 |
| 499 var name = property; | 500 var name = property; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 * @return {*} | 565 * @return {*} |
| 565 */ | 566 */ |
| 566 evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByVa
lue, generatePreview) | 567 evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByVa
lue, generatePreview) |
| 567 { | 568 { |
| 568 return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScript
Host, expression, objectGroup, false, injectCommandLineAPI, returnByValue, gener
atePreview); | 569 return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScript
Host, expression, objectGroup, false, injectCommandLineAPI, returnByValue, gener
atePreview); |
| 569 }, | 570 }, |
| 570 | 571 |
| 571 /** | 572 /** |
| 572 * @param {string} objectId | 573 * @param {string} objectId |
| 573 * @param {string} expression | 574 * @param {string} expression |
| 575 * @param {string} args |
| 574 * @param {boolean} returnByValue | 576 * @param {boolean} returnByValue |
| 575 * @return {!Object|string} | 577 * @return {!Object|string} |
| 576 */ | 578 */ |
| 577 callFunctionOn: function(objectId, expression, args, returnByValue) | 579 callFunctionOn: function(objectId, expression, args, returnByValue) |
| 578 { | 580 { |
| 579 var parsedObjectId = this._parseObjectId(objectId); | 581 var parsedObjectId = this._parseObjectId(objectId); |
| 580 var object = this._objectForId(parsedObjectId); | 582 var object = this._objectForId(parsedObjectId); |
| 581 if (!this._isDefined(object)) | 583 if (!this._isDefined(object)) |
| 582 return "Could not find object with given id"; | 584 return "Could not find object with given id"; |
| 583 | 585 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 602 return { wasThrown: false, | 604 return { wasThrown: false, |
| 603 result: this._wrapObject(func.apply(object, resolvedArgs),
objectGroup, returnByValue), | 605 result: this._wrapObject(func.apply(object, resolvedArgs),
objectGroup, returnByValue), |
| 604 __proto__: null }; | 606 __proto__: null }; |
| 605 } catch (e) { | 607 } catch (e) { |
| 606 return this._createThrownValue(e, objectGroup); | 608 return this._createThrownValue(e, objectGroup); |
| 607 } | 609 } |
| 608 }, | 610 }, |
| 609 | 611 |
| 610 /** | 612 /** |
| 611 * Resolves a value from CallArgument description. | 613 * Resolves a value from CallArgument description. |
| 612 * @param {RuntimeAgent.CallArgument} callArgumentJson | 614 * @param {!RuntimeAgent.CallArgument} callArgumentJson |
| 613 * @return {*} resolved value | 615 * @return {*} resolved value |
| 614 * @throws {string} error message | 616 * @throws {string} error message |
| 615 */ | 617 */ |
| 616 _resolveCallArgument: function(callArgumentJson) | 618 _resolveCallArgument: function(callArgumentJson) |
| 617 { | 619 { |
| 618 callArgumentJson = nullifyObjectProto(callArgumentJson); | 620 callArgumentJson = nullifyObjectProto(callArgumentJson); |
| 619 var objectId = callArgumentJson.objectId; | 621 var objectId = callArgumentJson.objectId; |
| 620 if (objectId) { | 622 if (objectId) { |
| 621 var parsedArgId = this._parseObjectId(objectId); | 623 var parsedArgId = this._parseObjectId(objectId); |
| 622 if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScri
ptId) | 624 if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScri
ptId) |
| 623 throw "Arguments should belong to the same JavaScript world as t
he target object."; | 625 throw "Arguments should belong to the same JavaScript world as t
he target object."; |
| 624 | 626 |
| 625 var resolvedArg = this._objectForId(parsedArgId); | 627 var resolvedArg = this._objectForId(parsedArgId); |
| 626 if (!this._isDefined(resolvedArg)) | 628 if (!this._isDefined(resolvedArg)) |
| 627 throw "Could not find object with given id"; | 629 throw "Could not find object with given id"; |
| 628 | 630 |
| 629 return resolvedArg; | 631 return resolvedArg; |
| 630 } else if ("value" in callArgumentJson) { | 632 } else if ("value" in callArgumentJson) { |
| 631 var value = callArgumentJson.value; | 633 var value = callArgumentJson.value; |
| 632 if (callArgumentJson.type === "number" && typeof value !== "number") | 634 if (callArgumentJson.type === "number" && typeof value !== "number") |
| 633 value = Number(value); | 635 value = Number(value); |
| 634 return value; | 636 return value; |
| 635 } | 637 } |
| 636 return undefined; | 638 return undefined; |
| 637 }, | 639 }, |
| 638 | 640 |
| 639 /** | 641 /** |
| 640 * @param {Function} evalFunction | 642 * @param {!Function} evalFunction |
| 641 * @param {Object} object | 643 * @param {!Object} object |
| 644 * @param {string} expression |
| 642 * @param {string} objectGroup | 645 * @param {string} objectGroup |
| 643 * @param {boolean} isEvalOnCallFrame | 646 * @param {boolean} isEvalOnCallFrame |
| 644 * @param {boolean} injectCommandLineAPI | 647 * @param {boolean} injectCommandLineAPI |
| 645 * @param {boolean} returnByValue | 648 * @param {boolean} returnByValue |
| 646 * @param {boolean} generatePreview | 649 * @param {boolean} generatePreview |
| 647 * @param {!Array.<!Object>=} scopeChain | 650 * @param {!Array.<!Object>=} scopeChain |
| 648 * @return {!Object} | 651 * @return {!Object} |
| 649 */ | 652 */ |
| 650 _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, is
EvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, scopeChai
n) | 653 _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, is
EvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, scopeChai
n) |
| 651 { | 654 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 666 _createThrownValue: function(value, objectGroup) | 669 _createThrownValue: function(value, objectGroup) |
| 667 { | 670 { |
| 668 var remoteObject = this._wrapObject(value, objectGroup); | 671 var remoteObject = this._wrapObject(value, objectGroup); |
| 669 try { | 672 try { |
| 670 remoteObject.description = toStringDescription(value); | 673 remoteObject.description = toStringDescription(value); |
| 671 } catch (e) {} | 674 } catch (e) {} |
| 672 return { wasThrown: true, result: remoteObject, __proto__: null }; | 675 return { wasThrown: true, result: remoteObject, __proto__: null }; |
| 673 }, | 676 }, |
| 674 | 677 |
| 675 /** | 678 /** |
| 676 * @param {Function} evalFunction | 679 * @param {!Function} evalFunction |
| 677 * @param {Object} object | 680 * @param {!Object} object |
| 678 * @param {string} objectGroup | 681 * @param {string} objectGroup |
| 679 * @param {string} expression | 682 * @param {string} expression |
| 680 * @param {boolean} isEvalOnCallFrame | 683 * @param {boolean} isEvalOnCallFrame |
| 681 * @param {boolean} injectCommandLineAPI | 684 * @param {boolean} injectCommandLineAPI |
| 682 * @param {!Array.<!Object>=} scopeChain | 685 * @param {!Array.<!Object>=} scopeChain |
| 683 * @return {*} | 686 * @return {*} |
| 684 */ | 687 */ |
| 685 _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalO
nCallFrame, injectCommandLineAPI, scopeChain) | 688 _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalO
nCallFrame, injectCommandLineAPI, scopeChain) |
| 686 { | 689 { |
| 687 // Only install command line api object for the time of evaluation. | 690 // Only install command line api object for the time of evaluation. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 if (asyncOrdinal) | 869 if (asyncOrdinal) |
| 867 topCallFrame = asyncCallStacks[asyncOrdinal - 1]; | 870 topCallFrame = asyncCallStacks[asyncOrdinal - 1]; |
| 868 var ordinal = parsedCallFrameId["ordinal"]; | 871 var ordinal = parsedCallFrameId["ordinal"]; |
| 869 var callFrame = topCallFrame; | 872 var callFrame = topCallFrame; |
| 870 while (--ordinal >= 0 && callFrame) | 873 while (--ordinal >= 0 && callFrame) |
| 871 callFrame = callFrame.caller; | 874 callFrame = callFrame.caller; |
| 872 return callFrame; | 875 return callFrame; |
| 873 }, | 876 }, |
| 874 | 877 |
| 875 /** | 878 /** |
| 876 * @param {Object} objectId | 879 * @param {!Object} objectId |
| 877 * @return {Object} | 880 * @return {!Object} |
| 878 */ | 881 */ |
| 879 _objectForId: function(objectId) | 882 _objectForId: function(objectId) |
| 880 { | 883 { |
| 881 return this._idToWrappedObject[objectId.id]; | 884 return this._idToWrappedObject[objectId.id]; |
| 882 }, | 885 }, |
| 883 | 886 |
| 884 /** | 887 /** |
| 885 * @param {string} objectId | 888 * @param {string} objectId |
| 886 * @return {Object} | 889 * @return {!Object} |
| 887 */ | 890 */ |
| 888 findObjectById: function(objectId) | 891 findObjectById: function(objectId) |
| 889 { | 892 { |
| 890 var parsedObjectId = this._parseObjectId(objectId); | 893 var parsedObjectId = this._parseObjectId(objectId); |
| 891 return this._objectForId(parsedObjectId); | 894 return this._objectForId(parsedObjectId); |
| 892 }, | 895 }, |
| 893 | 896 |
| 894 /** | 897 /** |
| 895 * @param {string} objectId | 898 * @param {string} objectId |
| 896 * @return {Node} | 899 * @return {?Node} |
| 897 */ | 900 */ |
| 898 nodeForObjectId: function(objectId) | 901 nodeForObjectId: function(objectId) |
| 899 { | 902 { |
| 900 var object = this.findObjectById(objectId); | 903 var object = this.findObjectById(objectId); |
| 901 if (!object || this._subtype(object) !== "node") | 904 if (!object || this._subtype(object) !== "node") |
| 902 return null; | 905 return null; |
| 903 return /** @type {Node} */ (object); | 906 return /** @type {!Node} */ (object); |
| 904 }, | 907 }, |
| 905 | 908 |
| 906 /** | 909 /** |
| 907 * @param {string} name | 910 * @param {string} name |
| 908 * @return {Object} | 911 * @return {!Object} |
| 909 */ | 912 */ |
| 910 module: function(name) | 913 module: function(name) |
| 911 { | 914 { |
| 912 return this._modules[name]; | 915 return this._modules[name]; |
| 913 }, | 916 }, |
| 914 | 917 |
| 915 /** | 918 /** |
| 916 * @param {string} name | 919 * @param {string} name |
| 917 * @param {string} source | 920 * @param {string} source |
| 918 * @return {Object} | 921 * @return {?Object} |
| 919 */ | 922 */ |
| 920 injectModule: function(name, source) | 923 injectModule: function(name, source) |
| 921 { | 924 { |
| 922 delete this._modules[name]; | 925 delete this._modules[name]; |
| 923 var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")"); | 926 var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")"); |
| 924 if (typeof moduleFunction !== "function") { | 927 if (typeof moduleFunction !== "function") { |
| 925 inspectedWindow.console.error("Web Inspector error: A function was e
xpected for module %s evaluation", name); | 928 inspectedWindow.console.error("Web Inspector error: A function was e
xpected for module %s evaluation", name); |
| 926 return null; | 929 return null; |
| 927 } | 930 } |
| 928 var module = moduleFunction.call(inspectedWindow, InjectedScriptHost, in
spectedWindow, injectedScriptId, this); | 931 var module = moduleFunction.call(inspectedWindow, InjectedScriptHost, in
spectedWindow, injectedScriptId, this); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 944 * @return {boolean} | 947 * @return {boolean} |
| 945 */ | 948 */ |
| 946 _isHTMLAllCollection: function(object) | 949 _isHTMLAllCollection: function(object) |
| 947 { | 950 { |
| 948 // document.all is reported as undefined, but we still want to process i
t. | 951 // document.all is reported as undefined, but we still want to process i
t. |
| 949 return (typeof object === "undefined") && InjectedScriptHost.isHTMLAllCo
llection(object); | 952 return (typeof object === "undefined") && InjectedScriptHost.isHTMLAllCo
llection(object); |
| 950 }, | 953 }, |
| 951 | 954 |
| 952 /** | 955 /** |
| 953 * @param {*} obj | 956 * @param {*} obj |
| 954 * @return {string?} | 957 * @return {?string} |
| 955 */ | 958 */ |
| 956 _subtype: function(obj) | 959 _subtype: function(obj) |
| 957 { | 960 { |
| 958 if (obj === null) | 961 if (obj === null) |
| 959 return "null"; | 962 return "null"; |
| 960 | 963 |
| 961 if (this.isPrimitiveValue(obj)) | 964 if (this.isPrimitiveValue(obj)) |
| 962 return null; | 965 return null; |
| 963 | 966 |
| 964 if (this._isHTMLAllCollection(obj)) | 967 if (this._isHTMLAllCollection(obj)) |
| 965 return "array"; | 968 return "array"; |
| 966 | 969 |
| 967 var preciseType = InjectedScriptHost.type(obj); | 970 var preciseType = InjectedScriptHost.type(obj); |
| 968 if (preciseType) | 971 if (preciseType) |
| 969 return preciseType; | 972 return preciseType; |
| 970 | 973 |
| 971 if (isArrayLike(obj)) | 974 if (isArrayLike(obj)) |
| 972 return "array"; | 975 return "array"; |
| 973 | 976 |
| 974 // If owning frame has navigated to somewhere else window properties wil
l be undefined. | 977 // If owning frame has navigated to somewhere else window properties wil
l be undefined. |
| 975 return null; | 978 return null; |
| 976 }, | 979 }, |
| 977 | 980 |
| 978 /** | 981 /** |
| 979 * @param {*} obj | 982 * @param {*} obj |
| 980 * @return {string?} | 983 * @return {?string} |
| 981 */ | 984 */ |
| 982 _describe: function(obj) | 985 _describe: function(obj) |
| 983 { | 986 { |
| 984 if (this.isPrimitiveValue(obj)) | 987 if (this.isPrimitiveValue(obj)) |
| 985 return null; | 988 return null; |
| 986 | 989 |
| 987 var type = typeof obj; | 990 var type = typeof obj; |
| 988 var subtype = this._subtype(obj); | 991 var subtype = this._subtype(obj); |
| 989 | 992 |
| 990 if (subtype === "regexp") | 993 if (subtype === "regexp") |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 case "-Infinity": | 1078 case "-Infinity": |
| 1076 case "-0": | 1079 case "-0": |
| 1077 this.value = this.description; | 1080 this.value = this.description; |
| 1078 break; | 1081 break; |
| 1079 } | 1082 } |
| 1080 } | 1083 } |
| 1081 | 1084 |
| 1082 return; | 1085 return; |
| 1083 } | 1086 } |
| 1084 | 1087 |
| 1085 object = /** @type {Object} */ (object); | 1088 object = /** @type {!Object} */ (object); |
| 1086 | 1089 |
| 1087 this.objectId = injectedScript._bind(object, objectGroupName); | 1090 this.objectId = injectedScript._bind(object, objectGroupName); |
| 1088 var subtype = injectedScript._subtype(object); | 1091 var subtype = injectedScript._subtype(object); |
| 1089 if (subtype) | 1092 if (subtype) |
| 1090 this.subtype = subtype; | 1093 this.subtype = subtype; |
| 1091 var className = InjectedScriptHost.internalConstructorName(object); | 1094 var className = InjectedScriptHost.internalConstructorName(object); |
| 1092 if (className) | 1095 if (className) |
| 1093 this.className = className; | 1096 this.className = className; |
| 1094 this.description = injectedScript._describe(object); | 1097 this.description = injectedScript._describe(object); |
| 1095 | 1098 |
| 1096 if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllC
ollection(object))) | 1099 if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllC
ollection(object))) |
| 1097 this.preview = this._generatePreview(object, undefined, columnNames, isT
able, false); | 1100 this.preview = this._generatePreview(object, undefined, columnNames, isT
able, false); |
| 1098 } | 1101 } |
| 1099 | 1102 |
| 1100 InjectedScript.RemoteObject.prototype = { | 1103 InjectedScript.RemoteObject.prototype = { |
| 1101 /** | 1104 /** |
| 1102 * @param {Object} object | 1105 * @param {!Object} object |
| 1103 * @param {Array.<string>=} firstLevelKeys | 1106 * @param {?Array.<string>=} firstLevelKeys |
| 1104 * @param {?Array.<string>=} secondLevelKeys | 1107 * @param {?Array.<string>=} secondLevelKeys |
| 1105 * @param {boolean=} isTable | 1108 * @param {boolean=} isTable |
| 1106 * @param {boolean=} isTableRow | 1109 * @param {boolean=} isTableRow |
| 1107 * @return {!RuntimeAgent.ObjectPreview} preview | 1110 * @return {!RuntimeAgent.ObjectPreview} preview |
| 1108 */ | 1111 */ |
| 1109 _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable,
isTableRow) | 1112 _generatePreview: function(object, firstLevelKeys, secondLevelKeys, isTable,
isTableRow) |
| 1110 { | 1113 { |
| 1111 var preview = { __proto__: null }; | 1114 var preview = { __proto__: null }; |
| 1112 preview.lossless = true; | 1115 preview.lossless = true; |
| 1113 preview.overflow = false; | 1116 preview.overflow = false; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 this.functionName = (callFrame.type === "function" ? callFrame.functionName
: ""); | 1266 this.functionName = (callFrame.type === "function" ? callFrame.functionName
: ""); |
| 1264 this.location = { scriptId: toString(callFrame.sourceID), lineNumber: callFr
ame.line, columnNumber: callFrame.column, __proto__: null }; | 1267 this.location = { scriptId: toString(callFrame.sourceID), lineNumber: callFr
ame.line, columnNumber: callFrame.column, __proto__: null }; |
| 1265 this.scopeChain = this._wrapScopeChain(callFrame); | 1268 this.scopeChain = this._wrapScopeChain(callFrame); |
| 1266 this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace"); | 1269 this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace"); |
| 1267 if (callFrame.isAtReturn) | 1270 if (callFrame.isAtReturn) |
| 1268 this.returnValue = injectedScript._wrapObject(callFrame.returnValue, "ba
cktrace"); | 1271 this.returnValue = injectedScript._wrapObject(callFrame.returnValue, "ba
cktrace"); |
| 1269 } | 1272 } |
| 1270 | 1273 |
| 1271 InjectedScript.CallFrameProxy.prototype = { | 1274 InjectedScript.CallFrameProxy.prototype = { |
| 1272 /** | 1275 /** |
| 1273 * @param {Object} callFrame | 1276 * @param {!Object} callFrame |
| 1274 * @return {!Array.<DebuggerAgent.Scope>} | 1277 * @return {!Array.<!DebuggerAgent.Scope>} |
| 1275 */ | 1278 */ |
| 1276 _wrapScopeChain: function(callFrame) | 1279 _wrapScopeChain: function(callFrame) |
| 1277 { | 1280 { |
| 1278 var scopeChain = callFrame.scopeChain; | 1281 var scopeChain = callFrame.scopeChain; |
| 1279 var scopeChainProxy = []; | 1282 var scopeChainProxy = []; |
| 1280 for (var i = 0; i < scopeChain.length; ++i) | 1283 for (var i = 0; i < scopeChain.length; ++i) |
| 1281 scopeChainProxy[i] = InjectedScript.CallFrameProxy._createScopeJson(
callFrame.scopeType(i), scopeChain[i], "backtrace"); | 1284 scopeChainProxy[i] = InjectedScript.CallFrameProxy._createScopeJson(
callFrame.scopeType(i), scopeChain[i], "backtrace"); |
| 1282 return scopeChainProxy; | 1285 return scopeChainProxy; |
| 1283 }, | 1286 }, |
| 1284 | 1287 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1302 /** @type {!Object.<number, string>} */ | 1305 /** @type {!Object.<number, string>} */ |
| 1303 var scopeTypeNames = { __proto__: null }; | 1306 var scopeTypeNames = { __proto__: null }; |
| 1304 scopeTypeNames[GLOBAL_SCOPE] = "global"; | 1307 scopeTypeNames[GLOBAL_SCOPE] = "global"; |
| 1305 scopeTypeNames[LOCAL_SCOPE] = "local"; | 1308 scopeTypeNames[LOCAL_SCOPE] = "local"; |
| 1306 scopeTypeNames[WITH_SCOPE] = "with"; | 1309 scopeTypeNames[WITH_SCOPE] = "with"; |
| 1307 scopeTypeNames[CLOSURE_SCOPE] = "closure"; | 1310 scopeTypeNames[CLOSURE_SCOPE] = "closure"; |
| 1308 scopeTypeNames[CATCH_SCOPE] = "catch"; | 1311 scopeTypeNames[CATCH_SCOPE] = "catch"; |
| 1309 | 1312 |
| 1310 return { | 1313 return { |
| 1311 object: injectedScript._wrapObject(scopeObject, groupId), | 1314 object: injectedScript._wrapObject(scopeObject, groupId), |
| 1312 type: /** @type {DebuggerAgent.ScopeType} */ (scopeTypeNames[scopeTypeCo
de]), | 1315 type: /** @type {!DebuggerAgent.ScopeType} */ (scopeTypeNames[scopeTypeC
ode]), |
| 1313 __proto__: null | 1316 __proto__: null |
| 1314 }; | 1317 }; |
| 1315 } | 1318 } |
| 1316 | 1319 |
| 1317 /** | 1320 /** |
| 1318 * @constructor | 1321 * @constructor |
| 1319 * @param {CommandLineAPIImpl} commandLineAPIImpl | 1322 * @param {!CommandLineAPIImpl} commandLineAPIImpl |
| 1320 * @param {Object} callFrame | 1323 * @param {?Object} callFrame |
| 1321 */ | 1324 */ |
| 1322 function CommandLineAPI(commandLineAPIImpl, callFrame) | 1325 function CommandLineAPI(commandLineAPIImpl, callFrame) |
| 1323 { | 1326 { |
| 1324 /** | 1327 /** |
| 1325 * @param {string} member | 1328 * @param {string} member |
| 1326 * @return {boolean} | 1329 * @return {boolean} |
| 1327 */ | 1330 */ |
| 1328 function inScopeVariables(member) | 1331 function inScopeVariables(member) |
| 1329 { | 1332 { |
| 1330 if (!callFrame) | 1333 if (!callFrame) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 } | 1381 } |
| 1379 | 1382 |
| 1380 this.$_ = injectedScript._lastResult; | 1383 this.$_ = injectedScript._lastResult; |
| 1381 | 1384 |
| 1382 this.__proto__ = null; | 1385 this.__proto__ = null; |
| 1383 } | 1386 } |
| 1384 | 1387 |
| 1385 // NOTE: Please keep the list of API methods below snchronized to that in WebIns
pector.RuntimeModel! | 1388 // NOTE: Please keep the list of API methods below snchronized to that in WebIns
pector.RuntimeModel! |
| 1386 // NOTE: Argument names of these methods will be printed in the console, so use
pretty names! | 1389 // NOTE: Argument names of these methods will be printed in the console, so use
pretty names! |
| 1387 /** | 1390 /** |
| 1388 * @type {Array.<string>} | 1391 * @type {!Array.<string>} |
| 1389 * @const | 1392 * @const |
| 1390 */ | 1393 */ |
| 1391 CommandLineAPI.members_ = [ | 1394 CommandLineAPI.members_ = [ |
| 1392 "$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd", | 1395 "$", "$$", "$x", "dir", "dirxml", "keys", "values", "profile", "profileEnd", |
| 1393 "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventLis
teners", | 1396 "monitorEvents", "unmonitorEvents", "inspect", "copy", "clear", "getEventLis
teners", |
| 1394 "debug", "undebug", "monitor", "unmonitor", "table" | 1397 "debug", "undebug", "monitor", "unmonitor", "table" |
| 1395 ]; | 1398 ]; |
| 1396 | 1399 |
| 1397 /** | 1400 /** |
| 1398 * @constructor | 1401 * @constructor |
| 1399 */ | 1402 */ |
| 1400 function CommandLineAPIImpl() | 1403 function CommandLineAPIImpl() |
| 1401 { | 1404 { |
| 1402 } | 1405 } |
| 1403 | 1406 |
| 1404 CommandLineAPIImpl.prototype = { | 1407 CommandLineAPIImpl.prototype = { |
| 1405 /** | 1408 /** |
| 1406 * @param {string} selector | 1409 * @param {string} selector |
| 1407 * @param {Node=} opt_startNode | 1410 * @param {!Node=} opt_startNode |
| 1411 * @return {*} |
| 1408 */ | 1412 */ |
| 1409 $: function (selector, opt_startNode) | 1413 $: function (selector, opt_startNode) |
| 1410 { | 1414 { |
| 1411 if (this._canQuerySelectorOnNode(opt_startNode)) | 1415 if (this._canQuerySelectorOnNode(opt_startNode)) |
| 1412 return opt_startNode.querySelector(selector); | 1416 return opt_startNode.querySelector(selector); |
| 1413 | 1417 |
| 1414 return inspectedWindow.document.querySelector(selector); | 1418 return inspectedWindow.document.querySelector(selector); |
| 1415 }, | 1419 }, |
| 1416 | 1420 |
| 1417 /** | 1421 /** |
| 1418 * @param {string} selector | 1422 * @param {string} selector |
| 1419 * @param {Node=} opt_startNode | 1423 * @param {!Node=} opt_startNode |
| 1424 * @return {*} |
| 1420 */ | 1425 */ |
| 1421 $$: function (selector, opt_startNode) | 1426 $$: function (selector, opt_startNode) |
| 1422 { | 1427 { |
| 1423 if (this._canQuerySelectorOnNode(opt_startNode)) | 1428 if (this._canQuerySelectorOnNode(opt_startNode)) |
| 1424 return opt_startNode.querySelectorAll(selector); | 1429 return opt_startNode.querySelectorAll(selector); |
| 1425 return inspectedWindow.document.querySelectorAll(selector); | 1430 return inspectedWindow.document.querySelectorAll(selector); |
| 1426 }, | 1431 }, |
| 1427 | 1432 |
| 1428 /** | 1433 /** |
| 1429 * @param {Node=} node | 1434 * @param {!Node=} node |
| 1430 * @return {boolean} | 1435 * @return {boolean} |
| 1431 */ | 1436 */ |
| 1432 _canQuerySelectorOnNode: function(node) | 1437 _canQuerySelectorOnNode: function(node) |
| 1433 { | 1438 { |
| 1434 return !!node && InjectedScriptHost.type(node) === "node" && (node.nodeT
ype === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nodeTy
pe === Node.DOCUMENT_FRAGMENT_NODE); | 1439 return !!node && InjectedScriptHost.type(node) === "node" && (node.nodeT
ype === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nodeTy
pe === Node.DOCUMENT_FRAGMENT_NODE); |
| 1435 }, | 1440 }, |
| 1436 | 1441 |
| 1437 /** | 1442 /** |
| 1438 * @param {string} xpath | 1443 * @param {string} xpath |
| 1439 * @param {Node=} opt_startNode | 1444 * @param {!Node=} opt_startNode |
| 1445 * @return {*} |
| 1440 */ | 1446 */ |
| 1441 $x: function(xpath, opt_startNode) | 1447 $x: function(xpath, opt_startNode) |
| 1442 { | 1448 { |
| 1443 var doc = (opt_startNode && opt_startNode.ownerDocument) || inspectedWin
dow.document; | 1449 var doc = (opt_startNode && opt_startNode.ownerDocument) || inspectedWin
dow.document; |
| 1444 var result = doc.evaluate(xpath, opt_startNode || doc, null, XPathResult
.ANY_TYPE, null); | 1450 var result = doc.evaluate(xpath, opt_startNode || doc, null, XPathResult
.ANY_TYPE, null); |
| 1445 switch (result.resultType) { | 1451 switch (result.resultType) { |
| 1446 case XPathResult.NUMBER_TYPE: | 1452 case XPathResult.NUMBER_TYPE: |
| 1447 return result.numberValue; | 1453 return result.numberValue; |
| 1448 case XPathResult.STRING_TYPE: | 1454 case XPathResult.STRING_TYPE: |
| 1449 return result.stringValue; | 1455 return result.stringValue; |
| 1450 case XPathResult.BOOLEAN_TYPE: | 1456 case XPathResult.BOOLEAN_TYPE: |
| 1451 return result.booleanValue; | 1457 return result.booleanValue; |
| 1452 default: | 1458 default: |
| 1453 var nodes = []; | 1459 var nodes = []; |
| 1454 var node; | 1460 var node; |
| 1455 while (node = result.iterateNext()) | 1461 while (node = result.iterateNext()) |
| 1456 push(nodes, node); | 1462 push(nodes, node); |
| 1457 return nodes; | 1463 return nodes; |
| 1458 } | 1464 } |
| 1459 }, | 1465 }, |
| 1460 | 1466 |
| 1467 /** |
| 1468 * @return {*} |
| 1469 */ |
| 1461 dir: function(var_args) | 1470 dir: function(var_args) |
| 1462 { | 1471 { |
| 1463 return inspectedWindow.console.dir.apply(inspectedWindow.console, argume
nts) | 1472 return inspectedWindow.console.dir.apply(inspectedWindow.console, argume
nts) |
| 1464 }, | 1473 }, |
| 1465 | 1474 |
| 1475 /** |
| 1476 * @return {*} |
| 1477 */ |
| 1466 dirxml: function(var_args) | 1478 dirxml: function(var_args) |
| 1467 { | 1479 { |
| 1468 return inspectedWindow.console.dirxml.apply(inspectedWindow.console, arg
uments) | 1480 return inspectedWindow.console.dirxml.apply(inspectedWindow.console, arg
uments) |
| 1469 }, | 1481 }, |
| 1470 | 1482 |
| 1483 /** |
| 1484 * @return {!Array.<string>} |
| 1485 */ |
| 1471 keys: function(object) | 1486 keys: function(object) |
| 1472 { | 1487 { |
| 1473 return Object.keys(object); | 1488 return Object.keys(object); |
| 1474 }, | 1489 }, |
| 1475 | 1490 |
| 1491 /** |
| 1492 * @return {!Array.<*>} |
| 1493 */ |
| 1476 values: function(object) | 1494 values: function(object) |
| 1477 { | 1495 { |
| 1478 var result = []; | 1496 var result = []; |
| 1479 for (var key in object) | 1497 for (var key in object) |
| 1480 push(result, object[key]); | 1498 push(result, object[key]); |
| 1481 return result; | 1499 return result; |
| 1482 }, | 1500 }, |
| 1483 | 1501 |
| 1502 /** |
| 1503 * @return {*} |
| 1504 */ |
| 1484 profile: function(opt_title) | 1505 profile: function(opt_title) |
| 1485 { | 1506 { |
| 1486 return inspectedWindow.console.profile.apply(inspectedWindow.console, ar
guments) | 1507 return inspectedWindow.console.profile.apply(inspectedWindow.console, ar
guments) |
| 1487 }, | 1508 }, |
| 1488 | 1509 |
| 1510 /** |
| 1511 * @return {*} |
| 1512 */ |
| 1489 profileEnd: function(opt_title) | 1513 profileEnd: function(opt_title) |
| 1490 { | 1514 { |
| 1491 return inspectedWindow.console.profileEnd.apply(inspectedWindow.console,
arguments) | 1515 return inspectedWindow.console.profileEnd.apply(inspectedWindow.console,
arguments) |
| 1492 }, | 1516 }, |
| 1493 | 1517 |
| 1494 /** | 1518 /** |
| 1495 * @param {Object} object | 1519 * @param {!Object} object |
| 1496 * @param {Array.<string>|string=} opt_types | 1520 * @param {!Array.<string>|string=} opt_types |
| 1497 */ | 1521 */ |
| 1498 monitorEvents: function(object, opt_types) | 1522 monitorEvents: function(object, opt_types) |
| 1499 { | 1523 { |
| 1500 if (!object || !object.addEventListener || !object.removeEventListener) | 1524 if (!object || !object.addEventListener || !object.removeEventListener) |
| 1501 return; | 1525 return; |
| 1502 var types = this._normalizeEventTypes(opt_types); | 1526 var types = this._normalizeEventTypes(opt_types); |
| 1503 for (var i = 0; i < types.length; ++i) { | 1527 for (var i = 0; i < types.length; ++i) { |
| 1504 object.removeEventListener(types[i], this._logEvent, false); | 1528 object.removeEventListener(types[i], this._logEvent, false); |
| 1505 object.addEventListener(types[i], this._logEvent, false); | 1529 object.addEventListener(types[i], this._logEvent, false); |
| 1506 } | 1530 } |
| 1507 }, | 1531 }, |
| 1508 | 1532 |
| 1509 /** | 1533 /** |
| 1510 * @param {Object} object | 1534 * @param {!Object} object |
| 1511 * @param {Array.<string>|string=} opt_types | 1535 * @param {!Array.<string>|string=} opt_types |
| 1512 */ | 1536 */ |
| 1513 unmonitorEvents: function(object, opt_types) | 1537 unmonitorEvents: function(object, opt_types) |
| 1514 { | 1538 { |
| 1515 if (!object || !object.addEventListener || !object.removeEventListener) | 1539 if (!object || !object.addEventListener || !object.removeEventListener) |
| 1516 return; | 1540 return; |
| 1517 var types = this._normalizeEventTypes(opt_types); | 1541 var types = this._normalizeEventTypes(opt_types); |
| 1518 for (var i = 0; i < types.length; ++i) | 1542 for (var i = 0; i < types.length; ++i) |
| 1519 object.removeEventListener(types[i], this._logEvent, false); | 1543 object.removeEventListener(types[i], this._logEvent, false); |
| 1520 }, | 1544 }, |
| 1521 | 1545 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1547 var remoteObject = injectedScript._wrapObject(string, "") | 1571 var remoteObject = injectedScript._wrapObject(string, "") |
| 1548 InjectedScriptHost.inspect(remoteObject, hints); | 1572 InjectedScriptHost.inspect(remoteObject, hints); |
| 1549 }, | 1573 }, |
| 1550 | 1574 |
| 1551 clear: function() | 1575 clear: function() |
| 1552 { | 1576 { |
| 1553 InjectedScriptHost.clearConsoleMessages(); | 1577 InjectedScriptHost.clearConsoleMessages(); |
| 1554 }, | 1578 }, |
| 1555 | 1579 |
| 1556 /** | 1580 /** |
| 1557 * @param {Node} node | 1581 * @param {!Node} node |
| 1558 * @return {{type: string, listener: function(), useCapture: boolean, remove
: function()}|undefined} | 1582 * @return {!{type: string, listener: function(), useCapture: boolean, remov
e: function()}|undefined} |
| 1559 */ | 1583 */ |
| 1560 getEventListeners: function(node) | 1584 getEventListeners: function(node) |
| 1561 { | 1585 { |
| 1562 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod
e)); | 1586 var result = nullifyObjectProto(InjectedScriptHost.getEventListeners(nod
e)); |
| 1563 if (!result) | 1587 if (!result) |
| 1564 return result; | 1588 return result; |
| 1565 /** @this {{type: string, listener: function(), useCapture: boolean}} */ | 1589 /** @this {{type: string, listener: function(), useCapture: boolean}} */ |
| 1566 var removeFunc = function() | 1590 var removeFunc = function() |
| 1567 { | 1591 { |
| 1568 node.removeEventListener(this.type, this.listener, this.useCapture); | 1592 node.removeEventListener(this.type, this.listener, this.useCapture); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 | 1628 |
| 1605 /** | 1629 /** |
| 1606 * @param {number} num | 1630 * @param {number} num |
| 1607 */ | 1631 */ |
| 1608 _inspectedObject: function(num) | 1632 _inspectedObject: function(num) |
| 1609 { | 1633 { |
| 1610 return InjectedScriptHost.inspectedObject(num); | 1634 return InjectedScriptHost.inspectedObject(num); |
| 1611 }, | 1635 }, |
| 1612 | 1636 |
| 1613 /** | 1637 /** |
| 1614 * @param {Array.<string>|string=} types | 1638 * @param {!Array.<string>|string=} types |
| 1615 * @return {Array.<string>} | 1639 * @return {!Array.<string>} |
| 1616 */ | 1640 */ |
| 1617 _normalizeEventTypes: function(types) | 1641 _normalizeEventTypes: function(types) |
| 1618 { | 1642 { |
| 1619 if (typeof types === "undefined") | 1643 if (typeof types === "undefined") |
| 1620 types = ["mouse", "key", "touch", "control", "load", "unload", "abor
t", "error", "select", "change", "submit", "reset", "focus", "blur", "resize", "
scroll", "search", "devicemotion", "deviceorientation"]; | 1644 types = ["mouse", "key", "touch", "control", "load", "unload", "abor
t", "error", "select", "change", "submit", "reset", "focus", "blur", "resize", "
scroll", "search", "devicemotion", "deviceorientation"]; |
| 1621 else if (typeof types === "string") | 1645 else if (typeof types === "string") |
| 1622 types = [types]; | 1646 types = [types]; |
| 1623 | 1647 |
| 1624 var result = []; | 1648 var result = []; |
| 1625 for (var i = 0; i < types.length; ++i) { | 1649 for (var i = 0; i < types.length; ++i) { |
| 1626 if (types[i] === "mouse") | 1650 if (types[i] === "mouse") |
| 1627 push(result, "mousedown", "mouseup", "click", "dblclick", "mouse
move", "mouseover", "mouseout", "mousewheel"); | 1651 push(result, "mousedown", "mouseup", "click", "dblclick", "mouse
move", "mouseover", "mouseout", "mousewheel"); |
| 1628 else if (types[i] === "key") | 1652 else if (types[i] === "key") |
| 1629 push(result, "keydown", "keyup", "keypress", "textInput"); | 1653 push(result, "keydown", "keyup", "keypress", "textInput"); |
| 1630 else if (types[i] === "touch") | 1654 else if (types[i] === "touch") |
| 1631 push(result, "touchstart", "touchmove", "touchend", "touchcancel
"); | 1655 push(result, "touchstart", "touchmove", "touchend", "touchcancel
"); |
| 1632 else if (types[i] === "control") | 1656 else if (types[i] === "control") |
| 1633 push(result, "resize", "scroll", "zoom", "focus", "blur", "selec
t", "change", "submit", "reset"); | 1657 push(result, "resize", "scroll", "zoom", "focus", "blur", "selec
t", "change", "submit", "reset"); |
| 1634 else | 1658 else |
| 1635 push(result, types[i]); | 1659 push(result, types[i]); |
| 1636 } | 1660 } |
| 1637 return result; | 1661 return result; |
| 1638 }, | 1662 }, |
| 1639 | 1663 |
| 1640 /** | 1664 /** |
| 1641 * @param {Event} event | 1665 * @param {!Event} event |
| 1642 */ | 1666 */ |
| 1643 _logEvent: function(event) | 1667 _logEvent: function(event) |
| 1644 { | 1668 { |
| 1645 inspectedWindow.console.log(event.type, event); | 1669 inspectedWindow.console.log(event.type, event); |
| 1646 } | 1670 } |
| 1647 } | 1671 } |
| 1648 | 1672 |
| 1649 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1673 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1650 return injectedScript; | 1674 return injectedScript; |
| 1651 }) | 1675 }) |
| OLD | NEW |