mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 867863. Be a little more careful in GlobalObject initialization. r=peterv
This commit is contained in:
parent
5a20ce811f
commit
797571f64b
@ -1631,6 +1631,7 @@ GlobalObject::GlobalObject(JSContext* aCx, JSObject* aObject)
|
||||
Maybe<JSAutoCompartment> ac;
|
||||
mGlobalJSObject = GetGlobalObject<true>(aCx, aObject, ac);
|
||||
if (!mGlobalJSObject) {
|
||||
mGlobalObject = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1717,14 +1718,18 @@ InterfaceHasInstance(JSContext* cx, JSHandleObject obj, JSMutableHandleValue vp,
|
||||
return InterfaceHasInstance(cx, obj, instanceObject, bp);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ReportLenientThisUnwrappingFailure(JSContext* cx, JS::Handle<JSObject*> obj)
|
||||
{
|
||||
GlobalObject global(cx, obj);
|
||||
if (global.Failed()) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());
|
||||
if (window && window->GetDoc()) {
|
||||
window->GetDoc()->WarnOnceAbout(nsIDocument::eLenientThis);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Date implementation methods
|
||||
|
@ -1768,8 +1768,9 @@ JSBool
|
||||
InterfaceHasInstance(JSContext* cx, JSHandleObject obj, JSMutableHandleValue vp,
|
||||
JSBool* bp);
|
||||
|
||||
// Helper for lenient getters/setters to report to console
|
||||
void
|
||||
// Helper for lenient getters/setters to report to console. If this
|
||||
// returns false, we couldn't even get a global.
|
||||
bool
|
||||
ReportLenientThisUnwrappingFailure(JSContext* cx, JS::Handle<JSObject*> obj);
|
||||
|
||||
inline JSObject*
|
||||
|
@ -5010,7 +5010,9 @@ class CGGenericGetter(CGAbstractBindingMethod):
|
||||
name = "genericLenientGetter"
|
||||
unwrapFailureCode = (
|
||||
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
|
||||
"ReportLenientThisUnwrappingFailure(cx, obj);\n"
|
||||
"if (!ReportLenientThisUnwrappingFailure(cx, obj)) {\n"
|
||||
" return false;\n"
|
||||
"}\n"
|
||||
"JS_SET_RVAL(cx, vp, JS::UndefinedValue());\n"
|
||||
"return true;")
|
||||
else:
|
||||
@ -5087,7 +5089,9 @@ class CGGenericSetter(CGAbstractBindingMethod):
|
||||
name = "genericLenientSetter"
|
||||
unwrapFailureCode = (
|
||||
"MOZ_ASSERT(!JS_IsExceptionPending(cx));\n"
|
||||
"ReportLenientThisUnwrappingFailure(cx, obj);\n"
|
||||
"if (!ReportLenientThisUnwrappingFailure(cx, obj)) {\n"
|
||||
" return false;\n"
|
||||
"}\n"
|
||||
"JS_SET_RVAL(cx, vp, JS::UndefinedValue());\n"
|
||||
"return true;")
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user