tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug397093.js (1098B)


      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 */
      6 
      7 const name_ascii = "asciiProperty";
      8 const value_ascii = "";
      9 
     10 const name_utf8 = "utf8Property";
     11 const value_utf8 = "";
     12 
     13 const name_latin1 = "latin1";
     14 const value_latin1 = "";
     15 
     16 function run_test() {
     17  var StringBundle = Services.strings;
     18  var bundleURI = Services.io.newFileURI(do_get_file("397093.properties"));
     19 
     20  var bundle = StringBundle.createBundle(bundleURI.spec);
     21 
     22  var bundle_ascii = "",
     23    bundle_utf8 = "",
     24    bundle_latin1 = "";
     25  try {
     26    bundle_ascii = bundle.GetStringFromName(name_ascii);
     27  } catch (e) {}
     28  Assert.equal(bundle_ascii, value_ascii);
     29 
     30  try {
     31    bundle_utf8 = bundle.GetStringFromName(name_utf8);
     32  } catch (e) {}
     33  Assert.equal(bundle_utf8, value_utf8);
     34 
     35  try {
     36    bundle_latin1 = bundle.GetStringFromName(name_latin1);
     37  } catch (e) {}
     38  Assert.equal(bundle_latin1, value_latin1);
     39 }