https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 3c1277e4f12ad53c7bcf1e28b92fd12b346b7339 authored by Ovidio Henriquez on 23 March 2018, 15:12:10 UTC
bluetooth: Add RemoveFakeDescriptor to BT test
Tip revision: 3c1277e
textdecoder-labels.html
<!DOCTYPE html>
<title>Encoding API: Encoding labels</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/encodings.js"></script>
<script>
var whitespace = [' ', '\t', '\n', '\f', '\r'];
encodings_table.forEach(function(section) {
  section.encodings.filter(function(encoding) {
    return encoding.name !== 'replacement';
  }).forEach(function(encoding) {
    encoding.labels.forEach(function(label) {
      const textDecoderName = encoding.name.toLowerCase(); // ASCII names only, so safe
      test(function(t) {
        assert_equals(
          new TextDecoder(label).encoding, textDecoderName,
          'label for encoding should match');
        assert_equals(
          new TextDecoder(label.toUpperCase()).encoding, textDecoderName,
          'label matching should be case-insensitive');
        whitespace.forEach(function(ws) {
          assert_equals(
            new TextDecoder(ws + label).encoding, textDecoderName,
            'label for encoding with leading whitespace should match');
          assert_equals(
            new TextDecoder(label + ws).encoding, textDecoderName,
            'label for encoding with trailing whitespace should match');
          assert_equals(
            new TextDecoder(ws + label + ws).encoding, textDecoderName,
            'label for encoding with surrounding whitespace should match');
        });
      }, label + ' => ' + encoding.name);
    });
  });
});
</script>
back to top