| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return 'null'; | 57 return 'null'; |
| 58 | 58 |
| 59 var type = typeof remoteObject; | 59 var type = typeof remoteObject; |
| 60 if (type !== 'object' && type !== 'function') | 60 if (type !== 'object' && type !== 'function') |
| 61 return type; | 61 return type; |
| 62 | 62 |
| 63 return remoteObject.type; | 63 return remoteObject.type; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @param {string} description |
| 68 * @return {string} |
| 69 */ |
| 70 static arrayNameFromDescription(description) { |
| 71 return description.replace(SDK.RemoteObject._descriptionLengthParenRegex, ''
) |
| 72 .replace(SDK.RemoteObject._descriptionLengthSquareRegex, ''); |
| 73 } |
| 74 |
| 75 /** |
| 67 * @param {!SDK.RemoteObject|!Protocol.Runtime.RemoteObject|!Protocol.Runtime.
ObjectPreview} object | 76 * @param {!SDK.RemoteObject|!Protocol.Runtime.RemoteObject|!Protocol.Runtime.
ObjectPreview} object |
| 68 * @return {number} | 77 * @return {number} |
| 69 */ | 78 */ |
| 70 static arrayLength(object) { | 79 static arrayLength(object) { |
| 71 if (object.subtype !== 'array' && object.subtype !== 'typedarray') | 80 if (object.subtype !== 'array' && object.subtype !== 'typedarray') |
| 72 return 0; | 81 return 0; |
| 73 // Array lengths in V8-generated descriptions switched from square brackets
to parentheses. | 82 // 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. | 83 // 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]+)\)/); | 84 var parenMatches = object.description.match(SDK.RemoteObject._descriptionLen
gthParenRegex); |
| 85 var squareMatches = object.description.match(SDK.RemoteObject._descriptionLe
ngthSquareRegex); |
| 86 return parenMatches ? parseInt(parenMatches[1], 10) : (squareMatches ? parse
Int(squareMatches[1], 10) : 0); |
| 87 } |
| 88 |
| 89 /** |
| 90 * @param {!Protocol.Runtime.ObjectPreview} preview |
| 91 * @return {number} |
| 92 */ |
| 93 static mapOrSetEntriesCount(preview) { |
| 94 if (preview.subtype !== 'map' && preview.subtype !== 'set') |
| 95 return 0; |
| 96 var matches = preview.description.match(SDK.RemoteObject._descriptionLengthP
arenRegex); |
| 76 if (!matches) | 97 if (!matches) |
| 77 return 0; | 98 return 0; |
| 78 return parseInt(matches[1], 10); | 99 return parseInt(matches[1], 10); |
| 79 } | 100 } |
| 80 | 101 |
| 81 /** | 102 /** |
| 82 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool
ean|undefined|null} object | 103 * @param {!Protocol.Runtime.RemoteObject|!SDK.RemoteObject|number|string|bool
ean|undefined|null} object |
| 83 * @return {!Protocol.Runtime.CallArgument} | 104 * @return {!Protocol.Runtime.CallArgument} |
| 84 */ | 105 */ |
| 85 static toCallArgument(object) { | 106 static toCallArgument(object) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 112 if (typeof object.objectId !== 'undefined') | 133 if (typeof object.objectId !== 'undefined') |
| 113 return {objectId: object.objectId}; | 134 return {objectId: object.objectId}; |
| 114 if (typeof object._objectId !== 'undefined') | 135 if (typeof object._objectId !== 'undefined') |
| 115 return {objectId: object._objectId}; | 136 return {objectId: object._objectId}; |
| 116 | 137 |
| 117 return {value: object.value}; | 138 return {value: object.value}; |
| 118 } | 139 } |
| 119 | 140 |
| 120 /** | 141 /** |
| 121 * @param {!SDK.RemoteObject} object | 142 * @param {!SDK.RemoteObject} object |
| 143 * @param {boolean} generatePreview |
| 122 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 144 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 123 */ | 145 */ |
| 124 static loadFromObjectPerProto(object, callback) { | 146 static loadFromObjectPerProto(object, generatePreview, callback) { |
| 125 // Combines 2 asynch calls. Doesn't rely on call-back orders (some calls may
be loop-back). | 147 // Combines 2 asynch calls. Doesn't rely on call-back orders (some calls may
be loop-back). |
| 126 var savedOwnProperties; | 148 var savedOwnProperties; |
| 127 var savedAccessorProperties; | 149 var savedAccessorProperties; |
| 128 var savedInternalProperties; | 150 var savedInternalProperties; |
| 129 var resultCounter = 2; | 151 var resultCounter = 2; |
| 130 | 152 |
| 131 function processCallback() { | 153 function processCallback() { |
| 132 if (--resultCounter) | 154 if (--resultCounter) |
| 133 return; | 155 return; |
| 134 if (savedOwnProperties && savedAccessorProperties) { | 156 if (savedOwnProperties && savedAccessorProperties) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 /** | 192 /** |
| 171 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 193 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 172 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 194 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 173 */ | 195 */ |
| 174 function ownPropertiesCallback(properties, internalProperties) { | 196 function ownPropertiesCallback(properties, internalProperties) { |
| 175 savedOwnProperties = properties; | 197 savedOwnProperties = properties; |
| 176 savedInternalProperties = internalProperties; | 198 savedInternalProperties = internalProperties; |
| 177 processCallback(); | 199 processCallback(); |
| 178 } | 200 } |
| 179 | 201 |
| 180 object.getAllProperties(true, allAccessorPropertiesCallback); | 202 object.getAllProperties(true /* accessorPropertiesOnly */, generatePreview,
allAccessorPropertiesCallback); |
| 181 object.getOwnProperties(ownPropertiesCallback); | 203 object.getOwnProperties(generatePreview, ownPropertiesCallback); |
| 182 } | 204 } |
| 183 | 205 |
| 184 /** | 206 /** |
| 185 * @return {?Protocol.Runtime.CustomPreview} | 207 * @return {?Protocol.Runtime.CustomPreview} |
| 186 */ | 208 */ |
| 187 customPreview() { | 209 customPreview() { |
| 188 return null; | 210 return null; |
| 189 } | 211 } |
| 190 | 212 |
| 191 /** @return {string} */ | 213 /** @return {string} */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 209 } | 231 } |
| 210 | 232 |
| 211 /** | 233 /** |
| 212 * @return {number} | 234 * @return {number} |
| 213 */ | 235 */ |
| 214 arrayLength() { | 236 arrayLength() { |
| 215 throw 'Not implemented'; | 237 throw 'Not implemented'; |
| 216 } | 238 } |
| 217 | 239 |
| 218 /** | 240 /** |
| 241 * @param {boolean} generatePreview |
| 219 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 242 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 220 */ | 243 */ |
| 221 getOwnProperties(callback) { | 244 getOwnProperties(generatePreview, callback) { |
| 222 throw 'Not implemented'; | 245 throw 'Not implemented'; |
| 223 } | 246 } |
| 224 | 247 |
| 225 /** | 248 /** |
| 249 * @param {boolean} generatePreview |
| 226 * @return {!Promise<!{properties: ?Array.<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>}>} | 250 * @return {!Promise<!{properties: ?Array.<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>}>} |
| 227 */ | 251 */ |
| 228 getOwnPropertiesPromise() { | 252 getOwnPropertiesPromise(generatePreview) { |
| 229 return new Promise(promiseConstructor.bind(this)); | 253 return new Promise(promiseConstructor.bind(this)); |
| 230 | 254 |
| 231 /** | 255 /** |
| 232 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} success | 256 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} success |
| 233 * @this {SDK.RemoteObject} | 257 * @this {SDK.RemoteObject} |
| 234 */ | 258 */ |
| 235 function promiseConstructor(success) { | 259 function promiseConstructor(success) { |
| 236 this.getOwnProperties(getOwnPropertiesCallback.bind(null, success)); | 260 this.getOwnProperties(!!generatePreview, getOwnPropertiesCallback.bind(nul
l, success)); |
| 237 } | 261 } |
| 238 | 262 |
| 239 /** | 263 /** |
| 240 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} callback | 264 * @param {function(!{properties: ?Array.<!SDK.RemoteObjectProperty>, intern
alProperties: ?Array.<!SDK.RemoteObjectProperty>})} callback |
| 241 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 265 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 242 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 266 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 243 */ | 267 */ |
| 244 function getOwnPropertiesCallback(callback, properties, internalProperties)
{ | 268 function getOwnPropertiesCallback(callback, properties, internalProperties)
{ |
| 245 callback({properties: properties, internalProperties: internalProperties})
; | 269 callback({properties: properties, internalProperties: internalProperties})
; |
| 246 } | 270 } |
| 247 } | 271 } |
| 248 | 272 |
| 249 /** | 273 /** |
| 250 * @param {boolean} accessorPropertiesOnly | 274 * @param {boolean} accessorPropertiesOnly |
| 275 * @param {boolean} generatePreview |
| 251 * @param {function(?Array<!SDK.RemoteObjectProperty>, ?Array<!SDK.RemoteObjec
tProperty>)} callback | 276 * @param {function(?Array<!SDK.RemoteObjectProperty>, ?Array<!SDK.RemoteObjec
tProperty>)} callback |
| 252 */ | 277 */ |
| 253 getAllProperties(accessorPropertiesOnly, callback) { | 278 getAllProperties(accessorPropertiesOnly, generatePreview, callback) { |
| 254 throw 'Not implemented'; | 279 throw 'Not implemented'; |
| 255 } | 280 } |
| 256 | 281 |
| 257 /** | 282 /** |
| 258 * @param {boolean} accessorPropertiesOnly | 283 * @param {boolean} accessorPropertiesOnly |
| 284 * @param {boolean} generatePreview |
| 259 * @return {!Promise<!{properties: ?Array<!SDK.RemoteObjectProperty>, internal
Properties: ?Array<!SDK.RemoteObjectProperty>}>} | 285 * @return {!Promise<!{properties: ?Array<!SDK.RemoteObjectProperty>, internal
Properties: ?Array<!SDK.RemoteObjectProperty>}>} |
| 260 */ | 286 */ |
| 261 getAllPropertiesPromise(accessorPropertiesOnly) { | 287 getAllPropertiesPromise(accessorPropertiesOnly, generatePreview) { |
| 262 return new Promise(promiseConstructor.bind(this)); | 288 return new Promise(promiseConstructor.bind(this)); |
| 263 | 289 |
| 264 /** | 290 /** |
| 265 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>})} success | 291 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array.<!SDK.RemoteObjectProperty>})} success |
| 266 * @this {SDK.RemoteObject} | 292 * @this {SDK.RemoteObject} |
| 267 */ | 293 */ |
| 268 function promiseConstructor(success) { | 294 function promiseConstructor(success) { |
| 269 this.getAllProperties(accessorPropertiesOnly, getAllPropertiesCallback.bin
d(null, success)); | 295 this.getAllProperties(accessorPropertiesOnly, generatePreview, getAllPrope
rtiesCallback.bind(null, success)); |
| 270 } | 296 } |
| 271 | 297 |
| 272 /** | 298 /** |
| 273 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback | 299 * @param {function(!{properties: ?Array<!SDK.RemoteObjectProperty>, interna
lProperties: ?Array<!SDK.RemoteObjectProperty>})} callback |
| 274 * @param {?Array<!SDK.RemoteObjectProperty>} properties | 300 * @param {?Array<!SDK.RemoteObjectProperty>} properties |
| 275 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties | 301 * @param {?Array<!SDK.RemoteObjectProperty>} internalProperties |
| 276 */ | 302 */ |
| 277 function getAllPropertiesCallback(callback, properties, internalProperties)
{ | 303 function getAllPropertiesCallback(callback, properties, internalProperties)
{ |
| 278 callback({properties: properties, internalProperties: internalProperties})
; | 304 callback({properties: properties, internalProperties: internalProperties})
; |
| 279 } | 305 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 513 |
| 488 /** | 514 /** |
| 489 * @return {!Protocol.Runtime.ObjectPreview|undefined} | 515 * @return {!Protocol.Runtime.ObjectPreview|undefined} |
| 490 */ | 516 */ |
| 491 get preview() { | 517 get preview() { |
| 492 return this._preview; | 518 return this._preview; |
| 493 } | 519 } |
| 494 | 520 |
| 495 /** | 521 /** |
| 496 * @override | 522 * @override |
| 523 * @param {boolean} generatePreview |
| 497 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 524 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 498 */ | 525 */ |
| 499 getOwnProperties(callback) { | 526 getOwnProperties(generatePreview, callback) { |
| 500 this.doGetProperties(true, false, false, callback); | 527 this.doGetProperties(true, false, generatePreview, callback); |
| 501 } | 528 } |
| 502 | 529 |
| 503 /** | 530 /** |
| 504 * @override | 531 * @override |
| 505 * @param {boolean} accessorPropertiesOnly | 532 * @param {boolean} accessorPropertiesOnly |
| 533 * @param {boolean} generatePreview |
| 506 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 534 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 507 */ | 535 */ |
| 508 getAllProperties(accessorPropertiesOnly, callback) { | 536 getAllProperties(accessorPropertiesOnly, generatePreview, callback) { |
| 509 this.doGetProperties(false, accessorPropertiesOnly, false, callback); | 537 this.doGetProperties(false, accessorPropertiesOnly, generatePreview, callbac
k); |
| 510 } | 538 } |
| 511 | 539 |
| 512 /** | 540 /** |
| 513 * @override | 541 * @override |
| 514 * @return {!Promise<?Array<!SDK.EventListener>>} | 542 * @return {!Promise<?Array<!SDK.EventListener>>} |
| 515 */ | 543 */ |
| 516 eventListeners() { | 544 eventListeners() { |
| 517 return new Promise(eventListeners.bind(this)); | 545 return new Promise(eventListeners.bind(this)); |
| 518 /** | 546 /** |
| 519 * @param {function(?)} fulfill | 547 * @param {function(?)} fulfill |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 * @return {boolean} | 1146 * @return {boolean} |
| 1119 */ | 1147 */ |
| 1120 get hasChildren() { | 1148 get hasChildren() { |
| 1121 if ((typeof this._value !== 'object') || (this._value === null)) | 1149 if ((typeof this._value !== 'object') || (this._value === null)) |
| 1122 return false; | 1150 return false; |
| 1123 return !!Object.keys(/** @type {!Object} */ (this._value)).length; | 1151 return !!Object.keys(/** @type {!Object} */ (this._value)).length; |
| 1124 } | 1152 } |
| 1125 | 1153 |
| 1126 /** | 1154 /** |
| 1127 * @override | 1155 * @override |
| 1156 * @param {boolean} generatePreview |
| 1128 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 1157 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 1129 */ | 1158 */ |
| 1130 getOwnProperties(callback) { | 1159 getOwnProperties(generatePreview, callback) { |
| 1131 callback(this._children(), null); | 1160 callback(this._children(), null); |
| 1132 } | 1161 } |
| 1133 | 1162 |
| 1134 /** | 1163 /** |
| 1135 * @override | 1164 * @override |
| 1136 * @param {boolean} accessorPropertiesOnly | 1165 * @param {boolean} accessorPropertiesOnly |
| 1166 * @param {boolean} generatePreview |
| 1137 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback | 1167 * @param {function(?Array.<!SDK.RemoteObjectProperty>, ?Array.<!SDK.RemoteObj
ectProperty>)} callback |
| 1138 */ | 1168 */ |
| 1139 getAllProperties(accessorPropertiesOnly, callback) { | 1169 getAllProperties(accessorPropertiesOnly, generatePreview, callback) { |
| 1140 if (accessorPropertiesOnly) | 1170 if (accessorPropertiesOnly) |
| 1141 callback([], null); | 1171 callback([], null); |
| 1142 else | 1172 else |
| 1143 callback(this._children(), null); | 1173 callback(this._children(), null); |
| 1144 } | 1174 } |
| 1145 | 1175 |
| 1146 /** | 1176 /** |
| 1147 * @return {!Array.<!SDK.RemoteObjectProperty>} | 1177 * @return {!Array.<!SDK.RemoteObjectProperty>} |
| 1148 */ | 1178 */ |
| 1149 _children() { | 1179 _children() { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 static objectAsFunction(object) { | 1391 static objectAsFunction(object) { |
| 1362 if (!object || object.type !== 'function') | 1392 if (!object || object.type !== 'function') |
| 1363 throw new Error('Object is empty or not a function'); | 1393 throw new Error('Object is empty or not a function'); |
| 1364 return new SDK.RemoteFunction(object); | 1394 return new SDK.RemoteFunction(object); |
| 1365 } | 1395 } |
| 1366 | 1396 |
| 1367 /** | 1397 /** |
| 1368 * @return {!Promise<!SDK.RemoteObject>} | 1398 * @return {!Promise<!SDK.RemoteObject>} |
| 1369 */ | 1399 */ |
| 1370 targetFunction() { | 1400 targetFunction() { |
| 1371 return this._object.getOwnPropertiesPromise().then(targetFunction.bind(this)
); | 1401 return this._object.getOwnPropertiesPromise(false /* generatePreview */).the
n(targetFunction.bind(this)); |
| 1372 | 1402 |
| 1373 /** | 1403 /** |
| 1374 * @param {!{properties: ?Array<!SDK.RemoteObjectProperty>, internalProperti
es: ?Array<!SDK.RemoteObjectProperty>}} ownProperties | 1404 * @param {!{properties: ?Array<!SDK.RemoteObjectProperty>, internalProperti
es: ?Array<!SDK.RemoteObjectProperty>}} ownProperties |
| 1375 * @return {!SDK.RemoteObject} | 1405 * @return {!SDK.RemoteObject} |
| 1376 * @this {SDK.RemoteFunction} | 1406 * @this {SDK.RemoteFunction} |
| 1377 */ | 1407 */ |
| 1378 function targetFunction(ownProperties) { | 1408 function targetFunction(ownProperties) { |
| 1379 if (!ownProperties.internalProperties) | 1409 if (!ownProperties.internalProperties) |
| 1380 return this._object; | 1410 return this._object; |
| 1381 var internalProperties = ownProperties.internalProperties; | 1411 var internalProperties = ownProperties.internalProperties; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 } | 1446 } |
| 1417 } | 1447 } |
| 1418 | 1448 |
| 1419 /** | 1449 /** |
| 1420 * @return {!SDK.RemoteObject} | 1450 * @return {!SDK.RemoteObject} |
| 1421 */ | 1451 */ |
| 1422 object() { | 1452 object() { |
| 1423 return this._object; | 1453 return this._object; |
| 1424 } | 1454 } |
| 1425 }; | 1455 }; |
| 1456 |
| 1457 /** |
| 1458 * @const |
| 1459 * @type {!RegExp} |
| 1460 */ |
| 1461 SDK.RemoteObject._descriptionLengthParenRegex = /\(([0-9]+)\)/; |
| 1462 |
| 1463 /** |
| 1464 * @const |
| 1465 * @type {!RegExp} |
| 1466 */ |
| 1467 SDK.RemoteObject._descriptionLengthSquareRegex = /\[([0-9]+)\]/; |
| OLD | NEW |