| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 * @return {boolean} | 145 * @return {boolean} |
| 146 */ | 146 */ |
| 147 function isArrayLike(obj) | 147 function isArrayLike(obj) |
| 148 { | 148 { |
| 149 try { | 149 try { |
| 150 if (typeof obj !== "object") | 150 if (typeof obj !== "object") |
| 151 return false; | 151 return false; |
| 152 if (typeof obj.splice === "function") | 152 if (typeof obj.splice === "function") |
| 153 return isFinite(obj.length); | 153 return isFinite(obj.length); |
| 154 var str = InjectedScriptHost.callFunction(Object.prototype.toString, obj
); | 154 var str = InjectedScriptHost.callFunction(Object.prototype.toString, obj
); |
| 155 if (str === "[object Array]" || | 155 if (str === "[object Arguments]") |
| 156 str === "[object Arguments]" || | |
| 157 str === "[object HTMLCollection]" || | |
| 158 str === "[object NodeList]" || | |
| 159 str === "[object DOMTokenList]") | |
| 160 return isFinite(obj.length); | 156 return isFinite(obj.length); |
| 161 } catch (e) { | 157 } catch (e) { |
| 162 } | 158 } |
| 163 return false; | 159 return false; |
| 164 } | 160 } |
| 165 | 161 |
| 166 /** | 162 /** |
| 167 * @param {number} a | 163 * @param {number} a |
| 168 * @param {number} b | 164 * @param {number} b |
| 169 * @return {number} | 165 * @return {number} |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 * @return {?string} | 971 * @return {?string} |
| 976 */ | 972 */ |
| 977 _subtype: function(obj) | 973 _subtype: function(obj) |
| 978 { | 974 { |
| 979 if (obj === null) | 975 if (obj === null) |
| 980 return "null"; | 976 return "null"; |
| 981 | 977 |
| 982 if (this.isPrimitiveValue(obj)) | 978 if (this.isPrimitiveValue(obj)) |
| 983 return null; | 979 return null; |
| 984 | 980 |
| 985 if (this._isHTMLAllCollection(obj)) | |
| 986 return "array"; | |
| 987 | |
| 988 var preciseType = InjectedScriptHost.type(obj); | 981 var preciseType = InjectedScriptHost.type(obj); |
| 989 if (preciseType) | 982 if (preciseType) |
| 990 return preciseType; | 983 return preciseType; |
| 991 | 984 |
| 992 if (isArrayLike(obj)) | 985 if (isArrayLike(obj)) |
| 993 return "array"; | 986 return "array"; |
| 994 | 987 |
| 995 // If owning frame has navigated to somewhere else window properties wil
l be undefined. | 988 // If owning frame has navigated to somewhere else window properties wil
l be undefined. |
| 996 return null; | 989 return null; |
| 997 }, | 990 }, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 if (subtype === "array") { | 1025 if (subtype === "array") { |
| 1033 if (typeof obj.length === "number") | 1026 if (typeof obj.length === "number") |
| 1034 className += "[" + obj.length + "]"; | 1027 className += "[" + obj.length + "]"; |
| 1035 return className; | 1028 return className; |
| 1036 } | 1029 } |
| 1037 | 1030 |
| 1038 // NodeList in JSC is a function, check for array prior to this. | 1031 // NodeList in JSC is a function, check for array prior to this. |
| 1039 if (typeof obj === "function") | 1032 if (typeof obj === "function") |
| 1040 return toString(obj); | 1033 return toString(obj); |
| 1041 | 1034 |
| 1042 if (isSymbol(obj)) { | 1035 if (subtype === "symbol") { |
| 1043 try { | 1036 try { |
| 1044 return InjectedScriptHost.callFunction(Symbol.prototype.toString
, obj) || "Symbol"; | 1037 return InjectedScriptHost.callFunction(Symbol.prototype.toString
, obj) || "Symbol"; |
| 1045 } catch (e) { | 1038 } catch (e) { |
| 1046 return "Symbol"; | 1039 return "Symbol"; |
| 1047 } | 1040 } |
| 1048 } | 1041 } |
| 1049 | 1042 |
| 1050 if (obj instanceof Error && !!obj.message) | 1043 if (obj instanceof Error && !!obj.message) |
| 1051 return className + ": " + obj.message; | 1044 return className + ": " + obj.message; |
| 1052 | 1045 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 */ | 1694 */ |
| 1702 _logEvent: function(event) | 1695 _logEvent: function(event) |
| 1703 { | 1696 { |
| 1704 inspectedWindow.console.log(event.type, event); | 1697 inspectedWindow.console.log(event.type, event); |
| 1705 } | 1698 } |
| 1706 } | 1699 } |
| 1707 | 1700 |
| 1708 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1701 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1709 return injectedScript; | 1702 return injectedScript; |
| 1710 }) | 1703 }) |
| OLD | NEW |