diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index a4ffa4a11cba..a5af0da7ec30 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -880,8 +880,9 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle global) // |gInitialized == true| but |gPaths == nullptr|. We cannot // |MOZ_ASSERT| this, as this would kill precompile_cache.js, // so we simply return an error. - JS_ReportErrorNumber(cx, js::GetErrorMessage, nullptr, - JSMSG_CANT_OPEN, "OSFileConstants", "initialization has failed"); + JS_ReportErrorNumberASCII(cx, js::GetErrorMessage, nullptr, + JSMSG_CANT_OPEN, + "OSFileConstants", "initialization has failed"); return false; } diff --git a/js/src/asmjs/AsmJS.cpp b/js/src/asmjs/AsmJS.cpp index 036cab45b1b7..f853f2a859f7 100644 --- a/js/src/asmjs/AsmJS.cpp +++ b/js/src/asmjs/AsmJS.cpp @@ -8758,9 +8758,9 @@ js::IsAsmJSModuleLoadedFromCache(JSContext* cx, unsigned argc, Value* vp) JSFunction* fun = MaybeWrappedNativeFunction(args.get(0)); if (!fun || !IsAsmJSModule(fun)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_USE_ASM_TYPE_FAIL, - "argument passed to isAsmJSModuleLoadedFromCache is not a " - "validated asm.js module"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_USE_ASM_TYPE_FAIL, + "argument passed to isAsmJSModuleLoadedFromCache is not a " + "validated asm.js module"); return false; } diff --git a/js/src/asmjs/WasmJS.cpp b/js/src/asmjs/WasmJS.cpp index 6ec1eb39a5eb..9753094888e5 100644 --- a/js/src/asmjs/WasmJS.cpp +++ b/js/src/asmjs/WasmJS.cpp @@ -933,7 +933,7 @@ WasmMemoryObject::construct(JSContext* cx, unsigned argc, Value* vp) return false; if (!args.get(0).isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "memory"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "memory"); return false; } @@ -998,7 +998,7 @@ WasmMemoryObject::growImpl(JSContext* cx, const CallArgs& args) uint32_t ret = grow(memory, delta, cx); if (ret == uint32_t(-1)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "memory"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "memory"); return false; } @@ -1217,7 +1217,7 @@ WasmTableObject::construct(JSContext* cx, unsigned argc, Value* vp) return false; if (!args.get(0).isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "table"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_DESC_ARG, "table"); return false; } @@ -1381,7 +1381,7 @@ WasmTableObject::growImpl(JSContext* cx, const CallArgs& args) uint32_t ret = table->table().grow(delta, cx); if (ret == uint32_t(-1)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "table"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_GROW, "table"); return false; } diff --git a/js/src/asmjs/WasmModule.cpp b/js/src/asmjs/WasmModule.cpp index 785773840abe..4965c4f8d1e9 100644 --- a/js/src/asmjs/WasmModule.cpp +++ b/js/src/asmjs/WasmModule.cpp @@ -400,7 +400,8 @@ Module::initSegments(JSContext* cx, uint32_t offset = EvaluateInitExpr(globalImports, seg.offset); if (offset > tableLength || tableLength - offset < seg.elemCodeRangeIndices.length()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT, "elem", "table"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT, + "elem", "table"); return false; } } @@ -411,7 +412,8 @@ Module::initSegments(JSContext* cx, uint32_t offset = EvaluateInitExpr(globalImports, seg.offset); if (offset > memoryLength || memoryLength - offset < seg.length) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT, "data", "memory"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_BAD_FIT, + "data", "memory"); return false; } } diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index aaf2e3f1e504..3615398e7392 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -528,8 +528,8 @@ MapObject::construct(JSContext* cx, unsigned argc, Value* vp) if (done) break; if (!pairVal.isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_INVALID_MAP_ITERABLE, "Map"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INVALID_MAP_ITERABLE, + "Map"); return false; } diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index 6fd0b6549360..6fc509389fae 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -437,15 +437,15 @@ obj_setPrototypeOf(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 2) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "Object.setPrototypeOf", "1", ""); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "Object.setPrototypeOf", "1", ""); return false; } /* Step 1-2. */ if (args[0].isNullOrUndefined()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, - args[0].isNull() ? "null" : "undefined", "object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + args[0].isNull() ? "null" : "undefined", "object"); return false; } @@ -677,8 +677,8 @@ js::obj_create(JSContext* cx, unsigned argc, Value* vp) // Step 1. if (args.length() == 0) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "Object.create", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "Object.create", "0", "s"); return false; } @@ -981,8 +981,8 @@ obj_defineProperties(JSContext* cx, unsigned argc, Value* vp) /* Step 2. */ if (args.length() < 2) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "Object.defineProperties", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "Object.defineProperties", "0", "s"); return false; } RootedValue val(cx, args[1]); diff --git a/js/src/builtin/Reflect.cpp b/js/src/builtin/Reflect.cpp index ad532f6c1d88..d8b21bd4247e 100644 --- a/js/src/builtin/Reflect.cpp +++ b/js/src/builtin/Reflect.cpp @@ -64,8 +64,8 @@ Reflect_apply(JSContext* cx, unsigned argc, Value* vp) // Step 1. if (!IsCallable(args.get(0))) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, - "Reflect.apply argument"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_FUNCTION, + "Reflect.apply argument"); return false; } @@ -87,8 +87,8 @@ Reflect_construct(JSContext* cx, unsigned argc, Value* vp) // Step 1. if (!IsConstructor(args.get(0))) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, - "Reflect.construct argument"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, + "Reflect.construct argument"); return false; } @@ -97,8 +97,8 @@ Reflect_construct(JSContext* cx, unsigned argc, Value* vp) if (argc > 2) { newTarget = args[2]; if (!IsConstructor(newTarget)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, - "Reflect.construct argument 3"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, + "Reflect.construct argument 3"); return false; } } diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index 56906123cb4c..80360fdf9225 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -3546,8 +3546,8 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "Reflect.parse", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "Reflect.parse", "0", "s"); return false; } diff --git a/js/src/builtin/SymbolObject.cpp b/js/src/builtin/SymbolObject.cpp index 3e56d6fbc15a..cf48402d69b5 100644 --- a/js/src/builtin/SymbolObject.cpp +++ b/js/src/builtin/SymbolObject.cpp @@ -98,7 +98,7 @@ SymbolObject::construct(JSContext* cx, unsigned argc, Value* vp) // yet, so just throw a TypeError. CallArgs args = CallArgsFromVp(argc, vp); if (args.isConstructing()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, "Symbol"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_CONSTRUCTOR, "Symbol"); return false; } diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index a39b1ea1ec5d..d26e79471aae 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -2624,8 +2624,8 @@ FindPath(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (argc < 2) { - JS_ReportErrorNumber(cx, GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, - "findPath", "1", ""); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED, + "findPath", "1", ""); return false; } diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 92fc5b4a49b7..836e0a6144a8 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -670,8 +670,8 @@ ArrayMetaTypeDescr::construct(JSContext* cx, unsigned argc, Value* vp) // Expect two arguments. The first is a type object, the second is a length. if (args.length() < 2) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "ArrayType", "1", ""); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "ArrayType", "1", ""); return false; } diff --git a/js/src/builtin/WeakMapObject.cpp b/js/src/builtin/WeakMapObject.cpp index 0bb520de0738..35c6f46cc2e9 100644 --- a/js/src/builtin/WeakMapObject.cpp +++ b/js/src/builtin/WeakMapObject.cpp @@ -334,8 +334,8 @@ WeakMap_construct(JSContext* cx, unsigned argc, Value* vp) // Step 12f. if (!pairVal.isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_INVALID_MAP_ITERABLE, "WeakMap"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INVALID_MAP_ITERABLE, + "WeakMap"); return false; } diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 2d9c4c9b8d05..0d5a29a49e14 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -2520,8 +2520,8 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, JS::Object * have a mutable [[Prototype]]. */ if (obj->is()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_PROTO_OF, - "incompatible ArrayBuffer"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_PROTO_OF, + "incompatible ArrayBuffer"); return false; } @@ -2529,8 +2529,8 @@ js::SetPrototype(JSContext* cx, HandleObject obj, HandleObject proto, JS::Object * Disallow mutating the [[Prototype]] on Typed Objects, per the spec. */ if (obj->is()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_PROTO_OF, - "incompatible TypedObject"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_PROTO_OF, + "incompatible TypedObject"); return false; } @@ -3171,8 +3171,8 @@ js::ToObjectSlow(JSContext* cx, JS::HandleValue val, bool reportScanStack) if (reportScanStack) { ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, val, nullptr); } else { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, - val.isNull() ? "null" : "undefined", "object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + val.isNull() ? "null" : "undefined", "object"); } return nullptr; } diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 779e8b65e9fa..73169c22305e 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -468,8 +468,8 @@ ToStringForStringFunction(JSContext* cx, HandleValue thisv) return nobj->unbox(); } } else if (thisv.isNullOrUndefined()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, - thisv.isNull() ? "null" : "undefined", "object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + thisv.isNull() ? "null" : "undefined", "object"); return nullptr; } @@ -1587,8 +1587,8 @@ js::str_includes(JSContext* cx, unsigned argc, Value* vp) // Step 6 if (isRegExp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, - "first", "", "Regular Expression"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, + "first", "", "Regular Expression"); return false; } @@ -1811,8 +1811,8 @@ js::str_startsWith(JSContext* cx, unsigned argc, Value* vp) // Step 6 if (isRegExp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, - "first", "", "Regular Expression"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, + "first", "", "Regular Expression"); return false; } @@ -1877,8 +1877,8 @@ js::str_endsWith(JSContext* cx, unsigned argc, Value* vp) // Step 6 if (isRegExp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, - "first", "", "Regular Expression"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INVALID_ARG_TYPE, + "first", "", "Regular Expression"); return false; } diff --git a/js/src/proxy/BaseProxyHandler.cpp b/js/src/proxy/BaseProxyHandler.cpp index a628b65b6f1c..1810f1d10828 100644 --- a/js/src/proxy/BaseProxyHandler.cpp +++ b/js/src/proxy/BaseProxyHandler.cpp @@ -406,8 +406,8 @@ BaseProxyHandler::setPrototype(JSContext* cx, HandleObject proxy, HandleObject p // Disallow sets of protos on proxies with dynamic prototypes but no hook. // This keeps us away from the footgun of having the first proto set opt // you out of having dynamic protos altogether. - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_PROTO_OF, - "incompatible Proxy"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_SET_PROTO_OF, + "incompatible Proxy"); return false; } diff --git a/js/src/proxy/ScriptedProxyHandler.cpp b/js/src/proxy/ScriptedProxyHandler.cpp index 21029da81572..e9131dbd691e 100644 --- a/js/src/proxy/ScriptedProxyHandler.cpp +++ b/js/src/proxy/ScriptedProxyHandler.cpp @@ -1325,7 +1325,7 @@ ProxyCreate(JSContext* cx, CallArgs& args, const char* callerName) // Step 2. if (IsRevokedScriptedProxy(target)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_ARG_REVOKED, "1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_PROXY_ARG_REVOKED, "1"); return false; } @@ -1336,7 +1336,7 @@ ProxyCreate(JSContext* cx, CallArgs& args, const char* callerName) // Step 4. if (IsRevokedScriptedProxy(handler)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_ARG_REVOKED, "2"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_PROXY_ARG_REVOKED, "2"); return false; } diff --git a/js/src/shell/OSObject.cpp b/js/src/shell/OSObject.cpp index 9f1e58b5f6fd..d1019c77fd25 100644 --- a/js/src/shell/OSObject.cpp +++ b/js/src/shell/OSObject.cpp @@ -232,14 +232,15 @@ ReadFile(JSContext* cx, unsigned argc, Value* vp, bool scriptRelative) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1 || args.length() > 2) { - JS_ReportErrorNumber(cx, js::shell::my_GetErrorMessage, nullptr, - args.length() < 1 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, - "snarf"); + JS_ReportErrorNumberASCII(cx, js::shell::my_GetErrorMessage, nullptr, + args.length() < 1 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, + "snarf"); return false; } if (!args[0].isString() || (args.length() == 2 && !args[1].isString())) { - JS_ReportErrorNumber(cx, js::shell::my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "snarf"); + JS_ReportErrorNumberASCII(cx, js::shell::my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "snarf"); return false; } @@ -292,8 +293,8 @@ osfile_writeTypedArrayToFile(JSContext* cx, unsigned argc, Value* vp) !args[1].isObject() || !args[1].toObject().is()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - JSSMSG_INVALID_ARGS, "writeTypedArrayToFile"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "writeTypedArrayToFile"); return false; } @@ -489,8 +490,8 @@ static bool Redirect(JSContext* cx, const CallArgs& args, RCFile** outFile) { if (args.length() > 1) { - JS_ReportErrorNumber(cx, js::shell::my_GetErrorMessage, nullptr, - JSSMSG_INVALID_ARGS, "redirect"); + JS_ReportErrorNumberASCII(cx, js::shell::my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "redirect"); return false; } @@ -559,8 +560,8 @@ osfile_close(JSContext* cx, unsigned argc, Value* vp) { } if (!fileObj) { - JS_ReportErrorNumber(cx, js::shell::my_GetErrorMessage, nullptr, - JSSMSG_INVALID_ARGS, "close"); + JS_ReportErrorNumberASCII(cx, js::shell::my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "close"); return false; } @@ -612,7 +613,8 @@ ospath_isAbsolute(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1 || !args[0].isString()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "isAbsolute"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "isAbsolute"); return false; } @@ -630,7 +632,7 @@ ospath_join(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "join"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "join"); return false; } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 42ae9cd8ab2c..853024b13fa3 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -1078,7 +1078,8 @@ Version(JSContext* cx, unsigned argc, Value* vp) v = fvi; } if (v < 0 || v > JSVERSION_LATEST) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "version"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "version"); return false; } JS_SetVersionForCompartment(js::GetContextCompartment(cx), JSVersion(v)); @@ -1099,9 +1100,9 @@ CreateMappedArrayBuffer(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1 || args.length() > 3) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - args.length() < 1 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, - "createMappedArrayBuffer"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, + args.length() < 1 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, + "createMappedArrayBuffer"); return false; } @@ -1132,8 +1133,8 @@ CreateMappedArrayBuffer(JSContext* cx, unsigned argc, Value* vp) return false; sizeGiven = true; if (offset > size) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, + "2"); return false; } } @@ -1153,8 +1154,8 @@ CreateMappedArrayBuffer(JSContext* cx, unsigned argc, Value* vp) return false; } if (st.st_size < off_t(offset)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); return false; } size = st.st_size - offset; @@ -1182,9 +1183,9 @@ AddPromiseReactions(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 3) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - args.length() < 3 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, - "addPromiseReactions"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, + args.length() < 3 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, + "addPromiseReactions"); return false; } @@ -1193,8 +1194,8 @@ AddPromiseReactions(JSContext* cx, unsigned argc, Value* vp) promise = &args[0].toObject(); if (!promise || !JS::IsPromiseObject(promise)) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - JSSMSG_INVALID_ARGS, "addPromiseReactions"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "addPromiseReactions"); return false; } @@ -1207,8 +1208,8 @@ AddPromiseReactions(JSContext* cx, unsigned argc, Value* vp) onReject = &args[2].toObject(); if (!onResolve || !onResolve->is() || !onReject || !onReject->is()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - JSSMSG_INVALID_ARGS, "addPromiseReactions"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "addPromiseReactions"); return false; } @@ -1289,7 +1290,8 @@ LoadScript(JSContext* cx, unsigned argc, Value* vp, bool scriptRelative) for (unsigned i = 0; i < args.length(); i++) { str = JS::ToString(cx, args[i]); if (!str) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "load"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "load"); return false; } str = ResolvePath(cx, str, scriptRelative ? ScriptRelative : RootRelative); @@ -1434,7 +1436,8 @@ CacheEntry(JSContext* cx, unsigned argc, JS::Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1 || !args[0].isString()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "CacheEntry"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "CacheEntry"); return false; } @@ -1499,9 +1502,9 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1 || args.length() > 2) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - args.length() < 1 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, - "evaluate"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, + args.length() < 1 ? JSSMSG_NOT_ENOUGH_ARGS : JSSMSG_TOO_MANY_ARGS, + "evaluate"); return false; } @@ -1515,7 +1518,7 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp) } if (!code || (args.length() == 2 && args[1].isPrimitive())) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "evaluate"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "evaluate"); return false; } @@ -1569,8 +1572,8 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp) return false; } if (!global || !(JS_GetClass(global)->flags & JSCLASS_IS_GLOBAL)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "\"global\" passed to evaluate()", "not a global object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "\"global\" passed to evaluate()", "not a global object"); return false; } } @@ -1599,8 +1602,8 @@ Evaluate(JSContext* cx, unsigned argc, Value* vp) // bytecode cache is stored. if (loadBytecode || saveBytecode) { if (!cacheEntry) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, - "evaluate"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "evaluate"); return false; } } @@ -1800,7 +1803,7 @@ Run(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "run"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "run"); return false; } @@ -2102,8 +2105,8 @@ StartTimingMutator(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() > 0) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - JSSMSG_TOO_MANY_ARGS, "startTimingMutator"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_TOO_MANY_ARGS, + "startTimingMutator"); return false; } @@ -2121,8 +2124,8 @@ StopTimingMutator(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() > 0) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - JSSMSG_TOO_MANY_ARGS, "stopTimingMutator"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_TOO_MANY_ARGS, + "stopTimingMutator"); return false; } @@ -2159,13 +2162,13 @@ AssertEq(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (!(args.length() == 2 || (args.length() == 3 && args[2].isString()))) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, - (args.length() < 2) - ? JSSMSG_NOT_ENOUGH_ARGS - : (args.length() == 3) - ? JSSMSG_INVALID_ARGS - : JSSMSG_TOO_MANY_ARGS, - "assertEq"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, + (args.length() < 2) + ? JSSMSG_NOT_ENOUGH_ARGS + : (args.length() == 3) + ? JSSMSG_INVALID_ARGS + : JSSMSG_TOO_MANY_ARGS, + "assertEq"); return false; } @@ -3810,8 +3813,8 @@ Compile(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "compile", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "compile", "0", "s"); return false; } if (!args[0].isString()) { @@ -3846,8 +3849,8 @@ ParseModule(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() == 0) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_MORE_ARGS_NEEDED, "parseModule", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "parseModule", "0", "s"); return false; } @@ -3901,8 +3904,8 @@ SetModuleResolveHook(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_MORE_ARGS_NEEDED, "setModuleResolveHook", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "setModuleResolveHook", "0", "s"); return false; } @@ -3935,8 +3938,8 @@ Parse(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "parse", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "parse", "0", "s"); return false; } if (!args[0].isString()) { @@ -3986,8 +3989,8 @@ SyntaxParse(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "parse", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "parse", "0", "s"); return false; } if (!args[0].isString()) { @@ -4051,8 +4054,8 @@ OffThreadCompileScript(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() < 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "offThreadCompileScript", "0", "s"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + "offThreadCompileScript", "0", "s"); return false; } if (!args[0].isString()) { @@ -4068,7 +4071,8 @@ OffThreadCompileScript(JSContext* cx, unsigned argc, Value* vp) if (args.length() >= 2) { if (args[1].isPrimitive()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "evaluate"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "evaluate"); return false; } @@ -4159,8 +4163,8 @@ OffThreadCompileModule(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1 || !args[0].isString()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, - "offThreadCompileModule"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "offThreadCompileModule"); return false; } @@ -4501,8 +4505,8 @@ WrapWithProto(JSContext* cx, unsigned argc, Value* vp) proto = args[1]; } if (!obj.isObject() || !proto.isObjectOrNull()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, - "wrapWithProto"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "wrapWithProto"); return false; } @@ -4610,8 +4614,8 @@ GetSelfHostedValue(JSContext* cx, unsigned argc, Value* vp) CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1 || !args[0].isString()) { - JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, - "getSelfHostedValue"); + JS_ReportErrorNumberASCII(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, + "getSelfHostedValue"); return false; } RootedAtom srcAtom(cx, ToAtom(cx, args[0])); @@ -6631,7 +6635,8 @@ dom_constructor(JSContext* cx, unsigned argc, JS::Value* vp) return false; if (!protov.isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_PROTOTYPE, "FakeDOMObject"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BAD_PROTOTYPE, + "FakeDOMObject"); return false; } diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 1eeeabd3c8fc..63edd05277e8 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -1211,8 +1211,8 @@ ToNativeDebuggerObject(JSContext* cx, MutableHandleObject obj) Value owner = ndobj->getReservedSlot(JSSLOT_DEBUGOBJECT_OWNER); if (owner.isUndefined()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_DEBUG_PROTO, "Debugger.Object", "Debugger.Object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_DEBUG_PROTO, "Debugger.Object", "Debugger.Object"); return nullptr; } @@ -1228,8 +1228,8 @@ Debugger::unwrapDebuggeeObject(JSContext* cx, MutableHandleObject obj) Value owner = ndobj->getReservedSlot(JSSLOT_DEBUGOBJECT_OWNER); if (&owner.toObject() != object) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_DEBUG_WRONG_OWNER, "Debugger.Object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_DEBUG_WRONG_OWNER, "Debugger.Object"); return false; } @@ -3451,8 +3451,8 @@ Debugger::setUncaughtExceptionHook(JSContext* cx, unsigned argc, Value* vp) if (!args.requireAtLeast(cx, "Debugger.set uncaughtExceptionHook", 1)) return false; if (!args[0].isNull() && (!args[0].isObject() || !args[0].toObject().isCallable())) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ASSIGN_FUNCTION_OR_NULL, - "uncaughtExceptionHook"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_ASSIGN_FUNCTION_OR_NULL, + "uncaughtExceptionHook"); return false; } dbg->uncaughtExceptionHook = args[0].toObjectOrNull(); @@ -3539,8 +3539,8 @@ GlobalObject* Debugger::unwrapDebuggeeArgument(JSContext* cx, const Value& v) { if (!v.isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "argument", "not a global object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "argument", "not a global object"); return nullptr; } @@ -3566,8 +3566,8 @@ Debugger::unwrapDebuggeeArgument(JSContext* cx, const Value& v) /* If that didn't produce a global object, it's an error. */ if (!obj->is()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "argument", "not a global object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "argument", "not a global object"); return nullptr; } @@ -3762,8 +3762,8 @@ Debugger::construct(JSContext* cx, unsigned argc, Value* vp) if (!argobj) return false; if (!argobj->is()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CCW_REQUIRED, - "Debugger"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CCW_REQUIRED, + "Debugger"); return false; } } @@ -4126,8 +4126,9 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!GetProperty(cx, query, query, cx->names().url, &url)) return false; if (!url.isUndefined() && !url.isString()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "query object's 'url' property", "neither undefined nor a string"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "query object's 'url' property", + "neither undefined nor a string"); return false; } @@ -4138,9 +4139,9 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!debuggerSource.isUndefined()) { if (!debuggerSource.isObject() || debuggerSource.toObject().getClass() != &DebuggerSource_class) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "query object's 'source' property", - "not undefined nor a Debugger.Source object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "query object's 'source' property", + "not undefined nor a Debugger.Source object"); return false; } @@ -4154,8 +4155,8 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery * probably a mistake. */ if (!owner.isObject()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_DEBUG_PROTO, "Debugger.Source", "Debugger.Source"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_PROTO, + "Debugger.Source", "Debugger.Source"); return false; } @@ -4165,8 +4166,8 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery * but mixing Debugger.Sources is probably a sign of confusion. */ if (&owner.toObject() != debugger->object) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_DEBUG_WRONG_OWNER, "Debugger.Source"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_WRONG_OWNER, + "Debugger.Source"); return false; } @@ -4179,9 +4180,9 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery if (!GetProperty(cx, query, query, cx->names().displayURL, &displayURL)) return false; if (!displayURL.isUndefined() && !displayURL.isString()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "query object's 'displayURL' property", - "neither undefined nor a string"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "query object's 'displayURL' property", + "neither undefined nor a string"); return false; } @@ -4211,9 +4212,9 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery hasLine = true; line = doubleLine; } else { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "query object's 'line' property", - "neither undefined nor an integer"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "query object's 'line' property", + "neither undefined nor an integer"); return false; } @@ -4617,9 +4618,9 @@ class MOZ_STACK_CLASS Debugger::ObjectQuery return false; if (!cls.isUndefined()) { if (!cls.isString()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "query object's 'class' property", - "neither undefined nor a string"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "query object's 'class' property", + "neither undefined nor a string"); return false; } className = cls; @@ -6653,8 +6654,8 @@ DebuggerScript_getOffsetsCoverage(JSContext* cx, unsigned argc, Value* vp) static bool DebuggerScript_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "Debugger.Script"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "Debugger.Script"); return false; } @@ -6788,8 +6789,8 @@ Debugger::wrapWasmSource(JSContext* cx, Handle wasmInstance static bool DebuggerSource_construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "Debugger.Source"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "Debugger.Source"); return false; } @@ -7606,8 +7607,8 @@ DebuggerFrame::isLive() const DebuggerFrame::requireLive(JSContext* cx, HandleDebuggerFrame frame) { if (!frame->isLive()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, - "Debugger.Frame"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + "Debugger.Frame"); return false; } @@ -8210,8 +8211,8 @@ DebuggerFrame::evalWithBindingsMethod(JSContext* cx, unsigned argc, Value* vp) /* static */ bool DebuggerFrame::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "Debugger.Frame"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "Debugger.Frame"); return false; } @@ -8336,8 +8337,8 @@ DebuggerObject::checkThis(JSContext* cx, const CallArgs& args, const char* fnnam /* static */ bool DebuggerObject::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "Debugger.Object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "Debugger.Object"); return false; } @@ -10222,8 +10223,8 @@ DebuggerEnvironment::checkThis(JSContext* cx, const CallArgs& args, const char* if (requireDebuggee) { Rooted env(cx, static_cast(nthisobj->getPrivate())); if (!Debugger::fromChildJSObject(nthisobj)->observesGlobal(&env->global())) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGEE, - "Debugger.Environment", "environment"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGEE, + "Debugger.Environment", "environment"); return nullptr; } } @@ -10240,8 +10241,8 @@ DebuggerEnvironment::checkThis(JSContext* cx, const CallArgs& args, const char* /* static */ bool DebuggerEnvironment::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "Debugger.Environment"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "Debugger.Environment"); return false; } @@ -10446,8 +10447,8 @@ bool DebuggerEnvironment::requireDebuggee(JSContext* cx) const { if (!isDebuggee()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGEE, - "Debugger.Environment", "environment"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_DEBUGGEE, + "Debugger.Environment", "environment"); return false; } diff --git a/js/src/vm/DebuggerMemory.cpp b/js/src/vm/DebuggerMemory.cpp index a8619a21b0db..9df2a4c05708 100644 --- a/js/src/vm/DebuggerMemory.cpp +++ b/js/src/vm/DebuggerMemory.cpp @@ -66,8 +66,8 @@ DebuggerMemory::getDebugger() /* static */ bool DebuggerMemory::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "Debugger.Memory"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "Debugger.Source"); return false; } @@ -178,8 +178,8 @@ DebuggerMemory::drainAllocationsLog(JSContext* cx, unsigned argc, Value* vp) Debugger* dbg = memory->getDebugger(); if (!dbg->trackingAllocationSites) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NOT_TRACKING_ALLOCATIONS, - "drainAllocationsLog"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NOT_TRACKING_ALLOCATIONS, + "drainAllocationsLog"); return false; } @@ -266,9 +266,9 @@ DebuggerMemory::setMaxAllocationsLogLength(JSContext* cx, unsigned argc, Value* return false; if (max < 1) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "(set maxAllocationsLogLength)'s parameter", - "not a positive integer"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "(set maxAllocationsLogLength)'s parameter", + "not a positive integer"); return false; } @@ -307,9 +307,9 @@ DebuggerMemory::setAllocationSamplingProbability(JSContext* cx, unsigned argc, V // Careful! This must also reject NaN. if (!(0.0 <= probability && probability <= 1.0)) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, - "(set allocationSamplingProbability)'s parameter", - "not a number between 0 and 1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE, + "(set allocationSamplingProbability)'s parameter", + "not a number between 0 and 1"); return false; } diff --git a/js/src/vm/EnvironmentObject.cpp b/js/src/vm/EnvironmentObject.cpp index 14e19f0278e7..7451ae17df34 100644 --- a/js/src/vm/EnvironmentObject.cpp +++ b/js/src/vm/EnvironmentObject.cpp @@ -1811,8 +1811,8 @@ class DebugEnvironmentProxyHandler : public BaseProxyHandler return false; if (!argsObj) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, - "Debugger scope"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + "Debugger scope"); return false; } @@ -1834,8 +1834,8 @@ class DebugEnvironmentProxyHandler : public BaseProxyHandler return false; if (!success) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, - "Debugger scope"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + "Debugger scope"); return false; } @@ -1891,8 +1891,8 @@ class DebugEnvironmentProxyHandler : public BaseProxyHandler return false; if (!argsObj) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, - "Debugger env"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + "Debugger env"); return false; } @@ -1908,8 +1908,8 @@ class DebugEnvironmentProxyHandler : public BaseProxyHandler return false; if (!success) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, - "Debugger env"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_NOT_LIVE, + "Debugger env"); return false; } diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index a3b0f842f398..46eb019d5f73 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -4036,8 +4036,8 @@ CASE(JSOP_SUPERBASE) goto error; if (!superBase) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, - "null", "object"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO, + "null", "object"); goto error; } PUSH_OBJECT(*superBase); diff --git a/js/src/vm/SavedStacks.cpp b/js/src/vm/SavedStacks.cpp index 3cef981d7a73..2eecdc28c727 100644 --- a/js/src/vm/SavedStacks.cpp +++ b/js/src/vm/SavedStacks.cpp @@ -534,8 +534,8 @@ SavedFrame::isSelfHosted(JSContext* cx) /* static */ bool SavedFrame::construct(JSContext* cx, unsigned argc, Value* vp) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, - "SavedFrame"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NO_CONSTRUCTOR, + "SavedFrame"); return false; } diff --git a/js/src/vm/StructuredClone.cpp b/js/src/vm/StructuredClone.cpp index 5483ad6bea12..1212ce826f2f 100644 --- a/js/src/vm/StructuredClone.cpp +++ b/js/src/vm/StructuredClone.cpp @@ -265,8 +265,8 @@ class SCInput { bool readArray(T* p, size_t nelems); bool reportTruncated() { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "truncated"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + "truncated"); return false; } @@ -1110,8 +1110,8 @@ JSStructuredCloneWriter::startObject(HandleObject obj, bool* backref) } if (memory.count() == UINT32_MAX) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_NEED_DIET, "object graph to serialize"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_NEED_DIET, + "object graph to serialize"); return false; } @@ -1607,8 +1607,8 @@ JSStructuredCloneReader::checkDouble(double d) jsval_layout l; l.asDouble = d; if (!JSVAL_IS_DOUBLE_IMPL(l)) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "unrecognized NaN"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + "unrecognized NaN"); return false; } return true; @@ -1645,8 +1645,8 @@ JSString* JSStructuredCloneReader::readStringImpl(uint32_t nchars) { if (nchars > JSString::MAX_LENGTH) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "string length"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + "string length"); return nullptr; } Chars chars(context()); @@ -1678,8 +1678,8 @@ JSStructuredCloneReader::readTypedArray(uint32_t arrayType, uint32_t nelems, Mut bool v1Read) { if (arrayType > Scalar::Uint8Clamped) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "unhandled typed array element type"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + "unhandled typed array element type"); return false; } @@ -1894,8 +1894,9 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) return false; JS::ClippedTime t = JS::TimeClip(d); if (!NumbersAreIdentical(d, t.toDouble())) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "date"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, + JSMSG_SC_BAD_SERIALIZED_DATA, + "date"); return false; } JSObject* obj = NewDateObjectMsec(context(), t); @@ -1911,8 +1912,9 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) if (!in.readPair(&tag2, &stringData)) return false; if (tag2 != SCTAG_STRING) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "regexp"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, + JSMSG_SC_BAD_SERIALIZED_DATA, + "regexp"); return false; } JSString* str = readString(stringData); @@ -1944,9 +1946,9 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) case SCTAG_BACK_REFERENCE_OBJECT: { if (data >= allObjs.length() || !allObjs[data].isObject()) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, - "invalid back reference in input"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, + JSMSG_SC_BAD_SERIALIZED_DATA, + "invalid back reference in input"); return false; } vp.set(allObjs[data]); @@ -1956,9 +1958,8 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) case SCTAG_TRANSFER_MAP_HEADER: case SCTAG_TRANSFER_MAP_PENDING_ENTRY: // We should be past all the transfer map tags. - JS_ReportErrorNumber(context(), GetErrorMessage, NULL, - JSMSG_SC_BAD_SERIALIZED_DATA, - "invalid input"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, NULL, JSMSG_SC_BAD_SERIALIZED_DATA, + "invalid input"); return false; case SCTAG_ARRAY_BUFFER_OBJECT: @@ -2019,8 +2020,9 @@ JSStructuredCloneReader::startRead(MutableHandleValue vp) } if (!callbacks || !callbacks->read) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "unsupported type"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, + JSMSG_SC_BAD_SERIALIZED_DATA, + "unsupported type"); return false; } JSObject* obj = callbacks->read(context(), this, tag, data, closure); @@ -2051,8 +2053,8 @@ JSStructuredCloneReader::readHeader() MOZ_ALWAYS_TRUE(in.readPair(&tag, &data)); if (data < uint32_t(scope)) { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "incompatible structured clone scope"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + "incompatible structured clone scope"); return false; } @@ -2178,8 +2180,8 @@ JSStructuredCloneReader::readSavedFrame(uint32_t principalsTag) } else if (principalsTag == SCTAG_NULL_JSPRINCIPALS) { principals = nullptr; } else { - JS_ReportErrorNumber(context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "bad SavedFrame principals"); + JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_BAD_SERIALIZED_DATA, + "bad SavedFrame principals"); return nullptr; } savedFrame->initPrincipalsAlreadyHeld(principals); @@ -2572,8 +2574,9 @@ JS_ReadTypedArray(JSStructuredCloneReader* r, MutableHandleValue vp) return false; return r->readTypedArray(arrayType, nelems, vp); } else { - JS_ReportErrorNumber(r->context(), GetErrorMessage, nullptr, - JSMSG_SC_BAD_SERIALIZED_DATA, "expected type array"); + JS_ReportErrorNumberASCII(r->context(), GetErrorMessage, nullptr, + JSMSG_SC_BAD_SERIALIZED_DATA, + "expected type array"); return false; } } diff --git a/js/src/vm/TraceLogging.cpp b/js/src/vm/TraceLogging.cpp index 1fb13c1b7a3f..3221b923bc16 100644 --- a/js/src/vm/TraceLogging.cpp +++ b/js/src/vm/TraceLogging.cpp @@ -229,8 +229,8 @@ TraceLoggerThread::enable(JSContext* cx) script = it.script(); engine = it.isIonJS() ? TraceLogger_IonMonkey : TraceLogger_Baseline; } else if (act->isWasm()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_TRACELOGGER_ENABLE_FAIL, - "not yet supported in wasm code"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TRACELOGGER_ENABLE_FAIL, + "not yet supported in wasm code"); return false; } else { MOZ_ASSERT(act->isInterpreter()); diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 6b903e021cba..ca3ecda85f03 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -734,8 +734,9 @@ class TypedArrayObjectTemplate : public TypedArrayObject if (!ToInt32(cx, args[1], &byteOffset)) return nullptr; if (byteOffset < 0) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_TYPED_ARRAY_NEGATIVE_ARG, "1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TYPED_ARRAY_NEGATIVE_ARG, + "1"); return nullptr; } @@ -743,8 +744,9 @@ class TypedArrayObjectTemplate : public TypedArrayObject if (!ToInt32(cx, args[2], &length)) return nullptr; if (length < 0) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_TYPED_ARRAY_NEGATIVE_ARG, "2"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_TYPED_ARRAY_NEGATIVE_ARG, + "2"); return nullptr; } } @@ -888,8 +890,8 @@ class TypedArrayObjectTemplate : public TypedArrayObject MutableHandle buffer) { if (count >= INT32_MAX / unit) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_NEED_DIET, "size and count"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_NEED_DIET, + "size and count"); return false; } uint32_t byteLength = count * unit; @@ -1616,7 +1618,8 @@ DataViewObject::getAndCheckConstructorArgs(JSContext* cx, JSObject* bufobj, cons if (!ToUint32(cx, args[1], &byteOffset)) return false; if (byteOffset > INT32_MAX) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, + "1"); return false; } } @@ -1628,7 +1631,8 @@ DataViewObject::getAndCheckConstructorArgs(JSContext* cx, JSObject* bufobj, cons if (args.length() > 1) { if (byteOffset > byteLength) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, + "1"); return false; } @@ -1638,16 +1642,16 @@ DataViewObject::getAndCheckConstructorArgs(JSContext* cx, JSObject* bufobj, cons if (!ToUint32(cx, args[2], &byteLength)) return false; if (byteLength > INT32_MAX) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_ARG_INDEX_OUT_OF_RANGE, "2"); return false; } MOZ_ASSERT(byteOffset + byteLength >= byteOffset, "can't overflow: both numbers are less than INT32_MAX"); if (byteOffset + byteLength > buffer->byteLength()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, - JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, + JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); return false; } } @@ -1773,7 +1777,8 @@ DataViewObject::getDataPointer(JSContext* cx, Handle obj, doubl const size_t TypeSize = sizeof(NativeType); if (offset > UINT32_MAX - TypeSize || offset + TypeSize > obj->byteLength()) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, "1"); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_ARG_INDEX_OUT_OF_RANGE, + "1"); return nullptr; }