intl/strres/tests/unit/test_bug378839.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 /* Tests getting properties from string bundles
     2  */
     4 const name_file = "file";
     5 const value_file = "File";
     7 const name_loyal = "loyal";
     8 const value_loyal = "\u5fe0\u5fc3"; // tests escaped Unicode
    10 const name_trout = "trout";
    11 const value_trout = "\u9cdf\u9b5a"; // tests UTF-8
    13 const name_edit = "edit";
    14 const value_edit = "Edit"; // tests literal leading spaces are stripped
    16 const name_view = "view";
    17 const value_view = "View"; // tests literal trailing spaces are stripped
    19 const name_go = "go";
    20 const value_go = " Go"; // tests escaped leading spaces are not stripped
    22 const name_message = "message";
    23 const value_message = "Message "; // tests escaped trailing spaces are not stripped
    25 const name_hello = "hello";
    26 const var_hello = "World";
    27 const value_hello = "Hello World"; // tests formatStringFromName with parameter
    30 function run_test() {
    31     var StringBundle = 
    32 	Components.classes["@mozilla.org/intl/stringbundle;1"]
    33 	 .getService(Components.interfaces.nsIStringBundleService);
    34     var ios = Components.classes["@mozilla.org/network/io-service;1"]
    35 	 .getService(Components.interfaces.nsIIOService);
    36     var bundleURI = ios.newFileURI(do_get_file("strres.properties"));
    38     var bundle = StringBundle.createBundle(bundleURI.spec);
    40     var bundle_file = bundle.GetStringFromName(name_file);
    41     do_check_eq(bundle_file, value_file);
    43     var bundle_loyal = bundle.GetStringFromName(name_loyal);
    44     do_check_eq(bundle_loyal, value_loyal);
    46     var bundle_trout = bundle.GetStringFromName(name_trout);
    47     do_check_eq(bundle_trout, value_trout);
    49     var bundle_edit = bundle.GetStringFromName(name_edit);
    50     do_check_eq(bundle_edit, value_edit);
    52     var bundle_view = bundle.GetStringFromName(name_view);
    53     do_check_eq(bundle_view, value_view);
    55     var bundle_go = bundle.GetStringFromName(name_go);
    56     do_check_eq(bundle_go, value_go);
    58     var bundle_message = bundle.GetStringFromName(name_message);
    59     do_check_eq(bundle_message, value_message);
    61     var bundle_hello = bundle.formatStringFromName(name_hello, [var_hello], 1);
    62     do_check_eq(bundle_hello, value_hello);
    63 }

mercurial