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.

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

mercurial