зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1822873 - Avoid mainthread IO in PathUtils.toFileURI r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D173330
This commit is contained in:
Родитель
4204288807
Коммит
81a96ac213
|
@ -28,6 +28,7 @@
|
|||
#include "nsLocalFile.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsURLHelper.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
@ -397,13 +398,8 @@ void PathUtils::ToFileURI(const GlobalObject&, const nsAString& aPath,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (nsresult rv = NS_NewFileURI(getter_AddRefs(uri), path); NS_FAILED(rv)) {
|
||||
ThrowError(aErr, rv, "Could not initialize File URI"_ns);
|
||||
return;
|
||||
}
|
||||
|
||||
if (nsresult rv = uri->GetSpec(aResult); NS_FAILED(rv)) {
|
||||
if (nsresult rv = net_GetURLSpecFromActualFile(path, aResult);
|
||||
NS_FAILED(rv)) {
|
||||
ThrowError(aErr, rv, "Could not retrieve URI spec"_ns);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -528,13 +528,13 @@
|
|||
if (Services.appinfo.OS === "WINNT") {
|
||||
is(
|
||||
PathUtils.toFileURI("C:\\"),
|
||||
"file:///C:/",
|
||||
"file:///C:",
|
||||
"PathUtils.toFileURI() with a root path"
|
||||
);
|
||||
|
||||
is(
|
||||
PathUtils.toFileURI("C:\\Windows\\"),
|
||||
"file:///C:/Windows/",
|
||||
"file:///C:/Windows",
|
||||
"PathUtils.toFileURI() with a non-root directory path"
|
||||
);
|
||||
|
||||
|
@ -552,7 +552,7 @@
|
|||
|
||||
is(
|
||||
PathUtils.toFileURI("/bin"),
|
||||
"file:///bin/",
|
||||
"file:///bin",
|
||||
"PathUtils.toFileURI() with a non-root directory path"
|
||||
);
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ add_task(async function test_download_writes_file_in_profile() {
|
|||
|
||||
Assert.equal(
|
||||
fileURL,
|
||||
PROFILE_URL + "settings/main/some-collection/test_file.pem"
|
||||
PROFILE_URL + "/settings/main/some-collection/test_file.pem"
|
||||
);
|
||||
Assert.ok(await IOUtils.exists(localFilePath));
|
||||
const stat = await IOUtils.stat(localFilePath);
|
||||
|
@ -292,13 +292,13 @@ add_task(async function test_downloader_is_accessible_via_client() {
|
|||
|
||||
Assert.equal(
|
||||
fileURL,
|
||||
PROFILE_URL +
|
||||
[
|
||||
"settings",
|
||||
client.bucketName,
|
||||
client.collectionName,
|
||||
RECORD.attachment.filename,
|
||||
].join("/")
|
||||
[
|
||||
PROFILE_URL,
|
||||
"settings",
|
||||
client.bucketName,
|
||||
client.collectionName,
|
||||
RECORD.attachment.filename,
|
||||
].join("/")
|
||||
);
|
||||
});
|
||||
add_task(clear_state);
|
||||
|
|
Загрузка…
Ссылка в новой задаче