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): serve worker URL encoding fixtures
ldm0446ac04b9b35
diff --git a/moli-benchmark/moli_benchmark/wpt_cross/server.py b/moli-benchmark/moli_benchmark/wpt_cross/server.pyindex 9bbe662d3..fee63469a 100644--- a/moli-benchmark/moli_benchmark/wpt_cross/server.py+++ b/moli-benchmark/moli_benchmark/wpt_cross/server.py@@ -1946,6 +1946,19 @@ def _directory_listing_body(directory: Path, path: str) -> bytes:).encode("utf-8")+def _workers_url_encoding_response(query: str) -> bytes:+ """Model workers/semantics/encodings/003-1.py's UTF-8 query check."""+ value = next(+ (+ value+ for name, value in parse_qsl(query, keep_blank_values=True)+ if name == "x"+ ),+ None,+ )+ return b"PASS" if value == "å" else b"FAIL"++def _make_handler(wpt_root: Path,results_store: "ResultsStore",@@ -2674,6 +2687,13 @@ requestExecutor("{executor_uuid}", {start_on_js});self.send_error(500, "Invalid WPT template or pipe")def _serve_response(self, *, emit_body: bool) -> None:+ if unquote(urlsplit(self.path).path) == "/workers/semantics/encodings/003-1.py":+ self._send_bytes(+ "text/plain; charset=utf-8",+ _workers_url_encoding_response(urlsplit(self.path).query),+ emit_body=emit_body,+ )+ returnif unquote(urlsplit(self.path).path) == FETCH_INSPECT_HEADERS_PATH:self._serve_fetch_inspect_headers(urlsplit(self.path).query, emit_body=self.command != "HEAD",diff --git a/moli-benchmark/tests/test_wpt_cross_fixture_responses.py b/moli-benchmark/tests/test_wpt_cross_fixture_responses.pyindex 709dbb3b9..cb9206b3f 100644--- a/moli-benchmark/tests/test_wpt_cross_fixture_responses.py+++ b/moli-benchmark/tests/test_wpt_cross_fixture_responses.py@@ -567,3 +567,41 @@ class WptCrossFixtureResponsesTests(WptCrossTestCase):response.headers["Access-Control-Expose-Headers"],"x-request-referer, x-request-origin",)++ def test_fixture_server_models_worker_url_utf8_query_check(self) -> None:+ self.assertEqual(_workers_url_encoding_response("x=%C3%A5"), b"PASS")+ self.assertEqual(_workers_url_encoding_response("x=%C3%A5&x=wrong"), b"PASS")+ self.assertEqual(_workers_url_encoding_response("x=%C3%83%C2%A5"), b"FAIL")+ self.assertEqual(_workers_url_encoding_response("x=%E5"), b"FAIL")+ self.assertEqual(_workers_url_encoding_response(""), b"FAIL")++ with tempfile.TemporaryDirectory() as root:+ root_path = Path(root)+ (root_path / "resources").mkdir()+ (root_path / "resources" / "testharness.js").write_text(+ "// testharness", encoding="utf-8"+ )+ with WptFixtureServer(root_path) as server:+ url = (+ f"{server.base_url}/workers/semantics/encodings/"+ "003-1.py?x=%C3%A5"+ )+ responses = []+ for method in ("GET", "HEAD"):+ with urlopen(Request(url, method=method), timeout=2) as response:+ responses.append(+ (+ method,+ response.status,+ response.read(),+ response.headers["Content-Type"],+ )+ )++ self.assertEqual(+ responses,+ [+ ("GET", 200, b"PASS", "text/plain; charset=utf-8"),+ ("HEAD", 200, b"", "text/plain; charset=utf-8"),+ ],+ )diff --git a/moli-benchmark/tests/wpt_cross_test_support.py b/moli-benchmark/tests/wpt_cross_test_support.pyindex cf9a17e78..562f9efea 100644--- a/moli-benchmark/tests/wpt_cross_test_support.py+++ b/moli-benchmark/tests/wpt_cross_test_support.py@@ -110,6 +110,7 @@ from moli_benchmark.wpt_cross.scheduler import (build_run_schedule,)from moli_benchmark.wpt_cross.server import (+ _workers_url_encoding_response,_fetch_status_response,BENCH_REPORT_BRIDGE,BENCH_TESTDRIVER_VENDOR_BRIDGE,