Backed out changeset 81723d4f90ed (bug 1287503) for jsreftest failures a=backout

This commit is contained in:
Wes Kocher 2016-08-31 16:40:12 -07:00
parent ed026e77c6
commit 4a88729982
7 changed files with 3 additions and 298 deletions

View File

@ -313,31 +313,9 @@ NumberingSystem::getName()
typedef void* UCalendar;
enum UCalendarType {
UCAL_TRADITIONAL,
UCAL_DEFAULT = UCAL_TRADITIONAL,
UCAL_GREGORIAN
};
enum UCalendarAttribute {
UCAL_FIRST_DAY_OF_WEEK,
UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
};
enum UCalendarDaysOfWeek {
UCAL_SUNDAY,
UCAL_MONDAY,
UCAL_TUESDAY,
UCAL_WEDNESDAY,
UCAL_THURSDAY,
UCAL_FRIDAY,
UCAL_SATURDAY
};
enum UCalendarWeekdayType {
UCAL_WEEKDAY,
UCAL_WEEKEND,
UCAL_WEEKEND_ONSET,
UCAL_WEEKEND_CEASE
UCAL_TRADITIONAL,
UCAL_DEFAULT = UCAL_TRADITIONAL,
UCAL_GREGORIAN
};
static UCalendar*
@ -366,19 +344,6 @@ ucal_close(UCalendar* cal)
MOZ_CRASH("ucal_close: Intl API disabled");
}
static UCalendarWeekdayType
ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status)
{
MOZ_CRASH("ucal_getDayOfWeekType: Intl API disabled");
}
static int32_t
ucal_getAttribute(const UCalendar* cal,
UCalendarAttribute attr)
{
MOZ_CRASH("ucal_getAttribute: Intl API disabled");
}
typedef void* UDateTimePatternGenerator;
static UDateTimePatternGenerator*
@ -2379,96 +2344,6 @@ js::intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp)
return true;
}
bool
js::intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 1);
JSAutoByteString locale(cx, args[0].toString());
if (!locale)
return false;
UErrorCode status = U_ZERO_ERROR;
const UChar* uTimeZone = nullptr;
int32_t uTimeZoneLength = 0;
UCalendar* cal = ucal_open(uTimeZone, uTimeZoneLength, locale.ptr(), UCAL_DEFAULT, &status);
if (U_FAILURE(status)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
return false;
}
ScopedICUObject<UCalendar, ucal_close> toClose(cal);
RootedObject info(cx, NewBuiltinClassInstance<PlainObject>(cx));
if (!info)
return false;
RootedValue v(cx);
int32_t firstDayOfWeek = ucal_getAttribute(cal, UCAL_FIRST_DAY_OF_WEEK);
v.setInt32(firstDayOfWeek);
if (!DefineProperty(cx, info, cx->names().firstDayOfWeek, v))
return false;
int32_t minDays = ucal_getAttribute(cal, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK);
v.setInt32(minDays);
if (!DefineProperty(cx, info, cx->names().minDays, v))
return false;
UCalendarWeekdayType prevDayType = ucal_getDayOfWeekType(cal, UCAL_SATURDAY, &status);
if (U_FAILURE(status)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
return false;
}
RootedValue weekendStart(cx), weekendEnd(cx);
for (int i = UCAL_SUNDAY; i <= UCAL_SATURDAY; i++) {
UCalendarDaysOfWeek dayOfWeek = static_cast<UCalendarDaysOfWeek>(i);
UCalendarWeekdayType type = ucal_getDayOfWeekType(cal, dayOfWeek, &status);
if (U_FAILURE(status)) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
return false;
}
if (prevDayType != type) {
switch (type) {
case UCAL_WEEKDAY:
// If the first Weekday after Weekend is Sunday (1),
// then the last Weekend day is Saturday (7).
// Otherwise we'll just take the previous days number.
weekendEnd.setInt32(i == 1 ? 7 : i - 1);
break;
case UCAL_WEEKEND:
weekendStart.setInt32(i);
break;
case UCAL_WEEKEND_ONSET:
case UCAL_WEEKEND_CEASE:
// At the time this code was added, ICU apparently never behaves this way,
// so just throw, so that users will report a bug and we can decide what to
// do.
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
return false;
default:
break;
}
}
prevDayType = type;
}
MOZ_ASSERT(weekendStart.isInt32());
MOZ_ASSERT(weekendEnd.isInt32());
if (!DefineProperty(cx, info, cx->names().weekendStart, weekendStart))
return false;
if (!DefineProperty(cx, info, cx->names().weekendEnd, weekendEnd))
return false;
args.rval().setObject(*info);
return true;
}
/******************** Intl ********************/

View File

@ -181,32 +181,6 @@ intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool
intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp);
/**
* Returns a plain object with calendar information for a single valid locale
* (callers must perform this validation). The object will have these
* properties:
*
* firstDayOfWeek
* an integer in the range 1=Sunday to 7=Saturday indicating the day
* considered the first day of the week in calendars, e.g. 1 for en-US,
* 2 for en-GB, 1 for bn-IN
* minDays
* an integer in the range of 1 to 7 indicating the minimum number
* of days required in the first week of the year, e.g. 1 for en-US, 4 for de
* weekendStart
* an integer in the range 1=Sunday to 7=Saturday indicating the day
* considered the beginning of a weekend, e.g. 7 for en-US, 7 for en-GB,
* 1 for bn-IN
* weekendEnd
* an integer in the range 1=Sunday to 7=Saturday indicating the day
* considered the end of a weekend, e.g. 1 for en-US, 1 for en-GB,
* 1 for bn-IN (note that "weekend" is *not* necessarily two days)
*
* NOTE: "calendar" and "locale" properties are *not* added to the object.
*/
extern MOZ_MUST_USE bool
intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp);
#if ENABLE_INTL_API
/**
* Cast char16_t* strings to UChar* strings used by ICU.

View File

@ -2882,25 +2882,3 @@ function Intl_getCanonicalLocales(locales) {
}
return result;
}
function Intl_getCalendarInfo(locales) {
const requestedLocales = CanonicalizeLocaleList(locales);
const DateTimeFormat = dateTimeFormatInternalProperties;
const localeData = DateTimeFormat.localeData;
const localeOpt = new Record();
localeOpt.localeMatcher = "best fit";
const r = ResolveLocale(callFunction(DateTimeFormat.availableLocales, DateTimeFormat),
requestedLocales,
localeOpt,
DateTimeFormat.relevantExtensionKeys,
localeData);
const result = intl_GetCalendarInfo(r.locale);
result.calendar = r.ca;
result.locale = r.locale;
return result;
}

View File

@ -878,30 +878,6 @@ SetPromiseRejectionTrackerCallback(JSContext* cx, unsigned argc, Value* vp)
return true;
}
#if ENABLE_INTL_API
static bool
AddIntlExtras(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (!args.get(0).isObject()) {
JS_ReportError(cx, "addIntlExtras must be passed an object");
return false;
}
JS::RootedObject intl(cx, &args[0].toObject());
static const JSFunctionSpec funcs[] = {
JS_SELF_HOSTED_FN("getCalendarInfo", "Intl_getCalendarInfo", 1, 0),
JS_FS_END
};
if (!JS_DefineFunctions(cx, intl, funcs))
return false;
args.rval().setUndefined();
return true;
}
#endif // ENABLE_INTL_API
static bool
EvalAndPrint(JSContext* cx, const char* bytes, size_t length,
int lineno, bool compileOnly)
@ -5824,16 +5800,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = {
"Sets the callback to be invoked whenever a Promise rejection is unhandled\n"
"or a previously-unhandled rejection becomes handled."),
#ifdef ENABLE_INTL_API
JS_FN_HELP("addIntlExtras", AddIntlExtras, 1, 0,
"addIntlExtras(obj)",
"Adds various not-yet-standardized Intl functions as properties on the\n"
"provided object (this should generally be Intl itself). The added\n"
"functions and their behavior are experimental: don't depend upon them\n"
"unless you're willing to update your code if these experimental APIs change\n"
"underneath you."),
#endif // ENABLE_INTL_API
JS_FS_HELP_END
};

View File

@ -1,83 +0,0 @@
// |reftest| skip-if(!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/. */
// Tests the getCalendarInfo function with a diverse set of arguments.
function checkCalendarInfo(info, expected)
{
assertEq(Object.getPrototypeOf(info), Object.prototype);
assertEq(info.firstDayOfWeek, expected.firstDayOfWeek);
assertEq(info.minDays, expected.minDays);
assertEq(info.weekendStart, expected.weekendStart);
assertEq(info.weekendEnd, expected.weekendEnd);
assertEq(info.calendar, expected.calendar);
assertEq(info.locale, expected.locale);
}
addIntlExtras(Intl);
let gCI = Intl.getCalendarInfo;
assertEq(gCI.length, 1);
checkCalendarInfo(gCI('en-US'), {
firstDayOfWeek: 1,
minDays: 1,
weekendStart: 7,
weekendEnd: 1,
calendar: "gregory",
locale: "en-US"
});
checkCalendarInfo(gCI('en-IL'), {
firstDayOfWeek: 1,
minDays: 1,
weekendStart: 6,
weekendEnd: 7,
calendar: "gregory",
locale: "en-IL"
});
checkCalendarInfo(gCI('en-GB'), {
firstDayOfWeek: 2,
minDays: 4,
weekendStart: 7,
weekendEnd: 1,
calendar: "gregory",
locale: "en-GB"
});
checkCalendarInfo(gCI('pl'), {
firstDayOfWeek: 2,
minDays: 4,
weekendStart: 7,
weekendEnd: 1,
calendar: "gregory",
locale: "pl"
});
checkCalendarInfo(gCI('ar-IQ'), {
firstDayOfWeek: 7,
minDays: 1,
weekendStart: 6,
weekendEnd: 7,
calendar: "gregory",
locale: "ar-IQ"
});
checkCalendarInfo(gCI('fa-IR'), {
firstDayOfWeek: 7,
minDays: 1,
weekendStart: 6,
weekendEnd: 6,
calendar: "persian",
locale: "fa-IR"
});
if (typeof reportCompare === 'function')
reportCompare(0, 0);

