diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
index adad4e302515..0e0b0a7b609c 100644
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2635,11 +2635,6 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
{
*aResult = nsnull;
- if (!mIsRegularHTML) {
- // We don't dynamically resolve names on non-HTML documents.
- return NS_OK;
- }
-
nsCOMPtr name(do_GetAtom(aName));
// We have built a table and cache the named items. The table will
diff --git a/content/html/document/test/Makefile.in b/content/html/document/test/Makefile.in
index 5d56ef8d8561..aa0932e250ff 100644
--- a/content/html/document/test/Makefile.in
+++ b/content/html/document/test/Makefile.in
@@ -97,6 +97,7 @@ _TEST_FILES = test_bug1682.html \
test_bug486741.html \
test_bug497242.xhtml \
test_bug512367.html \
+ test_bug340017.xhtml \
$(NULL)
libs:: $(_TEST_FILES)
diff --git a/content/html/document/test/test_bug340017.xhtml b/content/html/document/test/test_bug340017.xhtml
new file mode 100644
index 000000000000..1768640d3c7d
--- /dev/null
+++ b/content/html/document/test/test_bug340017.xhtml
@@ -0,0 +1,28 @@
+
+
+
+ Test for Bug 340017
+
+
+
+
+
+Mozilla Bug 340017
+
+
+
+
+
+
+
+
+