Bug 1275746 - Fix tests that assume a HTTP url without a hostname is valid r=bz,MattN,jdm,markh
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 07 Jul 2016 16:20:47 +0300
changeset 370510 89b5e454ca73ca5ffb772cfec606ab78a9f4ba9b
parent 370509 4d8ea16976d159ffb95e07e524ad5186ecafe714
child 370511 0224380866d46ab1a45ad55dcae27bd5864a1bfd
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, MattN, jdm, markh
bugs1275746
milestone54.0a1
Bug 1275746 - Fix tests that assume a HTTP url without a hostname is valid r=bz,MattN,jdm,markh MozReview-Commit-ID: DzRenakrcAG
docshell/test/unit/test_nsDefaultURIFixup_info.js
dom/html/test/test_bug558788-1.html
dom/url/tests/test_url.html
extensions/cookie/test/unit/test_bug526789.js
services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
services/fxaccounts/tests/xpcshell/test_profile_client.js
testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini
testing/web-platform/meta/url/url-constructor.html.ini
toolkit/components/passwordmgr/test/unit/test_logins_search.js
--- a/docshell/test/unit/test_nsDefaultURIFixup_info.js
+++ b/docshell/test/unit/test_nsDefaultURIFixup_info.js
@@ -421,34 +421,28 @@ var testcases = [ {
     protocolChange: true,
   }, {
     input: "a?.com",
     fixedURI: "http://a/?.com",
     alternateURI: "http://www.a.com/?.com",
     protocolChange: true,
   }, {
     input: "?'.com",
-    fixedURI: "http:///?%27.com",
-    alternateURI: "http://www..com/?%27.com",
     keywordLookup: true,
     protocolChange: true,
   }, {
     input: "' ?.com",
     keywordLookup: true,
     protocolChange: true
   }, {
     input: "?mozilla",
-    fixedURI: "http:///?mozilla",
-    alternateURI: "http://www..com/?mozilla",
     keywordLookup: true,
     protocolChange: true,
   }, {
     input: "??mozilla",
-    fixedURI: "http:///??mozilla",
-    alternateURI: "http://www..com/??mozilla",
     keywordLookup: true,
     protocolChange: true,
   }, {
     input: "mozilla/",
     fixedURI: "http://mozilla/",
     alternateURI: "http://www.mozilla.com/",
     protocolChange: true,
   }, {
--- a/dom/html/test/test_bug558788-1.html
+++ b/dom/html/test/test_bug558788-1.html
@@ -149,23 +149,24 @@ function checkInputURL()
   element.focus();
 
   synthesizeKey("h", {});
   checkInvalidApplies(element);
 
   sendString("ttp://mozilla.org");
   checkValidApplies(element);
 
-  for (var i=0; i<13; ++i) {
+  for (var i=0; i<10; ++i) {
     synthesizeKey("VK_BACK_SPACE", {});
     checkValidApplies(element);
   }
 
   synthesizeKey("VK_BACK_SPACE", {});
-  for (var i=0; i<4; ++i) {
+  // "http://" is now invalid
+  for (var i=0; i<7; ++i) {
     checkInvalidApplies(element);
     synthesizeKey("VK_BACK_SPACE", {});
   }
   checkValidApplies(element);
 
   gContent.removeChild(element);
 }
 
--- a/dom/url/tests/test_url.html
+++ b/dom/url/tests/test_url.html
@@ -394,16 +394,28 @@
     url = new URL("ftp:\\\\tmp\\test", base);
     is(url.href, "ftp://tmp/test");
 
     url = new URL("scheme://tmp\\test", base);
     is(url.href, "scheme://tmp\\test");
   </script>
 
   <script>
+    /** Test for Bug 1275746 **/
+    SimpleTest.doesThrow(() => { var url = new URL("http:"); }, "http: is not a valid URL");
+    SimpleTest.doesThrow(() => { var url = new URL("http:///"); }, "http: is not a valid URL");
+
+    var url = new URL("file:");
+    is(url.href, "file:///", "Parsing file: should work.");
+
+    url = new URL("file:///");
+    is(url.href, "file:///", "Parsing file:/// should work.");
+  </script>
+
+  <script>
     var url = new URL("scheme:path/to/file?query#hash");
     is(url.href, "scheme:path/to/file?query#hash");
     is(url.pathname, "path/to/file");
     is(url.search, "?query");
     is(url.hash, "#hash");
 
     // pathname cannot be overwritten.
     url.pathname = "new/path?newquery#newhash";
--- a/extensions/cookie/test/unit/test_bug526789.js
+++ b/extensions/cookie/test/unit/test_bug526789.js
@@ -74,33 +74,20 @@ function run_test() {
     cm.countCookiesFromHost(".co.uk");
   }, Cr.NS_ERROR_ILLEGAL_VALUE);
   do_check_throws(function() {
     cm.countCookiesFromHost(".co.uk.");
   }, Cr.NS_ERROR_ILLEGAL_VALUE);
 
   cm.removeAll();
 
-  // test that setting an empty or '.' http:// host results in a no-op
   var uri = NetUtil.newURI("http://baz.com/");
-  var emptyuri = NetUtil.newURI("http:///");
-  var doturi = NetUtil.newURI("http://./");
   do_check_eq(uri.asciiHost, "baz.com");
-  do_check_eq(emptyuri.asciiHost, "");
-  do_check_eq(doturi.asciiHost, ".");
-  cs.setCookieString(emptyuri, null, "foo2=bar", null);
-  do_check_eq(getCookieCount(), 0);
-  cs.setCookieString(doturi, null, "foo3=bar", null);
-  do_check_eq(getCookieCount(), 0);
   cs.setCookieString(uri, null, "foo=bar", null);
-  do_check_eq(getCookieCount(), 1);
-
   do_check_eq(cs.getCookieString(uri, null), "foo=bar");
-  do_check_eq(cs.getCookieString(emptyuri, null), null);
-  do_check_eq(cs.getCookieString(doturi, null), null);
 
   do_check_eq(cm.countCookiesFromHost(""), 0);
   do_check_throws(function() {
     cm.countCookiesFromHost(".");
   }, Cr.NS_ERROR_ILLEGAL_VALUE);
   do_check_throws(function() {
     cm.countCookiesFromHost("..");
   }, Cr.NS_ERROR_ILLEGAL_VALUE);
--- a/services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
+++ b/services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
@@ -137,17 +137,17 @@ add_test(function serverErrorResponse() 
       do_check_eq(e.message, "Unauthorized");
       run_next_test();
     }
   );
 });
 
 add_test(function networkErrorResponse() {
   let client = new FxAccountsOAuthGrantClient({
-    serverURL: "http://",
+    serverURL: "http://domain.dummy",
     client_id: "abc123"
   });
   Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
   client.getTokenFromAssertion("assertion", "scope")
     .then(
       null,
       function(e) {
         do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
--- a/services/fxaccounts/tests/xpcshell/test_profile_client.js
+++ b/services/fxaccounts/tests/xpcshell/test_profile_client.js
@@ -294,17 +294,17 @@ add_test(function server401ResponsePersi
       do_check_eq(numTokensRemoved, 2);
       run_next_test();
     }
   );
 });
 
 add_test(function networkErrorResponse() {
   let client = new FxAccountsProfileClient({
-    serverURL: "http://",
+    serverURL: "http://domain.dummy",
     fxa: mockFxa,
   });
   client.fetchProfile()
     .then(
       null,
       function(e) {
         do_check_eq(e.name, "FxAccountsProfileClientError");
         do_check_eq(e.code, null);
--- a/testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini
+++ b/testing/web-platform/meta/XMLHttpRequest/open-url-bogus.htm.ini
@@ -1,11 +1,4 @@
 [open-url-bogus.htm]
   type: testharness
   [XMLHttpRequest: open() - bogus URLs (http:)]
     expected: FAIL
-
-  [XMLHttpRequest: open() - bogus URLs (ftp:)]
-    expected: FAIL
-
-  [XMLHttpRequest: open() - bogus URLs (http:////////////)]
-    expected: FAIL
-
--- a/testing/web-platform/meta/url/url-constructor.html.ini
+++ b/testing/web-platform/meta/url/url-constructor.html.ini
@@ -196,19 +196,16 @@
     expected: FAIL
 
   [Parsing: <sc://ñ.test/> against <about:blank>]
     expected: FAIL
 
   [Parsing: <file:..> against <http://www.example.com/test>]
     expected: FAIL
 
-  [Parsing: <http:> against <https://example.org/foo/bar>]
-    expected: FAIL
-
   [Parsing: <http://[::127.0.0.1\]> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <http://[0:0:0:0:0:0:13.1.68.3\]> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <https://test:@test> against <about:blank>]
     expected: FAIL
--- a/toolkit/components/passwordmgr/test/unit/test_logins_search.js
+++ b/toolkit/components/passwordmgr/test/unit/test_logins_search.js
@@ -187,17 +187,16 @@ add_task(function test_searchLogins_inva
 /**
  * Tests that matches are case-sensitive, compare the full field value, and are
  * strict when interpreting the prePath of URIs.
  */
 add_task(function test_search_all_full_case_sensitive()
 {
   checkAllSearches({ hostname: "http://www.example.com" }, 1);
   checkAllSearches({ hostname: "http://www.example.com/" }, 0);
-  checkAllSearches({ hostname: "http://" }, 0);
   checkAllSearches({ hostname: "example.com" }, 0);
 
   checkAllSearches({ formSubmitURL: "http://www.example.com" }, 2);
   checkAllSearches({ formSubmitURL: "http://www.example.com/" }, 0);
   checkAllSearches({ formSubmitURL: "http://" }, 0);
   checkAllSearches({ formSubmitURL: "example.com" }, 0);
 
   checkAllSearches({ httpRealm: "The HTTP Realm" }, 3);