Title: [235712] trunk
Revision
235712
Author
[email protected]
Date
2018-09-05 15:18:09 -0700 (Wed, 05 Sep 2018)

Log Message

[ESNext] Symbol.prototype.description
https://bugs.webkit.org/show_bug.cgi?id=186686

Reviewed by Keith Miller.

JSTests:

* stress/symbol-description.js:
Add tests for empty and null symbol cases.

* test262/config.yaml:
Enable Symbol.prototype.description tests.

Source/_javascript_Core:

Symbol.prototype.description was implemented in r232404, but has one small bug:
It should return undefined for a null symbol.

* runtime/Symbol.cpp:
(JSC::Symbol::description const):
* runtime/SymbolPrototype.cpp:
(JSC::symbolProtoGetterDescription):
Address the null symbol case.

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (235711 => 235712)


--- trunk/JSTests/ChangeLog	2018-09-05 22:08:23 UTC (rev 235711)
+++ trunk/JSTests/ChangeLog	2018-09-05 22:18:09 UTC (rev 235712)
@@ -1,3 +1,16 @@
+2018-09-05  Ross Kirsling  <[email protected]>
+
+        [ESNext] Symbol.prototype.description
+        https://bugs.webkit.org/show_bug.cgi?id=186686
+
+        Reviewed by Keith Miller.
+
+        * stress/symbol-description.js:
+        Add tests for empty and null symbol cases.
+
+        * test262/config.yaml:
+        Enable Symbol.prototype.description tests.
+
 2018-09-05  David Fenton  <[email protected]>
 
         [32-bit JSC tests] Exception: ReferenceError: Can't find variable: WebAssembly.

Modified: trunk/JSTests/stress/symbol-description.js (235711 => 235712)


--- trunk/JSTests/stress/symbol-description.js	2018-09-05 22:08:23 UTC (rev 235711)
+++ trunk/JSTests/stress/symbol-description.js	2018-09-05 22:18:09 UTC (rev 235712)
@@ -20,19 +20,31 @@
 
 var s0 = Symbol("Cocoa");
 var s1 = Symbol("Cappuccino");
+var s2 = Symbol("");
+var s3 = Symbol();
 
 shouldBe(s0.description, "Cocoa");
 shouldBe(s0.toString(), "Symbol(Cocoa)");
 shouldBe(s1.description, "Cappuccino");
 shouldBe(s1.toString(), "Symbol(Cappuccino)");
+shouldBe(s2.description, "");
+shouldBe(s2.toString(), "Symbol()");
+shouldBe(s3.description, undefined);
+shouldBe(s3.toString(), "Symbol()");
 
 var o0 = Object(s0);
 var o1 = Object(s1);
+var o2 = Object(s2);
+var o3 = Object(s3);
 
 shouldBe(o0.description, "Cocoa");
 shouldBe(o0.toString(), "Symbol(Cocoa)");
 shouldBe(o1.description, "Cappuccino");
 shouldBe(o1.toString(), "Symbol(Cappuccino)");
+shouldBe(o2.description, "");
+shouldBe(o2.toString(), "Symbol()");
+shouldBe(o3.description, undefined);
+shouldBe(o3.toString(), "Symbol()");
 
 var descriptor = Object.getOwnPropertyDescriptor(Symbol.prototype, "description");
 shouldBe(descriptor.enumerable, false);

Modified: trunk/JSTests/test262/config.yaml (235711 => 235712)


--- trunk/JSTests/test262/config.yaml	2018-09-05 22:08:23 UTC (rev 235711)
+++ trunk/JSTests/test262/config.yaml	2018-09-05 22:18:09 UTC (rev 235712)
@@ -11,8 +11,6 @@
     - BigInt
     # https://bugs.webkit.org/show_bug.cgi?id=166693
     - async-iteration
-    # https://bugs.webkit.org/show_bug.cgi?id=186686
-    - Symbol.prototype.description
     # https://bugs.webkit.org/show_bug.cgi?id=186694
     - String.prototype.matchAll
     - Symbol.matchAll

Modified: trunk/Source/_javascript_Core/ChangeLog (235711 => 235712)


--- trunk/Source/_javascript_Core/ChangeLog	2018-09-05 22:08:23 UTC (rev 235711)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-09-05 22:18:09 UTC (rev 235712)
@@ -1,3 +1,19 @@
+2018-09-05  Ross Kirsling  <[email protected]>
+
+        [ESNext] Symbol.prototype.description
+        https://bugs.webkit.org/show_bug.cgi?id=186686
+
+        Reviewed by Keith Miller.
+
+        Symbol.prototype.description was implemented in r232404, but has one small bug:
+        It should return undefined for a null symbol.
+
+        * runtime/Symbol.cpp:
+        (JSC::Symbol::description const):
+        * runtime/SymbolPrototype.cpp:
+        (JSC::symbolProtoGetterDescription):
+        Address the null symbol case.
+
 2018-09-04  Keith Miller  <[email protected]>
 
         RELEASE_ASSERT at ../../Source/_javascript_Core/heap/MarkedSpace.h:83

Modified: trunk/Source/_javascript_Core/runtime/Symbol.cpp (235711 => 235712)


--- trunk/Source/_javascript_Core/runtime/Symbol.cpp	2018-09-05 22:08:23 UTC (rev 235711)
+++ trunk/Source/_javascript_Core/runtime/Symbol.cpp	2018-09-05 22:18:09 UTC (rev 235712)
@@ -105,7 +105,8 @@
 
 String Symbol::description() const
 {
-    return privateName().uid();
+    auto& uid = privateName().uid();
+    return uid.isNullSymbol() ? String() : uid;
 }
 
 Symbol* Symbol::create(VM& vm)

Modified: trunk/Source/_javascript_Core/runtime/SymbolPrototype.cpp (235711 => 235712)


--- trunk/Source/_javascript_Core/runtime/SymbolPrototype.cpp	2018-09-05 22:08:23 UTC (rev 235711)
+++ trunk/Source/_javascript_Core/runtime/SymbolPrototype.cpp	2018-09-05 22:18:09 UTC (rev 235712)
@@ -97,7 +97,8 @@
     if (!symbol)
         return throwVMTypeError(exec, scope, SymbolDescriptionTypeError);
     scope.release();
-    return JSValue::encode(jsString(&vm, symbol->description()));
+    const auto description = symbol->description();
+    return JSValue::encode(description.isNull() ? jsUndefined() : jsString(&vm, description));
 }
 
 EncodedJSValue JSC_HOST_CALL symbolProtoFuncToString(ExecState* exec)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to