Bug 1142351 - Part 2: Warn about deprecated flag argument for String.prototype.{search,match,replace}. r=jandem

This commit is contained in:
Tooru Fujisawa 2015-03-25 00:36:35 +09:00
Родитель 0493238e94
Коммит 0ab6f5ff1f
6 изменённых файлов: 27 добавлений и 2 удалений

Просмотреть файл

@ -232,6 +232,7 @@ MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 0, JSEXN_SYNTAXERR, "missing } in compoun
MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'export' keyword")
MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword")
MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated")
MSG_DEF(JSMSG_DEPRECATED_FLAGS_ARG, 0, JSEXN_NONE, "flags argument of String.prototype.{search,match,replace} is deprecated")
MSG_DEF(JSMSG_DEPRECATED_LET_BLOCK, 0, JSEXN_NONE, "JavaScript 1.7's let blocks are deprecated")
MSG_DEF(JSMSG_DEPRECATED_FOR_EACH, 0, JSEXN_NONE, "JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead")
MSG_DEF(JSMSG_DEPRECATED_LET_EXPRESSION, 0, JSEXN_NONE, "JavaScript 1.7's let expressions are deprecated")

Просмотреть файл

@ -46,6 +46,7 @@ JSCompartment::JSCompartment(Zone *zone, const JS::CompartmentOptions &options =
isSelfHosting(false),
marked(true),
warnedAboutNoSuchMethod(false),
warnedAboutFlagsArgument(false),
addonId(options.addonIdOrNull()),
#ifdef DEBUG
firedOnNewGlobalObject(false),

Просмотреть файл

@ -149,6 +149,7 @@ struct JSCompartment
bool isSelfHosting;
bool marked;
bool warnedAboutNoSuchMethod;
bool warnedAboutFlagsArgument;
// A null add-on ID means that the compartment is not associated with an
// add-on.

Просмотреть файл

@ -2137,6 +2137,13 @@ class MOZ_STACK_CLASS StringRegExpGuard
cx->compartment()->addTelemetry(filename, JSCompartment::DeprecatedFlagsArgument);
}
if (!cx->compartment()->warnedAboutFlagsArgument) {
if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr,
JSMSG_DEPRECATED_FLAGS_ARG))
return false;
cx->compartment()->warnedAboutFlagsArgument = true;
}
opt = ToString<CanGC>(cx, args[optarg]);
if (!opt)
return false;

Просмотреть файл

@ -0,0 +1,15 @@
// |reftest| skip-if(!xulRuntime.shell)
var BUGNUMBER = 1142351;
var summary = 'Add console warnings for non-standard flag argument of String.prototype.{search,match,replace}.';
printBugNumber(BUGNUMBER);
printStatus (summary);
options("werror");
assertEq(evaluate("'aaaA'.match('a', 'i')", {catchTermination: true}), "terminated");
assertEq(evaluate("'aaaA'.search('a', 'i')", {catchTermination: true}), "terminated");
assertEq(evaluate("'aaaA'.replace('a', 'b', 'g')", {catchTermination: true}), "terminated");
if (typeof reportCompare === "function")
reportCompare(true, true);

Просмотреть файл

@ -29,11 +29,11 @@ namespace js {
*
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
*/
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 267;
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 268;
static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
static_assert(JSErr_Limit == 388,
static_assert(JSErr_Limit == 389,
"GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
"removed MSG_DEFs from js.msg, you should increment "
"XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "