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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 var parsedArgId = this._parseObjectId(objectId); | 574 var parsedArgId = this._parseObjectId(objectId); |
575 if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScri
ptId) | 575 if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScri
ptId) |
576 throw "Arguments should belong to the same JavaScript world as t
he target object."; | 576 throw "Arguments should belong to the same JavaScript world as t
he target object."; |
577 | 577 |
578 var resolvedArg = this._objectForId(parsedArgId); | 578 var resolvedArg = this._objectForId(parsedArgId); |
579 if (!this._isDefined(resolvedArg)) | 579 if (!this._isDefined(resolvedArg)) |
580 throw "Could not find object with given id"; | 580 throw "Could not find object with given id"; |
581 | 581 |
582 return resolvedArg; | 582 return resolvedArg; |
583 } else if ("value" in callArgumentJson) { | 583 } else if ("value" in callArgumentJson) { |
584 return callArgumentJson.value; | 584 var value = callArgumentJson.value; |
| 585 if (callArgumentJson.type === "number" && typeof value !== "number") |
| 586 value = Number(value); |
| 587 return value; |
585 } | 588 } |
586 return undefined; | 589 return undefined; |
587 }, | 590 }, |
588 | 591 |
589 /** | 592 /** |
590 * @param {Function} evalFunction | 593 * @param {Function} evalFunction |
591 * @param {Object} object | 594 * @param {Object} object |
592 * @param {string} objectGroup | 595 * @param {string} objectGroup |
593 * @param {boolean} isEvalOnCallFrame | 596 * @param {boolean} isEvalOnCallFrame |
594 * @param {boolean} injectCommandLineAPI | 597 * @param {boolean} injectCommandLineAPI |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 if (injectedScript.isPrimitiveValue(object) || object === null || forceValue
Type) { | 1003 if (injectedScript.isPrimitiveValue(object) || object === null || forceValue
Type) { |
1001 // We don't send undefined values over JSON. | 1004 // We don't send undefined values over JSON. |
1002 if (this.type !== "undefined") | 1005 if (this.type !== "undefined") |
1003 this.value = object; | 1006 this.value = object; |
1004 | 1007 |
1005 // Null object is object with 'null' subtype. | 1008 // Null object is object with 'null' subtype. |
1006 if (object === null) | 1009 if (object === null) |
1007 this.subtype = "null"; | 1010 this.subtype = "null"; |
1008 | 1011 |
1009 // Provide user-friendly number values. | 1012 // Provide user-friendly number values. |
1010 if (this.type === "number") | 1013 if (this.type === "number") { |
1011 this.description = toStringDescription(object); | 1014 this.description = toStringDescription(object); |
| 1015 // Override "value" property for values that can not be JSON-stringi
fied. |
| 1016 switch (this.description) { |
| 1017 case "NaN": |
| 1018 case "Infinity": |
| 1019 case "-Infinity": |
| 1020 case "-0": |
| 1021 this.value = this.description; |
| 1022 break; |
| 1023 } |
| 1024 } |
| 1025 |
1012 return; | 1026 return; |
1013 } | 1027 } |
1014 | 1028 |
1015 object = /** @type {Object} */ (object); | 1029 object = /** @type {Object} */ (object); |
1016 | 1030 |
1017 this.objectId = injectedScript._bind(object, objectGroupName); | 1031 this.objectId = injectedScript._bind(object, objectGroupName); |
1018 var subtype = injectedScript._subtype(object); | 1032 var subtype = injectedScript._subtype(object); |
1019 if (subtype) | 1033 if (subtype) |
1020 this.subtype = subtype; | 1034 this.subtype = subtype; |
1021 this.className = InjectedScriptHost.internalConstructorName(object); | 1035 this.className = InjectedScriptHost.internalConstructorName(object); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 */ | 1586 */ |
1573 _logEvent: function(event) | 1587 _logEvent: function(event) |
1574 { | 1588 { |
1575 inspectedWindow.console.log(event.type, event); | 1589 inspectedWindow.console.log(event.type, event); |
1576 } | 1590 } |
1577 } | 1591 } |
1578 | 1592 |
1579 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1593 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1580 return injectedScript; | 1594 return injectedScript; |
1581 }) | 1595 }) |
OLD | NEW |