Bug 1924888 - Swap order of arguments to DescribeScriptedCaller r=sfink

It's not a standard exception throwing JSAPI function. The one caveat here is
that I couldn't put JSContext in last position: There are default params to
preserve. So instead it's in second position, which still communicates that
it's not an exception throwing function

Differential Revision: https://phabricator.services.mozilla.com/D225726
This commit is contained in:
Matthew Gaudet 2024-10-16 15:58:19 +00:00
parent 9a8179d9d8
commit cfd64173df
18 changed files with 21 additions and 20 deletions

View File

@ -4430,7 +4430,7 @@ void Document::NoteScriptTrackingStatus(const nsACString& aURL,
bool Document::IsScriptTracking(JSContext* aCx) const {
JS::AutoFilename filename;
if (!JS::DescribeScriptedCaller(aCx, &filename)) {
if (!JS::DescribeScriptedCaller(&filename, aCx)) {
return false;
}
return mTrackingScripts.Contains(nsDependentCString(filename.get()));

View File

@ -52,7 +52,7 @@ JSCallingLocation JSCallingLocation::Get(JSContext* aCx) {
JS::AutoFilename filename;
uint32_t line;
JS::ColumnNumberOneOrigin column;
if (!JS::DescribeScriptedCaller(aCx, &filename, &line, &column)) {
if (!JS::DescribeScriptedCaller(&filename, aCx, &line, &column)) {
return result;
}
nsCString file;

View File

@ -5008,7 +5008,7 @@ nsGlobalWindowInner::ShowSlowScriptDialog(JSContext* aCx,
// minified scripts which is more common in Web content that is loaded in the
// content process.
uint32_t* linenop = XRE_IsParentProcess() ? &lineno : nullptr;
bool hasFrame = JS::DescribeScriptedCaller(aCx, &filename, linenop);
bool hasFrame = JS::DescribeScriptedCaller(&filename, aCx, linenop);
// Record the slow script event if we haven't done so already for this inner
// window (which represents a particular page to the user).

View File

@ -1030,7 +1030,7 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName,
JS::ColumnNumberOneOrigin columnNum;
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (cx && !JS::DescribeScriptedCaller(cx, nullptr, &lineNum, &columnNum)) {
if (cx && !JS::DescribeScriptedCaller(nullptr, cx, &lineNum, &columnNum)) {
JS_ClearPendingException(cx);
}

View File

@ -283,7 +283,7 @@ static bool AssertParentProcessWithCallerLocationImpl(GlobalObject& aGlobal,
JS::ColumnNumberOneOrigin colNo;
NS_ENSURE_TRUE(
JS::DescribeScriptedCaller(cx, &scriptFilename, &lineNo, &colNo), false);
JS::DescribeScriptedCaller(&scriptFilename, cx, &lineNo, &colNo), false);
NS_ENSURE_TRUE(scriptFilename.get(), false);

View File

@ -1417,7 +1417,7 @@ already_AddRefed<WebSocket> WebSocket::ConstructorCommon(
uint32_t lineno;
JS::ColumnNumberOneOrigin column;
JS::AutoFilename file;
if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno,
if (!JS::DescribeScriptedCaller(&file, aGlobal.Context(), &lineno,
&column)) {
NS_WARNING("Failed to get line number and filename in workers.");
}
@ -1664,7 +1664,7 @@ nsresult WebSocketImpl::Init(nsIGlobalObject* aWindowGlobal, JSContext* aCx,
uint32_t lineno;
JS::ColumnNumberOneOrigin column;
JS::AutoFilename file;
if (JS::DescribeScriptedCaller(aCx, &file, &lineno, &column)) {
if (JS::DescribeScriptedCaller(&file, aCx, &lineno, &column)) {
mScriptFile = file.get();
mScriptLine = lineno;
mScriptColumn = column.oneOriginValue();

View File

@ -3152,7 +3152,7 @@ nsresult WorkerPrivate::GetLoadInfo(
// We're being created outside of a window. Need to figure out the script
// that is creating us in order for us to use relative URIs later on.
JS::AutoFilename fileName;
if (JS::DescribeScriptedCaller(aCx, &fileName)) {
if (JS::DescribeScriptedCaller(&fileName, aCx)) {
// In most cases, fileName is URI. In a few other cases
// (e.g. xpcshell), fileName is a file path. Ideally, we would
// prefer testing whether fileName parses as an URI and fallback

View File

@ -7241,7 +7241,7 @@ static bool EvalReturningScope(JSContext* cx, unsigned argc, Value* vp) {
JS::AutoFilename filename;
uint32_t lineno;
JS::DescribeScriptedCaller(cx, &filename, &lineno);
JS::DescribeScriptedCaller(&filename, cx, &lineno);
// CompileOption should be created in the target global's realm.
RootedObject global(cx);

View File

@ -4674,7 +4674,7 @@ const char* AutoFilename::get() const {
return filename_.as<UniqueChars>().get();
}
JS_PUBLIC_API bool DescribeScriptedCaller(JSContext* cx, AutoFilename* filename,
JS_PUBLIC_API bool DescribeScriptedCaller(AutoFilename* filename, JSContext* cx,
uint32_t* lineno,
JS::ColumnNumberOneOrigin* column) {
if (filename) {

View File

@ -954,7 +954,7 @@ class MOZ_RAII JS_PUBLIC_API AutoFilename {
* record, this will also return false.
*/
extern JS_PUBLIC_API bool DescribeScriptedCaller(
JSContext* cx, AutoFilename* filename, uint32_t* lineno = nullptr,
AutoFilename* filename, JSContext* cx, uint32_t* lineno = nullptr,
JS::ColumnNumberOneOrigin* column = nullptr);
extern JS_PUBLIC_API JSObject* GetScriptedCallerGlobal(JSContext* cx);

View File

@ -194,7 +194,8 @@ JSString* ResolvePath(JSContext* cx, HandleString filenameStr,
JS::AutoFilename scriptFilename;
if (resolveMode == ScriptRelative) {
// Get the currently executing script's name.
if (!DescribeScriptedCaller(cx, &scriptFilename) || !scriptFilename.get()) {
if (!DescribeScriptedCaller(&scriptFilename, cx) || !scriptFilename.get()) {
JS_ReportErrorASCII(
cx, "cannot resolve path due to hidden or unscripted caller");
return nullptr;

View File

@ -4432,7 +4432,7 @@ static bool EvalInContext(JSContext* cx, unsigned argc, Value* vp) {
JS::AutoFilename filename;
uint32_t lineno;
DescribeScriptedCaller(cx, &filename, &lineno);
DescribeScriptedCaller(&filename, cx, &lineno);
{
sobj = UncheckedUnwrap(sobj, true);
@ -6967,7 +6967,7 @@ static bool ThisFilename(JSContext* cx, unsigned argc, Value* vp) {
CallArgs args = CallArgsFromVp(argc, vp);
JS::AutoFilename filename;
if (!DescribeScriptedCaller(cx, &filename) || !filename.get()) {
if (!DescribeScriptedCaller(&filename, cx) || !filename.get()) {
args.rval().setString(cx->runtime()->emptyString);
return true;
}

View File

@ -380,7 +380,7 @@ static bool DescribeScriptedCaller(JSContext* cx, ScriptedCaller* caller,
// back to the more ordinary false-if-error form.
JS::AutoFilename af;
if (JS::DescribeScriptedCaller(cx, &af, &caller->line)) {
if (JS::DescribeScriptedCaller(&af, cx, &caller->line)) {
caller->filename =
FormatIntroducedFilename(af.get(), caller->line, introducer);
if (!caller->filename) {

View File

@ -349,7 +349,7 @@ nsresult mozJSSubScriptLoader::DoLoadSubScriptWithOptions(
// Figure out who's calling us
JS::AutoFilename filename;
if (!JS::DescribeScriptedCaller(cx, &filename)) {
if (!JS::DescribeScriptedCaller(&filename, cx)) {
// No scripted frame means we don't know who's calling, bail.
return NS_ERROR_FAILURE;
}

View File

@ -599,7 +599,7 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) {
JS::AutoFilename scriptFilename;
// Computing the line number can be very expensive (see bug 1330231 for
// example), so don't request it here.
if (JS::DescribeScriptedCaller(cx, &scriptFilename)) {
if (JS::DescribeScriptedCaller(&scriptFilename, cx)) {
if (const char* file = scriptFilename.get()) {
filename.Assign(file, strlen(file));
}

View File

@ -163,7 +163,7 @@ static bool GetLocationProperty(JSContext* cx, unsigned argc, Value* vp) {
return false;
#else
JS::AutoFilename filename;
if (JS::DescribeScriptedCaller(cx, &filename) && filename.get()) {
if (JS::DescribeScriptedCaller(&filename, cx) && filename.get()) {
NS_ConvertUTF8toUTF16 filenameString(filename.get());
# if defined(XP_WIN)

View File

@ -220,7 +220,7 @@ bool ReportWrapperDenial(JSContext* cx, HandleId id, WrapperDenialType type,
AutoFilename filename;
uint32_t line = 0;
JS::ColumnNumberOneOrigin column;
DescribeScriptedCaller(cx, &filename, &line, &column);
DescribeScriptedCaller(&filename, cx, &line, &column);
// Warn to the terminal for the logs.
NS_WARNING(

View File

@ -1731,7 +1731,7 @@ static void MaybeCurrentCaller(nsACString& aFilename, uint32_t& aLineNum,
JS::AutoFilename scriptFilename;
JS::ColumnNumberOneOrigin columnNum;
if (JS::DescribeScriptedCaller(cx, &scriptFilename, &aLineNum, &columnNum)) {
if (JS::DescribeScriptedCaller(&scriptFilename, cx, &aLineNum, &columnNum)) {
if (const char* file = scriptFilename.get()) {
aFilename = nsDependentCString(file);
}