Bug 1203463 - URL constructor should support about:blank URI, r=bz
☠☠ backed out by 27cdeffa4ae1 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 16 Sep 2015 00:45:34 +0800
changeset 295221 1023659e341377d894b12f030226afcdab35dbb5
parent 295220 a252f3d0a8c970231c8db43638d0f68e82b66ac3
child 295222 ccfddcbccdac3dabe0ffadd556b9e0e641cd4fb8
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1203463
milestone43.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 1203463 - URL constructor should support about:blank URI, r=bz
dom/base/URL.cpp
dom/base/test/test_url.html
--- a/dom/base/URL.cpp
+++ b/dom/base/URL.cpp
@@ -418,18 +418,25 @@ URL::SetPort(const nsAString& aPort, Err
 
 void
 URL::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
 {
   aPathname.Truncate();
 
   nsCOMPtr<nsIURL> url(do_QueryInterface(mURI));
   if (!url) {
-    // Do not throw!  Not having a valid URI or URL should result in an empty
-    // string.
+    nsAutoCString path;
+    nsresult rv = mURI->GetPath(path);
+    if (NS_FAILED(rv)){
+      // Do not throw!  Not having a valid URI or URL should result in an empty
+      // string.
+      return;
+    }
+
+    CopyUTF8toUTF16(path, aPathname);
     return;
   }
 
   nsAutoCString file;
   nsresult rv = url->GetFilePath(file);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(file, aPathname);
   }
--- a/dom/base/test/test_url.html
+++ b/dom/base/test/test_url.html
@@ -204,16 +204,24 @@
       error: false,
       protocol: 'wss:',
     },
     { url: 'foo://foo.something.net',
       base: undefined,
       error: false,
       protocol: 'foo:',
     },
+
+    { url: 'about:blank',
+      base: undefined,
+      error: false,
+      protocol: 'about:',
+      pathname: 'blank',
+      skip_setters: false,
+    },
   ];
 
   while(tests.length) {
     var test = tests.shift();
 
     var error = false;
     var url;
     try {
@@ -238,16 +246,21 @@
     if ('password' in test) is(url.password, test.password, "password");
     if ('host' in test) is(url.host, test.host, "host");
     if ('hostname' in test) is(url.hostname, test.hostname, "hostname");
     if ('port' in test) is(url.port, test.port, "port");
     if ('pathname' in test) is(url.pathname, test.pathname, "pathname");
     if ('search' in test) is(url.search, test.search, "search");
     if ('hash' in test) is(url.hash, test.hash, "hash");
 
+    if ('skip_setters' in test && test.skip_setters == false) {
+      info("Skip setter methods for URL: " + test);
+      continue;
+    }
+
     url = new URL('https://www.example.net/what#foo?bar');
     ok(url, "Url exists!");
 
     if ('href' in test) url.href = test.href;
     if ('protocol' in test) url.protocol = test.protocol;
     if ('username' in test && test.username) url.username = test.username;
     if ('password' in test && test.password) url.password = test.password;
     if ('host' in test) url.host = test.host;