if (globalScript) { docShell = globalScript->GetDocShell();
if (window) { docShell = window->GetDocShell();
static void DOMWindowToTreeOwner(              nsIDOMWindow *DOMWindow,              nsIDocShellTreeOwner** aTreeOwner){  if (!DOMWindow) {    return; // with webWindow unchanged -- its constructor gives it a null ptr  }  nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(DOMWindow));  nsIDocShell *docShell = nsnull;  if (globalScript) {    docShell = globalScript->GetDocShell();  }  nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));  if(!docShellAsItem)   return;  docShellAsItem->GetTreeOwner(aTreeOwner);}