mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1822873 - Avoid mainthread IO in PathUtils.toFileURI r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D173330
This commit is contained in:
parent
82c4d9ad65
commit
3e23e936ef
@ -28,6 +28,7 @@
|
|||||||
#include "nsLocalFile.h"
|
#include "nsLocalFile.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include "nsURLHelper.h"
|
||||||
#include "xpcpublic.h"
|
#include "xpcpublic.h"
|
||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
@ -397,13 +398,8 @@ void PathUtils::ToFileURI(const GlobalObject&, const nsAString& aPath,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
if (nsresult rv = net_GetURLSpecFromActualFile(path, aResult);
|
||||||
if (nsresult rv = NS_NewFileURI(getter_AddRefs(uri), path); NS_FAILED(rv)) {
|
NS_FAILED(rv)) {
|
||||||
ThrowError(aErr, rv, "Could not initialize File URI"_ns);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nsresult rv = uri->GetSpec(aResult); NS_FAILED(rv)) {
|
|
||||||
ThrowError(aErr, rv, "Could not retrieve URI spec"_ns);
|
ThrowError(aErr, rv, "Could not retrieve URI spec"_ns);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -528,13 +528,13 @@
|
|||||||
if (Services.appinfo.OS === "WINNT") {
|
if (Services.appinfo.OS === "WINNT") {
|
||||||
is(
|
is(
|
||||||
PathUtils.toFileURI("C:\\"),
|
PathUtils.toFileURI("C:\\"),
|
||||||
"file:///C:/",
|
"file:///C:",
|
||||||
"PathUtils.toFileURI() with a root path"
|
"PathUtils.toFileURI() with a root path"
|
||||||
);
|
);
|
||||||
|
|
||||||
is(
|
is(
|
||||||
PathUtils.toFileURI("C:\\Windows\\"),
|
PathUtils.toFileURI("C:\\Windows\\"),
|
||||||
"file:///C:/Windows/",
|
"file:///C:/Windows",
|
||||||
"PathUtils.toFileURI() with a non-root directory path"
|
"PathUtils.toFileURI() with a non-root directory path"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -552,7 +552,7 @@
|
|||||||
|
|
||||||
is(
|
is(
|
||||||
PathUtils.toFileURI("/bin"),
|
PathUtils.toFileURI("/bin"),
|
||||||
"file:///bin/",
|
"file:///bin",
|
||||||
"PathUtils.toFileURI() with a non-root directory path"
|
"PathUtils.toFileURI() with a non-root directory path"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ add_task(async function test_download_writes_file_in_profile() {
|
|||||||
|
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
fileURL,
|
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));
|
Assert.ok(await IOUtils.exists(localFilePath));
|
||||||
const stat = await IOUtils.stat(localFilePath);
|
const stat = await IOUtils.stat(localFilePath);
|
||||||
|
Loading…
Reference in New Issue
Block a user