Bug 1341901 - Make timesAccessed property JS shell only. r?jandem
MozReview-Commit-ID: Iq8vqsFCPwj
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -2577,25 +2577,16 @@ HelperThreadCount(JSContext* cx, unsigne
if (CanUseExtraThreads())
args.rval().setInt32(HelperThreadState().threadCount);
else
args.rval().setInt32(0);
#endif
return true;
}
-static bool
-TimesAccessed(JSContext* cx, unsigned argc, Value* vp)
-{
- static int32_t accessed = 0;
- CallArgs args = CallArgsFromVp(argc, vp);
- args.rval().setInt32(++accessed);
- return true;
-}
-
#ifdef JS_TRACE_LOGGING
static bool
EnableTraceLogger(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
if (!TraceLoggerEnable(logger, cx))
return false;
@@ -4838,33 +4829,25 @@ static const JSFunctionSpecWithHelp Fuzz
JS_FN_HELP("getErrorNotes", GetErrorNotes, 1, 0,
"getErrorNotes(error)",
" Returns an array of error notes."),
JS_FS_HELP_END
};
-static const JSPropertySpec TestingProperties[] = {
- JS_PSG("timesAccessed", TimesAccessed, 0),
- JS_PS_END
-};
-
bool
js::DefineTestingFunctions(JSContext* cx, HandleObject obj, bool fuzzingSafe_,
bool disableOOMFunctions_)
{
fuzzingSafe = fuzzingSafe_;
if (EnvVarIsDefined("MOZ_FUZZING_SAFE"))
fuzzingSafe = true;
disableOOMFunctions = disableOOMFunctions_;
- if (!JS_DefineProperties(cx, obj, TestingProperties))
- return false;
-
if (!fuzzingSafe) {
if (!JS_DefineFunctionsWithHelp(cx, obj, FuzzingUnsafeTestingFunctions))
return false;
}
return JS_DefineFunctionsWithHelp(cx, obj, TestingFunctions);
}
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -7457,16 +7457,30 @@ ShellBuildId(JS::BuildIdCharVector* buil
static const JS::AsmJSCacheOps asmJSCacheOps = {
ShellOpenAsmJSCacheEntryForRead,
ShellCloseAsmJSCacheEntryForRead,
ShellOpenAsmJSCacheEntryForWrite,
ShellCloseAsmJSCacheEntryForWrite
};
+static bool
+TimesAccessed(JSContext* cx, unsigned argc, Value* vp)
+{
+ static int32_t accessed = 0;
+ CallArgs args = CallArgsFromVp(argc, vp);
+ args.rval().setInt32(++accessed);
+ return true;
+}
+
+static const JSPropertySpec TestingProperties[] = {
+ JS_PSG("timesAccessed", TimesAccessed, 0),
+ JS_PS_END
+};
+
static JSObject*
NewGlobalObject(JSContext* cx, JS::CompartmentOptions& options,
JSPrincipals* principals)
{
RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, principals,
JS::DontFireOnNewGlobalHook, options));
if (!glob)
return nullptr;
@@ -7498,16 +7512,18 @@ NewGlobalObject(JSContext* cx, JS::Compa
return nullptr;
if (!JS_DefineFunctionsWithHelp(cx, glob, shell_functions) ||
!JS_DefineProfilingFunctions(cx, glob))
{
return nullptr;
}
if (!js::DefineTestingFunctions(cx, glob, fuzzingSafe, disableOOMFunctions))
return nullptr;
+ if (!JS_DefineProperties(cx, glob, TestingProperties))
+ return nullptr;
if (!fuzzingSafe) {
if (!JS_DefineFunctionsWithHelp(cx, glob, fuzzing_unsafe_functions))
return nullptr;
if (!DefineConsole(cx, glob))
return nullptr;
}