зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1271653 - Global environment functions should assert that referent is global;r=jimb
This commit is contained in:
Родитель
6de3b7e047
Коммит
8accfc65e9
|
@ -8662,6 +8662,9 @@ DebuggerObject_forceLexicalInitializationByName(JSContext *cx, unsigned argc, Va
|
||||||
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.forceLexicalInitializationByName", 1))
|
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.forceLexicalInitializationByName", 1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!DebuggerObject::requireGlobal(cx, object))
|
||||||
|
return false;
|
||||||
|
|
||||||
RootedId id(cx);
|
RootedId id(cx);
|
||||||
if (!ValueToIdentifier(cx, args[0], &id))
|
if (!ValueToIdentifier(cx, args[0], &id))
|
||||||
return false;
|
return false;
|
||||||
|
@ -8681,6 +8684,9 @@ DebuggerObject_executeInGlobal(JSContext* cx, unsigned argc, Value* vp)
|
||||||
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.executeInGlobal", 1))
|
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.executeInGlobal", 1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!DebuggerObject::requireGlobal(cx, object))
|
||||||
|
return false;
|
||||||
|
|
||||||
AutoStableStringChars stableChars(cx);
|
AutoStableStringChars stableChars(cx);
|
||||||
if (!ValueToStableChars(cx, "Debugger.Object.prototype.executeInGlobal", args[0],
|
if (!ValueToStableChars(cx, "Debugger.Object.prototype.executeInGlobal", args[0],
|
||||||
stableChars))
|
stableChars))
|
||||||
|
@ -8703,6 +8709,9 @@ DebuggerObject_executeInGlobalWithBindings(JSContext* cx, unsigned argc, Value*
|
||||||
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.executeInGlobalWithBindings", 2))
|
if (!args.requireAtLeast(cx, "Debugger.Object.prototype.executeInGlobalWithBindings", 2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!DebuggerObject::requireGlobal(cx, object))
|
||||||
|
return false;
|
||||||
|
|
||||||
AutoStableStringChars stableChars(cx);
|
AutoStableStringChars stableChars(cx);
|
||||||
if (!ValueToStableChars(cx, "Debugger.Object.prototype.executeInGlobalWithBindings", args[0],
|
if (!ValueToStableChars(cx, "Debugger.Object.prototype.executeInGlobalWithBindings", args[0],
|
||||||
stableChars))
|
stableChars))
|
||||||
|
@ -8871,6 +8880,14 @@ DebuggerObject::isDebuggeeFunction(JSContext* cx, Handle<DebuggerObject*> object
|
||||||
dbg->observesGlobal(&referent->as<JSFunction>().global());
|
dbg->observesGlobal(&referent->as<JSFunction>().global());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ bool
|
||||||
|
DebuggerObject::isGlobal(JSContext* cx, Handle<DebuggerObject*> object)
|
||||||
|
{
|
||||||
|
RootedObject referent(cx, object->referent());
|
||||||
|
|
||||||
|
return referent->is<GlobalObject>();
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
DebuggerObject::className(JSContext* cx, Handle<DebuggerObject*> object,
|
DebuggerObject::className(JSContext* cx, Handle<DebuggerObject*> object,
|
||||||
MutableHandleString result)
|
MutableHandleString result)
|
||||||
|
@ -9282,9 +9299,6 @@ DebuggerObject::call(JSContext* cx, Handle<DebuggerObject*> object, HandleValue
|
||||||
DebuggerObject::forceLexicalInitializationByName(JSContext* cx, Handle<DebuggerObject*> object,
|
DebuggerObject::forceLexicalInitializationByName(JSContext* cx, Handle<DebuggerObject*> object,
|
||||||
HandleId id, bool& result)
|
HandleId id, bool& result)
|
||||||
{
|
{
|
||||||
if (!DebuggerObject::requireGlobalObject(cx, object))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!JSID_IS_STRING(id)) {
|
if (!JSID_IS_STRING(id)) {
|
||||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
|
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
|
||||||
JSMSG_NOT_EXPECTED_TYPE, "Debugger.Object.prototype.forceLexicalInitializationByName",
|
JSMSG_NOT_EXPECTED_TYPE, "Debugger.Object.prototype.forceLexicalInitializationByName",
|
||||||
|
@ -9292,11 +9306,11 @@ DebuggerObject::forceLexicalInitializationByName(JSContext* cx, Handle<DebuggerO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(isGlobal(cx, object));
|
||||||
|
|
||||||
RootedObject referent(cx, object->referent());
|
Rooted<GlobalObject*> referent(cx, &object->referent()->as<GlobalObject>());
|
||||||
|
|
||||||
RootedObject globalLexical(cx, &referent->as<GlobalObject>().lexicalScope());
|
|
||||||
|
|
||||||
|
RootedObject globalLexical(cx, &referent->lexicalScope());
|
||||||
RootedObject pobj(cx);
|
RootedObject pobj(cx);
|
||||||
RootedShape shape(cx);
|
RootedShape shape(cx);
|
||||||
if (!LookupProperty(cx, globalLexical, id, &pobj, &shape))
|
if (!LookupProperty(cx, globalLexical, id, &pobj, &shape))
|
||||||
|
@ -9319,14 +9333,12 @@ DebuggerObject::executeInGlobal(JSContext* cx, Handle<DebuggerObject*> object,
|
||||||
mozilla::Range<const char16_t> chars, HandleObject bindings,
|
mozilla::Range<const char16_t> chars, HandleObject bindings,
|
||||||
const EvalOptions& options, MutableHandleValue result)
|
const EvalOptions& options, MutableHandleValue result)
|
||||||
{
|
{
|
||||||
if (!DebuggerObject::requireGlobalObject(cx, object))
|
MOZ_ASSERT(isGlobal(cx, object));
|
||||||
return false;
|
|
||||||
|
|
||||||
RootedObject referent(cx, object->referent());
|
Rooted<GlobalObject*> referent(cx, &object->referent()->as<GlobalObject>());
|
||||||
Debugger* dbg = object->owner();
|
Debugger* dbg = object->owner();
|
||||||
|
|
||||||
RootedObject globalLexical(cx, &referent->as<GlobalObject>().lexicalScope());
|
RootedObject globalLexical(cx, &referent->lexicalScope());
|
||||||
|
|
||||||
return DebuggerGenericEval(cx, chars, bindings, options, result, dbg, globalLexical,
|
return DebuggerGenericEval(cx, chars, bindings, options, result, dbg, globalLexical,
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
@ -9407,11 +9419,11 @@ DebuggerObject::unwrap(JSContext* cx, Handle<DebuggerObject*> object,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
DebuggerObject::requireGlobalObject(JSContext* cx, Handle<DebuggerObject*> object)
|
DebuggerObject::requireGlobal(JSContext* cx, Handle<DebuggerObject*> object)
|
||||||
{
|
{
|
||||||
RootedObject referent(cx, object->referent());
|
if (!DebuggerObject::isGlobal(cx, object)) {
|
||||||
|
RootedObject referent(cx, object->referent());
|
||||||
|
|
||||||
if (!referent->is<GlobalObject>()) {
|
|
||||||
const char* isWrapper = "";
|
const char* isWrapper = "";
|
||||||
const char* isWindowProxy = "";
|
const char* isWindowProxy = "";
|
||||||
|
|
||||||
|
|
|
@ -1053,6 +1053,7 @@ class DebuggerObject : public NativeObject
|
||||||
|
|
||||||
static bool isFunction(JSContext* cx, Handle<DebuggerObject*> object);
|
static bool isFunction(JSContext* cx, Handle<DebuggerObject*> object);
|
||||||
static bool isDebuggeeFunction(JSContext* cx, Handle<DebuggerObject*> object);
|
static bool isDebuggeeFunction(JSContext* cx, Handle<DebuggerObject*> object);
|
||||||
|
static bool isGlobal(JSContext* cx, Handle<DebuggerObject*> object);
|
||||||
static bool className(JSContext* cx, Handle<DebuggerObject*> object,
|
static bool className(JSContext* cx, Handle<DebuggerObject*> object,
|
||||||
MutableHandleString result);
|
MutableHandleString result);
|
||||||
static bool name(JSContext* cx, Handle<DebuggerObject*> object, MutableHandleString result);
|
static bool name(JSContext* cx, Handle<DebuggerObject*> object, MutableHandleString result);
|
||||||
|
@ -1101,6 +1102,8 @@ class DebuggerObject : public NativeObject
|
||||||
static bool unwrap(JSContext* cx, Handle<DebuggerObject*> object,
|
static bool unwrap(JSContext* cx, Handle<DebuggerObject*> object,
|
||||||
MutableHandle<DebuggerObject*> result);
|
MutableHandle<DebuggerObject*> result);
|
||||||
|
|
||||||
|
static bool requireGlobal(JSContext* cx, Handle<DebuggerObject*> object);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
OWNER_SLOT
|
OWNER_SLOT
|
||||||
|
@ -1114,8 +1117,6 @@ class DebuggerObject : public NativeObject
|
||||||
#endif // SPIDERMONKEY_PROMISE
|
#endif // SPIDERMONKEY_PROMISE
|
||||||
static const JSFunctionSpec methods_[];
|
static const JSFunctionSpec methods_[];
|
||||||
|
|
||||||
static bool requireGlobalObject(JSContext* cx, Handle<DebuggerObject*> object);
|
|
||||||
|
|
||||||
JSObject* referent() const {
|
JSObject* referent() const {
|
||||||
JSObject* obj = (JSObject*) getPrivate();
|
JSObject* obj = (JSObject*) getPrivate();
|
||||||
MOZ_ASSERT(obj);
|
MOZ_ASSERT(obj);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче