From 421fc415c0672feaee05c045c3b9eb42365842c2 Mon Sep 17 00:00:00 2001 From: "jst%mozilla.jstenback.com" Date: Wed, 28 Jan 2004 23:44:08 +0000 Subject: [PATCH] Fixing bug 227263. Making document.domain return null in stead of throwing an exception when there's no domain to return. r+sr=peterv@propagandism.org. git-svn-id: svn://10.0.0.236/trunk@151993 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/html/document/src/nsHTMLDocument.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 962b5d57210..0ac636c45f9 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1804,10 +1804,14 @@ nsHTMLDocument::GetDomain(nsAString& aDomain) } nsCAutoString hostName; - if (NS_FAILED(uri->GetHost(hostName))) - return NS_ERROR_FAILURE; - CopyUTF8toUTF16(hostName, aDomain); + if (NS_SUCCEEDED(uri->GetHost(hostName))) { + CopyUTF8toUTF16(hostName, aDomain); + } else { + // If we can't get the host from the URI (e.g. about:, javascript:, + // etc), just return an null string. + SetDOMStringToNull(aDomain); + } return NS_OK; }