diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 4c09b224f5e..5a5ed8dd4b4 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -45,6 +45,7 @@ JSCompartment::JSCompartment(Zone *zone, const JS::CompartmentOptions &options = isSystem(false), isSelfHosting(false), marked(true), + warnedAboutNoSuchMethod(false), addonId(options.addonIdOrNull()), #ifdef DEBUG firedOnNewGlobalObject(false), diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 2208fb1eea6..82ef976d2d1 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -149,6 +149,7 @@ struct JSCompartment bool isSystem; bool isSelfHosting; bool marked; + bool warnedAboutNoSuchMethod; // A null add-on ID means that the compartment is not associated with an // add-on. diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 5d8d81930a9..7ebe053f573 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -180,6 +180,17 @@ js::OnUnknownMethod(JSContext *cx, HandleObject obj, Value idval_, MutableHandle static bool NoSuchMethod(JSContext *cx, unsigned argc, Value *vp) { + if (JSScript *script = cx->currentScript()) { + const char *filename = script->filename(); + cx->compartment()->addTelemetry(filename, JSCompartment::DeprecatedNoSuchMethod); + } + + if (!cx->compartment()->warnedAboutNoSuchMethod) { + if (!JS_ReportWarning(cx, "__noSuchMethod__ is deprecated")) + return false; + cx->compartment()->warnedAboutNoSuchMethod = true; + } + InvokeArgs args(cx); if (!args.init(2)) return false; @@ -198,12 +209,6 @@ NoSuchMethod(JSContext *cx, unsigned argc, Value *vp) args[1].setObject(*argsobj); bool ok = Invoke(cx, args); vp[0] = args.rval(); - - if (JSScript *script = cx->currentScript()) { - const char *filename = script->filename(); - cx->compartment()->addTelemetry(filename, JSCompartment::DeprecatedNoSuchMethod); - } - return ok; }