Title: [179659] trunk
Revision
179659
Author
[email protected]
Date
2015-02-04 19:11:29 -0800 (Wed, 04 Feb 2015)

Log Message

Web Inspector: ES6: Improved Console Support for Symbol Objects
https://bugs.webkit.org/show_bug.cgi?id=141173

Reviewed by Timothy Hatcher.

Source/_javascript_Core:

* inspector/protocol/Runtime.json:
New type, "symbol".

* inspector/InjectedScriptSource.js:
Handle Symbol objects in a few places. They don't have properties
and they cannot be implicitly converted to strings.

Source/WebInspectorUI:

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject):
(WebInspector.RemoteObject.prototype._isSymbol):
Symbols have an objectId because it is a non-primitive that cannot be passed
by value, however it cannot have properties, so handle some cases.

* UserInterface/Views/LogContentView.css:
(.console-formatted-symbol):
Give Symbol's their own color.

LayoutTests:

* inspector/model/remote-object-expected.txt:
* inspector/model/remote-object.html:
Update the RemoteObject test to include Symbols.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (179658 => 179659)


--- trunk/LayoutTests/ChangeLog	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/LayoutTests/ChangeLog	2015-02-05 03:11:29 UTC (rev 179659)
@@ -1,3 +1,14 @@
+2015-02-04  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: ES6: Improved Console Support for Symbol Objects
+        https://bugs.webkit.org/show_bug.cgi?id=141173
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/model/remote-object-expected.txt:
+        * inspector/model/remote-object.html:
+        Update the RemoteObject test to include Symbols.
+
 2015-02-04  Alexey Proskuryakov  <[email protected]>
 
         http/tests/misc/detached-frame-console.html is flaky

Modified: trunk/LayoutTests/inspector/model/remote-object-expected.txt (179658 => 179659)


--- trunk/LayoutTests/inspector/model/remote-object-expected.txt	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/LayoutTests/inspector/model/remote-object-expected.txt	2015-02-05 03:11:29 UTC (rev 179659)
@@ -16,6 +16,24 @@
 }
 
 -----------------------------------------------------
+_expression_: Symbol()
+{
+  "_type": "symbol",
+  "_subtype": "symbol",
+  "_objectId": "<filtered>",
+  "_description": "Symbol()"
+}
+
+-----------------------------------------------------
+_expression_: Symbol('test')
+{
+  "_type": "symbol",
+  "_subtype": "symbol",
+  "_objectId": "<filtered>",
+  "_description": "Symbol(test)"
+}
+
+-----------------------------------------------------
 _expression_: true
 {
   "_type": "boolean",
@@ -1396,7 +1414,7 @@
 }
 
 -----------------------------------------------------
-_expression_: ({a: 1, b: "string", c :/regex/})
+_expression_: ({a: 1, b: "string", c: /regex/, d: Symbol('sym')})
 {
   "_type": "object",
   "_objectId": "<filtered>",
@@ -1421,6 +1439,11 @@
         "type": "object",
         "subtype": "regexp",
         "value": "/regex/"
+      },
+      {
+        "name": "d",
+        "type": "symbol",
+        "value": "Symbol(sym)"
       }
     ]
   }

Modified: trunk/LayoutTests/inspector/model/remote-object.html (179658 => 179659)


--- trunk/LayoutTests/inspector/model/remote-object.html	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/LayoutTests/inspector/model/remote-object.html	2015-02-05 03:11:29 UTC (rev 179659)
@@ -14,6 +14,10 @@
         {_expression_: "null"},
         {_expression_: "undefined"},
 
+        // Symbol
+        {_expression_: "Symbol()"},
+        {_expression_: "Symbol('test')"},
+
     // Primatives:
 
         // Boolean
@@ -83,7 +87,7 @@
         // Object
         {_expression_: "({})"},
         {_expression_: "({a: 1})"},
