Bug 995123 - Associate sandboxPrototyped Sandboxes to their prototype Window, if it exists. r=bz

This commit is contained in:
Bobby Holley 2014-04-14 08:56:38 -07:00
Родитель 1da45bee80
Коммит 2f9b5a76a7
1 изменённых файлов: 13 добавлений и 0 удалений

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

@ -1397,6 +1397,19 @@ XPCJSRuntime::InterruptCallback(JSContext *cx)
// running in a non-DOM scope, we have to just let it keep running.
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
nsRefPtr<nsGlobalWindow> win = WindowOrNull(global);
if (!win && IsSandbox(global)) {
// If this is a sandbox associated with a DOMWindow via a
// sandboxPrototype, use that DOMWindow. This supports GreaseMonkey
// and JetPack content scripts.
JS::Rooted<JSObject*> proto(cx);
if (!JS_GetPrototype(cx, global, &proto))
return false;
if (proto && IsSandboxPrototypeProxy(proto) &&
(proto = js::CheckedUnwrap(proto, /* stopAtOuter = */ false)))
{
win = WindowGlobalOrNull(proto);
}
}
if (!win)
return true;