Bug 1258490 - patch 3 - Fix Android error failures for root paths, r=me

This commit is contained in:
Andrea Marchesini 2016-05-13 17:20:26 +02:00
Родитель 0218fe027e
Коммит e5ac72be11
2 изменённых файлов: 15 добавлений и 6 удалений

Просмотреть файл

@ -153,7 +153,9 @@ FileSystemBase::GetDOMPath(nsIFile* aFile,
return;
}
parts.AppendElement(leafName);
if (!leafName.IsEmpty()) {
parts.AppendElement(leafName);
}
bool equal = false;
aRv = fileSystemPath->Equals(path, &equal);
@ -179,7 +181,10 @@ FileSystemBase::GetDOMPath(nsIFile* aFile,
}
}
MOZ_ASSERT(!parts.IsEmpty());
if (parts.IsEmpty()) {
aRetval.AppendLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL);
return;
}
for (int32_t i = parts.Length() - 1; i >= 0; --i) {
aRetval.AppendLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL);

Просмотреть файл

@ -1,3 +1,7 @@
function createPath(parentDir, dirOrFile) {
return parentDir.path + (parentDir.path == '/' ? '' : '/') + dirOrFile.name;
}
function setup_tests(aNext) {
SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
["dom.webkitBlink.dirPicker.enabled", true]]}, aNext);
@ -20,11 +24,11 @@ function test_getFilesAndDirectories(aDirectory, aRecursive, aNext) {
isnot(data[i].name, '/', "Subdirectory should be called with the leafname");
isnot(data[i].path, '/', "Subdirectory path should be called with the leafname");
isnot(data[i].path, dir.path, "Subdirectory path should contain the parent path.");
is(data[i].path, dir.path + '/' + data[i].name, "Subdirectory path should be called parentdir.path + '/' + leafname");
is(data[i].path, createPath(dir, data[i]), "Subdirectory path should be called parentdir.path + '/' + leafname: " + data[i].path);
}
if (data[i] instanceof File) {
is(data[i].webkitRelativePath, dir.path + '/' + data[i].name, "File.webkitRelativePath should be called: parentdir.path + '/' + file.name");
is(data[i].webkitRelativePath, createPath(dir, data[i]), "File.webkitRelativePath should be called: parentdir.path + '/' + file.name: " + data[i].webkitRelativePath);
}
}
}
@ -39,14 +43,14 @@ function test_getFilesAndDirectories(aDirectory, aRecursive, aNext) {
ok (data[i] instanceof File || data[i] instanceof Directory, "Just Files or Directories: " + data[i].name);
if (data[i] instanceof Directory) {
isnot(data[i].name, '/', "Subdirectory should be called with the leafname");
is(data[i].path, aDirectory.path + '/' + data[i].name, "Subdirectory path should be called parentdir.path + '/' + leafname");
is(data[i].path, createPath(aDirectory, data[i]), "Subdirectory path should be called parentdir.path + '/' + leafname: " + data[i].path);
if (aRecursive) {
promises.push(checkSubDir(data[i]));
}
}
if (data[i] instanceof File) {
is(data[i].webkitRelativePath, aDirectory.path + '/' + data[i].name, "File.webkitRelativePath should be called '/' + file.name");
is(data[i].webkitRelativePath, createPath(aDirectory, data[i]), "File.webkitRelativePath should be called '/' + file.name: " + data[i].webkitRelativePath);
}
}