-        {_expression_: "({a: 1, b: \"string\", c :/regex/})"},
+        {_expression_: "({a: 1, b: \"string\", c: /regex/, d: Symbol('sym')})"},
         {_expression_: "({a:function a(){}, b:function b(){}, get getter(){}, set setter(v){}})"},
         {_expression_: "function Foo() {}; new Foo"},
         {_expression_: "function Bar() { this._x = 5 }; Bar.prototype = {constructor: Bar, get x() {return this._x;}}; new Bar"},

Modified: trunk/Source/_javascript_Core/ChangeLog (179658 => 179659)


--- trunk/Source/_javascript_Core/ChangeLog	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-02-05 03:11:29 UTC (rev 179659)
@@ -1,3 +1,17 @@
+2015-02-04  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: ES6: Improved Console Support for Symbol Objects
+        https://bugs.webkit.org/show_bug.cgi?id=141173
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/protocol/Runtime.json:
+        New type, "symbol".
+
+        * inspector/InjectedScriptSource.js:
+        Handle Symbol objects in a few places. They don't have properties
+        and they cannot be implicitly converted to strings.
+
 2015-02-04  Mark Lam  <[email protected]>
 
         Undo gardening: Restoring the expected ERROR message since that is not the cause of the bot unhappiness.

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (179658 => 179659)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2015-02-05 03:11:29 UTC (rev 179659)
@@ -36,7 +36,7 @@
 
 function toString(obj)
 {
-    return "" + obj;
+    return String(obj);
 }
 
 function isUInt32(obj)
@@ -46,6 +46,11 @@
     return "" + (obj >>> 0) === obj;
 }
 
