1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/locale/tests/unit/test_bug371611.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,26 @@ 1.4 +const Cc = Components.classes; 1.5 +const Ci = Components.interfaces; 1.6 +const Cr = Components.results; 1.7 + 1.8 +function test_formatdatetime_return() 1.9 +{ 1.10 + var dateConv = Cc["@mozilla.org/intl/scriptabledateformat;1"]. 1.11 + getService(Ci.nsIScriptableDateFormat); 1.12 + 1.13 + /* Testing if we throw instead of crashing when we are passed 0s. */ 1.14 + var x = false; 1.15 + try { 1.16 + dateConv.FormatDate("", Ci.nsIScriptableDateFormat.dateFormatLong, 1.17 + 0, 0, 0); 1.18 + } 1.19 + catch (e if (e.result == Cr.NS_ERROR_INVALID_ARG)) { 1.20 + x = true; 1.21 + } 1.22 + if (!x) 1.23 + do_throw("FormatDate didn't throw when passed 0 for its arguments."); 1.24 +} 1.25 + 1.26 +function run_test() 1.27 +{ 1.28 + test_formatdatetime_return(); 1.29 +}