зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1029933
- Give BackstagePass an Enumerate hook to match its NewResolve hook. r=Waldo
This is required in order to avoid exposing resolve hook effects when Object.freeze() is invoked on the global. The freeze() call first enumerates the object, after which point any lazy properties need to be resolve so that we can safely mark the object as non-extensible.
This commit is contained in:
Родитель
3f882a20a0
Коммит
1c19351c9a
|
@ -1077,12 +1077,14 @@ ResolveWorkerClasses(JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid
|
|||
}
|
||||
}
|
||||
|
||||
bool shouldResolve = false;
|
||||
|
||||
for (uint32_t i = 0; i < ID_COUNT; i++) {
|
||||
if (gStringIDs[i] == aId) {
|
||||
shouldResolve = true;
|
||||
break;
|
||||
// Invoking this function with JSID_VOID means "always resolve".
|
||||
bool shouldResolve = JSID_IS_VOID(aId);
|
||||
if (!shouldResolve) {
|
||||
for (uint32_t i = 0; i < ID_COUNT; i++) {
|
||||
if (gStringIDs[i] == aId) {
|
||||
shouldResolve = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,9 @@ enum WorkerPreference
|
|||
};
|
||||
|
||||
// All of these are implemented in RuntimeService.cpp
|
||||
|
||||
// Resolves all of the worker classes onto |aObjp| if one of them matches |aId|
|
||||
// or if |aId| is JSID_VOID.
|
||||
bool
|
||||
ResolveWorkerClasses(JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JSObject*> aObjp);
|
||||
|
|
|
@ -30,6 +30,7 @@ NS_IMPL_RELEASE(BackstagePass)
|
|||
#define XPC_MAP_CLASSNAME BackstagePass
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "BackstagePass"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_ENUMERATE
|
||||
#define XPC_MAP_WANT_FINALIZE
|
||||
#define XPC_MAP_WANT_PRECREATE
|
||||
|
||||
|
@ -76,6 +77,22 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BackstagePass::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *objArg, bool *_retval)
|
||||
{
|
||||
JS::RootedObject obj(cx, objArg);
|
||||
|
||||
*_retval = JS_EnumerateStandardClasses(cx, obj);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
JS::RootedObject ignored(cx);
|
||||
*_retval = ResolveWorkerClasses(cx, obj, JSID_VOIDHANDLE, &ignored);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* void getInterfaces (out uint32_t count, [array, size_is (count), retval]
|
||||
out nsIIDPtr array); */
|
||||
|
|
Загрузка…
Ссылка в новой задаче