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
parent 8f936fb594
commit 55d4fbb621

View File

@ -1397,6 +1397,19 @@ XPCJSRuntime::InterruptCallback(JSContext *cx)
// running in a non-DOM scope, we have to just let it keep running. // running in a non-DOM scope, we have to just let it keep running.
RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
nsRefPtr<nsGlobalWindow> win = WindowOrNull(global); 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) if (!win)
return true; return true;