Bug 1135993 - Remove js::IsInNonStrictPropertySet. r=jorendorff

This commit is contained in:
Tom Schuster 2015-06-02 23:27:39 +02:00
Родитель 3091dad435
Коммит 8b3a3efd8b
8 изменённых файлов: 46 добавлений и 39 удалений

Просмотреть файл

@ -10457,15 +10457,13 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod):
# indexed setter. That's how the object would normally behave if
# you tried to set the property on it. That means we don't need to
# do anything special for Xrays here.
set += fill(
set += dedent(
"""
if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
return js::IsInNonStrictPropertySet(cx)
? opresult.succeed()
: ThrowErrorMessage(cx, MSG_NO_INDEXED_SETTER, "${name}");
*defined = true;
return opresult.failNoIndexedSetter();
}
""",
name=self.descriptor.name)
""")
namedSetter = self.descriptor.operations['NamedSetter']
if namedSetter:
@ -10498,13 +10496,11 @@ class CGDOMJSProxyHandler_defineProperty(ClassMethod):
$*{presenceChecker}
if (found) {
return js::IsInNonStrictPropertySet(cx)
? opresult.succeed()
: ThrowErrorMessage(cx, MSG_NO_NAMED_SETTER, "${name}");
*defined = true;
return opresult.failNoNamedSetter();
}
""",
presenceChecker=CGProxyNamedPresenceChecker(self.descriptor, foundVar="found").define(),
name=self.descriptor.name)
presenceChecker=CGProxyNamedPresenceChecker(self.descriptor, foundVar="found").define())
set += ("return mozilla::dom::DOMProxyHandler::defineProperty(%s);\n" %
", ".join(a.name for a in self.args))
return set

Просмотреть файл