View File

@ -106,7 +106,6 @@
macro(fill, fill, "fill") \
macro(find, find, "find") \
macro(findIndex, findIndex, "findIndex") \
macro(firstDayOfWeek, firstDayOfWeek, "firstDayOfWeek") \
macro(fix, fix, "fix") \
macro(flags, flags, "flags") \
macro(float32, float32, "float32") \
@ -182,7 +181,6 @@
macro(maximumFractionDigits, maximumFractionDigits, "maximumFractionDigits") \
macro(maximumSignificantDigits, maximumSignificantDigits, "maximumSignificantDigits") \
macro(message, message, "message") \
macro(minDays, minDays, "minDays") \
macro(minimumFractionDigits, minimumFractionDigits, "minimumFractionDigits") \
macro(minimumIntegerDigits, minimumIntegerDigits, "minimumIntegerDigits") \
macro(minimumSignificantDigits, minimumSignificantDigits, "minimumSignificantDigits") \
@ -323,8 +321,6 @@
macro(RegExpSearcher, RegExpSearcher, "RegExpSearcher") \
macro(RegExpTester, RegExpTester, "RegExpTester") \
macro(weekday, weekday, "weekday") \
macro(weekendEnd, weekendEnd, "weekendEnd") \
macro(weekendStart, weekendStart, "weekendStart") \
macro(writable, writable, "writable") \
macro(year, year, "year") \
macro(yield, yield, "yield") \

View File

@ -2506,7 +2506,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("intl_DateTimeFormat_availableLocales", intl_DateTimeFormat_availableLocales, 0,0),
JS_FN("intl_FormatDateTime", intl_FormatDateTime, 2,0),
JS_FN("intl_FormatNumber", intl_FormatNumber, 2,0),
JS_FN("intl_GetCalendarInfo", intl_GetCalendarInfo, 1,0),
JS_FN("intl_NumberFormat", intl_NumberFormat, 2,0),
JS_FN("intl_NumberFormat_availableLocales", intl_NumberFormat_availableLocales, 0,0),
JS_FN("intl_numberingSystem", intl_numberingSystem, 1,0),