wpt / html / infrastructure / urls / resolving-urls / query-encoding / lone-surrogates.sub.html?encoding=utf8

Open test on wpt.live | wpt.fyi

Runs: Chrome 160.0.8195.0 (wpt@1ab8957e4, 2026-12-01) | Firefox 163.0a1 (wpt@1ab8957e4, 2026-12-01) | Safari 257 preview (wpt@13099faa1, 2026-12-02) | Ladybird 1.0-cbbd8 (wpt@ef10039a5, 2026-12-02) | Servo Servo 0.8 (wpt@75c11f957, 2026-12-01) | Blitz af350c0af (wpt@705f393a6, 2026-12-02)

ChromeFirefoxSafariLadybirdServoBlitz
Total1/11/11/11/11/1NOT RUN
SubtestChromeFirefoxSafariLadybirdServoBlitz
Query parsing with lone surrogates in UTF-8PASSPASSPASSPASSPASS—

/html/infrastructure/urls/resolving-urls/query-encoding/lone-surrogates.sub.html

<!doctype html>
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
<meta name=variant content="?encoding=windows-1252">
<meta name=variant content="?encoding=utf8">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
function expected(encoding) {
  return "?" + {
    // Replacement character (not bogus UTF-8)
    "UTF-8": "%EF%BF%BD",
    // Charref for the replacement character (not the lone surrogate)
    "windows-1252": "%26%2365533%3B",
  }[encoding];
}

test(t => {
  const elm = document.createElement("a");
  document.body.appendChild(elm);
  t.add_cleanup(() => elm.remove());
  elm.setAttribute("href", "?\uD800");

  const shouldEndWith = expected(document.characterSet);
  assert_true(
    elm.href.endsWith(shouldEndWith),
    `${elm.href} did not end with ${shouldEndWith}`
  );
}, `Query parsing with lone surrogates in ${document.characterSet}`);
</script>