浏览代码

LibWeb: Don't override prototype on generated iterator prototypes

Generated iterator prototypes already have the IteratorPrototype as
their prototype, but we were incorrectly hijacking them and rerouting
to ObjectPrototype.

Regressed in cfe663435ed0780440e52bc66d69d787f6c0af2f.
Andreas Kling 2 年之前
父节点
当前提交
7f90b0cab7

+ 0 - 19
Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp

@@ -3881,25 +3881,6 @@ JS::ThrowCompletionOr<void> @prototype_class@::initialize(JS::Realm& realm)
 {
     auto& vm = this->vm();
     MUST_OR_THROW_OOM(Base::initialize(realm));
-
-)~~~");
-
-    if (interface.prototype_base_class == "ObjectPrototype") {
-        generator.append(R"~~~(
-
-    set_prototype(realm.intrinsics().object_prototype());
-
-)~~~");
-    } else {
-        generator.append(R"~~~(
-
-    set_prototype(&ensure_web_prototype<@prototype_base_class@>(realm, "@parent_name@"));
-
-)~~~");
-    }
-
-    generator.append(R"~~~(
-
     define_native_function(realm, vm.names.next, next, 0, JS::Attribute::Writable | JS::Attribute::Enumerable | JS::Attribute::Configurable);
     define_direct_property(vm.well_known_symbol_to_string_tag(), MUST_OR_THROW_OOM(JS::PrimitiveString::create(vm, "Iterator"sv)), JS::Attribute::Configurable);
 

+ 6 - 0
Tests/LibWeb/Text/expected/url-search-params-iterator-iterator.txt

@@ -0,0 +1,6 @@
+[object Iterator]
+[object Iterator]
+true
+hello
+1
+[object Window]

+ 13 - 0
Tests/LibWeb/Text/input/url-search-params-iterator-iterator.html

@@ -0,0 +1,13 @@
+<script src="include.js"></script>
+<script>
+    test(() => {
+        let u = new URLSearchParams();
+        let iterator = u[Symbol.iterator]();
+        println(iterator);
+        println(iterator[Symbol.iterator]());
+        println(iterator === iterator[Symbol.iterator]());
+        println(iterator[Symbol.iterator].call("hello"));
+        println(iterator[Symbol.iterator].call(1));
+        println(iterator[Symbol.iterator].call(window));
+    });
+</script>