nsCOMPtr<nsIScriptGlobalObject> globalObject; rv |= GetScriptGlobalObject(getter_AddRefs(globalObject));
nsIScriptGlobalObject* globalObject = GetScriptGlobalObject(); NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED);
nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream){    nsresult rv;    rv = aStream->Write32(XUL_FASTLOAD_FILE_VERSION);        rv |= aStream->WriteCompoundObject(mURI, NS_GET_IID(nsIURI), PR_TRUE);        PRUint32 referenceCount;    nsCOMPtr<nsIURI> referenceURI;    PRUint32 i;    // nsISupportsArray mStyleSheetReferences    mStyleSheetReferences->Count(&referenceCount);    rv |= aStream->Write32(referenceCount);        for (i = 0; i < referenceCount; ++i) {        mStyleSheetReferences->QueryElementAt(i, NS_GET_IID(nsIURI), getter_AddRefs(referenceURI));                rv |= aStream->WriteCompoundObject(referenceURI, NS_GET_IID(nsIURI), PR_TRUE);    }    // nsISupportsArray mOverlayReferences    mOverlayReferences->Count(&referenceCount);    rv |= aStream->Write32(referenceCount);        for (i = 0; i < referenceCount; ++i) {        mOverlayReferences->QueryElementAt(i, NS_GET_IID(nsIURI), getter_AddRefs(referenceURI));                rv |= aStream->WriteCompoundObject(referenceURI, NS_GET_IID(nsIURI), PR_TRUE);    }    // nsIPrincipal mDocumentPrincipal    rv |= NS_WriteOptionalObject(aStream, mDocumentPrincipal, PR_TRUE);        // nsINodeInfo table    nsCOMArray<nsINodeInfo> nodeInfos;    if (mRoot)        rv |= GetNodeInfos(mRoot, nodeInfos);    PRInt32 nodeInfoCount = nodeInfos.Count();    rv |= aStream->Write32(nodeInfoCount);    for (PRInt32 j = 0; j < nodeInfoCount; ++j) {        nsINodeInfo *nodeInfo = nodeInfos[j];        NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE);        nsAutoString namespaceURI;        rv |= nodeInfo->GetNamespaceURI(namespaceURI);        rv |= aStream->WriteWStringZ(namespaceURI.get());        nsAutoString qualifiedName;        nodeInfo->GetQualifiedName(qualifiedName);        rv |= aStream->WriteWStringZ(qualifiedName.get());    }    // Now serialize the document contents    nsCOMPtr<nsIScriptGlobalObject> globalObject;    rv |= GetScriptGlobalObject(getter_AddRefs(globalObject));    nsIScriptContext *scriptContext = globalObject->GetContext();    if (mRoot)        rv |= mRoot->Serialize(aStream, scriptContext, &nodeInfos);     return rv;}