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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 * @param {*} obj | 57 * @param {*} obj |
58 * @return {string} | 58 * @return {string} |
59 */ | 59 */ |
60 function toString(obj) | 60 function toString(obj) |
61 { | 61 { |
62 // We don't use String(obj) because it could be overriden. | 62 // We don't use String(obj) because it could be overriden. |
63 return "" + obj; | 63 return "" + obj; |
64 } | 64 } |
65 | 65 |
66 /** | 66 /** |
| 67 * @param {*} obj |
| 68 * @return {string} |
| 69 */ |
| 70 function toStringDescription(obj) |
| 71 { |
| 72 if (typeof obj === "number" && obj === 0 && 1 / obj < 0) |
| 73 return "-0"; // Negative zero. |
| 74 return "" + obj; |
| 75 } |
| 76 |
| 77 /** |
67 * Please use this bind, not the one from Function.prototype | 78 * Please use this bind, not the one from Function.prototype |
68 * @param {function(...)} func | 79 * @param {function(...)} func |
69 * @param {Object} thisObject | 80 * @param {Object} thisObject |
70 * @param {...number} var_args | 81 * @param {...number} var_args |
71 */ | 82 */ |
72 function bind(func, thisObject, var_args) | 83 function bind(func, thisObject, var_args) |
73 { | 84 { |
74 var args = slice(arguments, 2); | 85 var args = slice(arguments, 2); |
75 | 86 |
76 /** | 87 /** |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 if (objectId) { | 543 if (objectId) { |
533 var parsedArgId = this._parseObjectId(objectId); | 544 var parsedArgId = this._parseObjectId(objectId); |
534 if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScri
ptId) | 545 if (!parsedArgId || parsedArgId["injectedScriptId"] !== injectedScri
ptId) |
535 throw "Arguments should belong to the same JavaScript world as t
he target object."; | 546 throw "Arguments should belong to the same JavaScript world as t
he target object."; |
536 | 547 |
537 var resolvedArg = this._objectForId(parsedArgId); | 548 var resolvedArg = this._objectForId(parsedArgId); |
538 if (!this._isDefined(resolvedArg)) | 549 if (!this._isDefined(resolvedArg)) |
539 throw "Could not find object with given id"; | 550 throw "Could not find object with given id"; |
540 | 551 |
541 return resolvedArg; | 552 return resolvedArg; |
542 } else if ("value" in callArgumentJson) | 553 } else if ("value" in callArgumentJson) { |
543 return callArgumentJson.value; | 554 return callArgumentJson.value; |
544 else | 555 } |
545 return undefined; | 556 return undefined; |
546 }, | 557 }, |
547 | 558 |
548 /** | 559 /** |
549 * @param {Function} evalFunction | 560 * @param {Function} evalFunction |
550 * @param {Object} object | 561 * @param {Object} object |
551 * @param {string} objectGroup | 562 * @param {string} objectGroup |
552 * @param {boolean} isEvalOnCallFrame | 563 * @param {boolean} isEvalOnCallFrame |
553 * @param {boolean} injectCommandLineAPI | 564 * @param {boolean} injectCommandLineAPI |
554 * @param {boolean} returnByValue | 565 * @param {boolean} returnByValue |
555 * @param {boolean} generatePreview | 566 * @param {boolean} generatePreview |
(...skipping 11 matching lines...) Expand all Loading... |
567 | 578 |
568 /** | 579 /** |
569 * @param {*} value | 580 * @param {*} value |
570 * @param {string} objectGroup | 581 * @param {string} objectGroup |
571 * @return {Object} | 582 * @return {Object} |
572 */ | 583 */ |
573 _createThrownValue: function(value, objectGroup) | 584 _createThrownValue: function(value, objectGroup) |
574 { | 585 { |
575 var remoteObject = this._wrapObject(value, objectGroup); | 586 var remoteObject = this._wrapObject(value, objectGroup); |
576 try { | 587 try { |
577 remoteObject.description = toString(value); | 588 remoteObject.description = toStringDescription(value); |
578 } catch (e) {} | 589 } catch (e) {} |
579 return { wasThrown: true, | 590 return { wasThrown: true, result: remoteObject }; |
580 result: remoteObject }; | |
581 }, | 591 }, |
582 | 592 |
583 /** | 593 /** |
584 * @param {Function} evalFunction | 594 * @param {Function} evalFunction |
585 * @param {Object} object | 595 * @param {Object} object |
586 * @param {string} objectGroup | 596 * @param {string} objectGroup |
587 * @param {string} expression | 597 * @param {string} expression |
588 * @param {boolean} isEvalOnCallFrame | 598 * @param {boolean} isEvalOnCallFrame |
589 * @param {boolean} injectCommandLineAPI | 599 * @param {boolean} injectCommandLineAPI |
590 * @return {*} | 600 * @return {*} |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 // We don't send undefined values over JSON. | 934 // We don't send undefined values over JSON. |
925 if (this.type !== "undefined") | 935 if (this.type !== "undefined") |
926 this.value = object; | 936 this.value = object; |
927 | 937 |
928 // Null object is object with 'null' subtype. | 938 // Null object is object with 'null' subtype. |
929 if (object === null) | 939 if (object === null) |
930 this.subtype = "null"; | 940 this.subtype = "null"; |
931 | 941 |
932 // Provide user-friendly number values. | 942 // Provide user-friendly number values. |
933 if (this.type === "number") | 943 if (this.type === "number") |
934 this.description = toString(object); | 944 this.description = toStringDescription(object); |
935 return; | 945 return; |
936 } | 946 } |
937 | 947 |
938 object = /** @type {Object} */ (object); | 948 object = /** @type {Object} */ (object); |
939 | 949 |
940 this.objectId = injectedScript._bind(object, objectGroupName); | 950 this.objectId = injectedScript._bind(object, objectGroupName); |
941 var subtype = injectedScript._subtype(object); | 951 var subtype = injectedScript._subtype(object); |
942 if (subtype) | 952 if (subtype) |
943 this.subtype = subtype; | 953 this.subtype = subtype; |
944 this.className = InjectedScriptHost.internalConstructorName(object); | 954 this.className = InjectedScriptHost.internalConstructorName(object); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 if (!descriptor.enumerable && type === "function") | 1034 if (!descriptor.enumerable && type === "function") |
1025 continue; | 1035 continue; |
1026 if (type === "undefined" && injectedScript._isHTMLAllCollection(
value)) | 1036 if (type === "undefined" && injectedScript._isHTMLAllCollection(
value)) |
1027 type = "object"; | 1037 type = "object"; |
1028 | 1038 |
1029 if (InjectedScript.primitiveTypes[type]) { | 1039 if (InjectedScript.primitiveTypes[type]) { |
1030 if (type === "string" && value.length > maxLength) { | 1040 if (type === "string" && value.length > maxLength) { |
1031 value = this._abbreviateString(value, maxLength, true); | 1041 value = this._abbreviateString(value, maxLength, true); |
1032 preview.lossless = false; | 1042 preview.lossless = false; |
1033 } | 1043 } |
1034 this._appendPropertyPreview(preview, { name: name, type: typ
e, value: toString(value) }, propertiesThreshold); | 1044 this._appendPropertyPreview(preview, { name: name, type: typ
e, value: toStringDescription(value) }, propertiesThreshold); |
1035 continue; | 1045 continue; |
1036 } | 1046 } |
1037 | 1047 |
1038 if (secondLevelKeys === null || secondLevelKeys) { | 1048 if (secondLevelKeys === null || secondLevelKeys) { |
1039 var subPreview = this._generatePreview(value, secondLevelKey
s || undefined, undefined, false, isTable); | 1049 var subPreview = this._generatePreview(value, secondLevelKey
s || undefined, undefined, false, isTable); |
1040 var property = { name: name, type: type, valuePreview: subPr
eview }; | 1050 var property = { name: name, type: type, valuePreview: subPr
eview }; |
1041 this._appendPropertyPreview(preview, property, propertiesThr
eshold); | 1051 this._appendPropertyPreview(preview, property, propertiesThr
eshold); |
1042 if (!subPreview.lossless) | 1052 if (!subPreview.lossless) |
1043 preview.lossless = false; | 1053 preview.lossless = false; |
1044 if (subPreview.overflow) | 1054 if (subPreview.overflow) |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 */ | 1482 */ |
1473 _logEvent: function(event) | 1483 _logEvent: function(event) |
1474 { | 1484 { |
1475 inspectedWindow.console.log(event.type, event); | 1485 inspectedWindow.console.log(event.type, event); |
1476 } | 1486 } |
1477 } | 1487 } |
1478 | 1488 |
1479 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1489 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1480 return injectedScript; | 1490 return injectedScript; |
1481 }) | 1491 }) |
OLD | NEW |