瀏覽代碼

LibJS: Add @@toStringTag to Promise.prototype

Linus Groh 4 年之前
父節點
當前提交
b377777208

+ 1 - 0
Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp

@@ -29,6 +29,7 @@ void PromisePrototype::initialize(GlobalObject& global_object)
     define_native_function(vm.names.then, then, 2, attr);
     define_native_function(vm.names.catch_, catch_, 1, attr);
     define_native_function(vm.names.finally, finally, 1, attr);
+    define_property(vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), "Promise"), Attribute::Configurable);
 }
 
 static Promise* promise_from(VM& vm, GlobalObject& global_object)

+ 3 - 0
Userland/Libraries/LibJS/Tests/builtins/Promise/Promise.prototype.@@toStringTag.js

@@ -0,0 +1,3 @@
+test("basic functionality", () => {
+    expect(Promise.prototype[Symbol.toStringTag]).toBe("Promise");
+});