Bug 1203463 - URL constructor should support about:blank URI, r=bz

This commit is contained in:
Andrea Marchesini 2015-09-16 11:26:29 +08:00
parent 3f2fe01205
commit 416d6f35ed
5 changed files with 25 additions and 65 deletions

View File

@ -58,8 +58,8 @@ function* navigate(usage, options) {
* 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');
}

View File

@ -423,8 +423,15 @@ URL::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
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;
}

View File

@ -209,6 +209,14 @@
error: false,
protocol: 'foo:',
},
{ url: 'about:blank',
base: undefined,
error: false,
protocol: 'about:',
pathname: 'blank',
skip_setters: false,
},
];
while(tests.length) {
@ -243,6 +251,11 @@
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!");

View File

@ -36,12 +36,6 @@
[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
@ -51,9 +45,6 @@
[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
@ -66,42 +57,18 @@
[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
@ -174,42 +141,18 @@
[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
@ -417,9 +360,6 @@
[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

View File

@ -595,7 +595,7 @@ const deconstructRuleId = exports.deconstructRuleId = function(ruleId) {
*/
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;
};
/**