nsCOMPtr<nsIScriptGlobalObject> globalObject; mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
nsIScriptGlobalObject* globalObject = mDocument->GetScriptGlobalObject();
DocumentViewerImpl::Close(){  // All callers are supposed to call close to break circular  // references.  If we do this stuff in the destructor, the  // destructor might never be called (especially if we're being  // used from JS.  // Close is also needed to disable scripts during paint suppression,  // since we transfer the existing global object to the new document  // that is loaded.  In the future, the global object may become a proxy  // for an object that can be switched in and out so that we don't need  // to disable scripts during paint suppression.  if (mDocument) {#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)    // Turn scripting back on    // after PrintPreview had turned it off    if (GetIsPrintPreview() && mPrintEngine) {      mPrintEngine->TurnScriptingOn(PR_TRUE);    }#endif    // Break global object circular reference on the document created    // in the DocViewer Init    nsCOMPtr<nsIScriptGlobalObject> globalObject;    mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));    if (globalObject) {      globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE);    }#ifdef NS_PRINTING    // A Close was called while we were printing    // so don't clear the ScriptGlobalObject    // or clear the mDocument below    // Also, do an extra addref to keep the viewer from going away.    if (mPrintEngine && !mClosingWhilePrinting) {      mClosingWhilePrinting = PR_TRUE;      NS_ADDREF_THIS();    } else {      // out of band cleanup of webshell      mDocument->SetScriptGlobalObject(nsnull);    }#else    mDocument->SetScriptGlobalObject(nsnull);#endif    if (mFocusListener) {      // get the DOM event receiver      nsCOMPtr<nsIDOMEventReceiver> erP(do_QueryInterface(mDocument));      NS_WARN_IF_FALSE(erP, "No event receiver in document!");      if (erP) {        erP->RemoveEventListenerByIID(mFocusListener,                                      NS_GET_IID(nsIDOMFocusListener));      }    }  }#ifdef NS_PRINTING  // Don't clear the document if we are printing.  if (!mClosingWhilePrinting) {    mDocument = nsnull;  }#else    mDocument = nsnull;#endif  return NS_OK;}