Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(wpt): compute IDL lengths across overloads and variadic arguments
ldm07a36b6a63f7b
diff --git a/moli-renderer-v8/src/native_bridge/element/class_list/template.rs b/moli-renderer-v8/src/native_bridge/element/class_list/template.rsindex eb2056b26..1443b54cd 100644--- a/moli-renderer-v8/src/native_bridge/element/class_list/template.rs+++ b/moli-renderer-v8/src/native_bridge/element/class_list/template.rs@@ -45,10 +45,10 @@ struct DomTokenListTemplateMethodsDeclaration {)]contains: (),- #[webapi(method, length = 1, callback = methods::class_list_add_callback)]+ #[webapi(method, length = 0, callback = methods::class_list_add_callback)]add: (),- #[webapi(method, length = 1, callback = methods::class_list_remove_callback)]+ #[webapi(method, length = 0, callback = methods::class_list_remove_callback)]remove: (),#[webapi(method, length = 1, callback = methods::class_list_toggle_callback)]diff --git a/moli-wpt-compat/fixtures/wpt/ported/idl/idlharness-shim-basic.html b/moli-wpt-compat/fixtures/wpt/ported/idl/idlharness-shim-basic.htmlindex 79d8976bb..948b741cd 100644--- a/moli-wpt-compat/fixtures/wpt/ported/idl/idlharness-shim-basic.html+++ b/moli-wpt-compat/fixtures/wpt/ported/idl/idlharness-shim-basic.html@@ -6,6 +6,45 @@<script src="/wpt/resources/WebIDLParser.js"></script><script src="/wpt/resources/idlharness.js"></script><script>+test(function () {+ const [iface] = WebIDLParser.parse(`+ interface ArgumentLengths {+ constructor(DOMString... values);+ undefined add(DOMString... tokens);+ undefined remove([LegacyNullToEmptyString] DOMString... tokens);+ undefined fixedAndVariadic(DOMString name, DOMString... values);+ undefined fixedAndOptional(DOMString name, optional DOMString value);+ undefined twoFixed(DOMString first, DOMString second);+ static undefined staticVariadic(DOMString... values);+ };+ `);+ assert_equals(iface.constructors[0].length, 0);+ assert_array_equals(iface.operations.map(operation => operation.length), [0, 0, 1, 1, 2]);+ assert_equals(iface.staticOperations[0].length, 0);+}, "IDL function lengths count fixed required arguments, excluding variadic arguments");++test(function () {+ const [iface] = WebIDLParser.parse(`+ interface OverloadedLengths {+ undefined longFirst(long x, long y);+ undefined longFirst(long x);+ undefined shortFirst(long x);+ undefined shortFirst(long x, long y);+ undefined optionalTail(long x, optional long y);+ undefined optionalTail(long x, long y, long z);+ undefined variadic(long x);+ undefined variadic(DOMString... values);+ static undefined from(long x, long y);+ static undefined from(long x);+ };+ `);+ assert_array_equals(iface.operations.map(operation => operation.name),+ ["longFirst", "shortFirst", "optionalTail", "variadic"]);+ assert_array_equals(iface.operations.map(operation => operation.length), [1, 1, 1, 0]);+ assert_equals(iface.staticOperations.length, 1);+ assert_equals(iface.staticOperations[0].length, 1);+}, "IDL operation lengths use the minimum required argument count across all overloads");+const MoliIdlHarnessThingConstructor = function MoliIdlHarnessThing(value) {};Object.defineProperty(window, "MoliIdlHarnessThing", {value: MoliIdlHarnessThingConstructor,diff --git a/moli-wpt-compat/fixtures/wpt/resources/WebIDLParser.js b/moli-wpt-compat/fixtures/wpt/resources/WebIDLParser.jsindex 9aa0ceec5..f2a58fb99 100644--- a/moli-wpt-compat/fixtures/wpt/resources/WebIDLParser.js+++ b/moli-wpt-compat/fixtures/wpt/resources/WebIDLParser.js@@ -63,7 +63,7 @@let count = 0;for (const rawArg of splitTopLevel(args, ",")) {const arg = stripExtendedAttributes(rawArg).trim();- if (!arg || arg.startsWith("optional ") || arg.includes(" = ")) {+ if (!arg || arg.startsWith("optional ") || arg.includes(" = ") || arg.includes("...")) {continue;}count += 1;@@ -90,6 +90,15 @@}}+ function addOperation(list, entry) {+ const existing = list.find((item) => item.name === entry.name);+ if (existing) {+ existing.length = Math.min(existing.length, entry.length);+ } else {+ list.push(entry);+ }+ }+function parseMember(iface, rawMember) {const extendedAttributes = leadingExtendedAttributeNames(rawMember);let member = stripExtendedAttributes(rawMember);@@ -119,7 +128,7 @@/^static\s+[\s\S]+?\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/,);if (staticOperation) {- addUnique(iface.staticOperations, {+ addOperation(iface.staticOperations, {name: staticOperation[1],length: requiredArgumentCount(staticOperation[2]),unforgeable: extendedAttributes.has("LegacyUnforgeable"),@@ -131,7 +140,7 @@/^[\s\S]+?\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/,);if (operation) {- addUnique(iface.operations, {+ addOperation(iface.operations, {name: operation[1],length: requiredArgumentCount(operation[2]),unforgeable: extendedAttributes.has("LegacyUnforgeable"),