tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 3437b89d31602ec35a3e70efe20d34b948dff1b7
parent 173673d9463b6afcf1151539cb7e994e06563fe4
Author: Iain Ireland <iireland@mozilla.com>
Date:   Wed,  5 Nov 2025 18:52:31 +0000

Bug 1881130: Factor out EvaluateInner r=jandem

Mechanical change in preparation for the next patch

Differential Revision: https://phabricator.services.mozilla.com/D271329

Diffstat:
Mjs/src/shell/js.cpp | 22++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp @@ -1113,6 +1113,10 @@ static mozilla::UniqueFreePtr<char[]> GetLine(FILE* file, const char* prompt) { return buffer; } +static bool EvaluateInner(JSContext* cx, HandleString code, + MutableHandleObject global, HandleObject opts, + HandleObject cacheEntry, MutableHandleValue rval); + static bool ShellInterruptCallback(JSContext* cx) { ShellContext* sc = GetShellContext(cx); if (!sc->serviceInterrupt) { @@ -2825,6 +2829,12 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) { RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); MOZ_ASSERT(global); + return EvaluateInner(cx, code, &global, opts, cacheEntry, args.rval()); +} + +static bool EvaluateInner(JSContext* cx, HandleString code, + MutableHandleObject global, HandleObject opts, + HandleObject cacheEntry, MutableHandleValue rval) { // Check "global" property before everything to use the given global's // option as the default value. Maybe<CompileOptions> maybeOptions; @@ -2835,8 +2845,8 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) { } if (!v.isUndefined()) { if (v.isObject()) { - global = js::CheckedUnwrapDynamic(&v.toObject(), cx, - /* stopAtWindowProxy = */ false); + global.set(js::CheckedUnwrapDynamic(&v.toObject(), cx, + /* stopAtWindowProxy = */ false)); if (!global) { return false; } @@ -3083,8 +3093,8 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) { if (execute) { if (!(envChain.empty() - ? JS_ExecuteScript(cx, script, args.rval()) - : JS_ExecuteScript(cx, envChain, script, args.rval()))) { + ? JS_ExecuteScript(cx, script, rval) + : JS_ExecuteScript(cx, envChain, script, rval))) { if (catchTermination && !JS_IsExceptionPending(cx)) { ShellContext* sc = GetShellContext(cx); if (sc->quitting) { @@ -3096,7 +3106,7 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) { if (!str) { return false; } - args.rval().setString(str); + rval.setString(str); return true; } return false; @@ -3155,7 +3165,7 @@ static bool Evaluate(JSContext* cx, unsigned argc, Value* vp) { } } - return JS_WrapValue(cx, args.rval()); + return JS_WrapValue(cx, rval); } JSString* js::shell::FileAsString(JSContext* cx, JS::HandleString pathnameStr) {