Changeset 178796 in webkit
- Timestamp:
- Jan 20, 2015 8:22:24 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r178791 r178796 1 2015-01-20 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: Clean up InjectedScriptSource.js 4 https://bugs.webkit.org/show_bug.cgi?id=140709 5 6 Reviewed by Timothy Hatcher. 7 8 This patch includes some relevant Blink patches and small changes. 9 10 Patch by <aandrey@chromium.org> 11 DevTools: Remove console last result $_ on console clear. 12 https://src.chromium.org/viewvc/blink?revision=179179&view=revision 13 14 Patch by <eustas@chromium.org> 15 [Inspect DOM properties] incorrect CSS Selector Syntax 16 https://src.chromium.org/viewvc/blink?revision=156903&view=revision 17 18 * inspector/InjectedScriptSource.js: 19 1 20 2015-01-20 Joseph Pecoraro <pecoraro@apple.com> 2 21 -
trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js
r178768 r178796 29 29 //# sourceURL=__WebInspectorInjectedScript__ 30 30 31 /**32 * @param {InjectedScriptHost} InjectedScriptHost33 * @param {GlobalObject} inspectedGlobalObject34 * @param {number} injectedScriptId35 */36 31 (function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) { 37 32 … … 39 34 var Object = {}.constructor; 40 35 41 /**42 * @constructor43 */44 36 var InjectedScript = function() 45 37 { … … 51 43 } 52 44 53 /**54 * @type {Object.<string, boolean>}55 * @const56 */57 45 InjectedScript.primitiveTypes = { 58 46 undefined: true, … … 63 51 64 52 InjectedScript.prototype = { 65 /**66 * @param {*} object67 * @return {boolean}68 */69 53 isPrimitiveValue: function(object) 70 54 { … … 73 57 }, 74 58 75 /**76 * @param {*} object77 * @param {string} groupName78 * @param {boolean} canAccessInspectedGlobalObject79 * @param {boolean} generatePreview80 * @return {!RuntimeAgent.RemoteObject}81 */82 59 wrapObject: function(object, groupName, canAccessInspectedGlobalObject, generatePreview) 83 60 { … … 97 74 }, 98 75 99 /**100 * @param {*} object101 * @return {!RuntimeAgent.RemoteObject}102 */103 76 _fallbackWrapper: function(object) 104 77 { … … 109 82 else 110 83 result.description = this._toString(object); 111 return /** @type {!RuntimeAgent.RemoteObject} */ (result); 112 }, 113 114 /** 115 * @param {boolean} canAccessInspectedGlobalObject 116 * @param {Object} table 117 * @param {Array.<string>|string|boolean} columns 118 * @return {!RuntimeAgent.RemoteObject} 119 */ 84 return result; 85 }, 86 120 87 wrapTable: function(canAccessInspectedGlobalObject, table, columns) 121 88 { … … 125 92 if (typeof columns === "string") 126 93 columns = [columns]; 127 if (InjectedScriptHost.type(columns) == "array") {94 if (InjectedScriptHost.type(columns) === "array") { 128 95 columnNames = []; 129 96 for (var i = 0; i < columns.length; ++i) … … 133 100 }, 134 101 135 /**136 * @param {*} object137 */138 102 inspectObject: function(object) 139 103 { … … 142 106 }, 143 107 144 /**145 * This method cannot throw.146 * @param {*} object147 * @param {string=} objectGroupName148 * @param {boolean=} forceValueType149 * @param {boolean=} generatePreview150 * @param {?Array.<string>=} columnNames151 * @return {!RuntimeAgent.RemoteObject}152 * @suppress {checkTypes}153 */154 108 _wrapObject: function(object, objectGroupName, forceValueType, generatePreview, columnNames) 155 109 { … … 166 120 }, 167 121 168 /**169 * @param {*} object170 * @param {string=} objectGroupName171 * @return {string}172 */173 122 _bind: function(object, objectGroupName) 174 123 { … … 188 137 }, 189 138 190 /**191 * @param {string} objectId192 * @return {Object}193 */194 139 _parseObjectId: function(objectId) 195 140 { … … 197 142 }, 198 143 199 /**200 * @param {string} objectGroupName201 */202 144 releaseObjectGroup: function(objectGroupName) 203 145 { 146 if (objectGroupName === "console") 147 delete this._lastResult; 204 148 var group = this._objectGroups[objectGroupName]; 205 149 if (!group) … … 210 154 }, 211 155 212 /**213 * @param {string} methodName214 * @param {string} args215 * @return {*}216 */217 156 dispatch: function(methodName, args) 218 157 { … … 256 195 }, 257 196 258 /**259 * @param {string} objectId260 * @return {Array.<Object>|boolean}261 */262 197 getInternalProperties: function(objectId, ownProperties) 263 198 { … … 267 202 if (!this._isDefined(object)) 268 203 return false; 204 269 205 var descriptors = []; 270 206 var internalProperties = InjectedScriptHost.getInternalProperties(object); … … 279 215 } 280 216 } 217 281 218 return descriptors; 282 219 }, 283 220 284 /**285 * @param {string} functionId286 * @return {!DebuggerAgent.FunctionDetails|string}287 */288 221 getFunctionDetails: function(functionId) 289 222 { … … 307 240 }, 308 241 309 /**310 * @param {string} objectId311 */312 242 releaseObject: function(objectId) 313 243 { … … 316 246 }, 317 247 318 /**319 * @param {string} id320 */321 248 _releaseObject: function(id) 322 249 { … … 325 252 }, 326 253 327 /**328 * @param {string} expression329 * @param {string} objectGroup330 * @param {boolean} injectCommandLineAPI331 * @param {boolean} returnByValue332 * @param {boolean} generatePreview333 * @return {*}334 */335 254 evaluate: function(expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview) 336 255 { … … 338 257 }, 339 258 340 /**341 * @param {string} objectId342 * @param {string} expression343 * @param {boolean} returnByValue344 * @return {Object|string}345 */346 259 callFunctionOn: function(objectId, expression, args, returnByValue) 347 260 { … … 353 266 if (args) { 354 267 var resolvedArgs = []; 355 args = InjectedScriptHost.evaluate(args); 356 for (var i = 0; i < args.length; ++i) { 357 var resolvedCallArgument; 268 var callArgs = InjectedScriptHost.evaluate(args); 269 for (var i = 0; i < callArgs.length; ++i) { 358 270 try { 359 resolved CallArgument = this._resolveCallArgument(args[i]);271 resolvedArgs[i] = this._resolveCallArgument(callArgs[i]); 360 272 } catch (e) { 361 273 return String(e); 362 274 } 363 resolvedArgs.push(resolvedCallArgument)364 275 } 365 276 } … … 371 282 return "Given expression does not evaluate to a function"; 372 283 373 return { wasThrown: false, 374 result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue) }; 284 return { 285 wasThrown: false, 286 result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue) 287 }; 375 288 } catch (e) { 376 289 return this._createThrownValue(e, objectGroup); … … 378 291 }, 379 292 380 /**381 * Resolves a value from CallArgument description.382 * @param {RuntimeAgent.CallArgument} callArgumentJson383 * @return {*} resolved value384 * @throws {string} error message385 */386 293 _resolveCallArgument: function(callArgumentJson) { 387 294 var objectId = callArgumentJson.objectId; … … 398 305 } else if ("value" in callArgumentJson) 399 306 return callArgumentJson.value; 400 else 401 return undefined; 402 }, 403 404 /** 405 * @param {Function} evalFunction 406 * @param {Object} object 407 * @param {string} objectGroup 408 * @param {boolean} isEvalOnCallFrame 409 * @param {boolean} injectCommandLineAPI 410 * @param {boolean} returnByValue 411 * @param {boolean} generatePreview 412 * @return {*} 413 */ 307 return undefined; 308 }, 309 414 310 _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, isEvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview) 415 311 { 416 312 try { 417 return { wasThrown: false, 418 result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue, generatePreview) }; 313 return { 314 wasThrown: false, 315 result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue, generatePreview) 316 }; 419 317 } catch (e) { 420 318 return this._createThrownValue(e, objectGroup); … … 422 320 }, 423 321 424 /**425 * @param {*} value426 * @param {string} objectGroup427 * @return {Object}428 */429 322 _createThrownValue: function(value, objectGroup) 430 323 { … … 433 326 remoteObject.description = this._toString(value); 434 327 } catch (e) {} 435 return { wasThrown: true, 436 result: remoteObject }; 437 }, 438 439 /** 440 * @param {Function} evalFunction 441 * @param {Object} object 442 * @param {string} objectGroup 443 * @param {string} expression 444 * @param {boolean} isEvalOnCallFrame 445 * @param {boolean} injectCommandLineAPI 446 * @return {*} 447 */ 328 return { 329 wasThrown: true, 330 result: remoteObject 331 }; 332 }, 333 448 334 _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI) 449 335 { … … 525 411 }, 526 412 527 /**528 * @param {Object} callFrame529 * @return {Array.<InjectedScript.CallFrameProxy>|boolean}530 */531 413 wrapCallFrames: function(callFrame) 532 414 { … … 543 425 }, 544 426 545 /**546 * @param {Object} topCallFrame547 * @param {string} callFrameId548 * @param {string} expression549 * @param {string} objectGroup550 * @param {boolean} injectCommandLineAPI551 * @param {boolean} returnByValue552 * @param {boolean} generatePreview553 * @return {*}554 */555 427 evaluateOnCallFrame: function(topCallFrame, callFrameId, expression, objectGroup, injectCommandLineAPI, returnByValue, generatePreview) 556 428 { … … 561 433 }, 562 434 563 /**564 * @param {Object} topCallFrame565 * @param {string} callFrameId566 * @return {Object}567 */568 435 _callFrameForId: function(topCallFrame, callFrameId) 569 436 { … … 576 443 }, 577 444 578 /**579 * @param {Object} objectId580 * @return {Object}581 */582 445 _objectForId: function(objectId) 583 446 { … … 585 448 }, 586 449 587 /**588 * @param {string} objectId589 * @return {Object}590 */591 450 findObjectById: function(objectId) 592 451 { … … 595 454 }, 596 455 597 /**598 * @param {string} name599 * @return {Object}600 */601 456 module: function(name) 602 457 { … … 604 459 }, 605 460 606 /**607 * @param {string} name608 * @param {string} source609 * @return {Object}610 */611 461 injectModule: function(name, source, host) 612 462 { 613 463 delete this._modules[name]; 464 614 465 var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")"); 615 466 if (typeof moduleFunction !== "function") { … … 618 469 return null; 619 470 } 471 620 472 var module = moduleFunction.call(inspectedGlobalObject, InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this, host); 621 473 this._modules[name] = module; … … 726 578 }, 727 579 728 /**729 * @param {*} object730 * @return {boolean}731 */732 580 _isDefined: function(object) 733 581 { … … 735 583 }, 736 584 737 /**738 * @param {*} object739 * @return {boolean}740 */741 585 _isHTMLAllCollection: function(object) 742 586 { … … 745 589 }, 746 590 747 /**748 * @param {Object=} obj749 * @return {string?}750 */751 591 _subtype: function(obj) 752 592 { … … 777 617 }, 778 618 779 /**780 * @param {*} obj781 * @return {string?}782 */783 619 _describe: function(obj) 784 620 { … … 786 622 return null; 787 623 788 obj = /** @type {Object} */ (obj);789 790 // Type is object, get subtype.791 624 var subtype = this._subtype(obj); 792 625 … … 806 639 description += obj.id ? "#" + obj.id : ""; 807 640 var className = obj.className; 808 description += className ? "." + className: "";641 description += (className && typeof className === "string") ? "." + className.trim().replace(/\s+/g, ".") : ""; 809 642 break; 810 643 case 10 /*Node.DOCUMENT_TYPE_NODE */: … … 826 659 return this._toString(obj); 827 660 661 // FIXME: Can we remove this? 828 662 if (className === "Object") { 829 663 // In Chromium DOM wrapper prototypes will have Object as their constructor name, … … 836 670 }, 837 671 838 /**839 * @param {*} obj840 * @return {string}841 */842 672 _toString: function(obj) 843 673 { … … 847 677 } 848 678 849 /** 850 * @type {InjectedScript} 851 * @const 852 */ 853 var injectedScript = new InjectedScript(); 854 855 /** 856 * @constructor 857 * @param {*} object 858 * @param {string=} objectGroupName 859 * @param {boolean=} forceValueType 860 * @param {boolean=} generatePreview 861 * @param {?Array.<string>=} columnNames 862 */ 679 var injectedScript = new InjectedScript; 680 681 863 682 InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, generatePreview, columnNames) 864 683 { 865 684 this.type = typeof object; 685 686 if (this.type === "undefined" && injectedScript._isHTMLAllCollection(object)) 687 this.type = "object"; 688 866 689 if (injectedScript.isPrimitiveValue(object) || object === null || forceValueType) { 867 690 // We don't send undefined values over JSON. 868 if (t ypeof object!== "undefined")691 if (this.type !== "undefined") 869 692 this.value = object; 870 693 … … 874 697 875 698 // Provide user-friendly number values. 876 if (t ypeof object=== "number")699 if (this.type === "number") 877 700 this.description = object + ""; 878 701 return; 879 702 } 880 881 object = /** @type {Object} */ (object);882 703 883 704 this.objectId = injectedScript._bind(object, objectGroupName); … … 885 706 if (subtype) 886 707 this.subtype = subtype; 708 887 709 this.className = InjectedScriptHost.internalConstructorName(object); 888 710 this.description = injectedScript._describe(object); … … 893 715 894 716 InjectedScript.RemoteObject.prototype = { 895 /**896 * @param {Object} object897 * @param {Array.<string>=} firstLevelKeys898 * @param {?Array.<string>=} secondLevelKeys899 * @return {Object} preview900 */901 717 _generatePreview: function(object, firstLevelKeys, secondLevelKeys) 902 718 { … … 918 734 }, 919 735 920 /**921 * @param {Object} object922 * @param {Object} preview923 * @param {Object} propertiesThreshold924 * @param {Array.<string>=} firstLevelKeys925 * @param {Array.<string>=} secondLevelKeys926 */927 736 _generateProtoPreview: function(object, preview, propertiesThreshold, firstLevelKeys, secondLevelKeys) 928 737 { 929 var propertyNames = firstLevelKeys ? firstLevelKeys : Object.keys( /** @type {!Object} */(object));738 var propertyNames = firstLevelKeys ? firstLevelKeys : Object.keys(object); 930 739 try { 931 740 for (var i = 0; i < propertyNames.length; ++i) { … … 939 748 continue; 940 749 941 var descriptor = Object.getOwnPropertyDescriptor( /** @type {!Object} */(object), name);750 var descriptor = Object.getOwnPropertyDescriptor(object, name); 942 751 if (!("value" in descriptor) || !descriptor.enumerable) { 943 752 preview.lossless = false; … … 982 791 var description = ""; 983 792 if (type !== "function") 984 description = this._abbreviateString( /** @type {string} */ (injectedScript._describe(value)), maxLength, subtype === "regexp");793 description = this._abbreviateString(injectedScript._describe(value), maxLength, subtype === "regexp"); 985 794 986 795 var property = { name: name, type: type, value: description }; … … 993 802 }, 994 803 995 /**996 * @param {Object} preview997 * @param {Object} property998 * @param {Object} propertiesThreshold999 */1000 804 _appendPropertyPreview: function(preview, property, propertiesThreshold) 1001 805 { … … 1007 811 }, 1008 812 1009 /**1010 * @param {string} string1011 * @param {number} maxLength1012 * @param {boolean=} middle1013 * @returns1014 */1015 813 _abbreviateString: function(string, maxLength, middle) 1016 814 { 1017 815 if (string.length <= maxLength) 1018 816 return string; 817 1019 818 if (middle) { 1020 819 var leftHalf = maxLength >> 1; … … 1022 821 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.length - rightHalf, rightHalf); 1023 822 } 823 1024 824 return string.substr(0, maxLength) + "\u2026"; 1025 825 } 1026 826 } 1027 /** 1028 * @constructor 1029 * @param {number} ordinal 1030 * @param {Object} callFrame 1031 */ 827 1032 828 InjectedScript.CallFrameProxy = function(ordinal, callFrame) 1033 829 { 1034 830 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + injectedScriptId + "}"; 1035 831 this.functionName = (callFrame.type === "function" ? callFrame.functionName : ""); 1036 this.location = { scriptId: String(callFrame.sourceID), lineNumber: callFrame.line, columnNumber: callFrame.column};832 this.location = {scriptId: String(callFrame.sourceID), lineNumber: callFrame.line, columnNumber: callFrame.column}; 1037 833 this.scopeChain = this._wrapScopeChain(callFrame); 1038 834 this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace"); … … 1040 836 1041 837 InjectedScript.CallFrameProxy.prototype = { 1042 /**1043 * @param {Object} callFrame1044 * @return {!Array.<DebuggerAgent.Scope>}1045 */1046 838 _wrapScopeChain: function(callFrame) 1047 839 { 1048 840 var scopeChain = callFrame.scopeChain; 1049 841 var scopeChainProxy = []; 1050 for (var i = 0; i < scopeChain.length; i++) { 1051 var scope = InjectedScript.CallFrameProxy._createScopeJson(callFrame.scopeType(i), scopeChain[i], "backtrace"); 1052 scopeChainProxy.push(scope); 1053 } 842 for (var i = 0; i < scopeChain.length; i++) 843 scopeChainProxy[i] = InjectedScript.CallFrameProxy._createScopeJson(callFrame.scopeType(i), scopeChain[i], "backtrace"); 1054 844 return scopeChainProxy; 1055 845 } 1056 846 } 1057 847 1058 /** 1059 * @param {number} scopeTypeCode 1060 * @param {*} scopeObject 1061 * @param {string} groupId 1062 * @return {!DebuggerAgent.Scope} 1063 */ 1064 InjectedScript.CallFrameProxy._createScopeJson = function(scopeTypeCode, scopeObject, groupId) { 1065 const GLOBAL_SCOPE = 0; 1066 const LOCAL_SCOPE = 1; 1067 const WITH_SCOPE = 2; 1068 const CLOSURE_SCOPE = 3; 1069 const CATCH_SCOPE = 4; 1070 const FUNCTION_NAME_SCOPE = 5; 1071 1072 /** @type {!Object.<number, string>} */ 1073 var scopeTypeNames = {}; 1074 scopeTypeNames[GLOBAL_SCOPE] = "global"; 1075 scopeTypeNames[LOCAL_SCOPE] = "local"; 1076 scopeTypeNames[WITH_SCOPE] = "with"; 1077 scopeTypeNames[CLOSURE_SCOPE] = "closure"; 1078 scopeTypeNames[CATCH_SCOPE] = "catch"; 1079 scopeTypeNames[FUNCTION_NAME_SCOPE] = "functionName"; 1080 848 InjectedScript.CallFrameProxy._scopeTypeNames = { 849 0: "global", // GLOBAL_SCOPE 850 1: "local", // LOCAL_SCOPE 851 2: "with", // WITH_SCOPE 852 3: "closure", // CLOSURE_SCOPE 853 4: "catch", // CATCH_SCOPE 854 5: "functionName", // FUNCTION_NAME_SCOPE 855 } 856 857 InjectedScript.CallFrameProxy._createScopeJson = function(scopeTypeCode, scopeObject, groupId) 858 { 1081 859 return { 1082 860 object: injectedScript._wrapObject(scopeObject, groupId), 1083 type: /** @type {DebuggerAgent.ScopeType} */ (scopeTypeNames[scopeTypeCode])861 type: InjectedScript.CallFrameProxy._scopeTypeNames[scopeTypeCode] 1084 862 }; 1085 863 }
Note: See TracChangeset
for help on using the changeset viewer.