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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 * @template T | 104 * @template T |
105 */ | 105 */ |
106 function nullifyObjectProto(obj) | 106 function nullifyObjectProto(obj) |
107 { | 107 { |
108 if (obj && typeof obj === "object") | 108 if (obj && typeof obj === "object") |
109 obj.__proto__ = null; | 109 obj.__proto__ = null; |
110 return obj; | 110 return obj; |
111 } | 111 } |
112 | 112 |
113 /** | 113 /** |
| 114 * FireBug's array detection. |
| 115 * @param {*} obj |
| 116 * @return {boolean} |
| 117 */ |
| 118 function isArrayLike(obj) |
| 119 { |
| 120 try { |
| 121 if (typeof obj !== "object") |
| 122 return false; |
| 123 if (typeof obj.splice === "function") |
| 124 return isFinite(obj.length); |
| 125 var str = Object.prototype.toString.call(obj); |
| 126 if (str === "[object Array]" || |
| 127 str === "[object Arguments]" || |
| 128 str === "[object HTMLCollection]" || |
| 129 str === "[object NodeList]" || |
| 130 str === "[object DOMTokenList]") |
| 131 return isFinite(obj.length); |
| 132 } catch (e) { |
| 133 } |
| 134 return false; |
| 135 } |
| 136 |
| 137 /** |
114 * @constructor | 138 * @constructor |
115 */ | 139 */ |
116 var InjectedScript = function() | 140 var InjectedScript = function() |
117 { | 141 { |
118 /** @type {number} */ | 142 /** @type {number} */ |
119 this._lastBoundObjectId = 1; | 143 this._lastBoundObjectId = 1; |
120 /** @type {!Object.<number, Object>} */ | 144 /** @type {!Object.<number, Object>} */ |
121 this._idToWrappedObject = { __proto__: null }; | 145 this._idToWrappedObject = { __proto__: null }; |
122 /** @type {!Object.<number, string>} */ | 146 /** @type {!Object.<number, string>} */ |
123 this._idToObjectGroupName = { __proto__: null }; | 147 this._idToObjectGroupName = { __proto__: null }; |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 if (this.isPrimitiveValue(obj)) | 910 if (this.isPrimitiveValue(obj)) |
887 return null; | 911 return null; |
888 | 912 |
889 if (this._isHTMLAllCollection(obj)) | 913 if (this._isHTMLAllCollection(obj)) |
890 return "array"; | 914 return "array"; |
891 | 915 |
892 var preciseType = InjectedScriptHost.type(obj); | 916 var preciseType = InjectedScriptHost.type(obj); |
893 if (preciseType) | 917 if (preciseType) |
894 return preciseType; | 918 return preciseType; |
895 | 919 |
896 // FireBug's array detection. | 920 if (isArrayLike(obj)) |
897 try { | 921 return "array"; |
898 if (typeof obj.splice === "function" && isFinite(obj.length)) | |
899 return "array"; | |
900 if (Object.prototype.toString.call(obj) === "[object Arguments]" &&
isFinite(obj.length)) // arguments. | |
901 return "array"; | |
902 } catch (e) { | |
903 } | |
904 | 922 |
905 // If owning frame has navigated to somewhere else window properties wil
l be undefined. | 923 // If owning frame has navigated to somewhere else window properties wil
l be undefined. |
906 return null; | 924 return null; |
907 }, | 925 }, |
908 | 926 |
909 /** | 927 /** |
910 * @param {*} obj | 928 * @param {*} obj |
911 * @return {string?} | 929 * @return {string?} |
912 */ | 930 */ |
913 _describe: function(obj) | 931 _describe: function(obj) |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 */ | 1572 */ |
1555 _logEvent: function(event) | 1573 _logEvent: function(event) |
1556 { | 1574 { |
1557 inspectedWindow.console.log(event.type, event); | 1575 inspectedWindow.console.log(event.type, event); |
1558 } | 1576 } |
1559 } | 1577 } |
1560 | 1578 |
1561 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1579 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1562 return injectedScript; | 1580 return injectedScript; |
1563 }) | 1581 }) |
OLD | NEW |