Bug 1203463 - URL constructor should support about:blank URI, r=bz
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 16 Sep 2015 11:26:29 +0800
changeset 295342 7c1d4c3e68ad1aaaa681bded5629e3c682e70d56
parent 295341 67b5ece6a4c99f5ca2fec2d4d4ef490a76a95585
child 295343 faf94ffc0c5ad57c2e4f275e5789f08cf2b33831
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
browser/devtools/commandline/test/browser_cmd_csscoverage_startstop.js
dom/base/URL.cpp
dom/base/test/test_url.html
testing/web-platform/meta/url/url-constructor.html.ini
toolkit/devtools/server/actors/csscoverage.js
--- a/browser/devtools/commandline/test/browser_cmd_csscoverage_startstop.js
+++ b/browser/devtools/commandline/test/browser_cmd_csscoverage_startstop.js
@@ -53,18 +53,18 @@ function* navigate(usage, options) {
 
   ok(!usage.isRunning(), "csscoverage not is running");
 }
 
 /**
  * Check the expected pages have been visited
  */
 function* checkPages(usage) {
-  // 'load' event order. 'null' is for the initial location
-  let expectedVisited = [ 'null', PAGE_2, PAGE_1, PAGE_3 ];
+  // 'load' event order. '' is for the initial location
+  let expectedVisited = [ '', PAGE_2, PAGE_1, PAGE_3 ];
   let actualVisited = yield usage._testOnly_visitedPages();
   isEqualJson(actualVisited, expectedVisited, 'Visited');
 }
 
 /**
  * Check that createEditorReport returns the expected JSON
  */
 function* checkEditorReport(usage) {
--- 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;
--- a/testing/web-platform/meta/url/url-constructor.html.ini
+++ b/testing/web-platform/meta/url/url-constructor.html.ini
@@ -31,82 +31,49 @@
     expected: FAIL
 
   [Parsing: <http:\\\\foo.com\\> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <http:\\\\a\\b:c\\d@foo.com\\> against <http://example.org/foo/bar>]
     expected: FAIL
 
-  [Parsing: <foo:/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
-  [Parsing: <foo:/bar.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
   [Parsing: <foo://///////> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <foo://///////bar.com/> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <foo:////://///> against <http://example.org/foo/bar>]
     expected: FAIL
 
-  [Parsing: <c:/foo> against <http://example.org/foo/bar>]
-    expected: FAIL
-
   [Parsing: <[61:24:74\]:98> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <http:[61:27\]/:foo> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <http://2001::1\]> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <http://2001::1\]:80> against <http://example.org/foo/bar>]
     expected: FAIL
 
-  [Parsing: <madeupscheme:/example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
-  [Parsing: <ftps:/example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
   [Parsing: <gopher:/example.com/> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <data:/example.com/> against <http://example.org/foo/bar>]
     expected: FAIL
 
-  [Parsing: <javascript:/example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
-  [Parsing: <mailto:/example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
-  [Parsing: <madeupscheme:example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
-  [Parsing: <ftps:example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
   [Parsing: <gopher:example.com/> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <data:example.com/> against <http://example.org/foo/bar>]
     expected: FAIL
 
-  [Parsing: <javascript:example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
-  [Parsing: <mailto:example.com/> against <http://example.org/foo/bar>]
-    expected: FAIL
-
   [Parsing: <#β> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <data:text/html,test#test> against <http://example.org/foo/bar>]
     expected: FAIL
 
   [Parsing: <file:c:\\foo\\bar.html> against <file:///tmp/mock/path>]
     expected: FAIL
@@ -169,52 +136,28 @@
     expected: FAIL
 
   [Parsing: <gopher://foo:70/> against <about:blank>]
     expected: FAIL
 
   [Parsing: <gopher://foo:443/> against <about:blank>]
     expected: FAIL
 
-  [Parsing: <madeupscheme:/example.com/> against <about:blank>]
-    expected: FAIL
-
-  [Parsing: <ftps:/example.com/> against <about:blank>]
-    expected: FAIL
-
   [Parsing: <gopher:/example.com/> against <about:blank>]
     expected: FAIL
 
   [Parsing: <data:/example.com/> against <about:blank>]
     expected: FAIL
 
-  [Parsing: <javascript:/example.com/> against <about:blank>]
-    expected: FAIL
-
-  [Parsing: <mailto:/example.com/> against <about:blank>]
-    expected: FAIL
-
-  [Parsing: <madeupscheme:example.com/> against <about:blank>]
-    expected: FAIL
-
-  [Parsing: <ftps:example.com/> against <about:blank>]
-    expected: FAIL
-
   [Parsing: <gopher:example.com/> against <about:blank>]
     expected: FAIL
 
   [Parsing: <data:example.com/> against <about:blank>]
     expected: FAIL
 
-  [Parsing: <javascript:example.com/> against <about:blank>]
-    expected: FAIL
-
-  [Parsing: <mailto:example.com/> against <about:blank>]
-    expected: FAIL
-
   [Parsing: <http::b@www.example.com> against <about:blank>]
     expected: FAIL
 
   [Parsing: <http:/:b@www.example.com> against <about:blank>]
     expected: FAIL
 
   [Parsing: <http://:b@www.example.com> against <about:blank>]
     expected: FAIL
@@ -412,14 +355,11 @@
     expected: FAIL
 
   [Parsing: <mailto:/../> against <about:blank>]
     expected: FAIL
 
   [Parsing: <sc://ñ.test/> against <about:blank>]
     expected: FAIL
 
-  [Parsing: <sc:\\../> against <about:blank>]
-    expected: FAIL
-
   [Parsing: <file:..> against <http://www.example.com/test>]
     expected: FAIL
 
--- a/toolkit/devtools/server/actors/csscoverage.js
+++ b/toolkit/devtools/server/actors/csscoverage.js
@@ -590,17 +590,17 @@ const deconstructRuleId = exports.decons
 /**
  * We're only interested in the origin and pathname, because changes to the
  * username, password, hash, or query string probably don't significantly
  * change the CSS usage properties of a page.
  * @param document
  */
 const getURL = exports.getURL = function(document) {
   let url = new document.defaultView.URL(document.documentURI);
-  return '' + url.origin + url.pathname;
+  return url == 'about:blank' ? '' : '' + url.origin + url.pathname;
 };
 
 /**
  * Pseudo class handling constants:
  * We split pseudo-classes into a number of categories so we can decide how we
  * should match them. See getTestSelector for how we use these constants.
  *
  * @see http://dev.w3.org/csswg/selectors4/#overview