From adc3368fac66d967efcba4b7a98a937604a8970e Mon Sep 17 00:00:00 2001 From: Taejin Kim Date: Fri, 23 Jan 2026 21:38:32 +0900 Subject: [PATCH] test: fix location object to match Location interface in WPT The Location interface should not have a searchParams property according to the WHATWG URL spec. This commit fixes the WPT test runner to hide the searchParams property from the location object using a Proxy, ensuring that WPT tests expecting the Location interface behavior pass correctly. - Use Proxy to hide searchParams from location object in WPT runner - Remove historical.any.js from expected failures in url.json Fixes the 'searchParams on location object' test in historical.any.js --- test/common/wpt.js | 11 ++++++++++- test/wpt/status/url.json | 7 ------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/common/wpt.js b/test/common/wpt.js index 227734171f9121..6165a43ad6735b 100644 --- a/test/common/wpt.js +++ b/test/common/wpt.js @@ -596,7 +596,16 @@ class WPTRunner { const title = spec.getMeta().title; let { initScript } = this; - initScript = `${initScript}\n\n//===\nglobalThis.location = new URL("${url.href}");`; + initScript = `${initScript}\n\n//===\nconst _location = new URL("${url.href}");\n` + + `globalThis.location = new Proxy(_location, {\n` + + ` has(target, prop) { return prop !== 'searchParams' && prop in target; },\n` + + ` get(target, prop) { return prop === 'searchParams' ? undefined : target[prop]; },\n` + + ` ownKeys(target) { return Object.keys(target).filter(k => k !== 'searchParams'); },\n` + + ` getOwnPropertyDescriptor(target, prop) {\n` + + ` if (prop === 'searchParams') return undefined;\n` + + ` return Object.getOwnPropertyDescriptor(target, prop);\n` + + ` }\n` + + `});`; if (title) { initScript = `${initScript}\n\n//===\nglobalThis.META_TITLE = "${title}";`; diff --git a/test/wpt/status/url.json b/test/wpt/status/url.json index e92c1f27bc6208..9466edcab408b5 100644 --- a/test/wpt/status/url.json +++ b/test/wpt/status/url.json @@ -10,13 +10,6 @@ ] } }, - "historical.any.js": { - "fail": { - "expected": [ - "searchParams on location object" - ] - } - }, "javascript-urls.window.js": { "skip": "requires document.body reference" },