intl/uconv/tests/unit/test_decode_EUCKR_Hangul.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 // Tests conversion of 8-byte decomposed Hangul from EUC-KR (and variants)
     2 // to Unicode, including invalid input
     4 load('CharsetConversionTests.js');
     5 load('hangulTestStrings.js');
     7 const aliases = [ "euc-kr", "EUC-KR", "iso-ir-149", "ks_c_5601-1989", "ksc_5601", "ksc5601", "korean", "csksc56011987", "5601", "windows-949", "ks_c_5601-1987", "cseuckr"];
     9 function to8byteHangul(byte3, byte5, byte7)
    10 {
    11     return String.fromCharCode(0xa4, 0xd4, 0xa4, byte3, 0xa4, byte5, 0xa4, byte7);
    12 }
    14 function run_test() {
    15     var converter = CreateScriptableConverter();
    16     for (var i = 0; i < aliases.length; ++i) {
    17         var row = 0;
    18         for (var byte3 = 0xa0; byte3 < 0xc0; ++byte3) {
    19             for (var byte5 = 0xbe; byte5 < 0xd5; ++byte5) {
    20                 var inString = " row " + byte3.toString(16) + "_" +
    21                     byte5.toString(16) + "_: ";
    22                 for (var byte7 = 0xa0; byte7 < 0xc0; ++byte7) {
    23                     inString += to8byteHangul(byte3, byte5, byte7) + " ";
    24                 }
    25                 inString += to8byteHangul(byte3, byte5, 0xd4) + " ";
    26                 checkDecode(converter, aliases[i], inString, expectedStrings[row++]);
    27             }
    28         }
    29         do_check_eq(row, expectedStrings.length);
    30     }
    31 }

mercurial