Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

1.4 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<script src="/wpt/resources/testharness.js"></script>
<script src="/wpt/resources/testharnessreport.js"></script>
<script src="/wpt/resources/moli-wpt-adapter.js"></script>
<script>
test(function () {
  const encoder = new TextEncoder();
  assert_equals(encoder.encoding, "utf-8");
  assert_true(encoder.encode("abc") instanceof Uint8Array);
  assert_array_equals(Array.from(encoder.encode("abc")), [97, 98, 99]);
  assert_array_equals(Array.from(encoder.encode("\u00a3")), [194, 163]);
  assert_array_equals(Array.from(encoder.encode("\ud83d\ude00")), [240, 159, 152, 128]);
}, "TextEncoder exposes utf-8 encoding and encodes strings as UTF-8 bytes");

test(function () {
  const encoder = new TextEncoder();
  const destination = new Uint8Array(4);
  const result = encoder.encodeInto("a\u00a3z", destination);
  assert_equals(result.read, 3);
  assert_equals(result.written, 4);
  assert_array_equals(Array.from(destination), [97, 194, 163, 122]);
}, "TextEncoder.encodeInto writes UTF-8 bytes into the destination buffer");

test(function () {
  const encoder = new TextEncoder();
  const destination = new Uint8Array(2);
  const result = encoder.encodeInto("a\u00a3z", destination);
  assert_equals(result.read, 1);
  assert_equals(result.written, 1);
  assert_array_equals(Array.from(destination), [97, 0]);
}, "TextEncoder.encodeInto stops before a character that does not fit");
</script>