Web Inspector: generate preview for the objects dumped into the console upon logging.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 17:22:21 +0000 (17:22 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 17:22:21 +0000 (17:22 +0000)
commit1aec79392d63ae6360bd068a22ab00ab003da9a8
treef1e9e020dddbce78038dd4eb019351423a289722
parenta264727442690c42b5f04678204483679e3ecee6
Web Inspector: generate preview for the objects dumped into the console upon logging.
https://bugs.webkit.org/show_bug.cgi?id=35801

Reviewed by Vsevolod Vlasov.

Source/WebCore:

As of today, dumping an object (array) into console will result in objects' properties being
read upon console object expansion (i.e. lazily). This means that dumping the same object while
mutating it will be hard to debug using the console.

This change starts generating abbreviated previews for objects / arrays at the moment of their
logging and passes this information along into the front-end. This only happens when the front-end
is already opened, it only works for console.log(), not live console interaction.

Covered by the existing console tests + collections test has been expanded to capture both: pre and post-
front-end opening scenarios.

* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::addToFrontend):
* inspector/ConsoleMessage.h:
(ConsoleMessage):
* inspector/InjectedScript.cpp:
(WebCore::InjectedScript::wrapObject):
* inspector/InjectedScript.h:
(InjectedScript):
* inspector/InjectedScriptSource.js:
(.):
* inspector/Inspector.json:
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::enable):
(WebCore::InspectorConsoleAgent::addConsoleMessage):
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl.prototype._format):
(WebInspector.ConsoleMessageImpl.prototype._formatParameter):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsObject):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsArrayOrObject):
(WebInspector.ConsoleMessageImpl.prototype._appendObjectPreview):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsNode):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsArray):
(WebInspector.ConsoleMessageImpl.prototype._printArray):
(WebInspector.ConsoleMessageImpl.prototype._formatAsArrayEntry):
(WebInspector.ConsoleMessageImpl.prototype._formatWithSubstitutionString):
* inspector/front-end/DOMExtension.js:
(Element.prototype.createTextChild):
* inspector/front-end/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertiesSection):
* inspector/front-end/PropertiesSection.js:
* inspector/front-end/RemoteObject.js:
(WebInspector.RemoteObject):
(WebInspector.RemoteObject.fromPayload):
(WebInspector.RemoteObject.prototype.get previewProperties):
* inspector/front-end/Section.js:
* inspector/front-end/inspector.css:
(.console-group-messages .section .header .title):
(.section .console-formatted-node):
(.console-object-preview):
(.section .properties .name, .event-properties .name, .console-formatted-object .name):

LayoutTests:

* inspector/console/command-line-api-inspect-expected.txt:
* inspector/console/console-dir-expected.txt:
* inspector/console/console-eval-global-expected.txt:
* inspector/console/console-eval-global.html:
* inspector/console/console-format-collections-expected.txt:
* inspector/console/console-format-collections.html:
* inspector/console/console-format-expected.txt:
* inspector/console/console-format.html:
* inspector/console/console-log-document-proto-expected.txt:
* inspector/console/console-log-document-proto.html:
* inspector/console/console-log-toString-object-expected.txt:
* inspector/debugger/watch-expressions-panel-switch-expected.txt:
* inspector/elements/event-listener-sidebar-expected.txt:
* inspector/elements/event-listeners-about-blank-expected.txt:
* platform/chromium/inspector/console/console-dir-expected.txt:
* platform/chromium/inspector/console/console-eval-global-expected.txt: Removed.
* platform/chromium/inspector/console/console-format-collections-expected.txt:
* platform/chromium/inspector/console/console-format-expected.txt: Removed.
* platform/chromium/inspector/console/console-log-document-proto-expected.txt:
* platform/chromium/inspector/debugger/watch-expressions-panel-switch-expected.txt:
* platform/chromium/inspector/elements/event-listener-sidebar-expected.txt: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
36 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/console/command-line-api-inspect-expected.txt
LayoutTests/inspector/console/console-dir-expected.txt
LayoutTests/inspector/console/console-eval-global-expected.txt
LayoutTests/inspector/console/console-eval-global.html
LayoutTests/inspector/console/console-format-collections-expected.txt
LayoutTests/inspector/console/console-format-collections.html
LayoutTests/inspector/console/console-format-expected.txt
LayoutTests/inspector/console/console-format.html
LayoutTests/inspector/console/console-log-document-proto-expected.txt
LayoutTests/inspector/console/console-log-document-proto.html
LayoutTests/inspector/console/console-log-toString-object-expected.txt
LayoutTests/inspector/debugger/watch-expressions-panel-switch-expected.txt
LayoutTests/inspector/elements/event-listener-sidebar-expected.txt
LayoutTests/inspector/elements/event-listeners-about-blank-expected.txt
LayoutTests/platform/chromium/inspector/console/console-dir-expected.txt
LayoutTests/platform/chromium/inspector/console/console-eval-global-expected.txt [deleted file]
LayoutTests/platform/chromium/inspector/console/console-format-collections-expected.txt
LayoutTests/platform/chromium/inspector/console/console-format-expected.txt [deleted file]
LayoutTests/platform/chromium/inspector/console/console-log-document-proto-expected.txt
LayoutTests/platform/chromium/inspector/debugger/watch-expressions-panel-switch-expected.txt
LayoutTests/platform/chromium/inspector/elements/event-listener-sidebar-expected.txt [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/inspector/ConsoleMessage.cpp
Source/WebCore/inspector/ConsoleMessage.h
Source/WebCore/inspector/InjectedScript.cpp
Source/WebCore/inspector/InjectedScript.h
Source/WebCore/inspector/InjectedScriptSource.js
Source/WebCore/inspector/InspectorConsoleAgent.cpp
Source/WebCore/inspector/front-end/ConsoleMessage.js
Source/WebCore/inspector/front-end/DOMExtension.js
Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
Source/WebCore/inspector/front-end/PropertiesSection.js
Source/WebCore/inspector/front-end/RemoteObject.js
Source/WebCore/inspector/front-end/Section.js
Source/WebCore/inspector/front-end/inspector.css