Backed out changeset 97214e3bf73d (bug 1275746) for failing xpcshell test test_avoid_middle_complete.js. r=backout

This commit is contained in:
Sebastian Hengst 2017-01-18 14:56:19 +01:00
parent 0269ef6d15
commit 15d195900f
3 changed files with 34 additions and 29 deletions

View File

@ -1550,11 +1550,6 @@ nsStandardURL::SetSpec(const nsACString &input)
rv = BuildNormalizedSpec(spec);
}
// Make sure that a URLTYPE_AUTHORITY has a non-empty hostname.
if (mURLType == URLTYPE_AUTHORITY && mHost.mLen == -1) {
rv = NS_ERROR_MALFORMED_URI;
}
if (NS_FAILED(rv)) {
Clear();
// If parsing the spec has failed, restore the old URL
@ -3183,26 +3178,20 @@ nsStandardURL::SetFile(nsIFile *file)
rv = net_GetURLSpecFromFile(file, url);
if (NS_FAILED(rv)) return rv;
uint32_t oldURLType = mURLType;
uint32_t oldDefaultPort = mDefaultPort;
rv = Init(nsIStandardURL::URLTYPE_NO_AUTHORITY, -1, url, nullptr, nullptr);
SetSpec(url);
if (NS_FAILED(rv)) {
// Restore the old url type and default port if the call to Init fails.
mURLType = oldURLType;
mDefaultPort = oldDefaultPort;
return rv;
}
rv = Init(mURLType, mDefaultPort, url, nullptr, nullptr);
// must clone |file| since its value is not guaranteed to remain constant
InvalidateCache();
if (NS_FAILED(file->Clone(getter_AddRefs(mFile)))) {
NS_WARNING("nsIFile::Clone failed");
// failure to clone is not fatal (GetFile will generate mFile)
mFile = nullptr;
if (NS_SUCCEEDED(rv)) {
InvalidateCache();
if (NS_FAILED(file->Clone(getter_AddRefs(mFile)))) {
NS_WARNING("nsIFile::Clone failed");
// failure to clone is not fatal (GetFile will generate mFile)
mFile = nullptr;
}
}
return NS_OK;
return rv;
}
//----------------------------------------------------------------------------

View File

@ -92,6 +92,18 @@ var gTests = [
ref: "",
relativeURI: "data/text/plain,2",
nsIURL: true, nsINestedURI: false },
{ spec: "ftp://",
scheme: "ftp",
prePath: "ftp://",
path: "/",
ref: "",
nsIURL: true, nsINestedURI: false },
{ spec: "ftp:///",
scheme: "ftp",
prePath: "ftp://",
path: "/",
ref: "",
nsIURL: true, nsINestedURI: false },
{ spec: "ftp://ftp.mozilla.org/pub/mozilla.org/README",
scheme: "ftp",
prePath: "ftp://ftp.mozilla.org",
@ -123,6 +135,18 @@ var gTests = [
path: "//mozilla.org/",
ref: "",
nsIURL: false, nsINestedURI: false },
{ spec: "http://",
scheme: "http",
prePath: "http://",
path: "/",
ref: "",
nsIURL: true, nsINestedURI: false },
{ spec: "http:///",
scheme: "http",
prePath: "http://",
path: "/",
ref: "",
nsIURL: true, nsINestedURI: false },
{ spec: "http://www.example.com/",
scheme: "http",
prePath: "http://www.example.com",

View File

@ -333,14 +333,6 @@ add_test(function test_backslashReplacement()
run_next_test();
});
add_test(function test_authority_host()
{
Assert.throws(() => { stringToURL("http:"); }, "TYPE_AUTHORITY should have host");
Assert.throws(() => { stringToURL("http:///"); }, "TYPE_AUTHORITY should have host");
run_next_test();
});
add_test(function test_trim_C0_and_space()
{
var url = stringToURL("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f http://example.com/ \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ");