nsCOMPtr<nsIURI> url; doc->GetDocumentURL(getter_AddRefs(url));
nsIURI *url = doc->GetDocumentURL();
wallet_TraversalForPrefill    (nsIDOMWindow* win, nsVoidArray* wallet_PrefillElement_list, nsString& urlName) {  nsresult result;  if (nsnull != win) {    nsCOMPtr<nsIDOMDocument> domdoc;    result = win->GetDocument(getter_AddRefs(domdoc));    if (NS_SUCCEEDED(result)) {      nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);      if (doc) {        nsCOMPtr<nsIURI> url;        doc->GetDocumentURL(getter_AddRefs(url));        if (url) {          wallet_GetHostFile(url, urlName);        }        wallet_Initialize();        wallet_InitializeCurrentURL(doc);        nsCOMPtr<nsIDOMHTMLDocument> htmldoc = do_QueryInterface(doc);        if (htmldoc) {          nsCOMPtr<nsIDOMHTMLCollection> forms;          htmldoc->GetForms(getter_AddRefs(forms));          if (forms) {            wallet_InitializeStateTesting();            PRUint32 numForms;            forms->GetLength(&numForms);            for (PRUint32 formX = 0; (formX < numForms) && !gEncryptionFailure; formX++) {              nsCOMPtr<nsIDOMNode> formNode;              forms->Item(formX, getter_AddRefs(formNode));              if (formNode) {                nsCOMPtr<nsIDOMHTMLFormElement> formElement = do_QueryInterface(formNode);                if (formElement) {                  nsCOMPtr<nsIDOMHTMLCollection> elements;                  result = formElement->GetElements(getter_AddRefs(elements));                  if (elements) {                    /* got to the form elements at long last */                    PRUint32 numElements;                    elements->GetLength(&numElements);                    for (PRUint32 elementX = 0; (elementX < numElements) && !gEncryptionFailure; elementX++) {                      nsCOMPtr<nsIDOMNode> elementNode;                      elements->Item(elementX, getter_AddRefs(elementNode));                      if (elementNode) {                        wallet_PrefillElement * prefillElement;                        PRInt32 index = 0;                        wallet_PrefillElement * firstElement = nsnull;                        PRUint32 numberOfElements = 0;                        for (; !gEncryptionFailure;) {                          /* loop to allow for multiple values */                          /* first element in multiple-value group will have its count                           * field set to the number of elements in group.  All other                           * elements in group will have count field set to 0                           */                          prefillElement = new wallet_PrefillElement;                          nsCAutoString schemaUTF8;                          if (NS_SUCCEEDED(wallet_GetPrefills                              (elementNode,                              prefillElement->inputElement,                              prefillElement->selectElement,                              schemaUTF8,                              prefillElement->value,                              prefillElement->selectIndex,                              index))) {                            /* another value found */                            prefillElement->schema = ToNewCString(schemaUTF8);                            if (nsnull == firstElement) {                              firstElement = prefillElement;                            }                            numberOfElements++;                            prefillElement->count = 0;                            wallet_PrefillElement_list->AppendElement(prefillElement);                          } else {                            /* value not found, stop looking for more values */                            delete prefillElement;                            break;                          }                        } // for                        if (numberOfElements>0) {                          firstElement->count = numberOfElements;                        }                      }                    } // for                  }                }              }            }          }        }      }    }  }  nsCOMPtr<nsIDOMWindowCollection> frames;  win->GetFrames(getter_AddRefs(frames));  if (frames) {    PRUint32 numFrames;    frames->GetLength(&numFrames);    for (PRUint32 frameX = 0; (frameX < numFrames) && !gEncryptionFailure; frameX++) {      nsCOMPtr<nsIDOMWindow> frameNode;      frames->Item(frameX, getter_AddRefs(frameNode));      if (frameNode) {        wallet_TraversalForPrefill(frameNode, wallet_PrefillElement_list, urlName);      }    }  }}