Changeset 125046 in webkit
- Timestamp:
- Aug 8, 2012 10:22:21 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r125045 r125046 1 2012-08-08 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: generate preview for the objects dumped into the console upon logging. 4 https://bugs.webkit.org/show_bug.cgi?id=35801 5 6 Reviewed by Vsevolod Vlasov. 7 8 * inspector/console/command-line-api-inspect-expected.txt: 9 * inspector/console/console-dir-expected.txt: 10 * inspector/console/console-eval-global-expected.txt: 11 * inspector/console/console-eval-global.html: 12 * inspector/console/console-format-collections-expected.txt: 13 * inspector/console/console-format-collections.html: 14 * inspector/console/console-format-expected.txt: 15 * inspector/console/console-format.html: 16 * inspector/console/console-log-document-proto-expected.txt: 17 * inspector/console/console-log-document-proto.html: 18 * inspector/console/console-log-toString-object-expected.txt: 19 * inspector/debugger/watch-expressions-panel-switch-expected.txt: 20 * inspector/elements/event-listener-sidebar-expected.txt: 21 * inspector/elements/event-listeners-about-blank-expected.txt: 22 * platform/chromium/inspector/console/console-dir-expected.txt: 23 * platform/chromium/inspector/console/console-eval-global-expected.txt: Removed. 24 * platform/chromium/inspector/console/console-format-collections-expected.txt: 25 * platform/chromium/inspector/console/console-format-expected.txt: Removed. 26 * platform/chromium/inspector/console/console-log-document-proto-expected.txt: 27 * platform/chromium/inspector/debugger/watch-expressions-panel-switch-expected.txt: 28 * platform/chromium/inspector/elements/event-listener-sidebar-expected.txt: Removed. 29 1 30 2012-07-31 Philippe Normand <pnormand@igalia.com> 2 31 -
trunk/LayoutTests/inspector/console/command-line-api-inspect-expected.txt
r79556 r125046 5 5 6 6 7 WebInspector.inspect called with: HTMLParagraphElement7 WebInspector.inspect called with: <p> 8 8 WebInspector.inspect's hints are: [] 9 9 inspect($('p1')) = -
trunk/LayoutTests/inspector/console/console-dir-expected.txt
r114200 r125046 13 13 14 14 NodeList[1] 15 0: HTMLHtmlElement15 0: <html> 16 16 constructor: NodeListConstructor 17 17 length: 1 -
trunk/LayoutTests/inspector/console/console-eval-global-expected.txt
r92961 r125046 3 3 foo 4 4 "fooValue" 5 bar 16 ReferenceError: Can't find variable: bar1 5 bar 6 Object 7 7 -
trunk/LayoutTests/inspector/console/console-eval-global.html
r78535 r125046 16 16 function step1() 17 17 { 18 InspectorTest.evaluateInConsole("bar 1", step2);18 InspectorTest.evaluateInConsole("bar", step2); 19 19 } 20 20 -
trunk/LayoutTests/inspector/console/console-format-collections-expected.txt
r114200 r125046 1 CONSOLE MESSAGE: line 15: [object NodeList] 2 CONSOLE MESSAGE: line 19: [object HTMLCollection] 3 CONSOLE MESSAGE: line 23: [object HTMLOptionsCollection] 4 CONSOLE MESSAGE: line 27: [object HTMLAllCollection] 5 CONSOLE MESSAGE: line 31: [object HTMLCollection] 6 CONSOLE MESSAGE: line 35: [object NodeList] 7 CONSOLE MESSAGE: line 41: 1,2, 8 CONSOLE MESSAGE: line 44: [object Object] 9 CONSOLE MESSAGE: line 51: [object Arguments] 1 10 CONSOLE MESSAGE: line 15: [object NodeList] 2 11 CONSOLE MESSAGE: line 19: [object HTMLCollection] … … 21 30 NonArrayWithLength console-format-collections.html:44 22 31 [1, "2"] console-format-collections.html:51 32 [<select>] console-format-collections.html:15 33 console-format-collections.html:19 34 [<option>, <option>, selectedIndex: 0] console-format-collections.html:23 35 console-format-collections.html:27 36 console-format-collections.html:31 37 [<input>, <input>] console-format-collections.html:35 38 [1, Array[2]] console-format-collections.html:41 39 NonArrayWithLength {keys: Array[0]} console-format-collections.html:44 40 [1, "2"] console-format-collections.html:51 41 Page reloaded. 23 42 -
trunk/LayoutTests/inspector/console/console-format-collections.html
r112102 r125046 5 5 <script> 6 6 7 function onload()7 function logToConsole() 8 8 { 9 9 var formElement = document.getElementById("f"); … … 53 53 } 54 54 55 function onload() 56 { 57 logToConsole(); 58 } 59 55 60 function NonArrayWithLength() 56 61 { … … 66 71 function test() 67 72 { 68 InspectorTest.dumpConsoleMessages(); 69 InspectorTest.completeTest(); 73 InspectorTest.evaluateInPage("logToConsole()", callback); 74 75 function callback() 76 { 77 InspectorTest.dumpConsoleMessages(); 78 InspectorTest.completeTest(); 79 } 70 80 } 71 81 </script> -
trunk/LayoutTests/inspector/console/console-format-expected.txt
r110693 r125046 56 56 Array[10] console-format.html:22 57 57 /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i console-format.html:54 58 [/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\ .))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i] console-format.html:5558 [/^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\…?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i] console-format.html:55 59 59 globals[0] 60 60 /^url\(\s*(?:(?:"(?:[^\\\"]|(?:\\[\da-f]{1,6}\s?|\.))*"|'(?:[^\\\']|(?:\\[\da-f]{1,6}\s?|\.))*')|(?:[!#$%&*-~\w]|(?:\\[\da-f]{1,6}\s?|\.))*)\s*\)/i … … 75 75 globals[4] 76 76 Error 77 <body onload="onload()"> …</body>console-format.html:5478 [<body onload="onload()">…</body>] console-format.html:5577 <body onload="onload()"> console-format.html:54 78 [<body>] console-format.html:55 79 79 globals[5] 80 <body onload="onload()"> …</body>80 <body onload="onload()"> 81 81 function () { return 1; } console-format.html:54 82 82 [function () { return 1; }] console-format.html:55 … … 110 110 undefined 111 111 attr="" console-format.html:54 112 [attr =""] console-format.html:55112 [attr] console-format.html:55 113 113 globals[12] 114 114 attr="" 115 attr="value" console-format.html:54116 [attr ="value"] console-format.html:55115 attr="value""value" console-format.html:54 116 [attr] console-format.html:55 117 117 globals[13] 118 attr="value" 119 id="x" console-format.html:54120 [id ="x"] console-format.html:55118 attr="value""value" 119 id="x""x" console-format.html:54 120 [id] console-format.html:55 121 121 globals[14] 122 id="x" 122 id="x""x" 123 123 Object console-format.html:54 124 124 [Object] console-format.html:55 -
trunk/LayoutTests/inspector/console/console-format.html
r108511 r125046 15 15 16 16 var array = ["test", "test2"]; array.length = 10; 17 array.foo = "bar";17 array.foo = {}; 18 18 array[4] = "test4"; 19 19 … … 66 66 var next = current + 1; 67 67 if (next == total.description) { 68 InspectorTest.expandConsoleMessages(); 68 69 InspectorTest.dumpConsoleMessages(); 69 70 InspectorTest.completeTest(); 70 } 71 else 71 } else 72 72 loopOverGlobals(next, total); 73 73 } -
trunk/LayoutTests/inspector/console/console-log-document-proto-expected.txt
r110693 r125046 1 1 CONSOLE MESSAGE: line 6: [object HTMLDocumentPrototype] 2 Test that console. log(document.__proto__) won't result in an exception when the message is formatted in the inspector.Bug 27169.2 Test that console.dir(document.__proto__) won't result in an exception when the message is formatted in the inspector.Bug 27169. 3 3 4 4 HTMLDocumentPrototype console-log-document-proto.html:6 -
trunk/LayoutTests/inspector/console/console-log-document-proto.html
r85596 r125046 4 4 <script src="../../http/tests/inspector/console-test.js"></script> 5 5 <script> 6 console. log(document.__proto__);6 console.dir(document.__proto__); 7 7 8 8 function test() … … 15 15 <body onload="runTest()"> 16 16 <p> 17 Test that console. log(document.__proto__) won't result in an exception when the message17 Test that console.dir(document.__proto__) won't result in an exception when the message 18 18 is formatted in the inspector.<a bug="https://bugs.webkit.org/show_bug.cgi?id=27169">Bug 27169.</a> 19 19 </p> -
trunk/LayoutTests/inspector/console/console-log-toString-object-expected.txt
r110693 r125046 4 4 5 5 Page reloaded. 6 Object console-log-toString-object.html:76 Object {toString: Object} console-log-toString-object.html:7 7 7 -
trunk/LayoutTests/inspector/debugger/watch-expressions-panel-switch-expected.txt
r98454 r125046 7 7 Watch expressions updated. 8 8 [expanded] 9 window.document: HTMLDocument9 window.document: #document 10 10 windowa.document: ReferenceError: Can't find variable: windowa 11 11 Debugger was disabled. -
trunk/LayoutTests/inspector/elements/event-listener-sidebar-expected.txt
r113220 r125046 8 8 lineNumber: 19 9 9 listenerBody: function (event) { console.log("click - document - capturing"); } 10 node: HTMLDocument10 node: #document 11 11 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 12 12 type: click … … 15 15 isAttribute: false 16 16 listenerBody: ObjectHandler 17 node: HTMLDocument17 node: #document 18 18 type: click 19 19 useCapture: true … … 22 22 lineNumber: 15 23 23 listenerBody: function (event) { console.log("click - button - capturing"); } 24 node: HTMLButtonElement24 node: <button> 25 25 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 26 26 type: click … … 30 30 lineNumber: 12 31 31 listenerBody: function clickHandler(event) { console.log("click - button - bubbling (registered before attribute)"); } 32 node: HTMLButtonElement32 node: <button> 33 33 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 34 34 type: click … … 38 38 lineNumber: 16 39 39 listenerBody: function (event) { console.log("click - button - attribute"); } 40 node: HTMLButtonElement40 node: <button> 41 41 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 42 42 type: click … … 46 46 lineNumber: 17 47 47 listenerBody: function (event) { console.log("click - button - bubbling (registered after attribute)"); } 48 node: HTMLButtonElement48 node: <button> 49 49 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 50 50 type: click … … 54 54 lineNumber: 6 55 55 listenerBody: function documentClickHandler(event) { console.log("click - document - attribute"); } 56 node: HTMLDocument56 node: #document 57 57 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 58 58 type: click … … 64 64 lineNumber: 10 65 65 listenerBody: function f() {} 66 node: HTMLBodyElement66 node: <body> 67 67 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 68 68 type: custom event … … 74 74 lineNumber: 14 75 75 listenerBody: function hoverHandler(event) { console.log("hover - button - bubbling"); } 76 node: HTMLButtonElement76 node: <button> 77 77 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 78 78 type: hover … … 84 84 lineNumber: 19 85 85 listenerBody: function (event) { console.log("click - document - capturing"); } 86 node: HTMLDocument86 node: #document 87 87 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 88 88 type: click … … 91 91 isAttribute: false 92 92 listenerBody: ObjectHandler 93 node: HTMLDocument93 node: #document 94 94 type: click 95 95 useCapture: true … … 98 98 lineNumber: 6 99 99 listenerBody: function documentClickHandler(event) { console.log("click - document - attribute"); } 100 node: HTMLDocument100 node: #document 101 101 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 102 102 type: click … … 108 108 lineNumber: 10 109 109 listenerBody: function f() {} 110 node: HTMLBodyElement110 node: <body> 111 111 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listener-sidebar.html 112 112 type: custom event -
trunk/LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt
r111653 r125046 8 8 lineNumber: 9 9 9 listenerBody: function f() {} 10 node: HTMLBodyElement10 node: <body> 11 11 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listeners-about-blank.html 12 12 type: click … … 18 18 lineNumber: 9 19 19 listenerBody: function f() {} 20 node: HTMLDivElement20 node: <div> 21 21 sourceName: [clipped-for-test]/LayoutTests/inspector/elements/event-listeners-about-blank.html 22 22 type: hover -
trunk/LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt
r114200 r125046 13 13 14 14 NodeList[1] 15 0: HTMLHtmlElement15 0: <html> 16 16 length: 1 17 17 __proto__: NodeList console-dir.html:10 -
trunk/LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt
r116513 r125046 1 CONSOLE MESSAGE: line 15: [object NodeList] 2 CONSOLE MESSAGE: line 19: [object HTMLCollection] 3 CONSOLE MESSAGE: line 23: [object HTMLOptionsCollection] 4 CONSOLE MESSAGE: line 27: undefined 5 CONSOLE MESSAGE: line 31: [object HTMLCollection] 6 CONSOLE MESSAGE: line 35: [object NodeList] 7 CONSOLE MESSAGE: line 41: 1,2, 8 CONSOLE MESSAGE: line 44: [object Object] 9 CONSOLE MESSAGE: line 51: [object Arguments] 1 10 CONSOLE MESSAGE: line 15: [object NodeList] 2 11 CONSOLE MESSAGE: line 19: [object HTMLCollection] … … 21 30 NonArrayWithLength console-format-collections.html:44 22 31 [1, "2"] console-format-collections.html:51 32 [<select>] console-format-collections.html:15 33 [<script>, <script>, <script>] console-format-collections.html:19 34 [<option>, <option>, selectedIndex: 0] console-format-collections.html:23 35 [<html>, <head>, <script>, <script>, <script>, <body>, <p>, <div>, <form>, <select>, <option>, <option>, <input>, <input>] console-format-collections.html:27 36 [<select>, <input>, <input>] console-format-collections.html:31 37 [<input>, <input>] console-format-collections.html:35 38 [1, Array[2]] console-format-collections.html:41 39 NonArrayWithLength {keys: Array[0]} console-format-collections.html:44 40 [1, "2"] console-format-collections.html:51 23 41 -
trunk/LayoutTests/platform/chromium/inspector/console/console-log-document-proto-expected.txt
r110693 r125046 1 1 CONSOLE MESSAGE: line 6: [object Object] 2 Test that console. log(document.__proto__) won't result in an exception when the message is formatted in the inspector.Bug 27169.2 Test that console.dir(document.__proto__) won't result in an exception when the message is formatted in the inspector.Bug 27169. 3 3 4 4 HTMLDocument console-log-document-proto.html:6 -
trunk/LayoutTests/platform/chromium/inspector/debugger/watch-expressions-panel-switch-expected.txt
r98454 r125046 7 7 Watch expressions updated. 8 8 [expanded] 9 window.document: HTMLDocument9 window.document: #document 10 10 windowa.document: ReferenceError: windowa is not defined 11 11 Debugger was disabled. -
trunk/Source/WebCore/ChangeLog
r125045 r125046 1 2012-08-08 Pavel Feldman <pfeldman@chromium.org> 2 3 Web Inspector: generate preview for the objects dumped into the console upon logging. 4 https://bugs.webkit.org/show_bug.cgi?id=35801 5 6 Reviewed by Vsevolod Vlasov. 7 8 As of today, dumping an object (array) into console will result in objects' properties being 9 read upon console object expansion (i.e. lazily). This means that dumping the same object while 10 mutating it will be hard to debug using the console. 11 12 This change starts generating abbreviated previews for objects / arrays at the moment of their 13 logging and passes this information along into the front-end. This only happens when the front-end 14 is already opened, it only works for console.log(), not live console interaction. 15 16 Covered by the existing console tests + collections test has been expanded to capture both: pre and post- 17 front-end opening scenarios. 18 19 * inspector/ConsoleMessage.cpp: 20 (WebCore::ConsoleMessage::addToFrontend): 21 * inspector/ConsoleMessage.h: 22 (ConsoleMessage): 23 * inspector/InjectedScript.cpp: 24 (WebCore::InjectedScript::wrapObject): 25 * inspector/InjectedScript.h: 26 (InjectedScript): 27 * inspector/InjectedScriptSource.js: 28 (.): 29 * inspector/Inspector.json: 30 * inspector/InspectorConsoleAgent.cpp: 31 (WebCore::InspectorConsoleAgent::enable): 32 (WebCore::InspectorConsoleAgent::addConsoleMessage): 33 * inspector/front-end/ConsoleMessage.js: 34 (WebInspector.ConsoleMessageImpl.prototype._format): 35 (WebInspector.ConsoleMessageImpl.prototype._formatParameter): 36 (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsObject): 37 (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsArrayOrObject): 38 (WebInspector.ConsoleMessageImpl.prototype._appendObjectPreview): 39 (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsNode): 40 (WebInspector.ConsoleMessageImpl.prototype._formatParameterAsArray): 41 (WebInspector.ConsoleMessageImpl.prototype._printArray): 42 (WebInspector.ConsoleMessageImpl.prototype._formatAsArrayEntry): 43 (WebInspector.ConsoleMessageImpl.prototype._formatWithSubstitutionString): 44 * inspector/front-end/DOMExtension.js: 45 (Element.prototype.createTextChild): 46 * inspector/front-end/ObjectPropertiesSection.js: 47 (WebInspector.ObjectPropertiesSection): 48 * inspector/front-end/PropertiesSection.js: 49 * inspector/front-end/RemoteObject.js: 50 (WebInspector.RemoteObject): 51 (WebInspector.RemoteObject.fromPayload): 52 (WebInspector.RemoteObject.prototype.get previewProperties): 53 * inspector/front-end/Section.js: 54 * inspector/front-end/inspector.css: 55 (.console-group-messages .section .header .title): 56 (.section .console-formatted-node): 57 (.console-object-preview): 58 (.section .properties .name, .event-properties .name, .console-formatted-object .name): 59 1 60 2012-07-31 Philippe Normand <pnormand@igalia.com> 2 61 -
trunk/Source/WebCore/inspector/ConsoleMessage.cpp
r115553 r125046 134 134 } 135 135 136 void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager )136 void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview) 137 137 { 138 138 RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create() … … 152 152 RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject> > jsonArgs = TypeBuilder::Array<TypeBuilder::Runtime::RemoteObject>::create(); 153 153 for (unsigned i = 0; i < m_arguments->argumentCount(); ++i) { 154 RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console" );154 RefPtr<TypeBuilder::Runtime::RemoteObject> inspectorValue = injectedScript.wrapObject(m_arguments->argumentAt(i), "console", generatePreview); 155 155 if (!inspectorValue) { 156 156 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/inspector/ConsoleMessage.h
r115553 r125046 57 57 ~ConsoleMessage(); 58 58 59 void addToFrontend(InspectorFrontend::Console*, InjectedScriptManager* );59 void addToFrontend(InspectorFrontend::Console*, InjectedScriptManager*, bool generatePreview); 60 60 void updateRepeatCountInConsole(InspectorFrontend::Console*); 61 61 void incrementCount() { ++m_repeatCount; } -
trunk/Source/WebCore/inspector/InjectedScript.cpp
r120842 r125046 181 181 #endif 182 182 183 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName ) const183 PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const 184 184 { 185 185 ASSERT(!hasNoValue()); … … 188 188 wrapFunction.appendArgument(groupName); 189 189 wrapFunction.appendArgument(canAccessInspectedWindow()); 190 wrapFunction.appendArgument(generatePreview); 190 191 bool hadException = false; 191 192 ScriptValue r = callFunctionWithEvalEnabled(wrapFunction, hadException); -
trunk/Source/WebCore/inspector/InjectedScript.h
r120842 r125046 87 87 #endif 88 88 89 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName ) const;89 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName, bool generatePreview = false) const; 90 90 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName); 91 91 PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapSerializedObject(SerializedScriptValue*, const String& groupName) const; -
trunk/Source/WebCore/inspector/InjectedScriptSource.js
r125033 r125046 72 72 * @param {string} groupName 73 73 * @param {boolean} canAccessInspectedWindow 74 * @param {boolean} generatePreview 74 75 * @return {Object} 75 76 */ 76 wrapObject: function(object, groupName, canAccessInspectedWindow )77 wrapObject: function(object, groupName, canAccessInspectedWindow, generatePreview) 77 78 { 78 79 if (canAccessInspectedWindow) 79 return this._wrapObject(object, groupName );80 return this._wrapObject(object, groupName, false, generatePreview); 80 81 81 82 var result = {}; … … 129 130 * @param {string=} objectGroupName 130 131 * @param {boolean=} forceValueType 132 * @param {boolean=} generatePreview 131 133 * @return {InjectedScript.RemoteObject} 132 134 */ 133 _wrapObject: function(object, objectGroupName, forceValueType )135 _wrapObject: function(object, objectGroupName, forceValueType, generatePreview) 134 136 { 135 137 try { 136 return new InjectedScript.RemoteObject(object, objectGroupName, forceValueType );138 return new InjectedScript.RemoteObject(object, objectGroupName, forceValueType, generatePreview); 137 139 } catch (e) { 138 140 try { … … 405 407 try { 406 408 return { wasThrown: false, 407 result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue ) };409 result: this._wrapObject(this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI), objectGroup, returnByValue, false) }; 408 410 } catch (e) { 409 411 return this._createThrownValue(e, objectGroup); … … 636 638 return this._toString(obj); 637 639 640 if (subtype === "node") { 641 var description = obj.nodeName.toLowerCase(); 642 switch (obj.nodeType) { 643 case 1 /* Node.ELEMENT_NODE */: 644 description = "<" + description + ">"; 645 break; 646 case 10 /*Node.DOCUMENT_TYPE_NODE */: 647 description = "<!DOCTYPE " + description + ">"; 648 break; 649 } 650 return description; 651 } 652 638 653 var className = InjectedScriptHost.internalConstructorName(obj); 639 654 if (subtype === "array") { … … 679 694 * @param {string=} objectGroupName 680 695 * @param {boolean=} forceValueType 696 * @param {boolean=} generatePreview 681 697 */ 682 InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType )698 InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType, generatePreview) 683 699 { 684 700 this.type = typeof object; … … 699 715 700 716 this.objectId = injectedScript._bind(object, objectGroupName); 701 var subtype = injectedScript._subtype(object) 717 var subtype = injectedScript._subtype(object); 702 718 if (subtype) 703 719 this.subtype = subtype; 704 720 this.className = InjectedScriptHost.internalConstructorName(object); 705 721 this.description = injectedScript._describe(object); 722 723 if (generatePreview && (this.type === "object" || injectedScript._isHTMLAllCollection(object))) 724 this.preview = this._generatePreview(/** @type {!Object} */ object); 706 725 } 707 726 727 InjectedScript.RemoteObject.prototype = { 728 /** 729 * @param {!Object} object 730 */ 731 _generatePreview: function(object) 732 { 733 var preview = []; 734 var isArray = this.subtype === "array"; 735 var elementsToDump = isArray ? 100 : 5; 736 737 var propertyNames = Object.getOwnPropertyNames(object); 738 var lossless = true; 739 var overflow = false; 740 741 try { 742 for (var i = 0; i < propertyNames.length; ++i) { 743 if (preview.length >= elementsToDump) { 744 overflow = true; 745 lossless = false; 746 break; 747 } 748 var name = propertyNames[i]; 749 if (isArray && name === "length") 750 continue; 751 752 var descriptor = Object.getOwnPropertyDescriptor(object, name); 753 if (!("value" in descriptor) || !descriptor.enumerable) { 754 lossless = false; 755 continue; 756 } 757 758 var value = descriptor.value; 759 if (value === null) { 760 preview.push([name, "null"]); 761 continue; 762 } 763 764 const maxLength = 100; 765 var type = typeof value; 766 767 if (InjectedScript.primitiveTypes[type]) { 768 if (type === "string" && value.length > maxLength) { 769 value = this._abbreviateString(value, maxLength, true); 770 lossless = false; 771 } 772 preview.push([name, type, value + ""]); 773 continue; 774 } 775 776 lossless = false; 777 778 if (type === "function") 779 continue; 780 781 var subtype = injectedScript._subtype(value); 782 preview.push([name, type, this._abbreviateString(injectedScript._describe(value), maxLength, subtype === "regexp"), subtype]); 783 } 784 if (!preview.length) 785 return undefined; 786 787 if (!lossless) 788 preview.push("lossy"); 789 if (overflow) 790 preview.push("overflow"); 791 return preview; 792 } catch (e) { 793 return undefined; 794 } 795 }, 796 797 /** 798 * @param {string} string 799 * @param {number} maxLength 800 * @param {boolean=} middle 801 * @returns 802 */ 803 _abbreviateString: function(string, maxLength, middle) 804 { 805 if (string.length <= maxLength) 806 return string; 807 if (middle) { 808 var leftHalf = maxLength >> 1; 809 var rightHalf = maxLength - leftHalf - 1; 810 return string.substr(0, leftHalf) + "\u2026" + string.substr(string.length - rightHalf, rightHalf); 811 } 812 return string.substr(0, maxLength) + "\u2026"; 813 } 814 } 708 815 /** 709 816 * @constructor -
trunk/Source/WebCore/inspector/InspectorConsoleAgent.cpp
r115553 r125046 84 84 if (m_expiredConsoleMessageCount) { 85 85 ConsoleMessage expiredMessage(OtherMessageSource, LogMessageType, WarningMessageLevel, String::format("%d console messages are not shown.", m_expiredConsoleMessageCount), "", 0, ""); 86 expiredMessage.addToFrontend(m_frontend, m_injectedScriptManager );86 expiredMessage.addToFrontend(m_frontend, m_injectedScriptManager, false); 87 87 } 88 88 89 89 size_t messageCount = m_consoleMessages.size(); 90 90 for (size_t i = 0; i < messageCount; ++i) 91 m_consoleMessages[i]->addToFrontend(m_frontend, m_injectedScriptManager );91 m_consoleMessages[i]->addToFrontend(m_frontend, m_injectedScriptManager, false); 92 92 } 93 93 … … 282 282 m_consoleMessages.append(consoleMessage); 283 283 if (m_frontend && m_state->getBoolean(ConsoleAgentState::consoleMessagesEnabled)) 284 m_previousMessage->addToFrontend(m_frontend, m_injectedScriptManager );284 m_previousMessage->addToFrontend(m_frontend, m_injectedScriptManager, true); 285 285 } 286 286 -
trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js
r116940 r125046 226 226 formattedResult.appendChild(document.createTextNode(parameters[i].description)); 227 227 else 228 formattedResult.appendChild(this._formatParameter(parameters[i] ));228 formattedResult.appendChild(this._formatParameter(parameters[i], false, true)); 229 229 if (i < parameters.length - 1) 230 230 formattedResult.appendChild(document.createTextNode(" ")); … … 235 235 /** 236 236 * @param {boolean=} forceObjectFormat 237 * @param {boolean=} includePreview 237 238 */ 238 _formatParameter: function(output, forceObjectFormat )239 _formatParameter: function(output, forceObjectFormat, includePreview) 239 240 { 240 241 var type; … … 254 255 var span = document.createElement("span"); 255 256 span.className = "console-formatted-" + type + " source-code"; 256 formatter.call(this, output, span );257 formatter.call(this, output, span, includePreview); 257 258 return span; 258 259 }, … … 263 264 }, 264 265 265 _formatParameterAsObject: function(obj, elem) 266 { 267 var section = new WebInspector.ObjectPropertiesSection(obj, obj.description); 266 _formatParameterAsObject: function(obj, elem, includePreview) 267 { 268 this._formatParameterAsArrayOrObject(obj, obj.description, elem, includePreview); 269 }, 270 271 /** 272 * @param {WebInspector.RemoteObject} obj 273 * @param {string} description 274 * @param {Element} elem 275 * @param {boolean} includePreview 276 */ 277 _formatParameterAsArrayOrObject: function(obj, description, elem, includePreview) 278 { 279 var titleElement = document.createElement("span"); 280 if (description) 281 titleElement.createTextChild(description); 282 if (includePreview && obj.previewProperties) { 283 titleElement.addStyleClass("console-object-preview"); 284 var lossless = this._appendObjectPreview(obj, description, titleElement); 285 if (lossless) { 286 elem.appendChild(titleElement); 287 return; 288 } 289 } 290 var section = new WebInspector.ObjectPropertiesSection(obj, titleElement); 268 291 section.enableContextMenu(); 269 292 elem.appendChild(section.element); 293 }, 294 295 /** 296 * @param {WebInspector.RemoteObject} obj 297 * @param {string} description 298 * @param {Element} titleElement 299 * @return {boolean} true iff preview captured all information. 300 */ 301 _appendObjectPreview: function(obj, description, titleElement) 302 { 303 var preview = obj.previewProperties; 304 var isLosslessPreview = true; 305 var isArray = obj.subtype === "array"; 306 307 if (description) 308 titleElement.createTextChild(" "); 309 titleElement.createTextChild(isArray ? "[" : "{"); 310 for (var i = 0; i < preview.length; ++i) { 311 var property = preview[i]; 312 if (property === "lossy") { 313 isLosslessPreview = false; 314 continue; 315 } 316 if (property === "overflow") { 317 titleElement.createChild("span").textContent = "\u2026"; 318 break; 319 } 320 321 var name = property[0]; 322 var type = property[1]; 323 var value = property[2]; 324 325 if (i > 0) 326 titleElement.createTextChild(", "); 327 328 if (!isArray || name != i) { 329 titleElement.createChild("span", "name").textContent = name; 330 titleElement.createTextChild(": "); 331 } 332 333 var span = titleElement.createChild("span", "console-formatted-" + type); 334 switch (type) { 335 case "object": 336 var subtype = property[3]; 337 if (subtype === "node") 338 span.addStyleClass("console-formatted-preview-node"); 339 else if (subtype === "regexp") 340 span.addStyleClass("console-formatted-string"); 341 span.textContent = value; 342 break; 343 case "string": 344 span.textContent = "\"" + value.replace(/\n/g, "\u21B5") + "\""; 345 break; 346 case "null": 347 case "undefined": 348 span.textContent = type; 349 break; 350 default: 351 span.textContent = String(value); 352 } 353 } 354 titleElement.createTextChild(isArray ? "]" : "}"); 355 return isLosslessPreview; 270 356 }, 271 357 … … 277 363 // Sometimes DOM is loaded after the sync message is being formatted, so we get no 278 364 // nodeId here. So we fall back to object formatting here. 279 this._formatParameterAsObject(object, elem );365 this._formatParameterAsObject(object, elem, false); 280 366 return; 281 367 } … … 294 380 _formatParameterAsArray: function(array, elem) 295 381 { 382 if (array.previewProperties) { 383 this._formatParameterAsArrayOrObject(array, "", elem, true); 384 return; 385 } 386 296 387 const maxFlatArrayLength = 100; 297 388 if (array.arrayLength() > maxFlatArrayLength) … … 353 444 if (i < length - 1) 354 445 elem.appendChild(document.createTextNode(", ")); 355 } 446 } 356 447 appendUndefined(elem, length); 357 448 … … 362 453 { 363 454 // Prevent infinite expansion of cross-referencing arrays. 364 return this._formatParameter(output, output.subtype && output.subtype === "array" );455 return this._formatParameter(output, output.subtype && output.subtype === "array", false); 365 456 }, 366 457 … … 371 462 function parameterFormatter(force, obj) 372 463 { 373 return this._formatParameter(obj, force );464 return this._formatParameter(obj, force, false); 374 465 } 375 466 -
trunk/Source/WebCore/inspector/front-end/DOMExtension.js
r114126 r125046 254 254 255 255 /** 256 * @param {string} text 257 */ 258 Element.prototype.createTextChild = function(text) 259 { 260 var element = this.ownerDocument.createTextNode(text); 261 this.appendChild(element); 262 return element; 263 } 264 265 DocumentFragment.prototype.createTextChild = Element.prototype.createTextChild; 266 267 /** 256 268 * @return {number} 257 269 */ -
trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
r124876 r125046 29 29 * @extends {WebInspector.PropertiesSection} 30 30 * @param {WebInspector.RemoteObject=} object 31 * @param {string =} title31 * @param {string|Element=} title 32 32 * @param {string=} subtitle 33 33 * @param {string=} emptyPlaceholder … … 46 46 this.skipProto = false; 47 47 48 WebInspector.PropertiesSection.call(this, title , subtitle);48 WebInspector.PropertiesSection.call(this, title || "", subtitle); 49 49 } 50 50 -
trunk/Source/WebCore/inspector/front-end/PropertiesSection.js
r109348 r125046 31 31 * @constructor 32 32 * @extends {WebInspector.Section} 33 * @param {string|Element} title 33 34 * @param {string=} subtitle 34 35 */ -
trunk/Source/WebCore/inspector/front-end/RemoteObject.js
r124876 r125046 36 36 * @param {*} value 37 37 * @param {string=} description 38 */ 39 WebInspector.RemoteObject = function(objectId, type, subtype, value, description) 38 * @param {Array=} previewProperties 39 */ 40 WebInspector.RemoteObject = function(objectId, type, subtype, value, description, previewProperties) 40 41 { 41 42 this._type = type; … … 46 47 this._description = description; 47 48 this._hasChildren = true; 49 this._previewProperties = previewProperties; 48 50 } else { 49 51 // Primitive or null object. … … 105 107 console.assert(typeof payload === "object", "Remote object payload should only be an object"); 106 108 107 return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description );109 return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.preview); 108 110 } 109 111 … … 153 155 { 154 156 return this._hasChildren; 157 }, 158 159 /** @return {Array|undefined} */ 160 get previewProperties() 161 { 162 return this._previewProperties; 155 163 }, 156 164 -
trunk/Source/WebCore/inspector/front-end/Section.js
r111551 r125046 30 30 /** 31 31 * @constructor 32 * @param {string|Element} title 32 33 * @param {string=} subtitle 33 34 */ -
trunk/Source/WebCore/inspector/front-end/inspector.css
r124878 r125046 1026 1026 color: black; 1027 1027 font-weight: normal; 1028 line-height: 13px; 1028 1029 } 1029 1030 … … 1086 1087 .console-formatted-null, .console-formatted-undefined { 1087 1088 color: rgb(128, 128, 128); 1089 } 1090 1091 .console-formatted-preview-node, 1092 .section .console-formatted-node { 1093 color: rgb(136, 18, 128); 1094 } 1095 1096 .console-object-preview { 1097 font-style: italic; 1088 1098 } 1089 1099 … … 1581 1591 } 1582 1592 1583 .section .properties .name, .event-properties .name {1593 .section .properties .name, .event-properties .name, .console-formatted-object .name { 1584 1594 color: rgb(136, 19, 145); 1585 1595 }
Note: See TracChangeset
for help on using the changeset viewer.