Changeset 74225 in webkit


Ignore:
Timestamp:
Dec 16, 2010 6:28:48 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2010-12-16 Yong Li <yoli@rim.com>

Reviewed by Alexey Proskuryakov.

https://bugs.webkit.org/show_bug.cgi?id=51199
Add decoding tests for UTF-16 LE/BE and their variants.
Also, check the full decoded text but not only the first one.

  • fast/encoding/char-decoding.html:
  • fast/encoding/char-decoding-expected.txt:
  • fast/encoding/resources/char-decoding-utils.js:
Location:
trunk/LayoutTests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r74222 r74225  
     12010-12-16  Yong Li  <yoli@rim.com>
     2
     3        Reviewed by Alexey Proskuryakov.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=51199
     6        Add decoding tests for UTF-16 LE/BE and their variants.
     7        Also, check the full decoded text but not only the first one.
     8
     9        * fast/encoding/char-decoding.html:
     10        * fast/encoding/char-decoding-expected.txt:
     11        * fast/encoding/resources/char-decoding-utils.js:
     12
    1132010-12-16  Jian Li  <jianli@chromium.org>
    214
  • trunk/LayoutTests/fast/encoding/char-decoding-expected.txt

    r74186 r74225  
    156156PASS decode('dos-874', '%A1') is 'U+0E01'
    157157PASS decode('dos-874', '%DB') is 'U+F8C1'
    158 PASS decode('UTF-7', '+AD4') is 'U+002B'
    159 PASS decode('utf-7', '+AD4') is 'U+002B'
     158PASS decode('UTF-7', '+AD4') is 'U+002B/U+0041/U+0044/U+0034'
     159PASS decode('utf-7', '+AD4') is 'U+002B/U+0041/U+0044/U+0034'
     160PASS decode('UTF-16LE', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     161PASS decode('unicodeFEFF', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     162PASS decode('UTF-16', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     163PASS decode('ISO-10646-UCS-2', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     164PASS decode('UCS-2', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     165PASS decode('Unicode', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     166PASS decode('csUnicode', '%69%D8%D6%DE') is 'U+D869/U+DED6'
     167PASS decode('UTF-16BE', '%D8%69%DE%D6') is 'U+D869/U+DED6'
     168PASS decode('unicodeFFFE', '%D8%69%DE%D6') is 'U+D869/U+DED6'
    160169PASS successfullyParsed is true
    161170
  • trunk/LayoutTests/fast/encoding/char-decoding.html

    r74186 r74225  
    9090// UTF-7 is expressly forbidden, so decoding it should not work correctly.
    9191// This attempts to decode '<' as UTF-7 (+AD4) but it ends up being decoded
    92 // as a '+'.
    93 testDecode('UTF-7', '+AD4', 'U+002B');
    94 testDecode('utf-7', '+AD4', 'U+002B');
     92// as a '+AD4'.
     93testDecode('UTF-7', '+AD4', 'U+002B/U+0041/U+0044/U+0034');
     94testDecode('utf-7', '+AD4', 'U+002B/U+0041/U+0044/U+0034');
     95
     96// UTF-16LE and variants.
     97testDecode('UTF-16LE', '%69%D8%D6%DE', 'U+D869/U+DED6');
     98testDecode('unicodeFEFF', '%69%D8%D6%DE', 'U+D869/U+DED6');
     99// According to HTML5 and for IE compatibility, UTF-16 is treated as little endian. The following tests fail as of Firefox 3.6.13.
     100testDecode('UTF-16', '%69%D8%D6%DE', 'U+D869/U+DED6');
     101testDecode('ISO-10646-UCS-2', '%69%D8%D6%DE', 'U+D869/U+DED6');
     102testDecode('UCS-2', '%69%D8%D6%DE', 'U+D869/U+DED6');
     103testDecode('Unicode', '%69%D8%D6%DE', 'U+D869/U+DED6');
     104testDecode('csUnicode', '%69%D8%D6%DE', 'U+D869/U+DED6');
     105
     106// UTF-16BE and variants.
     107testDecode('UTF-16BE', '%D8%69%DE%D6', 'U+D869/U+DED6');
     108testDecode('unicodeFFFE', '%D8%69%DE%D6', 'U+D869/U+DED6');
    95109
    96110successfullyParsed = true;
  • trunk/LayoutTests/fast/encoding/resources/char-decoding-utils.js

    r74186 r74225  
    1010}
    1111
    12 function decode(charsetName, characterSequence)
     12function decodeText(charsetName, characterSequence)
    1313{
    1414    var req = new XMLHttpRequest;
     
    1616    req.overrideMimeType('text/plain; charset="' + charsetName + '"');
    1717    req.send('');
    18     var code = hex(req.responseText.charCodeAt(0));
    19     return "U+" + ("0000" + code).substr(code.length, 4);
     18    return req.responseText;
     19}
     20
     21function decode(charsetName, characterSequence)
     22{
     23    var decodedText = decodeText(charsetName, characterSequence);
     24    var result = "";
     25    for (var i = 0; i < decodedText.length; ++i) {
     26        var code = hex(decodedText.charCodeAt(i));
     27        if (i)
     28            result += "/";
     29        result += "U+" + ("0000" + code).substr(code.length, 4);
     30    }
     31    return result;
    2032}
    2133
Note: See TracChangeset for help on using the changeset viewer.