Bug 1301344 - Add test. r=valentin
☠☠ backed out by 3f507148324c ☠ ☠
authorJunior Hsu <juhsu@mozilla.com>
Thu, 08 Sep 2016 02:36:00 -0400
changeset 354667 bb033983fe8d5128bc3e01df3b56974898e25c57
parent 354666 ab059611db16cfeee8cbc1cdf88c8c371c2ae59f
child 354668 6820b76ed3784fc08ce64375ccdd9c70c90a8db4
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1301344
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301344 - Add test. r=valentin
netwerk/test/gtest/TestStandardURL.cpp
--- a/netwerk/test/gtest/TestStandardURL.cpp
+++ b/netwerk/test/gtest/TestStandardURL.cpp
@@ -62,8 +62,35 @@ MOZ_GTEST_BENCH(TestStandardURL, Perf, [
         url->SetPath(NS_LITERAL_CSTRING("/some-path/one-the-net/about.html?with-a-query#for-you"));
         url->GetPath(out);
         url->SetQuery(NS_LITERAL_CSTRING("a=b&d=c&what-ever-you-want-to-be-called=45"));
         url->GetQuery(out);
         url->SetRef(NS_LITERAL_CSTRING("#some-book-mark"));
         url->GetRef(out);
     }
 });
+
+TEST(TestStandardURL, IPv4) {
+    nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
+    ASSERT_TRUE(url);
+    ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://other.com/")), NS_OK);
+
+    nsAutoCString out;
+
+    ASSERT_EQ(url->GetSpec(out), NS_OK);
+    ASSERT_TRUE(out == NS_LITERAL_CSTRING("http://other.com/"));
+
+    ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://%30%78%63%30%2e%30%32%35%30.01%2e")), NS_OK);
+    ASSERT_EQ(url->GetSpec(out), NS_OK);
+    ASSERT_TRUE(out == NS_LITERAL_CSTRING("http://192.168.0.1/"));
+
+    ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://0x7f000001")), NS_OK);
+    ASSERT_EQ(url->GetSpec(out), NS_OK);
+    ASSERT_TRUE(out == NS_LITERAL_CSTRING("http://127.0.0.1/"));
+
+    ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://00000000000000000000000000177.0000000.0000000.0001")), NS_OK);
+    ASSERT_EQ(url->GetSpec(out), NS_OK);
+    ASSERT_TRUE(out == NS_LITERAL_CSTRING("http://127.0.0.1/"));
+
+    ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://0x7f.0x00.0x00.0x01")), NS_OK);
+    ASSERT_EQ(url->GetSpec(out), NS_OK);
+    ASSERT_TRUE(out == NS_LITERAL_CSTRING("http://127.0.0.1/"));
+}