mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1113369, part 1½ - Avoid regressing error messages by adding obj to the ObjectOpResult methods that could throw a TypeError. r=Waldo.
This commit is contained in:
parent
729237bb78
commit
8df02cae75
@ -70,7 +70,7 @@ class AutoIdVector;
|
||||
* if (!DefineProperty(cx, obj, id, ..., result))
|
||||
* return false;
|
||||
* if (!result)
|
||||
* return result.reportError(cx, id);
|
||||
* return result.reportError(cx, obj, id);
|
||||
*
|
||||
* Users don't have to call `result.report()`; another possible ending is:
|
||||
*
|
||||
@ -122,12 +122,14 @@ class ObjectOpResult
|
||||
* Convenience method. Return true if ok() or if strict is false; otherwise
|
||||
* throw a TypeError and return false.
|
||||
*/
|
||||
bool checkStrict(JSContext *cx, HandleId id) {
|
||||
return ok() || reportError(cx, id);
|
||||
bool checkStrict(JSContext *cx, HandleObject obj, HandleId id) {
|
||||
if (ok())
|
||||
return true;
|
||||
return reportError(cx, obj, id);
|
||||
}
|
||||
|
||||
/* Throw an exception. Call this only if !ok(). */
|
||||
JS_PUBLIC_API(bool) reportError(JSContext *cx, HandleId id);
|
||||
JS_PUBLIC_API(bool) reportError(JSContext *cx, HandleObject obj, HandleId id);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -138,14 +138,17 @@ ErrorTakesIdArgument(unsigned msg)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::ObjectOpResult::reportError(JSContext *cx, HandleId id)
|
||||
JS::ObjectOpResult::reportError(JSContext *cx, HandleObject obj, HandleId id)
|
||||
{
|
||||
static_assert(unsigned(OkCode) == unsigned(JSMSG_NOT_AN_ERROR),
|
||||
"unsigned value of OkCode must not be an error code");
|
||||
MOZ_ASSERT(!ok());
|
||||
MOZ_ASSERT(code_ != Uninitialized);
|
||||
|
||||
if (ErrorTakesIdArgument(code_)) {
|
||||
if (code_ == JSMSG_OBJECT_NOT_EXTENSIBLE) {
|
||||
RootedValue val(cx, ObjectValue(*obj));
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, code_, JSDVG_IGNORE_STACK, val,
|
||||
NullPtr(), nullptr, nullptr);
|
||||
} else if (ErrorTakesIdArgument(code_)) {
|
||||
RootedValue idv(cx, IdToValue(id));
|
||||
RootedString str(cx, ValueToSource(cx, idv));
|
||||
if (!str)
|
||||
|
@ -913,7 +913,7 @@ js::StandardDefineProperty(JSContext *cx, HandleObject obj, HandleId id, const P
|
||||
{
|
||||
ObjectOpResult success;
|
||||
return StandardDefineProperty(cx, obj, id, desc, success) &&
|
||||
success.checkStrict(cx, id);
|
||||
success.checkStrict(cx, obj, id);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -922,7 +922,7 @@ js::StandardDefineProperty(JSContext *cx, HandleObject obj, HandleId id,
|
||||
{
|
||||
ObjectOpResult success;
|
||||
return StandardDefineProperty(cx, obj, id, desc, success) &&
|
||||
success.checkStrict(cx, id);
|
||||
success.checkStrict(cx, obj, id);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -33,7 +33,7 @@ function test()
|
||||
|
||||
try
|
||||
{
|
||||
expect = "TypeError: can't redefine non-configurable property '5'";
|
||||
expect = "TypeError: can't redefine non-configurable property 5";
|
||||
"012345".__defineSetter__(5, function(){});
|
||||
}
|
||||
catch(ex)
|
||||
|
Loading…
Reference in New Issue
Block a user