diff --git a/devtools/server/actors/errordocs.js b/devtools/server/actors/errordocs.js index 17b05b7daa6d..60b02a9eaab5 100644 --- a/devtools/server/actors/errordocs.js +++ b/devtools/server/actors/errordocs.js @@ -73,7 +73,6 @@ const ErrorDocs = { 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", diff --git a/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js b/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js index f4b363ec6885..e6ca7e87fbcd 100644 --- a/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js +++ b/js/src/jit-test/tests/basic/testCrossCompartmentTransparency.js @@ -148,7 +148,6 @@ 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))); diff --git a/js/src/js.msg b/js/src/js.msg index 1dbabbfda3b3..d2419acf4ae2 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -124,7 +124,6 @@ MSG_DEF(JSMSG_CANT_DECLARE_GLOBAL_BINDING, 2, JSEXN_TYPEERR, "cannot declare glo // 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") diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 8e258e1142ca..551f52ca3584 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -55,7 +55,6 @@ JSCompartment::JSCompartment(Zone* zone, const JS::CompartmentOptions& options = isAtomsCompartment_(false), isSelfHosting(false), marked(true), - warnedAboutDateToLocaleFormat(false), warnedAboutExprClosure(false), warnedAboutForEach(false), warnedAboutLegacyGenerator(false), diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 45fef600252a..f62a1f7fdb09 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -622,7 +622,6 @@ struct JSCompartment public: bool isSelfHosting; bool marked; - bool warnedAboutDateToLocaleFormat : 1; bool warnedAboutExprClosure : 1; bool warnedAboutForEach : 1; bool warnedAboutLegacyGenerator : 1; diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 93590c70018d..01bd1c42a6cb 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -2733,6 +2733,7 @@ FormatDate(JSContext* cx, double utcTime, FormatSpec format, MutableHandleValue return true; } +#if !EXPOSE_INTL_API static bool ToLocaleFormatHelper(JSContext* cx, HandleObject obj, const char* format, MutableHandleValue rval) { @@ -2778,7 +2779,7 @@ ToLocaleFormatHelper(JSContext* cx, HandleObject obj, const char* format, Mutabl return true; } -#if !EXPOSE_INTL_API + /* ES5 15.9.5.5. */ MOZ_ALWAYS_INLINE bool date_toLocaleString_impl(JSContext* cx, const CallArgs& args) @@ -2849,56 +2850,6 @@ date_toLocaleTimeString(JSContext* cx, unsigned argc, Value* vp) } #endif /* !EXPOSE_INTL_API */ -MOZ_ALWAYS_INLINE bool -date_toLocaleFormat_impl(JSContext* cx, const CallArgs& args) -{ - Rooted dateObj(cx, &args.thisv().toObject().as()); - -#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(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(cx, args); -} - /* ES5 15.9.5.4. */ MOZ_ALWAYS_INLINE bool date_toTimeString_impl(JSContext* cx, const CallArgs& args) @@ -3055,7 +3006,6 @@ static const JSFunctionSpec date_methods[] = { 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), diff --git 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 index 5ea399fe8719..d0364a26ad09 100644 --- 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 @@ -34,8 +34,7 @@ var ClassToMethodMap = "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"], }; diff --git a/js/src/tests/js1_5/extensions/toLocaleFormat-01.js b/js/src/tests/js1_5/extensions/toLocaleFormat-01.js deleted file mode 100644 index 02f269125dd6..000000000000 --- 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+'")'); diff --git a/js/src/tests/js1_5/extensions/toLocaleFormat-02.js b/js/src/tests/js1_5/extensions/toLocaleFormat-02.js deleted file mode 100644 index efb4e8221426..000000000000 --- 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")'); diff --git a/js/src/tests/js1_5/extensions/toLocaleFormat-deprecated-no-Intl.js b/js/src/tests/js1_5/extensions/toLocaleFormat-deprecated-no-Intl.js deleted file mode 100644 index e1ffd646acb8..000000000000 --- 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); diff --git a/js/src/tests/js1_5/extensions/toLocaleFormat-deprecated.js b/js/src/tests/js1_5/extensions/toLocaleFormat-deprecated.js deleted file mode 100644 index 618aa6c877b7..000000000000 --- 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); diff --git a/js/src/vm/Time.cpp b/js/src/vm/Time.cpp index 9ad56f30a7d6..4578df197626 100644 --- a/js/src/vm/Time.cpp +++ b/js/src/vm/Time.cpp @@ -322,8 +322,6 @@ PRMJ_FormatTime(char* buf, int buflen, const char* fmt, PRMJTime* prtm) * 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) { diff --git a/js/xpconnect/src/XPCLocale.cpp b/js/xpconnect/src/XPCLocale.cpp index ce92cdea2ab9..cd6f2ded7c59 100644 --- a/js/xpconnect/src/XPCLocale.cpp +++ b/js/xpconnect/src/XPCLocale.cpp @@ -8,11 +8,8 @@ #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" @@ -76,11 +73,12 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks // 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 locObs = new XPCLocaleObserver(); @@ -93,15 +91,6 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks 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.) @@ -115,93 +104,20 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks 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(lc); ths->AssertThreadSafety(); return const_cast(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 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 mCollation; - NS_DECL_OWNINGTHREAD }; diff --git a/js/xpconnect/tests/chrome/test_xrayToJS.xul b/js/xpconnect/tests/chrome/test_xrayToJS.xul index 2100dea72d6c..74fd8fae0a60 100644 --- a/js/xpconnect/tests/chrome/test_xrayToJS.xul +++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul @@ -182,7 +182,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681 "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]; diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 3fc052559b58..74b4c17a7944 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -5223,6 +5223,7 @@ SetupErrorHandling(const char* progname) 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.