@ -34,8 +34,6 @@ MSG_DEF(MSG_THIS_DOES_NOT_IMPLEMENT_INTERFACE, 1, JSEXN_TYPEERR, "\"this\" objec
MSG_DEF(MSG_NOT_IN_UNION, 2, JSEXN_TYPEERR, "{0} could not be converted to any of: {1}.")
MSG_DEF(MSG_ILLEGAL_CONSTRUCTOR, 0, JSEXN_TYPEERR, "Illegal constructor.")
MSG_DEF(MSG_CONSTRUCTOR_WITHOUT_NEW, 1, JSEXN_TYPEERR, "Constructor {0} requires 'new'")
MSG_DEF(MSG_NO_INDEXED_SETTER, 1, JSEXN_TYPEERR, "{0} doesn't have an indexed property setter.")
MSG_DEF(MSG_NO_NAMED_SETTER, 1, JSEXN_TYPEERR, "{0} doesn't have a named property setter.")
MSG_DEF(MSG_ENFORCE_RANGE_NON_FINITE, 1, JSEXN_TYPEERR, "Non-finite value is out of range for {0}.")
MSG_DEF(MSG_ENFORCE_RANGE_OUT_OF_RANGE, 1, JSEXN_TYPEERR, "Value is out of range for {0}.")
MSG_DEF(MSG_NOT_SEQUENCE, 1, JSEXN_TYPEERR, "{0} can't be converted to a sequence.")

Просмотреть файл

@ -142,6 +142,8 @@ class ObjectOpResult
JS_PUBLIC_API(bool) failCantDeleteWindowElement();
JS_PUBLIC_API(bool) failCantDeleteWindowNamedProperty();
JS_PUBLIC_API(bool) failCantPreventExtensions();
JS_PUBLIC_API(bool) failNoNamedSetter();
JS_PUBLIC_API(bool) failNoIndexedSetter();
uint32_t failureCode() const {
MOZ_ASSERT(!ok());

Просмотреть файл

@ -487,11 +487,13 @@ MSG_DEF(JSMSG_ATOMICS_TOO_LONG, 0, JSEXN_RANGEERR, "timeout value too l
MSG_DEF(JSMSG_ATOMICS_WAIT_NOT_ALLOWED, 0, JSEXN_ERR, "waiting is not allowed on this thread")
// XPConnect wrappers and DOM bindings
MSG_DEF(JSMSG_CANT_SET_INTERPOSED, 1, JSEXN_TYPEERR, "unable to set interposed data property '{0}'")
MSG_DEF(JSMSG_CANT_SET_INTERPOSED, 1, JSEXN_TYPEERR, "unable to set interposed data property '{0}'")
MSG_DEF(JSMSG_CANT_DEFINE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't define elements on a Window object")
MSG_DEF(JSMSG_CANT_DELETE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't delete elements from a Window object")
MSG_DEF(JSMSG_CANT_DELETE_WINDOW_NAMED_PROPERTY, 1, JSEXN_TYPEERR, "can't delete property {0} from window's named properties object")
MSG_DEF(JSMSG_CANT_PREVENT_EXTENSIONS, 0, JSEXN_TYPEERR, "can't prevent extensions on this proxy object")
MSG_DEF(JSMSG_CANT_PREVENT_EXTENSIONS, 0, JSEXN_TYPEERR, "can't prevent extensions on this proxy object")
MSG_DEF(JSMSG_NO_NAMED_SETTER, 2, JSEXN_TYPEERR, "{0} doesn't have a named property setter for '{1}'")
MSG_DEF(JSMSG_NO_INDEXED_SETTER, 2, JSEXN_TYPEERR, "{0} doesn't have an indexed property setter for '{1}'")
// Super
MSG_DEF(JSMSG_CANT_DELETE_SUPER, 0, JSEXN_REFERENCEERR, "invalid delete involving 'super'")

Просмотреть файл

@ -130,12 +130,21 @@ JS::CallArgs::requireAtLeast(JSContext* cx, const char* fnname, unsigned require
}
static bool
ErrorTakesIdArgument(unsigned msg)
ErrorTakesArguments(unsigned msg)
{
MOZ_ASSERT(msg < JSErr_Limit);
unsigned argCount = js_ErrorFormatString[msg].argCount;
MOZ_ASSERT(argCount <= 1);
return argCount == 1;
MOZ_ASSERT(argCount <= 2);
return argCount == 1 || argCount == 2;
}
static bool
ErrorTakesObjectArgument(unsigned msg)
{
MOZ_ASSERT(msg < JSErr_Limit);
unsigned argCount = js_ErrorFormatString[msg].argCount;
MOZ_ASSERT(argCount <= 2);
return argCount == 2;
}
JS_PUBLIC_API(bool)
@ -153,7 +162,7 @@ JS::ObjectOpResult::reportStrictErrorOrWarning(JSContext* cx, HandleObject obj,
return ReportValueErrorFlags(cx, flags, code_, JSDVG_IGNORE_STACK, val,
nullptr, nullptr, nullptr);
}
if (ErrorTakesIdArgument(code_)) {
if (ErrorTakesArguments(code_)) {
RootedValue idv(cx, IdToValue(id));
RootedString str(cx, ValueToSource(cx, idv));
if (!str)
@ -163,6 +172,11 @@ JS::ObjectOpResult::reportStrictErrorOrWarning(JSContext* cx, HandleObject obj,
if (!propName)
return false;
if (ErrorTakesObjectArgument(code_)) {
return JS_ReportErrorFlagsAndNumber(cx, flags, GetErrorMessage, nullptr, code_,
obj->getClass()->name, propName.ptr());
}
return JS_ReportErrorFlagsAndNumber(cx, flags, GetErrorMessage, nullptr, code_,
propName.ptr());
}
@ -174,7 +188,7 @@ JS::ObjectOpResult::reportStrictErrorOrWarning(JSContext* cx, HandleObject obj,
{
MOZ_ASSERT(code_ != Uninitialized);
MOZ_ASSERT(!ok());
MOZ_ASSERT(!ErrorTakesIdArgument(code_));
MOZ_ASSERT(!ErrorTakesArguments(code_));
unsigned flags = strict ? JSREPORT_ERROR : (JSREPORT_WARNING | JSREPORT_STRICT);
return JS_ReportErrorFlagsAndNumber(cx, flags, GetErrorMessage, nullptr, code_);
@ -234,6 +248,18 @@ JS::ObjectOpResult::failCantPreventExtensions()
return fail(JSMSG_CANT_PREVENT_EXTENSIONS);
}
JS_PUBLIC_API(bool)
JS::ObjectOpResult::failNoNamedSetter()
{
return fail(JSMSG_NO_NAMED_SETTER);
}
JS_PUBLIC_API(bool)
JS::ObjectOpResult::failNoIndexedSetter()
{
return fail(JSMSG_NO_INDEXED_SETTER);
}
JS_PUBLIC_API(int64_t)
JS_Now()
{

Просмотреть файл

@ -308,14 +308,6 @@ js::IsAtomsZone(JS::Zone* zone)
return zone->runtimeFromAnyThread()->isAtomsZone(zone);
}
JS_FRIEND_API(bool)
js::IsInNonStrictPropertySet(JSContext* cx)
{
jsbytecode* pc;
JSScript* script = cx->currentScript(&pc, JSContext::ALLOW_CROSS_COMPARTMENT);
return script && !IsStrictSetPC(pc) && (js_CodeSpec[*pc].format & JOF_SET);
}
JS_FRIEND_API(bool)
js::IsFunctionObject(JSObject* obj)
{

Просмотреть файл

@ -481,15 +481,6 @@ IsAtomsCompartment(JSCompartment* comp);
extern JS_FRIEND_API(bool)
IsAtomsZone(JS::Zone* zone);
/*
* Returns whether we're in a non-strict property set (in that we're in a
* non-strict script and the bytecode we're on is a property set). The return
* value does NOT indicate any sort of exception was thrown: it's just a
* boolean.
*/
extern JS_FRIEND_API(bool)
IsInNonStrictPropertySet(JSContext* cx);
struct WeakMapTracer
{
JSRuntime* runtime;

Просмотреть файл

@ -29,11 +29,11 @@ namespace js {
*
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
*/
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 287;
static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 288;
static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
static_assert(JSErr_Limit == 398,
static_assert(JSErr_Limit == 400,
"GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
"removed MSG_DEFs from js.msg, you should increment "
"XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "