Bug 966710. Flag document.getElementsByTagNameNS as being able to throw, since it can. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 03 Feb 2014 11:03:54 -0500
changeset 166635 ed88a1b7b429c57bf33ee20052db9bce4f8e1b72
parent 166634 06095fccf046df3bcf7b835d1f9ef8c9e81ec0c7
child 166636 05db27fe116410d37cef3c52755813845385b92a
push id4808
push userryanvm@gmail.com
push dateMon, 03 Feb 2014 23:16:15 +0000
treeherderfx-team@c150845d077d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs966710
milestone29.0a1
Bug 966710. Flag document.getElementsByTagNameNS as being able to throw, since it can. r=smaug
content/base/public/nsIDocument.h
content/base/src/nsDocument.cpp
dom/webidl/Document.webidl
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -1992,17 +1992,18 @@ public:
            mozilla::ErrorResult& rv) = 0;
   already_AddRefed<nsContentList>
   GetElementsByTagName(const nsAString& aTagName)
   {
     return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName);
   }
   already_AddRefed<nsContentList>
     GetElementsByTagNameNS(const nsAString& aNamespaceURI,
-                           const nsAString& aLocalName);
+                           const nsAString& aLocalName,
+                           mozilla::ErrorResult& aResult);
   already_AddRefed<nsContentList>
     GetElementsByClassName(const nsAString& aClasses);
   // GetElementById defined above
   already_AddRefed<Element> CreateElement(const nsAString& aTagName,
                                           mozilla::ErrorResult& rv);
   already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI,
                                             const nsAString& aQualifiedName,
                                             mozilla::ErrorResult& rv);
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -5398,40 +5398,46 @@ nsDocument::GetElementsByTagName(const n
 
   // transfer ref to aReturn
   *aReturn = list.forget().get();
   return NS_OK;
 }
 
 already_AddRefed<nsContentList>
 nsIDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
-                                    const nsAString& aLocalName)
+                                    const nsAString& aLocalName,
+                                    ErrorResult& aResult)
 {
   int32_t nameSpaceId = kNameSpaceID_Wildcard;
 
   if (!aNamespaceURI.EqualsLiteral("*")) {
-    nsresult rv =
+    aResult =
       nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
                                                             nameSpaceId);
-    NS_ENSURE_SUCCESS(rv, nullptr);
+    if (aResult.Failed()) {
+      return nullptr;
+    }
   }
 
   NS_ASSERTION(nameSpaceId != kNameSpaceID_Unknown, "Unexpected namespace ID!");
 
   return NS_GetContentList(this, nameSpaceId, aLocalName);
 }
 
 NS_IMETHODIMP
 nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
                                    const nsAString& aLocalName,
                                    nsIDOMNodeList** aReturn)
 {
+  ErrorResult rv;
   nsRefPtr<nsContentList> list =
-    nsIDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName);
-  NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
+    nsIDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv);
+  if (rv.Failed()) {
+    return rv.ErrorCode();
+  }
 
   // transfer ref to aReturn
   *aReturn = list.forget().get();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetAsync(bool *aAsync)
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -40,17 +40,17 @@ interface Document : Node {
   readonly attribute DOMString contentType;
 
   [Pure]
   readonly attribute DocumentType? doctype;
   [Pure]
   readonly attribute Element? documentElement;
   [Pure]
   HTMLCollection getElementsByTagName(DOMString localName);
-  [Pure]
+  [Pure, Throws]
   HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
   [Pure]
   HTMLCollection getElementsByClassName(DOMString classNames);
   [Pure]
   Element? getElementById(DOMString elementId);
 
   [NewObject, Throws]
   Element createElement(DOMString localName);