mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 03:49:42 +00:00
Bug 1873186 - Deprecate day of week late in Date.parse format r=arai
Differential Revision: https://phabricator.services.mozilla.com/D197838
This commit is contained in:
parent
6042640ee4
commit
231b768e20
@ -154,6 +154,7 @@ 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_LATE_WEEKDAY, 0, JSEXN_WARN, "day of week after day of month in date format is deprecated")
|
||||
|
||||
// String
|
||||
MSG_DEF(JSMSG_BAD_URI, 0, JSEXN_URIERR, "malformed URI sequence")
|
||||
|
34
js/src/jit-test/tests/basic/date-late-weekday-warning.js
Normal file
34
js/src/jit-test/tests/basic/date-late-weekday-warning.js
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Test deprecation warning for late weekday in Date.parse
|
||||
*/
|
||||
|
||||
function testWarn(date) {
|
||||
const g = newGlobal();
|
||||
g.eval(`Date.parse("${date}")`);
|
||||
const warning = getLastWarning();
|
||||
assertEq(warning !== null, true, `warning should be caught for ${date}`);
|
||||
assertEq(warning.name, "Warning", warning.name);
|
||||
|
||||
clearLastWarning();
|
||||
|
||||
g.eval(`Date.parse("${date}")`);
|
||||
assertEq(getLastWarning(), null, "warning should not be caught for 2nd ocurrence");
|
||||
}
|
||||
|
||||
function testNoWarn(date) {
|
||||
Date.parse(date);
|
||||
assertEq(getLastWarning(), null, `warning should not be caught for ${date}`);
|
||||
}
|
||||
|
||||
enableLastWarning();
|
||||
|
||||
testWarn("Sep 26 1995 Tues");
|
||||
testWarn("Sep 26 Tues 1995");
|
||||
testWarn("Sep 26 Tues 1995 Tues");
|
||||
testWarn("Sep 26 1995 10:Tues:00");
|
||||
|
||||
testNoWarn("Sep 26 1995");
|
||||
testNoWarn("Tues Sep 26 1995");
|
||||
testNoWarn("Sep Tues 26 1995");
|
||||
|
||||
disableLastWarning();
|
@ -56,6 +56,7 @@
|
||||
#include "vm/JSObject.h"
|
||||
#include "vm/StringType.h"
|
||||
#include "vm/Time.h"
|
||||
#include "vm/Warnings.h"
|
||||
|
||||
#include "vm/Compartment-inl.h" // For js::UnwrapAndTypeCheckThis
|
||||
#include "vm/GeckoProfiler-inl.h"
|
||||
@ -1910,6 +1911,16 @@ static bool ParseDate(DateTimeInfo::ForceUTC forceUTC, JSLinearString* s,
|
||||
// JSRuntime::setUseCounter out of AutoCheckCannotGC's scope.
|
||||
if (countLateWeekday) {
|
||||
cx->runtime()->setUseCounter(cx->global(), JSUseCounter::LATE_WEEKDAY);
|
||||
|
||||
if (!cx->realm()->warnedAboutDateLateWeekday) {
|
||||
if (!WarnNumberASCII(cx, JSMSG_DEPRECATED_LATE_WEEKDAY)) {
|
||||
// Proceed as if nothing happened if warning fails
|
||||
if (cx->isExceptionPending()) {
|
||||
cx->clearPendingException();
|
||||
}
|
||||
}
|
||||
cx->realm()->warnedAboutDateLateWeekday = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@ -435,6 +435,9 @@ class JS::Realm : public JS::shadow::Realm {
|
||||
// features are required.
|
||||
bool isUnlimitedStacksCapturingEnabled = false;
|
||||
|
||||
// Whether or not the deprecation warning for bug 1873186 has been shown.
|
||||
bool warnedAboutDateLateWeekday = false;
|
||||
|
||||
private:
|
||||
void updateDebuggerObservesFlag(unsigned flag);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user