Revision d0d62244432d329aa22e9278d3e83184301c3e7f authored by Chris Nardi on 07 April 2018, 01:36:26 UTC, committed by Xidorn Quan on 07 April 2018, 02:05:46 UTC
See https://github.com/w3c/csswg-drafts/issues/2509#issuecomment-379152590 for the change to target9. Also remove the extra whitespace in target8 and target1 which causes these tests to fail in Chrome and Firefox.

Also remove testcase.propertyName from each test's name as this doesn't exist and just outputs undefined.
1 parent 6e68c44
Raw File
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