diff --git a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp index 26035ec439..561f8027bf 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorPrototype.cpp @@ -20,6 +20,10 @@ ThrowCompletionOr IteratorPrototype::initialize(Realm& realm) { auto& vm = this->vm(); MUST_OR_THROW_OOM(Base::initialize(realm)); + + // 3.1.3.13 Iterator.prototype [ @@toStringTag ], https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype-@@tostringtag + define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(PrimitiveString::create(vm, "Iterator"sv)), Attribute::Configurable | Attribute::Writable); + u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.well_known_symbol_iterator(), symbol_iterator, 0, attr); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Iterator/Iterator.prototype.@@toStringTag.js b/Userland/Libraries/LibJS/Tests/builtins/Iterator/Iterator.prototype.@@toStringTag.js new file mode 100644 index 0000000000..802fd88d80 --- /dev/null +++ b/Userland/Libraries/LibJS/Tests/builtins/Iterator/Iterator.prototype.@@toStringTag.js @@ -0,0 +1,3 @@ +test("basic functionality", () => { + expect(Iterator.prototype[Symbol.toStringTag]).toBe("Iterator"); +});