Bug 818634 - Remove support for Date.prototype.toLocaleFormat. r=gandalf, r=anba
authorRofael Aleezada <me@rofael.com>
Wed, 18 Oct 2017 21:51:32 -0500
changeset 430887 d376cac28778edfaf3ba95f12bda3df7a9cecefe
parent 430886 186606ff9e5e6d6da877d488109e5d9f2acd3e95
child 430888 a3785ec9a48c8c76dd98b5c5140283f8ac44c851
push id108
push userfmarier@mozilla.com
push dateFri, 03 Nov 2017 18:37:44 +0000
reviewersgandalf, anba
bugs818634
milestone58.0a1
Bug 818634 - Remove support for Date.prototype.toLocaleFormat. r=gandalf, r=anba
devtools/server/actors/errordocs.js
js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js
js/src/js.msg
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdate.cpp
js/src/tests/ecma_5/extensions/extension-methods-reject-null-undefined-this.js
js/src/tests/js1_5/extensions/toLocaleFormat-01.js
js/src/tests/js1_5/extensions/toLocaleFormat-02.js
js/src/tests/js1_5/extensions/toLocaleFormat-deprecated-no-Intl.js
js/src/tests/js1_5/extensions/toLocaleFormat-deprecated.js
js/src/vm/Time.cpp
js/xpconnect/src/XPCLocale.cpp
js/xpconnect/tests/chrome/test_xrayToJS.xul
toolkit/xre/nsAppRunner.cpp
--- a/devtools/server/actors/errordocs.js
+++ b/devtools/server/actors/errordocs.js
@@ -68,17 +68,16 @@ const ErrorDocs = {
   JSMSG_NO_VARIABLE_NAME: "No_variable_name",
   JSMSG_UNNAMED_FUNCTION_STMT: "Unnamed_function_statement",
   JSMSG_CANT_DEFINE_PROP_OBJECT_NOT_EXTENSIBLE:
     "Cant_define_property_object_not_extensible",
   JSMSG_TYPED_ARRAY_BAD_ARGS: "Typed_array_invalid_arguments",
   JSMSG_GETTER_ONLY: "Getter_only",
   JSMSG_INVALID_DATE: "Invalid_date",
   JSMSG_DEPRECATED_STRING_METHOD: "Deprecated_String_generics",
-  JSMSG_DEPRECATED_TOLOCALEFORMAT: "Deprecated_toLocaleFormat",
   JSMSG_RESERVED_ID: "Reserved_identifier",
   JSMSG_BAD_CONST_ASSIGN: "Invalid_const_assignment",
   JSMSG_BAD_CONST_DECL: "Missing_initializer_in_const",
   JSMSG_OF_AFTER_FOR_LOOP_DECL: "Invalid_for-of_initializer",
   JSMSG_BAD_URI: "Malformed_URI",
   JSMSG_DEPRECATED_DELETE_OPERAND: "Delete_in_strict_mode",
   JSMSG_MISSING_FORMAL: "Missing_formal_parameter",
   JSMSG_CANT_TRUNCATE_ARRAY: "Non_configurable_array_element",
--- a/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js
+++ b/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js
@@ -143,16 +143,15 @@ test("new Date()", d => justDontThrow(Da
 test("new Date()", d => justDontThrow(Date.prototype.setFullYear.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.setUTCFullYear.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.setYear.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toGMTString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toISOString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toLocaleString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toLocaleDateString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toLocaleTimeString.call(d)));
-test("new Date()", d => justDontThrow(Date.prototype.toLocaleFormat.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toTimeString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toDateString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toSource.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.toString.call(d)));
 test("new Date()", d => justDontThrow(Date.prototype.valueOf.call(d)));
 
 throw "done";
--- a/js/src/js.msg
+++ b/js/src/js.msg
@@ -119,17 +119,16 @@ MSG_DEF(JSMSG_TOO_MANY_CON_SPREADARGS, 0
 MSG_DEF(JSMSG_TOO_MANY_FUN_SPREADARGS, 0, JSEXN_RANGEERR, "too many function arguments")
 MSG_DEF(JSMSG_UNINITIALIZED_LEXICAL,   1, JSEXN_REFERENCEERR, "can't access lexical declaration `{0}' before initialization")
 MSG_DEF(JSMSG_BAD_CONST_ASSIGN,        1, JSEXN_TYPEERR, "invalid assignment to const `{0}'")
 MSG_DEF(JSMSG_CANT_DECLARE_GLOBAL_BINDING, 2, JSEXN_TYPEERR, "cannot declare global binding `{0}': {1}")
 
 // Date
 MSG_DEF(JSMSG_INVALID_DATE,            0, JSEXN_RANGEERR, "invalid date")
 MSG_DEF(JSMSG_BAD_TOISOSTRING_PROP,    0, JSEXN_TYPEERR, "toISOString property is not callable")
-MSG_DEF(JSMSG_DEPRECATED_TOLOCALEFORMAT, 0, JSEXN_WARN, "Date.prototype.toLocaleFormat is deprecated; consider using Intl.DateTimeFormat instead")
 
 // String
 MSG_DEF(JSMSG_BAD_URI,                 0, JSEXN_URIERR, "malformed URI sequence")
 MSG_DEF(JSMSG_INVALID_NORMALIZE_FORM,  0, JSEXN_RANGEERR, "form must be one of 'NFC', 'NFD', 'NFKC', or 'NFKD'")
 MSG_DEF(JSMSG_NEGATIVE_REPETITION_COUNT, 0, JSEXN_RANGEERR, "repeat count must be non-negative")
 MSG_DEF(JSMSG_NOT_A_CODEPOINT,         1, JSEXN_RANGEERR, "{0} is not a valid code point")
 MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size")
 MSG_DEF(JSMSG_DEPRECATED_STRING_METHOD, 2, JSEXN_WARN, "String.{0} is deprecated; use String.prototype.{1} instead")
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -50,17 +50,16 @@ JSCompartment::JSCompartment(Zone* zone,
     behaviors_(options.behaviors()),
     zone_(zone),
     runtime_(zone->runtimeFromAnyThread()),
     principals_(nullptr),
     isSystem_(false),
     isAtomsCompartment_(false),
     isSelfHosting(false),
     marked(true),
-    warnedAboutDateToLocaleFormat(false),
     warnedAboutExprClosure(false),
     warnedAboutForEach(false),
     warnedAboutLegacyGenerator(false),
     warnedAboutStringGenericsMethods(0),
 #ifdef DEBUG
     firedOnNewGlobalObject(false),
 #endif
     global_(nullptr),
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -617,17 +617,16 @@ struct JSCompartment
   private:
     JSPrincipals*                principals_;
     bool                         isSystem_;
     bool                         isAtomsCompartment_;
 
   public:
     bool                         isSelfHosting;
     bool                         marked;
-    bool                         warnedAboutDateToLocaleFormat : 1;
     bool                         warnedAboutExprClosure : 1;
     bool                         warnedAboutForEach : 1;
     bool                         warnedAboutLegacyGenerator : 1;
     uint32_t                     warnedAboutStringGenericsMethods;
 
 #ifdef DEBUG
     bool                         firedOnNewGlobalObject;
 #endif
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -2728,16 +2728,17 @@ FormatDate(JSContext* cx, double utcTime
     }
 
     if (!str)
         return false;
     rval.setString(str);
     return true;
 }
 
+#if !EXPOSE_INTL_API
 static bool
 ToLocaleFormatHelper(JSContext* cx, HandleObject obj, const char* format, MutableHandleValue rval)
 {
     double utcTime = obj->as<DateObject>().UTCTime().toNumber();
 
     char buf[100];
     if (!IsFinite(utcTime)) {
         strcpy(buf, js_NaN_date_str);
@@ -2773,17 +2774,17 @@ ToLocaleFormatHelper(JSContext* cx, Hand
 
     JSString* str = NewStringCopyZ<CanGC>(cx, buf);
     if (!str)
         return false;
     rval.setString(str);
     return true;
 }
 
-#if !EXPOSE_INTL_API
+
 /* ES5 15.9.5.5. */
 MOZ_ALWAYS_INLINE bool
 date_toLocaleString_impl(JSContext* cx, const CallArgs& args)
 {
     /*
      * Use '%#c' for windows, because '%c' is backward-compatible and non-y2k
      * with msvc; '%#c' requests that a full year be used in the result string.
      */
@@ -2844,66 +2845,16 @@ date_toLocaleTimeString_impl(JSContext* 
 static bool
 date_toLocaleTimeString(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     return CallNonGenericMethod<IsDate, date_toLocaleTimeString_impl>(cx, args);
 }
 #endif /* !EXPOSE_INTL_API */
 
-MOZ_ALWAYS_INLINE bool
-date_toLocaleFormat_impl(JSContext* cx, const CallArgs& args)
-{
-    Rooted<DateObject*> dateObj(cx, &args.thisv().toObject().as<DateObject>());
-
-#if EXPOSE_INTL_API
-    if (!cx->compartment()->warnedAboutDateToLocaleFormat) {
-        if (!JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_WARNING, GetErrorMessage, nullptr,
-                                               JSMSG_DEPRECATED_TOLOCALEFORMAT))
-        {
-            return false;
-        }
-        cx->compartment()->warnedAboutDateToLocaleFormat = true;
-    }
-#endif
-
-    if (args.length() == 0) {
-        /*
-         * Use '%#c' for windows, because '%c' is backward-compatible and non-y2k
-         * with msvc; '%#c' requests that a full year be used in the result string.
-         */
-        static const char format[] =
-#if defined(_WIN32) && !defined(__MWERKS__)
-                                       "%#c"
-#else
-                                       "%c"
-#endif
-                                       ;
-
-        return ToLocaleFormatHelper(cx, dateObj, format, args.rval());
-    }
-
-    RootedString fmt(cx, ToString<CanGC>(cx, args[0]));
-    if (!fmt)
-        return false;
-
-    JSAutoByteString fmtbytes(cx, fmt);
-    if (!fmtbytes)
-        return false;
-
-    return ToLocaleFormatHelper(cx, dateObj, fmtbytes.ptr(), args.rval());
-}
-
-static bool
-date_toLocaleFormat(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    return CallNonGenericMethod<IsDate, date_toLocaleFormat_impl>(cx, args);
-}
-
 /* ES5 15.9.5.4. */
 MOZ_ALWAYS_INLINE bool
 date_toTimeString_impl(JSContext* cx, const CallArgs& args)
 {
     return FormatDate(cx, args.thisv().toObject().as<DateObject>().UTCTime().toNumber(),
                       FormatSpec::Time, args.rval());
 }
 
@@ -3050,17 +3001,16 @@ static const JSFunctionSpec date_methods
     JS_FN("setUTCHours",         date_setUTCHours,        4,0),
     JS_FN("setMinutes",          date_setMinutes,         3,0),
     JS_FN("setUTCMinutes",       date_setUTCMinutes,      3,0),
     JS_FN("setSeconds",          date_setSeconds,         2,0),
     JS_FN("setUTCSeconds",       date_setUTCSeconds,      2,0),
     JS_FN("setMilliseconds",     date_setMilliseconds,    1,0),
     JS_FN("setUTCMilliseconds",  date_setUTCMilliseconds, 1,0),
     JS_FN("toUTCString",         date_toGMTString,        0,0),
-    JS_FN("toLocaleFormat",      date_toLocaleFormat,     0,0),
 #if EXPOSE_INTL_API
     JS_SELF_HOSTED_FN(js_toLocaleString_str, "Date_toLocaleString", 0,0),
     JS_SELF_HOSTED_FN("toLocaleDateString", "Date_toLocaleDateString", 0,0),
     JS_SELF_HOSTED_FN("toLocaleTimeString", "Date_toLocaleTimeString", 0,0),
 #else
     JS_FN(js_toLocaleString_str, date_toLocaleString,     0,0),
     JS_FN("toLocaleDateString",  date_toLocaleDateString, 0,0),
     JS_FN("toLocaleTimeString",  date_toLocaleTimeString, 0,0),
--- a/js/src/tests/ecma_5/extensions/extension-methods-reject-null-undefined-this.js
+++ b/js/src/tests/ecma_5/extensions/extension-methods-reject-null-undefined-this.js
@@ -29,18 +29,17 @@ var ClassToMethodMap =
                "toSource"],
     Function: ["toSource"],
     Array:    ["toSource"],
     String:   ["toSource", "quote", "bold", "italics", "fixed", "fontsize",
                "fontcolor", "link", "anchor", "strike", "small", "big", "blink",
                "sup", "sub", "substr", "trimLeft", "trimRight", "toJSON"],
     Boolean:  ["toSource", "toJSON"],
     Number:   ["toSource", "toJSON"],
-    Date:     ["toSource", "toLocaleFormat", "getYear", "setYear",
-               "toGMTString"],
+    Date:     ["toSource", "getYear", "setYear",  "toGMTString"],
     RegExp:   ["toSource"],
     Error:    ["toSource"],
   };
 
 var badThisValues = [null, undefined];
 
 function testMethod(Class, className, method)
 {
deleted file mode 100644
--- a/js/src/tests/js1_5/extensions/toLocaleFormat-01.js
+++ /dev/null
@@ -1,230 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 291494;
-var summary = 'Date.prototype.toLocaleFormat extension';
-var actual = '';
-var expect = '';
-var temp;
-
-/*
- * SpiderMonkey only.
- *
- * When the output of toLocaleFormat exceeds 100 bytes toLocaleFormat
- * defaults to using toString to produce the result.
-*/
-
-enterFunc ('test');
-printBugNumber(BUGNUMBER);
-printStatus (summary);
-
-var date = new Date("06/05/2005 00:00:00 GMT-0000");
-
-expect = date.getTimezoneOffset() > 0 ? 'Sat' : 'Sun';
-actual = date.toLocaleFormat('%a');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%a")');
-
-expect = date.getTimezoneOffset() > 0 ? 'Saturday' : 'Sunday';
-actual = date.toLocaleFormat('%A');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%A")');
-
-expect = 'Jun';
-actual = date.toLocaleFormat('%b');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%b")');
-
-expect = 'June';
-actual = date.toLocaleFormat('%B');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%B")');
-
-expect = (date.getTimezoneOffset() > 0) ? '04' : '05';
-actual = date.toLocaleFormat('%d');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%d")');
-
-expect = '0';
-actual = String((Number(date.toLocaleFormat('%H')) +
-                 date.getTimezoneOffset()/60) % 24);
-reportCompare(expect, actual, 'Date.toLocaleFormat(%H)');
-
-expect = '12';
-actual = String(Number(date.toLocaleFormat('%I')) +
-                date.getTimezoneOffset()/60);
-reportCompare(expect, actual, 'Date.toLocaleFormat(%I)');
-
-expect = String(155 + ((date.getTimezoneOffset() > 0) ? 0 : 1));
-actual = date.toLocaleFormat('%j');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%j")');
-
-expect = '06';
-actual = date.toLocaleFormat('%m');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%m")');
-
-expect = '00';
-actual = date.toLocaleFormat('%M');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%M")');
-
-expect = true;
-temp   = date.toLocaleFormat('%p');
-actual = temp == 'AM' || date.toLocaleFormat('%p') == 'PM';
-reportCompare(expect, actual, 'Date.toLocaleFormat("%p") is AM or PM');
-
-expect = '00';
-actual = date.toLocaleFormat('%S');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%S")');
-
-expect = String(22 + ((date.getTimezoneOffset() > 0) ? 0 : 1));
-actual = date.toLocaleFormat('%U');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%U")');
-
-expect = String((6 + ((date.getTimezoneOffset() > 0) ? 0 : 1))%7);
-actual = date.toLocaleFormat('%w');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%w")');
-
-expect = '22';
-actual = date.toLocaleFormat('%W');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%W")');
-
-expect = '05';
-actual = date.toLocaleFormat('%y');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%y")');
-
-expect = '2005';
-actual = date.toLocaleFormat('%Y');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%Y")');
-
-expect = '%';
-actual = date.toLocaleFormat('%%');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%%")');
-
-
-expect = '1899 99';
-temp='%Y %y';
-actual = new Date(0, 0, 0, 13, 14, 15, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '1899189918991899189918991899189918991899189918991899189918991899189918991899189918991899';
-temp = '%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(0, 0, 0, 13, 14, 15, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = 'xxx189918991899189918991899189918991899189918991899189918991899189918991899189918991899189918991899';
-temp = 'xxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(0, 0, 0, 13, 14, 15, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = new Date(0, 0, 0, 13, 14, 15, 0).toString();
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(0, 0, 0, 13, 14, 15, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = 'xxxx189918991899189918991899189918991899';
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(0, 0, 0, 13, 14, 15, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-
-expect = '-51 49';
-temp = '%Y %y';
-actual = new Date(-51, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51';
-temp = '%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(-51, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = 'xxx-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51-51';
-temp = 'xxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(-51, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = new Date(-51, 0).toString();
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(-51, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-
-expect = '1851 51';
-temp = '%Y %y';
-actual = new Date(1851, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '1851185118511851185118511851185118511851185118511851185118511851185118511851185118511851';
-temp = '%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(1851, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = 'xxx185118511851185118511851185118511851185118511851185118511851185118511851185118511851185118511851';
-temp = 'xxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(1851, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = new Date(1851, 0).toString();
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(1851, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-
-expect = '-1 99';
-temp = '%Y %y';
-actual = new Date(-1, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '-100 00';
-temp = '%Y %y';
-actual = new Date(-100, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '1900 00';
-temp = '%Y %y';
-actual = new Date(0, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '1901 01';
-temp = '%Y %y';
-actual = new Date(1, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '1970 70';
-temp = '%Y %y';
-actual = new Date(1970, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-
-expect = new Date(32767, 0).toString();
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(32767, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = '32767327673276732767327673276732767327673276732767327673276732767327673276732767327673276732767';
-temp = '%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(32767, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = 'xxxx32767327673276732767327673276732767327673276732767327673276732767327673276732767327673276732767';
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(32767, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = new Date(32767, 0).toString();
-temp = 'xxxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(32767, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-
-expect = '-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999';
-temp = '%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(-9999, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = 'xxxx-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999-9999';
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(-9999, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
-
-expect = new Date(-9999, 0).toString();
-temp = 'xxxx%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y%Y';
-actual = new Date(-9999, 0).toLocaleFormat(temp);
-reportCompare(expect, actual, 'Date.toLocaleFormat("'+temp+'")');
deleted file mode 100644
--- a/js/src/tests/js1_5/extensions/toLocaleFormat-02.js
+++ /dev/null
@@ -1,105 +0,0 @@
-// |reftest| skip-if(xulRuntime.OS=="WINNT")
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-//-----------------------------------------------------------------------------
-var BUGNUMBER = 291494;
-var summary = 'Date.prototype.toLocaleFormat extension';
-var actual = '';
-var expect = '';
-var temp;
-
-/*
- * SpiderMonkey only.
- *
- * This test uses format strings which are not supported cross
- * platform and are expected to fail on at least some platforms
- * however they all currently pass on Linux (Fedora Core 6). They are
- * included here in order to increase coverage for cases where a crash
- * may occur.  These failures will be tracked in the
- * mozilla/js/tests/public-failures.txt list.
- * 
- */
-
-enterFunc ('test');
-printBugNumber(BUGNUMBER);
-printStatus (summary);
- 
-var date = new Date("06/05/2005 00:00:00 GMT-0000");
-
-expect = '20';
-actual = date.toLocaleFormat('%C');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%C")');
-
-expect = date.toLocaleFormat('%C%y');
-actual = date.toLocaleFormat('%Y');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%C%y") == ' +
-              'Date.toLocaleFormat("%Y")');
-
-expect = date.toLocaleFormat('%m/%d/%y');
-actual = date.toLocaleFormat('%D');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%m/%d/%y") == ' +
-              'Date.toLocaleFormat("%D")');
-
-expect = (date.getTimezoneOffset() > 0) ? ' 4' : ' 5';
-actual = date.toLocaleFormat('%e');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%e")');
-
-expect = date.toLocaleFormat('%Y-%m-%d');
-actual = date.toLocaleFormat('%F');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%Y-%m-%d") == ' +
-              'Date.toLocaleFormat("%F")');
-
-expect = '05';
-actual = date.toLocaleFormat('%g');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%g")');
-
-expect = '2005';
-actual = date.toLocaleFormat('%G');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%G")');
-
-expect = date.toLocaleFormat('%b');
-actual = date.toLocaleFormat('%h');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%b") == ' +
-              'Date.toLocaleFormat("%h")');
-
-expect = '\n';
-actual = date.toLocaleFormat('%n');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%n") == "\\n"');
-
-expect = date.toLocaleFormat('%I:%M:%S %p');
-actual = date.toLocaleFormat('%r');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%I:%M:%S %p") == ' +
-              'Date.toLocaleFormat("%r")');
-
-expect = date.toLocaleFormat('%H:%M');
-actual = date.toLocaleFormat('%R');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%H:%M") == ' +
-              'Date.toLocaleFormat("%R")');
-
-expect = '\t';
-actual = date.toLocaleFormat('%t');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%t") == "\\t"');
-
-expect = date.toLocaleFormat('%H:%M:%S');
-actual = date.toLocaleFormat('%T');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%H:%M:%S") == ' +
-              'Date.toLocaleFormat("%T")');
-
-expect = String(6 + ((date.getTimezoneOffset() > 0) ? 0 : 1));
-actual = date.toLocaleFormat('%u');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%u")');
-
-expect = '22';
-actual = date.toLocaleFormat('%V');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%V")');
-
-print('Note: For Date.toLocaleFormat("%m/%d/%y") == Date.toLocaleFormat("%x") ' + 
-      'to pass in Windows, the Regional Setting for the short date must be ' + 
-      'set to mm/dd/yyyy');
-expect = date.toLocaleFormat('%m/%d/%Y');
-actual = date.toLocaleFormat('%x');
-reportCompare(expect, actual, 'Date.toLocaleFormat("%m/%d/%Y") == ' +
-              'Date.toLocaleFormat("%x")');
deleted file mode 100644
--- a/js/src/tests/js1_5/extensions/toLocaleFormat-deprecated-no-Intl.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// |reftest| skip-if(!xulRuntime.shell||this.hasOwnProperty("Intl"))
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Don't warn about Date.prototype.toLocaleFormat() when Intl isn't supported.
-
-enableLastWarning();
-
-new Date().toLocaleFormat("%Y");
-
-var warning = getLastWarning();
-assertEq(warning, null, "warning shouldn't be emitted for toLocaleFormat");
-
-disableLastWarning();
-
-if (typeof reportCompare === 'function')
-    reportCompare(0, 0);
deleted file mode 100644
--- a/js/src/tests/js1_5/extensions/toLocaleFormat-deprecated.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// |reftest| skip-if(!xulRuntime.shell||!this.hasOwnProperty("Intl"))
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Warn once about Date.prototype.toLocaleFormat().
-
-enableLastWarning();
-
-new Date().toLocaleFormat("%Y");
-
-var warning = getLastWarning();
-assertEq(warning !== null, true, "warning should be emitted for toLocaleFormat");
-assertEq(warning.name, "Warning");
-assertEq(warning.message.indexOf("toLocaleFormat") !== -1, true,
-         "warning should mention toLocaleFormat");
-
-clearLastWarning();
-
-new Date().toLocaleFormat("%Y");
-
-warning = getLastWarning();
-assertEq(warning, null, "warning shouldn't be emitted for 2nd call to toLocaleFormat");
-
-disableLastWarning();
-
-if (typeof reportCompare === 'function')
-    reportCompare(0, 0);
--- a/js/src/vm/Time.cpp
+++ b/js/src/vm/Time.cpp
@@ -317,18 +317,16 @@ PRMJ_FormatTime(char* buf, int buflen, c
 
     /*
      * Years before 1900 and after 9999 cause strftime() to abort on Windows.
      * To avoid that we replace it with FAKE_YEAR_BASE + year % 100 and then
      * replace matching substrings in the strftime() result with the real year.
      * Note that FAKE_YEAR_BASE should be a multiple of 100 to make 2-digit
      * year formats (%y) work correctly (since we won't find the fake year
      * in that case).
-     * e.g. new Date(1873, 0).toLocaleFormat('%Y %y') => "1873 73"
-     * See bug 327869.
      */
 #define FAKE_YEAR_BASE 9900
     if (prtm->tm_year < 1900 || prtm->tm_year > 9999) {
         fake_tm_year = FAKE_YEAR_BASE + prtm->tm_year % 100;
         a.tm_year = fake_tm_year - 1900;
     }
     else {
         a.tm_year = prtm->tm_year - 1900;
--- a/js/xpconnect/src/XPCLocale.cpp
+++ b/js/xpconnect/src/XPCLocale.cpp
@@ -3,21 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Assertions.h"
 
 #include "jsapi.h"
 
-#include "nsCollationCID.h"
 #include "nsJSUtils.h"
-#include "nsICollation.h"
 #include "nsIObserver.h"
-#include "nsNativeCharsetUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/CycleCollectedJSContext.h"
 #include "mozilla/intl/LocaleService.h"
 #include "mozilla/Preferences.h"
 
 #include "xpcpublic.h"
 
@@ -71,142 +68,61 @@ XPCLocaleObserver::Observe(nsISupports* 
 struct XPCLocaleCallbacks : public JSLocaleCallbacks
 {
   XPCLocaleCallbacks()
   {
     MOZ_COUNT_CTOR(XPCLocaleCallbacks);
 
     // Disable the toLocaleUpper/Lower case hooks to use the standard,
     // locale-insensitive definition from String.prototype. (These hooks are
-    // only consulted when EXPOSE_INTL_API is not set.)
+    // only consulted when EXPOSE_INTL_API is not set.) Since EXPOSE_INTL_API
+    // is always set, these hooks should be disabled.
     localeToUpperCase = nullptr;
     localeToLowerCase = nullptr;
-    localeCompare = LocaleCompare;
-    localeToUnicode = LocaleToUnicode;
+    localeCompare = nullptr;
+    localeToUnicode = nullptr;
 
     // It's going to be retained by the ObserverService.
     RefPtr<XPCLocaleObserver> locObs = new XPCLocaleObserver();
     locObs->Init();
   }
 
   ~XPCLocaleCallbacks()
   {
     AssertThreadSafety();
     MOZ_COUNT_DTOR(XPCLocaleCallbacks);
   }
 
   /**
-   * Return the XPCLocaleCallbacks from |cx|'s runtime (see below).
-   */
-  static XPCLocaleCallbacks*
-  This(JSContext* cx)
-  {
-    return This(JS_GetRuntime(cx));
-  }
-
-  /**
    * Return the XPCLocaleCallbacks that's hidden away in |rt|. (This impl uses
    * the locale callbacks struct to store away its per-context data.)
    */
   static XPCLocaleCallbacks*
   This(JSRuntime* rt)
   {
     // Locale information for |cx| was associated using xpc_LocalizeContext;
     // assert and double-check this.
     const JSLocaleCallbacks* lc = JS_GetLocaleCallbacks(rt);
     MOZ_ASSERT(lc);
     MOZ_ASSERT(lc->localeToUpperCase == nullptr);
     MOZ_ASSERT(lc->localeToLowerCase == nullptr);
-    MOZ_ASSERT(lc->localeCompare == LocaleCompare);
-    MOZ_ASSERT(lc->localeToUnicode == LocaleToUnicode);
+    MOZ_ASSERT(lc->localeCompare == nullptr);
+    MOZ_ASSERT(lc->localeToUnicode == nullptr);
 
     const XPCLocaleCallbacks* ths = static_cast<const XPCLocaleCallbacks*>(lc);
     ths->AssertThreadSafety();
     return const_cast<XPCLocaleCallbacks*>(ths);
   }
 
-  static bool
-  LocaleToUnicode(JSContext* cx, const char* src, MutableHandleValue rval)
-  {
-    return This(cx)->ToUnicode(cx, src, rval);
-  }
-
-  static bool
-  LocaleCompare(JSContext* cx, HandleString src1, HandleString src2, MutableHandleValue rval)
-  {
-    return This(cx)->Compare(cx, src1, src2, rval);
-  }
-
 private:
-  bool
-  Compare(JSContext* cx, HandleString src1, HandleString src2, MutableHandleValue rval)
-  {
-    nsresult rv;
-
-    if (!mCollation) {
-      nsCOMPtr<nsICollationFactory> colFactory =
-        do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv);
-
-      if (NS_SUCCEEDED(rv)) {
-        rv = colFactory->CreateCollation(getter_AddRefs(mCollation));
-      }
-
-      if (NS_FAILED(rv)) {
-        xpc::Throw(cx, rv);
-        return false;
-      }
-    }
-
-    nsAutoJSString autoStr1, autoStr2;
-    if (!autoStr1.init(cx, src1) || !autoStr2.init(cx, src2)) {
-      return false;
-    }
-
-    int32_t result;
-    rv = mCollation->CompareString(nsICollation::kCollationStrengthDefault,
-                                   autoStr1, autoStr2, &result);
-
-    if (NS_FAILED(rv)) {
-      xpc::Throw(cx, rv);
-      return false;
-    }
-
-    rval.setInt32(result);
-    return true;
-  }
-
-  bool
-  ToUnicode(JSContext* cx, const char* src, MutableHandleValue rval)
-  {
-    // This code is only used by our prioprietary toLocaleFormat method
-    // and should be removed once we get rid of it.
-    // toLocaleFormat is used in non-ICU scenarios where we don't have
-    // access to any other date/time than the OS one, so we have to also
-    // use the OS locale for unicode conversions.
-    // See bug 1349470 for more details.
-    nsAutoString result;
-    NS_CopyNativeToUnicode(nsDependentCString(src), result);
-    JSString* ucstr =
-      JS_NewUCStringCopyN(cx, result.get(), result.Length());
-    if (ucstr) {
-      rval.setString(ucstr);
-      return true;
-    }
-
-    xpc::Throw(cx, NS_ERROR_OUT_OF_MEMORY);
-    return false;
-  }
-
   void AssertThreadSafety() const
   {
     NS_ASSERT_OWNINGTHREAD(XPCLocaleCallbacks);
   }
 
-  nsCOMPtr<nsICollation> mCollation;
-
   NS_DECL_OWNINGTHREAD
 };
 
 bool
 xpc_LocalizeRuntime(JSRuntime* rt)
 {
   // We want to assign the locale callbacks only the first time we
   // localize the context.
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -177,17 +177,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   gPrototypeProperties['Date'] =
     ["getTime", "getTimezoneOffset", "getYear", "getFullYear", "getUTCFullYear",
     "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay",
     "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds",
     "getUTCSeconds", "getMilliseconds", "getUTCMilliseconds", "setTime",
     "setYear", "setFullYear", "setUTCFullYear", "setMonth", "setUTCMonth",
     "setDate", "setUTCDate", "setHours", "setUTCHours", "setMinutes",
     "setUTCMinutes", "setSeconds", "setUTCSeconds", "setMilliseconds",
-    "setUTCMilliseconds", "toUTCString", "toLocaleFormat", "toLocaleString",
+    "setUTCMilliseconds", "toUTCString", "toLocaleString",
     "toLocaleDateString", "toLocaleTimeString", "toDateString", "toTimeString",
     "toISOString", "toJSON", "toSource", "toString", "valueOf", "constructor",
     "toGMTString", Symbol.toPrimitive];
   gConstructorProperties['Date'] = constructorProps(["UTC", "parse", "now"]);
   gPrototypeProperties['Object'] =
     ["constructor", "toSource", "toString", "toLocaleString", "valueOf",
      "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable",
      "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__",
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -5218,16 +5218,17 @@ SetupErrorHandling(const char* progname)
 #endif
 
   InstallSignalHandlers(progname);
 
   // Unbuffer stdout, needed for tinderbox tests.
   setbuf(stdout, 0);
 }
 
+// Note: This function should not be needed anymore. See Bug 818634 for details.
 void
 OverrideDefaultLocaleIfNeeded() {
   // Read pref to decide whether to override default locale with US English.
   if (mozilla::Preferences::GetBool("javascript.use_us_english_locale", false)) {
     // Set the application-wide C-locale. Needed to resist fingerprinting
     // of Date.toLocaleFormat(). We use the locale to "C.UTF-8" if possible,
     // to avoid interfering with non-ASCII keyboard input on some Linux desktops.
     // Otherwise fall back to the "C" locale, which is available on all platforms.