js/src/tests/js1_5/Regress/regress-315974.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     8 /*
     9   This test case uses String.quote(), because that method uses the JS printf()
    10   functions internally. The printf() functions print to a char* buffer, causing
    11   conversion to and from UTF-8 if UTF-8 is enabled. If not, UTF-8 sequences are
    12   converted to ASCII \uXXXX sequences. Thus, both return values are acceptable.
    13 */
    15 var BUGNUMBER = 315974;
    16 var summary = 'Test internal printf() for wide characters';
    18 printBugNumber(BUGNUMBER);
    19 printStatus (summary);
    21 enterFunc (String (BUGNUMBER));
    23 var goodSurrogatePair = '\uD841\uDC42';
    24 var badSurrogatePair = '\uD841badbad';
    26 var goodSurrogatePairQuotedUtf8 = '"\uD841\uDC42"';
    27 var badSurrogatePairQuotedUtf8 = 'no error thrown!';
    28 var goodSurrogatePairQuotedNoUtf8 = '"\\uD841\\uDC42"';
    29 var badSurrogatePairQuotedNoUtf8 = '"\\uD841badbad"';
    31 var status = summary + ': String.quote() should pay respect to surrogate pairs';
    32 var actual = goodSurrogatePair.quote();
    33 /* Result in case UTF-8 is enabled. */
    34 var expect = goodSurrogatePairQuotedUtf8;
    35 /* Result in case UTF-8 is disabled. */
    36 if (actual != expect && actual == goodSurrogatePairQuotedNoUtf8)
    37   expect = actual;
    38 reportCompare(expect, actual, status);
    40 /*
    41  * A malformed surrogate pair throws an out-of-memory error,
    42  * but only if UTF-8 is enabled.
    43  */
    44 status = summary + ': String.quote() should throw error on bad surrogate pair';
    45 /* Out of memory is not catchable. */
    46 actual = badSurrogatePair.quote();
    47 /* Come here only if UTF-8 is disabled. */
    48 reportCompare(badSurrogatePairQuotedNoUtf8, actual, status);
    50 exitFunc (String (BUGNUMBER));

mercurial