js/src/builtin/Number.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 /*global intl_NumberFormat: false, */
     8 var numberFormatCache = new Record();
    11 /**
    12  * Format this Number object into a string, using the locale and formatting options
    13  * provided.
    14  *
    15  * Spec: ECMAScript Language Specification, 5.1 edition, 15.7.4.3.
    16  * Spec: ECMAScript Internationalization API Specification, 13.2.1.
    17  */
    18 function Number_toLocaleString() {
    19     // Steps 1-2.  Note that valueOf enforces "this Number value" restrictions.
    20     var x = callFunction(std_Number_valueOf, this);
    22     // Steps 2-3.
    23     var locales = arguments.length > 0 ? arguments[0] : undefined;
    24     var options = arguments.length > 1 ? arguments[1] : undefined;
    26     // Step 4.
    27     var numberFormat;
    28     if (locales === undefined && options === undefined) {
    29         // This cache only optimizes for the old ES5 toLocaleString without
    30         // locales and options.
    31         if (numberFormatCache.numberFormat === undefined)
    32             numberFormatCache.numberFormat = intl_NumberFormat(locales, options);
    33         numberFormat = numberFormatCache.numberFormat;
    34     } else {
    35         numberFormat = intl_NumberFormat(locales, options);
    36     }
    38     // Step 5.
    39     return intl_FormatNumber(numberFormat, x);
    40 }

mercurial