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(webidl): retain enumerable symbol record keys
ldm0b0780fbe0e85
diff --git a/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs b/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rsindex 89756e904..9f1adc060 100644--- a/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs+++ b/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs@@ -6780,6 +6780,45 @@ fn webidl_initializer_unions_observe_iterators_on_platform_objects() {assert_eq!(result, "ok");}+#[test]+fn webidl_initializer_records_reject_enumerable_symbol_keys() {+ let mut vm = new_storage_test_vm("https://initializer-symbol-record.test/");+ let result = vm+ .eval(+ r#"+(() => {+ const consumers = [+ ['Headers', input => new Headers(input)],+ ['URLSearchParams', input => new URLSearchParams(input)],+ ['Request', input => new Request('https://initializer-symbol-record.test/', {headers: input})],+ ['Response', input => new Response(null, {headers: input})],+ ];+ const symbols = [+ ['Symbol.iterator', Symbol.iterator],+ ['ordinary symbol', Symbol('x')],+ ];+ for (const [target, create] of consumers) {+ for (const [description, symbol] of symbols) {+ const input = {};+ Object.defineProperty(input, symbol, {+ enumerable: true,+ value: undefined,+ });+ let caught;+ try { create(input); } catch (error) { caught = error; }+ if (!(caught instanceof TypeError)) {+ throw new Error(target + ' must convert its enumerable ' + description + ' record key');+ }+ }+ }+ return 'ok';+})()+"#,+ )+ .unwrap();+ assert_eq!(result, "ok");+}+#[test]fn webidl_initializer_unions_convert_url_objects_as_records() {let mut vm = new_storage_test_vm("https://initializer-record.test/");diff --git a/moli-webidl/src/convert.rs b/moli-webidl/src/convert.rsindex a07af9bce..b23045752 100644--- a/moli-webidl/src/convert.rs+++ b/moli-webidl/src/convert.rs@@ -1166,7 +1166,13 @@ fn own_property_names<'s>() -> Result<v8::Local<'s, v8::Array>, WebIdlError> {let try_catch = std::pin::pin!(v8::TryCatch::new(scope));let mut scope = try_catch.init();- match object.get_own_property_names(&scope, v8::GetPropertyNamesArgs::default()) {+ // WebIDL record conversion starts with [[OwnPropertyKeys]], including symbols,+ // and then considers only enumerable properties. V8's default arguments skip+ // symbols, which would bypass the record key conversion that rejects them.+ let property_names_args = v8::GetPropertyNamesArgsBuilder::new()+ .property_filter(v8::PropertyFilter::ONLY_ENUMERABLE)+ .build();+ match object.get_own_property_names(&scope, property_names_args) {Some(properties) => Ok(properties),None if scope.has_caught() => {let _ = scope.rethrow();diff --git a/moli-wpt-compat/fixtures/wpt/ported/url/urlsearchparams-basic.html b/moli-wpt-compat/fixtures/wpt/ported/url/urlsearchparams-basic.htmlindex fde2ecc82..225910334 100644--- a/moli-wpt-compat/fixtures/wpt/ported/url/urlsearchparams-basic.html+++ b/moli-wpt-compat/fixtures/wpt/ported/url/urlsearchparams-basic.html@@ -666,7 +666,10 @@ test(function () {test(function () {const record = { visible: "yes" };const symbolKey = Symbol("hidden");- record[symbolKey] = "symbol";+ Object.defineProperty(record, symbolKey, {+ value: "symbol",+ enumerable: false,+ });Object.defineProperty(record, "hidden", {value: "no",enumerable: false,@@ -675,7 +678,15 @@ test(function () {assert_equals(params.toString(), "visible=yes");assert_false(params.has("hidden"));assert_false(params.has("Symbol(hidden)"));-}, "URLSearchParams constructor ignores non-enumerable and symbol record properties");+}, "URLSearchParams constructor ignores non-enumerable record properties");++test(function () {+ const record = {};+ record[Symbol("key")] = "value";+ assert_throws_name("TypeError", function () {+ new URLSearchParams(record);+ }, "enumerable symbol record keys should be converted");+}, "URLSearchParams constructor rejects enumerable symbol record keys");test(function () {const sequence = new URLSearchParams([