chromium/third_party/blink/web_tests/http/tests/xmlhttprequest/bom.html

<!doctype html>
<script src="/js-test-resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;
description('BOM can override the encoding when decoding the response in ' +
            'responseText.');

xhr = new XMLHttpRequest;
xhr.open('GET', 'resources/bom-utf-8.php');
xhr.onreadystatechange = function() {
  if (xhr.readyState != xhr.DONE) { return; }
  // A string with utf-8 BOM is decoded as utf-8.
  shouldBeEqualToString('xhr.responseText',
                        '\u4e09\u6751\u304b\u306a\u5b50');
  xhr2 = new XMLHttpRequest;
  xhr2.open('GET', 'resources/bom-utf-16be.php');
  xhr2.onreadystatechange = function() {
    if (xhr2.readyState != xhr2.DONE) { return; }
    // A string with utf-16be BOM is decoded as utf-16be.
    shouldBeEqualToString('xhr2.responseText',
                          '\u4e09\u6751\u304b\u306a\u5b50');
    xhr3 = new XMLHttpRequest;
    xhr3.open('GET', 'resources/bom-utf-16le.php');
    xhr3.onreadystatechange = function() {
      if (xhr3.readyState != xhr3.DONE) { return; }
      // A string with utf-16le BOM is decoded as utf-16le.
      shouldBeEqualToString('xhr3.responseText',
                            '\u4e09\u6751\u304b\u306a\u5b50');
      finishJSTest();
    };
    xhr3.send();
  };
  xhr2.send();
};
xhr.send();
</script>