Bug 918707 - Return syntax error if url is invalid, r=khuey
authorShawn Huang <shuang@mozilla.com>
Sun, 03 Apr 2016 20:33:04 +0800
changeset 291504 4c17ed03e401275309d890ddcbb0cd4af2d13347
parent 291503 5027257b611edc9260756bc55659388b90d95736
child 291505 71eb251a0f29de94082623b91326e2449a3aa81e
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs918707
milestone48.0a1
Bug 918707 - Return syntax error if url is invalid, r=khuey
dom/base/nsXMLHttpRequest.cpp
testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -1561,18 +1561,23 @@ nsXMLHttpRequest::Open(const nsACString&
   if (mBaseURI) {
     baseURI = mBaseURI;
   }
   else if (doc) {
     baseURI = doc->GetBaseURI();
   }
 
   rv = NS_NewURI(getter_AddRefs(uri), url, nullptr, baseURI);
-  if (NS_FAILED(rv)) return rv;
-
+
+  if (NS_FAILED(rv)) {
+    if (rv ==  NS_ERROR_MALFORMED_URI) {
+      return NS_ERROR_DOM_SYNTAX_ERR;
+    }
+    return rv;
+  }
   rv = CheckInnerWindowCorrectness();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // XXXbz this is wrong: we should only be looking at whether
   // user/password were passed, not at the values!  See bug 759624.
   if (user.WasPassed() && !user.Value().IsEmpty()) {
     nsAutoCString userpass;
     CopyUTF16toUTF8(user.Value(), userpass);
--- a/testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini
+++ b/testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini
@@ -1,8 +1,5 @@
 [open-url-bogus.htm]
   type: testharness
   [XMLHttpRequest: open() - bogus URLs (http:)]
     expected: FAIL
 
-  [XMLHttpRequest: open() - bogus URLs (http://a a/)]
-    expected: FAIL
-