intl/strres/tests/unit/test_bug397093.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 with incorrect encoding.
     2  * The string bundle contains one ascii property, one UTF-8 and one Latin-1.
     3  * Expected behaviour is that the whole string bundle should be rejected and
     4  * all GetStringFromName calls should fail.
     5  */
     7 const name_ascii = "asciiProperty";
     8 const value_ascii = "";
    10 const name_utf8 = "utf8Property";
    11 const value_utf8 = "";
    13 const name_latin1 = "latin1";
    14 const value_latin1 = "";
    17 function run_test() {
    18     var StringBundle = 
    19 	Components.classes["@mozilla.org/intl/stringbundle;1"]
    20 	 .getService(Components.interfaces.nsIStringBundleService);
    21     var ios = Components.classes["@mozilla.org/network/io-service;1"]
    22 	 .getService(Components.interfaces.nsIIOService);
    23     var bundleURI = ios.newFileURI(do_get_file("397093.properties"));
    25     var bundle = StringBundle.createBundle(bundleURI.spec);
    27     var bundle_ascii="", bundle_utf8="", bundle_latin1="";
    28     try {
    29 	bundle_ascii = bundle.GetStringFromName(name_ascii);
    30     } catch(e) {}
    31     do_check_eq(bundle_ascii, value_ascii);
    33     try {
    34 	bundle_utf8 = bundle.GetStringFromName(name_utf8);
    35     } catch(e) {}
    36     do_check_eq(bundle_utf8, value_utf8);
    38     try {
    39 	bundle_latin1 = bundle.GetStringFromName(name_latin1);
    40     } catch(e) {}
    41     do_check_eq(bundle_latin1, value_latin1);
    42 }

mercurial