Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 * @this {WebInspector.ExecutionContext} | 519 * @this {WebInspector.ExecutionContext} |
| 520 */ | 520 */ |
| 521 function evaluated(result, wasThrown) | 521 function evaluated(result, wasThrown) |
| 522 { | 522 { |
| 523 if (!result || wasThrown) { | 523 if (!result || wasThrown) { |
| 524 completionsReadyCallback([]); | 524 completionsReadyCallback([]); |
| 525 return; | 525 return; |
| 526 } | 526 } |
| 527 | 527 |
| 528 /** | 528 /** |
| 529 * @param {!WebInspector.RemoteObject} object | |
| 530 * @return {!Promise<?WebInspector.RemoteObject>} | |
| 531 */ | |
| 532 function extractTarget(object) | |
| 533 { | |
| 534 if (object.type !== "object" || object.subtype !== "proxy") | |
| 535 return Promise.resolve(/** @type {?WebInspector.RemoteObject } */(object)); | |
| 536 var callback; | |
| 537 var promise = new Promise(fullfill => callback = fullfill); | |
| 538 object.getOwnProperties(extractTargetFromProperties); | |
|
lushnikov
2016/05/05 01:06:03
return object.getOwnPropertiesPromise()
.then(f
kozy
2016/05/05 01:35:22
Done.
| |
| 539 return promise; | |
| 540 | |
| 541 /** | |
| 542 * @param {?Array<!WebInspector.RemoteObjectProperty>} propertie s | |
| 543 * @param {?Array.<!WebInspector.RemoteObjectProperty>} internal Properties | |
| 544 */ | |
| 545 function extractTargetFromProperties(properties, internalPropert ies) | |
| 546 { | |
| 547 internalProperties = internalProperties || []; | |
|
lushnikov
2016/05/05 01:06:04
var target = internalProperties.find(property => p
kozy
2016/05/05 01:35:22
Done.
| |
| 548 for (var property of internalProperties) { | |
| 549 if (property.name === "[[Target]]") { | |
| 550 extractTarget(property.value).then(callback); | |
| 551 return; | |
| 552 } | |
| 553 } | |
| 554 callback(null); | |
| 555 } | |
| 556 } | |
| 557 | |
| 558 /** | |
| 559 * @param {?WebInspector.RemoteObject} object | |
| 560 * @return {!Promise<?Object>} | |
| 561 */ | |
| 562 function completionsForObject(object) | |
| 563 { | |
| 564 if (!object) | |
| 565 return Promise.resolve(/** @type {?Object} */(null)); | |
| 566 var callback; | |
| 567 var promise = new Promise(fullfill => callback = fullfill); | |
| 568 object.callFunctionJSON(getCompletions, [WebInspector.RemoteObje ct.toCallArgument(object.subtype)], callback); | |
| 569 return promise; | |
| 570 } | |
| 571 | |
| 572 /** | |
| 529 * @param {string=} type | 573 * @param {string=} type |
| 530 * @suppressReceiverCheck | 574 * @suppressReceiverCheck |
| 531 * @this {WebInspector.ExecutionContext} | 575 * @this {*} |
| 532 */ | 576 */ |
| 533 function getCompletions(type) | 577 function getCompletions(type) |
| 534 { | 578 { |
| 535 var object; | 579 var object; |
| 536 if (type === "string") | 580 if (type === "string") |
| 537 object = new String(""); | 581 object = new String(""); |
| 538 else if (type === "number") | 582 else if (type === "number") |
| 539 object = new Number(0); | 583 object = new Number(0); |
| 540 else if (type === "boolean") | 584 else if (type === "boolean") |
| 541 object = new Boolean(false); | 585 object = new Boolean(false); |
| 542 else | 586 else |
| 543 object = this; | 587 object = this; |
| 544 | 588 |
| 545 var resultSet = {}; | 589 var resultSet = {}; |
| 546 try { | 590 try { |
| 547 for (var o = object; o; o = o.__proto__) { | 591 for (var o = object; o; o = o.__proto__) { |
| 548 if (type === "array" && o === object && ArrayBuffer.isVi ew(o) && o.length > 9999) | 592 if (type === "array" && o === object && ArrayBuffer.isVi ew(o) && o.length > 9999) |
| 549 continue; | 593 continue; |
| 550 var names = Object.getOwnPropertyNames(o); | 594 var names = Object.getOwnPropertyNames(/** @type{!Object } */(o)); |
| 551 var isArray = Array.isArray(o); | 595 var isArray = Array.isArray(o); |
| 552 for (var i = 0; i < names.length; ++i) { | 596 for (var i = 0; i < names.length; ++i) { |
| 553 // Skip array elements indexes. | 597 // Skip array elements indexes. |
| 554 if (isArray && /^[0-9]/.test(names[i])) | 598 if (isArray && /^[0-9]/.test(names[i])) |
| 555 continue; | 599 continue; |
| 556 resultSet[names[i]] = true; | 600 resultSet[names[i]] = true; |
| 557 } | 601 } |
| 558 } | 602 } |
| 559 } catch (e) { | 603 } catch (e) { |
| 560 } | 604 } |
| 561 return resultSet; | 605 return resultSet; |
| 562 } | 606 } |
| 563 | 607 |
| 564 if (result.type === "object" || result.type === "function") | 608 if (result.type === "object") |
| 565 result.callFunctionJSON(getCompletions, [WebInspector.RemoteObje ct.toCallArgument(result.subtype)], receivedPropertyNames.bind(this)); | 609 extractTarget(result).then(completionsForObject).then(receivedPr opertyNames.bind(this)); |
| 566 else if (result.type === "string" || result.type === "number" || res ult.type === "boolean") | 610 else if (result.type === "string" || result.type === "number" || res ult.type === "boolean") |
| 567 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\") ", "completion", false, true, true, false, false, receivedPropertyNamesFromEval. bind(this)); | 611 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\") ", "completion", false, true, true, false, false, receivedPropertyNamesFromEval. bind(this)); |
| 568 } | 612 } |
| 569 | 613 |
| 570 /** | 614 /** |
| 571 * @param {?WebInspector.RemoteObject} notRelevant | 615 * @param {?WebInspector.RemoteObject} notRelevant |
| 572 * @param {boolean} wasThrown | 616 * @param {boolean} wasThrown |
| 573 * @param {?RuntimeAgent.RemoteObject=} result | 617 * @param {?RuntimeAgent.RemoteObject=} result |
| 574 * @this {WebInspector.ExecutionContext} | 618 * @this {WebInspector.ExecutionContext} |
| 575 */ | 619 */ |
| 576 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) | 620 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) |
| 577 { | 621 { |
| 578 if (result && !wasThrown) | 622 if (result && !wasThrown) |
| 579 receivedPropertyNames.call(this, result.value); | 623 receivedPropertyNames.call(this, /** @type {!Object} */(result.v alue)); |
| 580 else | 624 else |
| 581 completionsReadyCallback([]); | 625 completionsReadyCallback([]); |
| 582 } | 626 } |
| 583 | 627 |
| 584 /** | 628 /** |
| 629 * @param {?Object} propertyNames | |
| 585 * @this {WebInspector.ExecutionContext} | 630 * @this {WebInspector.ExecutionContext} |
| 586 */ | 631 */ |
| 587 function receivedPropertyNames(propertyNames) | 632 function receivedPropertyNames(propertyNames) |
| 588 { | 633 { |
| 589 this.target().runtimeAgent().releaseObjectGroup("completion"); | 634 this.target().runtimeAgent().releaseObjectGroup("completion"); |
| 590 if (!propertyNames) { | 635 if (!propertyNames) { |
| 591 completionsReadyCallback([]); | 636 completionsReadyCallback([]); |
| 592 return; | 637 return; |
| 593 } | 638 } |
| 594 var includeCommandLineAPI = (!dotNotation && !bracketNotation); | 639 var includeCommandLineAPI = (!dotNotation && !bracketNotation); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 813 /** | 858 /** |
| 814 * @param {string} listenerType | 859 * @param {string} listenerType |
| 815 */ | 860 */ |
| 816 setListenerType: function(listenerType) | 861 setListenerType: function(listenerType) |
| 817 { | 862 { |
| 818 this._listenerType = listenerType; | 863 this._listenerType = listenerType; |
| 819 }, | 864 }, |
| 820 | 865 |
| 821 __proto__: WebInspector.SDKObject.prototype | 866 __proto__: WebInspector.SDKObject.prototype |
| 822 } | 867 } |
| OLD | NEW |