| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return 0; | 72 return 0; |
| 73 // Array lengths in V8-generated descriptions switched from square brackets
to parentheses. | 73 // Array lengths in V8-generated descriptions switched from square brackets
to parentheses. |
| 74 // Both formats are checked in case the front end is dealing with an old ver
sion of V8. | 74 // Both formats are checked in case the front end is dealing with an old ver
sion of V8. |
| 75 var matches = object.description.match(/\[([0-9]+)\]/) || object.description
.match(/\(([0-9]+)\)/); | 75 var matches = object.description.match(/\[([0-9]+)\]/) || object.description
.match(/\(([0-9]+)\)/); |
| 76 if (!matches) | 76 if (!matches) |
| 77 return 0; | 77 return 0; |
| 78 return parseInt(matches[1], 10); | 78 return parseInt(matches[1], 10); |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @param {!Protocol.Runtime.ObjectPreview} preview |
| 83 * @return {number} |
| 84 */ |
| 85 static mapOrSetEntriesCount(preview) { |
| 86 if (preview.subtype !== 'map' && preview.subtype !== 'set') |
| 87 return 0; |
| 88 var matches = preview.description.match(/\(([0-9]+)\)/); |
| 89 if (!matches) |
| 90 return 0; |
| 91 return parseInt(matches[1], 10); |
| 92 } |
| 93 |
| 94 /** |
| 82 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool
ean|undefined|null} object | 95 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool
ean|undefined|null} object |
| 83 * @return {!Protocol.Runtime.CallArgument} | 96 * @return {!Protocol.Runtime.CallArgument} |
| 84 */ | 97 */ |
| 85 static toCallArgument(object) { | 98 static toCallArgument(object) { |
| 86 var type = typeof object; | 99 var type = typeof object; |
| 87 if (type === 'undefined') | 100 if (type === 'undefined') |
| 88 return {}; | 101 return {}; |
| 89 if (type === 'number') { | 102 if (type === 'number') { |
| 90 var description = String(object); | 103 var description = String(object); |
| 91 if (object === 0 && 1 / object < 0) | 104 if (object === 0 && 1 / object < 0) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 if (typeof object.objectId !== 'undefined') | 125 if (typeof object.objectId !== 'undefined') |
| 113 return {objectId: object.objectId}; | 126 return {objectId: object.objectId}; |
| 114 if (typeof object._objectId !== 'undefined') | 127 if (typeof object._objectId !== 'undefined') |
| 115 return {objectId: object._objectId}; | 128 return {objectId: object._objectId}; |
| 116 | 129 |
| 117 return {value: object.value}; | 130 return {value: object.value}; |
| 118 } | 131 } |
| 119 | 132 |
| 120 /** | 133 /** |
| 121 * @param {!SDK.RemoteObject} object | 134 * @param {!SDK.RemoteObject} object |
| 135 * @param {boolean} generatePreview |
| 122 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 136 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 123 */ | 137 */ |
| 124 static loadFromObjectPerProto(object, callback) { | 138 static loadFromObjectPerProto(object, generatePreview, callback) { |
| 125 // Combines 2 asynch calls. Doesn't rely on call-back orders (some calls may
be loop-back). | 139 // Combines 2 asynch calls. Doesn't rely on call-back orders (some calls may
be loop-back). |
| 126 var savedOwnProperties; | 140 var savedOwnProperties; |
| 127 var savedAccessorProperties; | 141 var savedAccessorProperties; |
| 128 var savedInternalProperties; | 142 var savedInternalProperties; |
| 129 var resultCounter = 2; | 143 var resultCounter = 2; |
| 130 | 144 |
| 131 function processCallback() { | 145 function processCallback() { |
| 132 if (--resultCounter) | 146 if (--resultCounter) |
| 133 return; | 147 return; |
| 134 if (savedOwnProperties && savedAccessorProperties) { | 148 if (savedOwnProperties && savedAccessorProperties) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 /** | 184 /** |
| 171 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 185 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 172 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 186 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 173 */ | 187 */ |
| 174 function ownPropertiesCallback(properties, internalProperties) { | 188 function ownPropertiesCallback(properties, internalProperties) { |
| 175 savedOwnProperties = properties; | 189 savedOwnProperties = properties; |
| 176 savedInternalProperties = internalProperties; | 190 savedInternalProperties = internalProperties; |
| 177 processCallback(); | 191 processCallback(); |
| 178 } | 192 } |
| 179 | 193 |
| 180 object.getAllProperties(true, allAccessorPropertiesCallback); | 194 object.getAllProperties(true, generatePreview, allAccessorPropertiesCallback
); |
| 181 object.getOwnProperties(ownPropertiesCallback); | 195 object.getOwnProperties(generatePreview, ownPropertiesCallback); |
| 182 } | 196 } |
| 183 | 197 |
| 184 /** | 198 /** |
| 185 * @return {?Protocol.Runtime.CustomPreview} | 199 * @return {?Protocol.Runtime.CustomPreview} |
| 186 */ | 200 */ |
| 187 customPreview() { | 201 customPreview() { |
| 188 return null; | 202 return null; |
| 189 } | 203 } |
| 190 | 204 |
| 191 /** @return {string} */ | 205 /** @return {string} */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 209 } | 223 } |
| 210 | 224 |
| 211 /** | 225 /** |
| 212 * @return {number} | 226 * @return {number} |
| 213 */ | 227 */ |
| 214 arrayLength() { | 228 arrayLength() { |
| 215 throw 'Not implemented'; | 229 throw 'Not implemented'; |
| 216 } | 230 } |
| 217 | 231 |
| 218 /** | 232 /** |
| 233 * @param {boolean} generatePreview |
| 219 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 234 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 220 */ | 235 */ |
| 221 getOwnProperties(callback) { | 236 getOwnProperties(generatePreview, callback) { |
| 222 throw 'Not implemented'; | 237 throw 'Not implemented'; |
| 223 } | 238 } |
| 224 | 239 |
| 225 /** | 240 /** |
| 241 * @param {boolean=} generatePreview |
| 226 * @return {!Promise<!{properties: ?Array.<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>}>} | 242 * @return {!Promise<!{properties: ?Array.<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>}>} |
| 227 */ | 243 */ |
| 228 getOwnPropertiesPromise() { | 244 getOwnPropertiesPromise(generatePreview) { |
| 229 return new Promise(promiseConstructor.bind(this)); | 245 return new Promise(promiseConstructor.bind(this)); |
| 230 | 246 |
| 231 /** | 247 /** |
| 232 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} success | 248 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} success |
| 233 * @this {SDK.RemoteObject} | 249 * @this {SDK.RemoteObject} |
| 234 */ | 250 */ |
| 235 function promiseConstructor(success) { | 251 function promiseConstructor(success) { |
| 236 this.getOwnProperties(getOwnPropertiesCallback.bind(null, success)); | 252 this.getOwnProperties(!!generatePreview, getOwnPropertiesCallback.bind(nul
l, success)); |
| 237 } | 253 } |
| 238 | 254 |
| 239 /** | 255 /** |
| 240 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} callback | 256 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} callback |
| 241 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 257 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 242 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 258 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 243 */ | 259 */ |
| 244 function getOwnPropertiesCallback(callback, properties, internalProperties)
{ | 260 function getOwnPropertiesCallback(callback, properties, internalProperties)
{ |
| 245 callback({properties: properties, internalProperties: internalProperties})
; | 261 callback({properties: properties, internalProperties: internalProperties})
; |
| 246 } | 262 } |
| 247 } | 263 } |
| 248 | 264 |
| 249 /** | 265 /** |
| 250 * @param {boolean} accessorPropertiesOnly | 266 * @param {boolean} accessorPropertiesOnly |
| 267 * @param {boolean} generatePreview |
| 251 * @param {function(?Array<!SDK.RemoteObjectProperty>, ?Array<!SDK.RemoteObjec
tProperty>)} callback | 268 * @param {function(?Array<!SDK.RemoteObjectProperty>, ?Array<!SDK.RemoteObjec
tProperty>)} callback |
| 252 */ | 269 */ |
| 253 getAllProperties(accessorPropertiesOnly, callback) { | 270 getAllProperties(accessorPropertiesOnly, generatePreview, callback) { |
| 254 throw 'Not implemented'; | 271 throw 'Not implemented'; |
| 255 } | 272 } |
| 256 | 273 |
| 257 /** | 274 /** |
| 258 * @param {boolean} accessorPropertiesOnly | 275 * @param {boolean} accessorPropertiesOnly |
| 276 * @param {boolean} generatePreview |
| 259 * @return {!Promise<!{properties: ?Array<!SDK.RemoteObjectProperty>, internal
Properties: ?Array<!SDK.RemoteObjectProperty>}>} | 277 * @return {!Promise<!{properties: ?Array<!SDK.RemoteObjectProperty>, internal
Properties: ?Array<!SDK.RemoteObjectProperty>}>} |
| 260 */ | 278 */ |
| 261 getAllPropertiesPromise(accessorPropertiesOnly) { | 279 getAllPropertiesPromise(accessorPropertiesOnly, generatePreview) { |
| 262 return new Promise(promiseConstructor.bind(this)); | 280 return new Promise(promiseConstructor.bind(this)); |
| 263 | 281 |
| 264 /** | 282 /** |
| 265 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>})} success | 283 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>})} success |
| 266 * @this {SDK.RemoteObject} | 284 * @this {SDK.RemoteObject} |
| 267 */ | 285 */ |
| 268 function promiseConstructor(success) { | 286 function promiseConstructor(success) { |
| 269 this.getAllProperties(accessorPropertiesOnly, getAllPropertiesCallback.bin
d(null, success)); | 287 this.getAllProperties(accessorPropertiesOnly, generatePreview, getAllPrope
rtiesCallback.bind(null, success)); |
| 270 } | 288 } |
| 271 | 289 |
| 272 /** | 290 /** |
| 273 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback | 291 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback |
| 274 * @param {?Array<!SDK.RemoteObjectProperty>} properties | 292 * @param {?Array<!SDK.RemoteObjectProperty>} properties |
| 275 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties | 293 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties |
| 276 */ | 294 */ |
| 277 function getAllPropertiesCallback(callback, properties, internalProperties)
{ | 295 function getAllPropertiesCallback(callback, properties, internalProperties)
{ |
| 278 callback({properties: properties, internalProperties: internalProperties})
; | 296 callback({properties: properties, internalProperties: internalProperties})
; |
| 279 } | 297 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 505 |
| 488 /** | 506 /** |
| 489 * @return {!Protocol.Runtime.ObjectPreview|undefined} | 507 * @return {!Protocol.Runtime.ObjectPreview|undefined} |
| 490 */ | 508 */ |
| 491 get preview() { | 509 get preview() { |
| 492 return this._preview; | 510 return this._preview; |
| 493 } | 511 } |
| 494 | 512 |
| 495 /** | 513 /** |
| 496 * @override | 514 * @override |
| 515 * @param {boolean} generatePreview |
| 497 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 516 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 498 */ | 517 */ |
| 499 getOwnProperties(callback) { | 518 getOwnProperties(generatePreview, callback) { |
| 500 this.doGetProperties(true, false, false, callback); | 519 this.doGetProperties(true, false, generatePreview, callback); |
| 501 } | 520 } |
| 502 | 521 |
| 503 /** | 522 /** |
| 504 * @override | 523 * @override |
| 505 * @param {boolean} accessorPropertiesOnly | 524 * @param {boolean} accessorPropertiesOnly |
| 525 * @param {boolean} generatePreview |
| 506 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 526 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 507 */ | 527 */ |
| 508 getAllProperties(accessorPropertiesOnly, callback) { | 528 getAllProperties(accessorPropertiesOnly, generatePreview, callback) { |
| 509 this.doGetProperties(false, accessorPropertiesOnly, false, callback); | 529 this.doGetProperties(false, accessorPropertiesOnly, generatePreview, callbac
k); |
| 510 } | 530 } |
| 511 | 531 |
| 512 /** | 532 /** |
| 513 * @override | 533 * @override |
| 514 * @return {!Promise<?Array<!SDK.EventListener>>} | 534 * @return {!Promise<?Array<!SDK.EventListener>>} |
| 515 */ | 535 */ |
| 516 eventListeners() { | 536 eventListeners() { |
| 517 return new Promise(eventListeners.bind(this)); | 537 return new Promise(eventListeners.bind(this)); |
| 518 /** | 538 /** |
| 519 * @param {function(?)} fulfill | 539 * @param {function(?)} fulfill |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 * @return {boolean} | 1138 * @return {boolean} |
| 1119 */ | 1139 */ |
| 1120 get hasChildren() { | 1140 get hasChildren() { |
| 1121 if ((typeof this._value !== 'object') || (this._value === null)) | 1141 if ((typeof this._value !== 'object') || (this._value === null)) |
| 1122 return false; | 1142 return false; |
| 1123 return !!Object.keys(/** @type {!Object} */ (this._value)).length; | 1143 return !!Object.keys(/** @type {!Object} */ (this._value)).length; |
| 1124 } | 1144 } |
| 1125 | 1145 |
| 1126 /** | 1146 /** |
| 1127 * @override | 1147 * @override |
| 1148 * @param {boolean} generatePreview |
| 1128 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 1149 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 1129 */ | 1150 */ |
| 1130 getOwnProperties(callback) { | 1151 getOwnProperties(generatePreview, callback) { |
| 1131 callback(this._children(), null); | 1152 callback(this._children(), null); |
| 1132 } | 1153 } |
| 1133 | 1154 |
| 1134 /** | 1155 /** |
| 1135 * @override | 1156 * @override |
| 1136 * @param {boolean} accessorPropertiesOnly | 1157 * @param {boolean} accessorPropertiesOnly |
| 1158 * @param {boolean} generatePreview |
| 1137 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 1159 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 1138 */ | 1160 */ |
| 1139 getAllProperties(accessorPropertiesOnly, callback) { | 1161 getAllProperties(accessorPropertiesOnly, generatePreview, callback) { |
| 1140 if (accessorPropertiesOnly) | 1162 if (accessorPropertiesOnly) |
| 1141 callback([], null); | 1163 callback([], null); |
| 1142 else | 1164 else |
| 1143 callback(this._children(), null); | 1165 callback(this._children(), null); |
| 1144 } | 1166 } |
| 1145 | 1167 |
| 1146 /** | 1168 /** |
| 1147 * @return {!Array.<!SDK.RemoteObjectProperty>} | 1169 * @return {!Array.<!SDK.RemoteObjectProperty>} |
| 1148 */ | 1170 */ |
| 1149 _children() { | 1171 _children() { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 } | 1438 } |
| 1417 } | 1439 } |
| 1418 | 1440 |
| 1419 /** | 1441 /** |
| 1420 * @return {!SDK.RemoteObject} | 1442 * @return {!SDK.RemoteObject} |
| 1421 */ | 1443 */ |
| 1422 object() { | 1444 object() { |
| 1423 return this._object; | 1445 return this._object; |
| 1424 } | 1446 } |
| 1425 }; | 1447 }; |
| OLD | NEW |