Web Inspector: Object Previews in the Console
https://bugs.webkit.org/show_bug.cgi?id=129204

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Update the very old, unused object preview code. Part of this comes from
the earlier WebKit legacy implementation, and the Blink implementation.

A RemoteObject may include a preview, if it is asked for, and if the
RemoteObject is an object. Previews are a shallow (single level) list
of a limited number of properties on the object. The previewed
properties are always stringified (even if primatives). Previews are
limited to just 5 properties or 100 indices. Previews are marked
as lossless if they are a complete snapshot of the object.

There is a path to make previews two levels deep, that is currently
unused but should soon be used for tables (e.g. IndexedDB).

* inspector/InjectedScriptSource.js:
- Move some code off of InjectedScript to be generic functions
usable by RemoteObject as well.
- Update preview generation to use

* inspector/protocol/Runtime.json:
- Add a new type, "accessor" for preview objects. This represents
a getter / setter. We currently don't get the value.

Source/WebInspectorUI:

* UserInterface/Controllers/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController.prototype.consolePromptTextCommitted):
* UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js:
(get WebInspector.JavaScriptRuntimeCompletionProvider.prototype.):
Update RuntimeManager callsites that do not need object previews.

* UserInterface/Controllers/RuntimeManager.js:
(WebInspector.RuntimeManager.prototype.evalCallback):
(WebInspector.RuntimeManager.prototype.evaluateInInspectedWindow):
Update the main evaluate method to include a boolean parameter for
object previews. Most callers do not need them. Also, since previews
were not available on iOS 6, switch to invoke, to conditionally
include the command parameter.

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject):
(WebInspector.RemoteObject.fromPayload):
(WebInspector.RemoteObject.prototype.get preview):
Store the preview from the payload.

* UserInterface/Views/ConsoleMessageImpl.js:
(WebInspector.ConsoleMessageImpl.prototype._format):
(WebInspector.ConsoleMessageImpl.prototype._formatParameter):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsNode):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsString):
(WebInspector.ConsoleMessageImpl.prototype._formatAsArrayEntry):
Pass an explicit false for most formatters to not use a preview if available.

(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsArray):
(WebInspector.ConsoleMessageImpl.prototype._formatParameterAsObject):
Currently only object types are previewed. Though we request previews
for arrays, we don't use the preview because we show a better preview
by just immediately requesting for a full non-preview property list.

(WebInspector.ConsoleMessageImpl.prototype._appendObjectPreview):
Quickly output an object preview into the title element. The format
is "ClassName {prop: value...}". Elide the class name if it is "Object".
Also skip over certain preview properties that may not be useful
at a glance (like constructor, or accessors without values).

* UserInterface/Views/LogContentView.css:
(.console-object-preview):
(.console-formatted-array .console-object-preview):
(.console-object-preview-lossless):
(.expanded .console-object-preview):
Show lossy previews in italics.
Show lossless previews and array previews without italics.
Do not show the class name in the preview in italics when expanded.

(.console-object-preview .name):
Give preview property names the same color as ObjectPropertiesSection property names.

(.expanded .console-object-preview > .console-object-preview-body):
When expanding an object, hide the preview.

(.console-object-preview > .console-object-preview-name.console-object-preview-name-Object):
(.expanded .console-object-preview > .console-object-preview-name.console-object-preview-name-Object):
For "Object" previews, hide the name "Object" when not expanded, and show it when expanded.

LayoutTests:

* inspector/debugger/command-line-api-exception-nested-catch.html:
* inspector/debugger/command-line-api-exception.html:
* inspector/model/remote-object-get-properties.html:
Update RuntimeManager callsites to not ask for previews when evaluating.

* inspector/model/remote-object-expected.txt: Added.
* inspector/model/remote-object.html: Added.
Add a test specifically for Remote Object. This test can also be
opened in a browser. It attempts to run the gamut of all different
types of objects and shows the RemoteObject constructed for it.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@179019 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index 08bda96..11f413e 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -95,6 +95,7 @@
 webkit.org/b/137130 inspector/replay [ Skip ]
 webkit.org/b/137131 inspector/timeline [ Skip ]
 inspector/model/remote-object-get-properties.html [ Skip ]
+inspector/model/remote-object.html [ Skip ]
 
 # Doesn't work yet, relies on network replay functionality (webkit.org/b/130728, webkit.org/b/129391)
 webkit.org/b/131318 http/tests/inspector/replay/document-last-modified-fallback-value.html [ Skip ]