+function isSymbol(obj)
+{
+    return typeof obj === "symbol";
+}
+
 var InjectedScript = function()
 {
     this._lastBoundObjectId = 1;
@@ -59,7 +64,7 @@
     undefined: true,
     boolean: true,
     number: true,
-    string: true
+    string: true,
 }
 
 InjectedScript.CollectionMode = {
@@ -200,6 +205,9 @@
         if (!this._isDefined(object))
             return false;
 
+        if (isSymbol(object))
+            return false;
+
         var collectionMode = InjectedScript.CollectionMode.AllProperties;
         if (ownProperties)
             collectionMode = InjectedScript.CollectionMode.OwnProperties;
@@ -231,9 +239,13 @@
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
         var objectGroupName = this._idToObjectGroupName[parsedObjectId.id];
+
         if (!this._isDefined(object))
             return false;
 
+        if (isSymbol(object))
+            return false;
+
         var descriptors = [];
         var internalProperties = InjectedScriptHost.getInternalProperties(object);
         if (internalProperties) {
@@ -669,6 +681,9 @@
         if (this.isPrimitiveValue(obj))
             return null;
 
+        if (isSymbol(obj))
+            return toString(obj);
+
         var subtype = this._subtype(obj);
 
         if (subtype === "regexp")
@@ -940,6 +955,17 @@
                 continue;
             }
 
+            // Symbol.
+            if (isSymbol(value)) {
+                var symbolString = toString(value);
+                if (symbolString.length > maxLength) {
+                    symbolString = this._abbreviateString(symbolString, maxLength, true);
+                    preview.lossless = false;
+                }
+                this._appendPropertyPreview(preview, {name: name, type: type, value: symbolString}, propertiesThreshold);
+                return;
+            }
+
             // Object.
             var property = {name: name, type: type};
             var subtype = injectedScript._subtype(value);

Modified: trunk/Source/_javascript_Core/inspector/protocol/Runtime.json (179658 => 179659)


--- trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2015-02-05 03:11:29 UTC (rev 179659)
@@ -12,7 +12,7 @@
             "type": "object",
             "description": "Mirror object referencing original _javascript_ object.",
             "properties": [
-                { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean"], "description": "Object type." },
+                { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
                 { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "className", "type": "string", "optional": true, "description": "Object class (constructor) name. Specified for <code>object</code> type values only." },
                 { "name": "value", "type": "any", "optional": true, "description": "Remote object value (in case of primitive values or JSON values if it was requested)." },
@@ -26,7 +26,7 @@
             "type": "object",
             "description": "Object containing abbreviated remote object value.",
             "properties": [
-                { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean"], "description": "Object type." },
+                { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol"], "description": "Object type." },
                 { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "description", "type": "string", "optional": true, "description": "String representation of the object." },
                 { "name": "lossless", "type": "boolean", "description": "Determines whether preview is lossless (contains all information of the original object)." },
@@ -40,7 +40,7 @@
             "type": "object",
             "properties": [
                 { "name": "name", "type": "string", "description": "Property name." },
-                { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "accessor"], "description": "Object type." },
+                { "name": "type", "type": "string", "enum": ["object", "function", "undefined", "string", "number", "boolean", "symbol", "accessor"], "description": "Object type." },
                 { "name": "subtype", "type": "string", "optional": true, "enum": ["array", "null", "node", "regexp", "date", "error", "map", "set", "weakmap"], "description": "Object subtype hint. Specified for <code>object</code> type values only." },
                 { "name": "value", "type": "string", "optional": true, "description": "User-friendly property value string." },
                 { "name": "valuePreview", "$ref": "ObjectPreview", "optional": true, "description": "Nested value preview." }

Modified: trunk/Source/WebInspectorUI/ChangeLog (179658 => 179659)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-02-05 03:11:29 UTC (rev 179659)
@@ -1,3 +1,20 @@
+2015-02-04  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: ES6: Improved Console Support for Symbol Objects
+        https://bugs.webkit.org/show_bug.cgi?id=141173
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Protocol/RemoteObject.js:
+        (WebInspector.RemoteObject):
+        (WebInspector.RemoteObject.prototype._isSymbol):
+        Symbols have an objectId because it is a non-primitive that cannot be passed
+        by value, however it cannot have properties, so handle some cases.
+
+        * UserInterface/Views/LogContentView.css:
+        (.console-formatted-symbol):
+        Give Symbol's their own color.
+
 2015-02-04  Nikita Vasilyev  <[email protected]>
 
         Web Inspector: Insertion bar (caret) is hidden behind the placeholder text in the style editor

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (179658 => 179659)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js	2015-02-05 03:11:29 UTC (rev 179659)
@@ -36,7 +36,7 @@
         // handle
         this._objectId = objectId;
         this._description = description;
-        this._hasChildren = true;
+        this._hasChildren = type !== "symbol";
         this._preview = preview;
     } else {
         // Primitive or null object.
@@ -134,7 +134,7 @@
 
     _getProperties: function(ownProperties, ownAndGetterProperties, callback)
     {
-        if (!this._objectId) {
+        if (!this._objectId || this._isSymbol()) {
             callback([]);
             return;
         }
@@ -188,7 +188,7 @@
 
     setPropertyValue: function(name, value, callback)
     {
-        if (!this._objectId) {
+        if (!this._objectId || this._isSymbol()) {
             callback("Can't set a property of non-object.");
             return;
         }
@@ -223,6 +223,11 @@
         }
     },
 
+    _isSymbol: function()
+    {
+        return this.type === "symbol";
+    },
+
     isCollectionType: function()
     {
         return this.subtype === "map" || this.subtype === "set" || this.subtype === "weakmap";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css (179658 => 179659)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css	2015-02-05 02:36:22 UTC (rev 179658)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css	2015-02-05 03:11:29 UTC (rev 179659)
@@ -337,6 +337,10 @@
     color: rgb(255, 88, 0);
 }
 
+.console-formatted-symbol {
+    color: rgb(63, 169, 156);
+}
+
 .console-formatted-null, .console-formatted-undefined {
     color: rgb(128, 128, 128);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to