nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();
nsCOMPtr<nsISupports> documentContainer = doc->GetContainer(); nsCOMPtr<nsIScriptGlobalObject> sgo(do_GetInterface(documentContainer));
GetJSContext(NPP npp){  NS_ENSURE_TRUE(npp, nsnull);  ns4xPluginInstance *inst = (ns4xPluginInstance *)npp->ndata;  NS_ENSURE_TRUE(inst, nsnull);  nsCOMPtr<nsPIPluginInstancePeer> pp(do_QueryInterface(inst->Peer()));  NS_ENSURE_TRUE(pp, nsnull);  nsCOMPtr<nsIPluginInstanceOwner> owner;  pp->GetOwner(getter_AddRefs(owner));  NS_ENSURE_TRUE(owner, nsnull);  nsCOMPtr<nsIDocument> doc;  owner->GetDocument(getter_AddRefs(doc));  NS_ENSURE_TRUE(doc, nsnull);  nsIScriptGlobalObject *sgo = doc->GetScriptGlobalObject();  NS_ENSURE_TRUE(sgo, nsnull);  nsIScriptContext *scx = sgo->GetContext();  NS_ENSURE_TRUE(scx, nsnull);  return (JSContext *)scx->GetNativeContext();}