nsCAutoString prepath; nsCAutoString filepath; nsCAutoString query; nsCAutoString param; rv = uri->GetPrePath(prepath); NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr<nsIURL> aURL(do_QueryInterface(uri, &rv)); if (NS_SUCCEEDED(rv)) { rv = aURL->GetFilePath(filepath); NS_ENSURE_SUCCESS(rv,rv); rv = aURL->GetQuery(query); NS_ENSURE_SUCCESS(rv,rv); rv = aURL->GetParam(param); NS_ENSURE_SUCCESS(rv,rv); } else {     rv = uri->GetPath(filepath); NS_ENSURE_SUCCESS(rv,rv); }  PRInt32 matchCount = 0; nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell); nsCOMPtr<nsIDocShellTreeItem> parentAsItem; treeItem->GetParent(getter_AddRefs(parentAsItem)); while (parentAsItem) {  PRInt32 parentType; parentAsItem->GetItemType(&parentType); if (parentType != nsIDocShellTreeItem::typeContent) { break; }  nsCOMPtr<nsIWebNavigation> parentAsNav(do_QueryInterface(parentAsItem)); if (parentAsNav) {  nsCOMPtr<nsIURI> parentURI; parentAsNav->GetCurrentURI(getter_AddRefs(parentURI)); if (parentURI) {            nsCAutoString parentPrePath; nsCAutoString parentFilePath; nsCAutoString parentQuery; nsCAutoString parentParam; rv = parentURI->GetPrePath(parentPrePath); NS_ENSURE_SUCCESS(rv,rv); nsCOMPtr<nsIURL> parentURL(do_QueryInterface(parentURI, &rv)); if (NS_SUCCEEDED(rv)) { rv = parentURL->GetFilePath(parentFilePath); NS_ENSURE_SUCCESS(rv,rv); rv = parentURL->GetQuery(parentQuery); NS_ENSURE_SUCCESS(rv,rv); rv = parentURL->GetParam(parentParam); NS_ENSURE_SUCCESS(rv,rv); } else { rv = uri->GetPath(filepath); NS_ENSURE_SUCCESS(rv,rv); }   if (filepath.Equals(parentFilePath) && query.Equals(parentQuery) && prepath.Equals(parentPrePath) && param.Equals(parentParam)) { matchCount++; if (matchCount >= MAX_SAME_URL_CONTENT_FRAMES) { NS_WARNING("Too many nested content frames have the same url (recursion?) so giving up"); return NS_ERROR_UNEXPECTED; } } } } nsIDocShellTreeItem* temp = parentAsItem; temp->GetParent(getter_AddRefs(parentAsItem)); }
nsFrameLoader::LoadFrame(){  NS_ENSURE_TRUE(mOwnerContent, NS_ERROR_NOT_INITIALIZED);  nsresult rv = EnsureDocShell();  NS_ENSURE_SUCCESS(rv, rv);  nsIDocument* doc = mOwnerContent->GetDocument();  if (!doc) {    return NS_OK;  }  nsAutoString src;  GetURL(src);  src.Trim(" \t\n\r");  if (src.IsEmpty()) {    src.Assign(NS_LITERAL_STRING("about:blank"));  }  // Make an absolute URI  nsCOMPtr<nsIURI> base_uri;  doc->GetBaseURL(getter_AddRefs(base_uri));  nsCAutoString doc_charset;  doc->GetDocumentCharacterSet(doc_charset);  nsCOMPtr<nsIURI> uri;  rv = NS_NewURI(getter_AddRefs(uri), src,                 doc_charset.IsEmpty() ? nsnull :                 doc_charset.get(), base_uri);  NS_ENSURE_SUCCESS(rv, rv);  // Check for security  nsCOMPtr<nsIScriptSecurityManager> secMan =    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);  NS_ENSURE_SUCCESS(rv, rv);  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;  mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);  // Get referring URL  nsCOMPtr<nsIURI> referrer;  nsCOMPtr<nsIPrincipal> principal;  rv = secMan->GetSubjectPrincipal(getter_AddRefs(principal));  NS_ENSURE_SUCCESS(rv, rv);  // If we were called from script, get the referring URL from the script  if (principal) {    rv = principal->GetURI(getter_AddRefs(referrer));    NS_ENSURE_SUCCESS(rv, rv);    // Pass the script principal to the docshell    loadInfo->SetOwner(principal);  }  if (!referrer) {    // We're not being called form script, tell the docshell    // to inherit an owner from the current document.    loadInfo->SetInheritOwner(PR_TRUE);    referrer = base_uri;  }  loadInfo->SetReferrer(referrer);  // Check if we are allowed to load absURL  rv = secMan->CheckLoadURI(referrer, uri,                            nsIScriptSecurityManager::STANDARD);  if (NS_FAILED(rv)) {    return rv; // We're not  }  // Kick off the load...  rv = mDocShell->LoadURI(uri, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE,                          PR_FALSE);  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to load URL");  return rv;}