chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/binary-x-user-defined.html

<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=15555">bug 15555</a>:
XMLHttpRequest does not support charset "x-user-defined", which can facilitate loading of binary data.</p>
<script>
if (window.testRunner)
  testRunner.dumpAsText();

try {
  req = new XMLHttpRequest;
  req.overrideMimeType("text/plain; charset=x-user-defined");
  req.open("GET", "resources/256.bin", false);
  req.send();
  for (var i = 0; i < 128; i++) {
    var byt = req.responseText.charCodeAt(i);
    if (byt != i)
      throw "incorrect byte: " + byt + " (should be " + i + ")";
  }

  for (var i = 128; i < 256; i++) {
    var byt = req.responseText.charCodeAt(i);
    if (byt != i + 0xf700)
      throw "incorrect byte: " + byt + " (should be " + (i + 0xf700) + ")";
  }

  document.write("<div>SUCCESS</div>");

} catch (ex) {
  document.write("<div>" + ex + "</div>");
}
</script>