Bug 1766130 - Properly propagate errors from Promise creation. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D144515
This commit is contained in:
@@ -1527,16 +1527,10 @@ bool Document::CallerIsTrustedAboutHttpsOnlyError(JSContext* aCx,
|
||||
}
|
||||
|
||||
already_AddRefed<mozilla::dom::Promise> Document::AddCertException(
|
||||
bool aIsTemporary) {
|
||||
nsIGlobalObject* global = GetScopeObject();
|
||||
if (!global) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorResult er;
|
||||
RefPtr<Promise> promise =
|
||||
Promise::Create(global, er, Promise::ePropagateUserInteraction);
|
||||
if (er.Failed()) {
|
||||
bool aIsTemporary, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetScopeObject(), aError,
|
||||
Promise::ePropagateUserInteraction);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -4025,7 +4025,8 @@ class Document : public nsINode,
|
||||
static bool AutomaticStorageAccessPermissionCanBeGranted(
|
||||
nsIPrincipal* aPrincipal);
|
||||
|
||||
already_AddRefed<Promise> AddCertException(bool aIsTemporary);
|
||||
already_AddRefed<Promise> AddCertException(bool aIsTemporary,
|
||||
ErrorResult& aError);
|
||||
|
||||
void ReloadWithHttpsOnlyException();
|
||||
|
||||
|
||||
@@ -1397,7 +1397,8 @@ Promise* Navigator::GetBattery(ErrorResult& aRv) {
|
||||
// Navigator::Share() - Web Share API
|
||||
//*****************************************************************************
|
||||
|
||||
Promise* Navigator::Share(const ShareData& aData, ErrorResult& aRv) {
|
||||
already_AddRefed<Promise> Navigator::Share(const ShareData& aData,
|
||||
ErrorResult& aRv) {
|
||||
if (!mWindow || !mWindow->IsFullyActive()) {
|
||||
aRv.ThrowInvalidStateError("The document is not fully active.");
|
||||
return nullptr;
|
||||
@@ -1495,7 +1496,7 @@ Promise* Navigator::Share(const ShareData& aData, ErrorResult& aRv) {
|
||||
}
|
||||
self->mSharePromise = nullptr;
|
||||
});
|
||||
return mSharePromise;
|
||||
return do_AddRef(mSharePromise);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
||||
@@ -133,7 +133,7 @@ class Navigator final : public nsISupports, public nsWrapperCache {
|
||||
Promise* GetBattery(ErrorResult& aRv);
|
||||
|
||||
bool CanShare(const ShareData& aData);
|
||||
Promise* Share(const ShareData& aData, ErrorResult& aRv);
|
||||
already_AddRefed<Promise> Share(const ShareData& aData, ErrorResult& aRv);
|
||||
|
||||
static void AppName(nsAString& aAppName, nsIPrincipal* aCallerPrincipal,
|
||||
bool aUsePrefOverriddenValue);
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace IOUtils {
|
||||
* @return Resolves with an array of unsigned byte values read from disk,
|
||||
* otherwise rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<Uint8Array> read(DOMString path, optional ReadOptions opts = {});
|
||||
/**
|
||||
* Reads the UTF-8 text file located at |path| and returns the decoded
|
||||
@@ -45,6 +46,7 @@ namespace IOUtils {
|
||||
* @return Resolves with the file contents encoded as a string, otherwise
|
||||
* rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<UTF8String> readUTF8(DOMString path, optional ReadUTF8Options opts = {});
|
||||
/**
|
||||
* Read the UTF-8 text file located at |path| and return the contents
|
||||
@@ -56,6 +58,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @return Resolves with the contents of the file parsed as JSON.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<any> readJSON(DOMString path, optional ReadUTF8Options opts = {});
|
||||
/**
|
||||
* Attempts to safely write |data| to a file at |path|.
|
||||
@@ -74,6 +77,7 @@ namespace IOUtils {
|
||||
* @return Resolves with the number of bytes successfully written to the file,
|
||||
* otherwise rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<unsigned long long> write(DOMString path, Uint8Array data, optional WriteOptions options = {});
|
||||
/**
|
||||
* Attempts to encode |string| to UTF-8, then safely write the result to a
|
||||
@@ -86,6 +90,7 @@ namespace IOUtils {
|
||||
* @return Resolves with the number of bytes successfully written to the file,
|
||||
* otherwise rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<unsigned long long> writeUTF8(DOMString path, UTF8String string, optional WriteOptions options = {});
|
||||
/**
|
||||
* Attempts to serialize |value| into a JSON string and encode it as into a
|
||||
@@ -99,6 +104,7 @@ namespace IOUtils {
|
||||
* @return Resolves with the number of bytes successfully written to the file,
|
||||
* otherwise rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<unsigned long long> writeJSON(DOMString path, any value, optional WriteOptions options = {});
|
||||
/**
|
||||
* Moves the file from |sourcePath| to |destPath|, creating necessary parents.
|
||||
@@ -113,6 +119,7 @@ namespace IOUtils {
|
||||
* @return Resolves if the file is moved successfully, otherwise rejects with
|
||||
* a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> move(DOMString sourcePath, DOMString destPath, optional MoveOptions options = {});
|
||||
/**
|
||||
* Removes a file or directory at |path| according to |options|.
|
||||
@@ -123,6 +130,7 @@ namespace IOUtils {
|
||||
* @return Resolves if the file is removed successfully, otherwise rejects
|
||||
* with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> remove(DOMString path, optional RemoveOptions options = {});
|
||||
/**
|
||||
* Creates a new directory at |path| according to |options|.
|
||||
@@ -132,6 +140,7 @@ namespace IOUtils {
|
||||
* @return Resolves if the directory is created successfully, otherwise
|
||||
* rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> makeDirectory(DOMString path, optional MakeDirectoryOptions options = {});
|
||||
/**
|
||||
* Obtains information about a file, such as size, modification dates, etc.
|
||||
@@ -144,6 +153,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @see FileInfo
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<FileInfo> stat(DOMString path);
|
||||
/**
|
||||
* Copies a file or directory from |sourcePath| to |destPath| according to
|
||||
@@ -157,6 +167,7 @@ namespace IOUtils {
|
||||
* @return Resolves if the file was copied successfully, otherwise rejects
|
||||
* with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> copy(DOMString sourcePath, DOMString destPath, optional CopyOptions options = {});
|
||||
/**
|
||||
* Updates the |modification| time for the file at |path|.
|
||||
@@ -173,6 +184,7 @@ namespace IOUtils {
|
||||
* milliseconds since the Unix epoch, otherwise rejects with a
|
||||
* DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<long long> setModificationTime(DOMString path, optional long long modification);
|
||||
/**
|
||||
* Retrieves a (possibly empty) list of immediate children of the directory at
|
||||
@@ -184,6 +196,7 @@ namespace IOUtils {
|
||||
* children of the directory at |path|, otherwise rejects with a
|
||||
* DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<sequence<DOMString>> getChildren(DOMString path, optional GetChildrenOptions options = {});
|
||||
/**
|
||||
* Set the permissions of the file at |path|.
|
||||
@@ -204,6 +217,7 @@ namespace IOUtils {
|
||||
* @return Resolves if the permissions were set successfully, otherwise
|
||||
* rejects with a DOMException.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> setPermissions(DOMString path, unsigned long permissions, optional boolean honorUmask = true);
|
||||
/**
|
||||
* Return whether or not the file exists at the given path.
|
||||
@@ -212,6 +226,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @return A promise that resolves to whether or not the given file exists.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<boolean> exists(DOMString path);
|
||||
|
||||
/**
|
||||
@@ -223,6 +238,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @return A promise that resolves to a unique filename.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<DOMString> createUniqueFile(DOMString parent, DOMString prefix, optional unsigned long permissions = 0644);
|
||||
|
||||
/**
|
||||
@@ -234,6 +250,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @return A promise that resolves to a unique directory name.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<DOMString> createUniqueDirectory(DOMString parent, DOMString prefix, optional unsigned long permissions = 0755);
|
||||
|
||||
#if defined(XP_WIN)
|
||||
@@ -244,6 +261,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @return A promise that resolves to the Windows-specific file attributes.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<WindowsFileAttributes> getWindowsAttributes(DOMString path);
|
||||
|
||||
/**
|
||||
@@ -256,6 +274,7 @@ namespace IOUtils {
|
||||
*
|
||||
* @return A promise that resolves is the attributes were set successfully.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> setWindowsAttributes(DOMString path, optional WindowsFileAttributes attrs = {});
|
||||
#elif defined(XP_MACOSX)
|
||||
/**
|
||||
@@ -267,6 +286,7 @@ namespace IOUtils {
|
||||
* @return A promise that resolves to whether or not the file has an extended
|
||||
* attribute, or rejects with an error.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<boolean> hasMacXAttr(DOMString path, UTF8String attr);
|
||||
/**
|
||||
* Return the value of an extended attribute for a file.
|
||||
@@ -277,6 +297,7 @@ namespace IOUtils {
|
||||
* @return A promise that resolves to the value of the extended attribute, or
|
||||
* rejects with an error.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<Uint8Array> getMacXAttr(DOMString path, UTF8String attr);
|
||||
/**
|
||||
* Set the extended attribute on a file.
|
||||
@@ -288,6 +309,7 @@ namespace IOUtils {
|
||||
* @return A promise that resolves to whether or not the file has an extended
|
||||
* attribute, or rejects with an error.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> setMacXAttr(DOMString path, UTF8String attr, Uint8Array value);
|
||||
/**
|
||||
* Delete the extended attribute on a file.
|
||||
@@ -298,6 +320,7 @@ namespace IOUtils {
|
||||
* @return A promise that resolves if the attribute was deleted, or rejects
|
||||
* with an error.
|
||||
*/
|
||||
[NewObject]
|
||||
Promise<void> delMacXAttr(DOMString path, UTF8String attr);
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -144,6 +144,7 @@ interface FluentBundleIterator {
|
||||
|
||||
[LegacyNoInterfaceObject, Exposed=Window]
|
||||
interface FluentBundleAsyncIterator {
|
||||
[NewObject]
|
||||
Promise<FluentBundleIteratorResult> next();
|
||||
[Alias="@@asyncIterator"] FluentBundleAsyncIterator values();
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ already_AddRefed<Promise> CredentialsContainer::Get(
|
||||
}
|
||||
|
||||
EnsureWebAuthnManager();
|
||||
return mManager->GetAssertion(aOptions.mPublicKey, aOptions.mSignal);
|
||||
return mManager->GetAssertion(aOptions.mPublicKey, aOptions.mSignal, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CredentialsContainer::Create(
|
||||
@@ -121,7 +121,7 @@ already_AddRefed<Promise> CredentialsContainer::Create(
|
||||
}
|
||||
|
||||
EnsureWebAuthnManager();
|
||||
return mManager->MakeCredential(aOptions.mPublicKey, aOptions.mSignal);
|
||||
return mManager->MakeCredential(aOptions.mPublicKey, aOptions.mSignal, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CredentialsContainer::Store(
|
||||
@@ -131,7 +131,7 @@ already_AddRefed<Promise> CredentialsContainer::Store(
|
||||
}
|
||||
|
||||
EnsureWebAuthnManager();
|
||||
return mManager->Store(aCredential);
|
||||
return mManager->Store(aCredential, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CredentialsContainer::PreventSilentAccess(
|
||||
|
||||
@@ -47,11 +47,10 @@ FileSystemDirectoryHandle::Values() {
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemDirectoryHandle::GetFileHandle(
|
||||
const nsAString& aName, const FileSystemGetFileOptions& aOptions) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
const nsAString& aName, const FileSystemGetFileOptions& aOptions,
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -61,11 +60,10 @@ already_AddRefed<Promise> FileSystemDirectoryHandle::GetFileHandle(
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemDirectoryHandle::GetDirectoryHandle(
|
||||
const nsAString& aName, const FileSystemGetDirectoryOptions& aOptions) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
const nsAString& aName, const FileSystemGetDirectoryOptions& aOptions,
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -75,11 +73,10 @@ already_AddRefed<Promise> FileSystemDirectoryHandle::GetDirectoryHandle(
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemDirectoryHandle::RemoveEntry(
|
||||
const nsAString& aName, const FileSystemRemoveOptions& aOptions) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
const nsAString& aName, const FileSystemRemoveOptions& aOptions,
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -89,11 +86,9 @@ already_AddRefed<Promise> FileSystemDirectoryHandle::RemoveEntry(
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemDirectoryHandle::Resolve(
|
||||
FileSystemHandle& aPossibleDescendant) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
FileSystemHandle& aPossibleDescendant, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
#include "mozilla/dom/FileSystemHandle.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class FileSystemDirectoryIterator;
|
||||
struct FileSystemGetFileOptions;
|
||||
@@ -36,20 +40,25 @@ class FileSystemDirectoryHandle final : public FileSystemHandle {
|
||||
[[nodiscard]] already_AddRefed<FileSystemDirectoryIterator> Values();
|
||||
|
||||
already_AddRefed<Promise> GetFileHandle(
|
||||
const nsAString& aName, const FileSystemGetFileOptions& aOptions);
|
||||
const nsAString& aName, const FileSystemGetFileOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> GetDirectoryHandle(
|
||||
const nsAString& aName, const FileSystemGetDirectoryOptions& aOptions);
|
||||
const nsAString& aName, const FileSystemGetDirectoryOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> RemoveEntry(
|
||||
const nsAString& aName, const FileSystemRemoveOptions& aOptions);
|
||||
already_AddRefed<Promise> RemoveEntry(const nsAString& aName,
|
||||
const FileSystemRemoveOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> Resolve(FileSystemHandle& aPossibleDescendant);
|
||||
already_AddRefed<Promise> Resolve(FileSystemHandle& aPossibleDescendant,
|
||||
ErrorResult& aError);
|
||||
|
||||
private:
|
||||
~FileSystemDirectoryHandle() = default;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_FS_FILESYSTEMDIRECTORYHANDLE_H_
|
||||
|
||||
@@ -37,11 +37,10 @@ JSObject* FileSystemDirectoryIterator::WrapObject(
|
||||
|
||||
// WebIDL Interface
|
||||
|
||||
already_AddRefed<Promise> FileSystemDirectoryIterator::Next() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemDirectoryIterator::Next(
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class Promise;
|
||||
|
||||
@@ -31,7 +35,7 @@ class FileSystemDirectoryIterator : public nsISupports, public nsWrapperCache {
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// WebIDL Interface
|
||||
already_AddRefed<Promise> Next();
|
||||
already_AddRefed<Promise> Next(ErrorResult& aError);
|
||||
|
||||
protected:
|
||||
virtual ~FileSystemDirectoryIterator() = default;
|
||||
@@ -39,6 +43,7 @@ class FileSystemDirectoryIterator : public nsISupports, public nsWrapperCache {
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_FS_FILESYSTEMDIRECTORYITERATOR_H_
|
||||
|
||||
@@ -30,11 +30,9 @@ FileSystemHandleKind FileSystemFileHandle::Kind() {
|
||||
return FileSystemHandleKind::File;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemFileHandle::GetFile() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemFileHandle::GetFile(ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -44,11 +42,9 @@ already_AddRefed<Promise> FileSystemFileHandle::GetFile() {
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemFileHandle::CreateWritable(
|
||||
const FileSystemCreateWritableOptions& aOptions) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
const FileSystemCreateWritableOptions& aOptions, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -57,11 +53,10 @@ already_AddRefed<Promise> FileSystemFileHandle::CreateWritable(
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemFileHandle::CreateSyncAccessHandle() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemFileHandle::CreateSyncAccessHandle(
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
#include "mozilla/dom/FileSystemHandle.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
struct FileSystemCreateWritableOptions;
|
||||
|
||||
@@ -26,17 +30,18 @@ class FileSystemFileHandle final : public FileSystemHandle {
|
||||
// WebIDL interface
|
||||
FileSystemHandleKind Kind() override;
|
||||
|
||||
already_AddRefed<Promise> GetFile();
|
||||
already_AddRefed<Promise> GetFile(ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> CreateWritable(
|
||||
const FileSystemCreateWritableOptions& aOptions);
|
||||
const FileSystemCreateWritableOptions& aOptions, ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> CreateSyncAccessHandle();
|
||||
already_AddRefed<Promise> CreateSyncAccessHandle(ErrorResult& aError);
|
||||
|
||||
private:
|
||||
~FileSystemFileHandle() = default;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_FS_FILESYSTEMFILEHANDLE_H_
|
||||
|
||||
@@ -34,11 +34,9 @@ JSObject* FileSystemHandle::WrapObject(JSContext* aCx,
|
||||
void FileSystemHandle::GetName(DOMString& aResult) { aResult.SetNull(); }
|
||||
|
||||
already_AddRefed<Promise> FileSystemHandle::IsSameEntry(
|
||||
FileSystemHandle& aOther) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
FileSystemHandle& aOther, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class DOMString;
|
||||
enum class FileSystemHandleKind : uint8_t;
|
||||
@@ -35,7 +39,8 @@ class FileSystemHandle : public nsISupports, public nsWrapperCache {
|
||||
|
||||
void GetName(DOMString& aResult);
|
||||
|
||||
already_AddRefed<Promise> IsSameEntry(FileSystemHandle& aOther);
|
||||
already_AddRefed<Promise> IsSameEntry(FileSystemHandle& aOther,
|
||||
ErrorResult& aError);
|
||||
|
||||
protected:
|
||||
virtual ~FileSystemHandle() = default;
|
||||
@@ -43,6 +48,7 @@ class FileSystemHandle : public nsISupports, public nsWrapperCache {
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_FS_FILESYSTEMHANDLE_H_
|
||||
|
||||
@@ -45,11 +45,10 @@ uint64_t FileSystemSyncAccessHandle::Write(
|
||||
return 0;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::Truncate(uint64_t aSize) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::Truncate(
|
||||
uint64_t aSize, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -58,11 +57,10 @@ already_AddRefed<Promise> FileSystemSyncAccessHandle::Truncate(uint64_t aSize) {
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::GetSize() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::GetSize(
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -71,11 +69,10 @@ already_AddRefed<Promise> FileSystemSyncAccessHandle::GetSize() {
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::Flush() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::Flush(
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -84,11 +81,10 @@ already_AddRefed<Promise> FileSystemSyncAccessHandle::Flush() {
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::Close() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FileSystemSyncAccessHandle::Close(
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
struct FileSystemReadWriteOptions;
|
||||
class MaybeSharedArrayBufferViewOrMaybeSharedArrayBuffer;
|
||||
@@ -40,13 +44,13 @@ class FileSystemSyncAccessHandle final : public nsISupports,
|
||||
const MaybeSharedArrayBufferViewOrMaybeSharedArrayBuffer& aBuffer,
|
||||
const FileSystemReadWriteOptions& aOptions);
|
||||
|
||||
already_AddRefed<Promise> Truncate(uint64_t aSize);
|
||||
already_AddRefed<Promise> Truncate(uint64_t aSize, ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> GetSize();
|
||||
already_AddRefed<Promise> GetSize(ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> Flush();
|
||||
already_AddRefed<Promise> Flush(ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> Close();
|
||||
already_AddRefed<Promise> Close(ErrorResult& aError);
|
||||
|
||||
private:
|
||||
virtual ~FileSystemSyncAccessHandle() = default;
|
||||
@@ -54,6 +58,7 @@ class FileSystemSyncAccessHandle final : public nsISupports,
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_FS_FILESYSTEMSYNCACCESSHANDLE_H_
|
||||
|
||||
@@ -26,11 +26,10 @@ JSObject* FileSystemWritableFileStream::WrapObject(
|
||||
// WebIDL Interface
|
||||
|
||||
already_AddRefed<Promise> FileSystemWritableFileStream::Write(
|
||||
const ArrayBufferViewOrArrayBufferOrBlobOrUSVStringOrWriteParams& aData) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
const ArrayBufferViewOrArrayBufferOrBlobOrUSVStringOrWriteParams& aData,
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -40,11 +39,9 @@ already_AddRefed<Promise> FileSystemWritableFileStream::Write(
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemWritableFileStream::Seek(
|
||||
uint64_t aPosition) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
uint64_t aPosition, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -54,11 +51,9 @@ already_AddRefed<Promise> FileSystemWritableFileStream::Seek(
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FileSystemWritableFileStream::Truncate(
|
||||
uint64_t aSize) {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
uint64_t aSize, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
#include "mozilla/dom/WritableStream.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
namespace mozilla {
|
||||
|
||||
class ErrorResult;
|
||||
|
||||
namespace dom {
|
||||
|
||||
class ArrayBufferViewOrArrayBufferOrBlobOrUSVStringOrWriteParams;
|
||||
|
||||
@@ -25,16 +29,18 @@ class FileSystemWritableFileStream final : public WritableStream {
|
||||
|
||||
// WebIDL Interface
|
||||
already_AddRefed<Promise> Write(
|
||||
const ArrayBufferViewOrArrayBufferOrBlobOrUSVStringOrWriteParams& aData);
|
||||
const ArrayBufferViewOrArrayBufferOrBlobOrUSVStringOrWriteParams& aData,
|
||||
ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> Seek(uint64_t aPosition);
|
||||
already_AddRefed<Promise> Seek(uint64_t aPosition, ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> Truncate(uint64_t aSize);
|
||||
already_AddRefed<Promise> Truncate(uint64_t aSize, ErrorResult& aError);
|
||||
|
||||
private:
|
||||
~FileSystemWritableFileStream() = default;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_FS_FILESYSTEMWRITABLEFILESTREAM_H_
|
||||
|
||||
@@ -103,6 +103,7 @@ already_AddRefed<Promise> GamepadServiceTest::AddGamepad(
|
||||
uint32_t aNumButtons, uint32_t aNumAxes, uint32_t aNumHaptics,
|
||||
uint32_t aNumLightIndicator, uint32_t aNumTouchEvents, ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -134,6 +135,7 @@ already_AddRefed<Promise> GamepadServiceTest::AddGamepad(
|
||||
already_AddRefed<Promise> GamepadServiceTest::RemoveGamepad(
|
||||
uint32_t aHandleSlot, ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -161,6 +163,7 @@ already_AddRefed<Promise> GamepadServiceTest::NewButtonEvent(
|
||||
uint32_t aHandleSlot, uint32_t aButton, bool aPressed, bool aTouched,
|
||||
ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -186,6 +189,7 @@ already_AddRefed<Promise> GamepadServiceTest::NewButtonValueEvent(
|
||||
uint32_t aHandleSlot, uint32_t aButton, bool aPressed, bool aTouched,
|
||||
double aValue, ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -210,6 +214,7 @@ already_AddRefed<Promise> GamepadServiceTest::NewButtonValueEvent(
|
||||
already_AddRefed<Promise> GamepadServiceTest::NewAxisMoveEvent(
|
||||
uint32_t aHandleSlot, uint32_t aAxis, double aValue, ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -239,6 +244,7 @@ already_AddRefed<Promise> GamepadServiceTest::NewPoseMove(
|
||||
const Nullable<Float32Array>& aLinVelocity,
|
||||
const Nullable<Float32Array>& aLinAcceleration, ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -322,6 +328,7 @@ already_AddRefed<Promise> GamepadServiceTest::NewTouch(
|
||||
uint8_t aSurfaceId, const Float32Array& aPos,
|
||||
const Nullable<Float32Array>& aSurfDim, ErrorResult& aRv) {
|
||||
if (mShuttingDown) {
|
||||
aRv.ThrowInvalidStateError("Shutting down");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1112,13 +1112,17 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(PeerConnectionImpl::Operation)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(PeerConnectionImpl::Operation)
|
||||
|
||||
PeerConnectionImpl::Operation::Operation(PeerConnectionImpl* aPc)
|
||||
: mPromise(aPc->MakePromise()), mPc(aPc) {}
|
||||
PeerConnectionImpl::Operation::Operation(PeerConnectionImpl* aPc,
|
||||
ErrorResult& aError)
|
||||
: mPromise(aPc->MakePromise(aError)), mPc(aPc) {}
|
||||
|
||||
PeerConnectionImpl::Operation::~Operation() = default;
|
||||
|
||||
void PeerConnectionImpl::Operation::Call() {
|
||||
RefPtr<dom::Promise> opPromise = CallImpl();
|
||||
void PeerConnectionImpl::Operation::Call(ErrorResult& aError) {
|
||||
RefPtr<dom::Promise> opPromise = CallImpl(aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
// Upon fulfillment or rejection of the promise returned by the operation,
|
||||
// run the following steps:
|
||||
// (NOTE: mPromise is p from https://w3c.github.io/webrtc-pc/#dfn-chain,
|
||||
@@ -1138,7 +1142,7 @@ void PeerConnectionImpl::Operation::ResolvedCallback(
|
||||
// steps:
|
||||
// (Static analysis forces us to use a temporary)
|
||||
RefPtr<PeerConnectionImpl> pc = mPc;
|
||||
pc->RunNextOperation();
|
||||
pc->RunNextOperation(aRv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1154,7 +1158,7 @@ void PeerConnectionImpl::Operation::RejectedCallback(
|
||||
// steps:
|
||||
// (Static analysis forces us to use a temporary)
|
||||
RefPtr<PeerConnectionImpl> pc = mPc;
|
||||
pc->RunNextOperation();
|
||||
pc->RunNextOperation(aRv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1170,21 +1174,29 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PeerConnectionImpl::JSOperation)
|
||||
NS_INTERFACE_MAP_END_INHERITING(PeerConnectionImpl::Operation)
|
||||
|
||||
PeerConnectionImpl::JSOperation::JSOperation(PeerConnectionImpl* aPc,
|
||||
dom::ChainedOperation& aOp)
|
||||
: Operation(aPc), mOperation(&aOp) {}
|
||||
dom::ChainedOperation& aOp,
|
||||
ErrorResult& aError)
|
||||
: Operation(aPc, aError), mOperation(&aOp) {}
|
||||
|
||||
RefPtr<dom::Promise> PeerConnectionImpl::JSOperation::CallImpl() {
|
||||
RefPtr<dom::Promise> PeerConnectionImpl::JSOperation::CallImpl(
|
||||
ErrorResult& aError) {
|
||||
// Static analysis will not let us call this without a temporary :(
|
||||
RefPtr<dom::ChainedOperation> op = mOperation;
|
||||
return op->Call();
|
||||
return op->Call(aError);
|
||||
}
|
||||
|
||||
already_AddRefed<dom::Promise> PeerConnectionImpl::Chain(
|
||||
dom::ChainedOperation& aOperation) {
|
||||
dom::ChainedOperation& aOperation, ErrorResult& aError) {
|
||||
MOZ_RELEASE_ASSERT(!mChainingOperation);
|
||||
mChainingOperation = true;
|
||||
RefPtr<Operation> operation = new JSOperation(this, aOperation);
|
||||
RefPtr<Promise> promise = Chain(operation);
|
||||
RefPtr<Operation> operation = new JSOperation(this, aOperation, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<Promise> promise = Chain(operation, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
mChainingOperation = false;
|
||||
return promise.forget();
|
||||
}
|
||||
@@ -1194,12 +1206,15 @@ already_AddRefed<dom::Promise> PeerConnectionImpl::Chain(
|
||||
// run _immediately_ (without any Promise.Then!) if the operations chain is
|
||||
// empty.
|
||||
already_AddRefed<dom::Promise> PeerConnectionImpl::Chain(
|
||||
const RefPtr<Operation>& aOperation) {
|
||||
const RefPtr<Operation>& aOperation, ErrorResult& aError) {
|
||||
// If connection.[[IsClosed]] is true, return a promise rejected with a newly
|
||||
// created InvalidStateError.
|
||||
if (IsClosed()) {
|
||||
CSFLogDebug(LOGTAG, "%s:%d: Peer connection is closed", __FILE__, __LINE__);
|
||||
RefPtr<dom::Promise> error = MakePromise();
|
||||
RefPtr<dom::Promise> error = MakePromise(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
error->MaybeRejectWithInvalidStateError("Peer connection is closed");
|
||||
return error.forget();
|
||||
}
|
||||
@@ -1209,14 +1224,17 @@ already_AddRefed<dom::Promise> PeerConnectionImpl::Chain(
|
||||
|
||||
// If the length of [[Operations]] is exactly 1, execute operation.
|
||||
if (mOperations.Length() == 1) {
|
||||
aOperation->Call();
|
||||
aOperation->Call(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// This is the promise p from https://w3c.github.io/webrtc-pc/#dfn-chain
|
||||
return do_AddRef(aOperation->GetPromise());
|
||||
}
|
||||
|
||||
void PeerConnectionImpl::RunNextOperation() {
|
||||
void PeerConnectionImpl::RunNextOperation(ErrorResult& aError) {
|
||||
// If connection.[[IsClosed]] is true, abort these steps.
|
||||
if (IsClosed()) {
|
||||
return;
|
||||
@@ -1230,7 +1248,7 @@ void PeerConnectionImpl::RunNextOperation() {
|
||||
if (mOperations.Length()) {
|
||||
// Cannot call without a temporary :(
|
||||
RefPtr<Operation> op = mOperations[0];
|
||||
op->Call();
|
||||
op->Call(aError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1246,14 +1264,10 @@ void PeerConnectionImpl::RunNextOperation() {
|
||||
UpdateNegotiationNeeded();
|
||||
}
|
||||
|
||||
already_AddRefed<dom::Promise> PeerConnectionImpl::MakePromise() const {
|
||||
already_AddRefed<dom::Promise> PeerConnectionImpl::MakePromise(
|
||||
ErrorResult& aError) const {
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
|
||||
ErrorResult rv;
|
||||
RefPtr<dom::Promise> result = dom::Promise::Create(global, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
rv.StealNSResult();
|
||||
}
|
||||
return result.forget();
|
||||
return dom::Promise::Create(global, aError);
|
||||
}
|
||||
|
||||
void PeerConnectionImpl::UpdateNegotiationNeeded() {
|
||||
|
||||
@@ -403,9 +403,9 @@ class PeerConnectionImpl final
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(Operation)
|
||||
explicit Operation(PeerConnectionImpl* aPc);
|
||||
Operation(PeerConnectionImpl* aPc, ErrorResult& aError);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void Call();
|
||||
void Call(ErrorResult& aError);
|
||||
dom::Promise* GetPromise() { return mPromise; }
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
@@ -417,7 +417,7 @@ class PeerConnectionImpl final
|
||||
|
||||
protected:
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
virtual RefPtr<dom::Promise> CallImpl() = 0;
|
||||
virtual RefPtr<dom::Promise> CallImpl(ErrorResult& aError) = 0;
|
||||
virtual ~Operation();
|
||||
// This is the promise p from https://w3c.github.io/webrtc-pc/#dfn-chain
|
||||
// This will be a content promise, since we return this to the caller of
|
||||
@@ -428,22 +428,25 @@ class PeerConnectionImpl final
|
||||
|
||||
class JSOperation final : public Operation {
|
||||
public:
|
||||
explicit JSOperation(PeerConnectionImpl* aPc, dom::ChainedOperation& aOp);
|
||||
JSOperation(PeerConnectionImpl* aPc, dom::ChainedOperation& aOp,
|
||||
ErrorResult& aError);
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JSOperation, Operation)
|
||||
|
||||
private:
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
RefPtr<dom::Promise> CallImpl() override;
|
||||
RefPtr<dom::Promise> CallImpl(ErrorResult& aError) override;
|
||||
~JSOperation() = default;
|
||||
RefPtr<dom::ChainedOperation> mOperation;
|
||||
};
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<dom::Promise> Chain(dom::ChainedOperation& aOperation);
|
||||
already_AddRefed<dom::Promise> Chain(dom::ChainedOperation& aOperation,
|
||||
ErrorResult& aError);
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<dom::Promise> Chain(const RefPtr<Operation>& aOperation);
|
||||
already_AddRefed<dom::Promise> MakePromise() const;
|
||||
already_AddRefed<dom::Promise> Chain(const RefPtr<Operation>& aOperation,
|
||||
ErrorResult& aError);
|
||||
already_AddRefed<dom::Promise> MakePromise(ErrorResult& aError) const;
|
||||
|
||||
void UpdateNegotiationNeeded();
|
||||
|
||||
@@ -545,7 +548,7 @@ class PeerConnectionImpl final
|
||||
const;
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
void RunNextOperation();
|
||||
void RunNextOperation(ErrorResult& aError);
|
||||
|
||||
// Timecard used to measure processing time. This should be the first class
|
||||
// attribute so that we accurately measure the time required to instantiate
|
||||
|
||||
@@ -146,12 +146,10 @@ RTCDtlsTransport* RTCRtpReceiver::GetTransport() const {
|
||||
return mTransceiverImpl->GetDtlsTransport();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> RTCRtpReceiver::GetStats() {
|
||||
already_AddRefed<Promise> RTCRtpReceiver::GetStats(ErrorResult& aError) {
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(global, rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
rv.StealNSResult();
|
||||
RefPtr<Promise> promise = Promise::Create(global, aError);
|
||||
if (NS_WARN_IF(aError.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class RTCRtpReceiver : public nsISupports, public nsWrapperCache {
|
||||
// webidl
|
||||
MediaStreamTrack* Track() const { return mTrack; }
|
||||
RTCDtlsTransport* GetTransport() const;
|
||||
already_AddRefed<Promise> GetStats();
|
||||
already_AddRefed<Promise> GetStats(ErrorResult& aError);
|
||||
void GetContributingSources(
|
||||
nsTArray<dom::RTCRtpContributingSource>& aSources);
|
||||
void GetSynchronizationSources(
|
||||
|
||||
@@ -85,8 +85,11 @@ RTCDtlsTransport* RTCRtpSender::GetTransport() const {
|
||||
|
||||
RTCDTMFSender* RTCRtpSender::GetDtmf() const { return mDtmf; }
|
||||
|
||||
already_AddRefed<Promise> RTCRtpSender::GetStats() {
|
||||
RefPtr<Promise> promise = MakePromise();
|
||||
already_AddRefed<Promise> RTCRtpSender::GetStats(ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = MakePromise(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (NS_WARN_IF(!mPipeline)) {
|
||||
// TODO(bug 1056433): When we stop nulling this out when the PC is closed
|
||||
// (or when the transceiver is stopped), we can remove this code. We
|
||||
@@ -391,9 +394,12 @@ nsTArray<RefPtr<dom::RTCStatsPromise>> RTCRtpSender::GetStatsInternal() {
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> RTCRtpSender::SetParameters(
|
||||
const dom::RTCRtpParameters& aParameters) {
|
||||
const dom::RTCRtpParameters& aParameters, ErrorResult& aError) {
|
||||
// TODO(bug 1401592): transaction ids and other spec fixes
|
||||
RefPtr<dom::Promise> p = MakePromise();
|
||||
RefPtr<dom::Promise> p = MakePromise(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (mPc->IsClosed()) {
|
||||
p->MaybeRejectWithInvalidStateError("Peer connection is closed");
|
||||
return p.forget();
|
||||
@@ -515,14 +521,15 @@ class ReplaceTrackOperation final : public PeerConnectionImpl::Operation {
|
||||
public:
|
||||
ReplaceTrackOperation(PeerConnectionImpl* aPc,
|
||||
const RefPtr<TransceiverImpl>& aTransceiver,
|
||||
const RefPtr<MediaStreamTrack>& aTrack);
|
||||
const RefPtr<MediaStreamTrack>& aTrack,
|
||||
ErrorResult& aError);
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ReplaceTrackOperation,
|
||||
PeerConnectionImpl::Operation)
|
||||
|
||||
private:
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
RefPtr<dom::Promise> CallImpl() override;
|
||||
RefPtr<dom::Promise> CallImpl(ErrorResult& aError) override;
|
||||
~ReplaceTrackOperation() = default;
|
||||
RefPtr<TransceiverImpl> mTransceiver;
|
||||
RefPtr<MediaStreamTrack> mNewTrack;
|
||||
@@ -540,17 +547,20 @@ NS_INTERFACE_MAP_END_INHERITING(PeerConnectionImpl::Operation)
|
||||
|
||||
ReplaceTrackOperation::ReplaceTrackOperation(
|
||||
PeerConnectionImpl* aPc, const RefPtr<TransceiverImpl>& aTransceiver,
|
||||
const RefPtr<MediaStreamTrack>& aTrack)
|
||||
: PeerConnectionImpl::Operation(aPc),
|
||||
const RefPtr<MediaStreamTrack>& aTrack, ErrorResult& aError)
|
||||
: PeerConnectionImpl::Operation(aPc, aError),
|
||||
mTransceiver(aTransceiver),
|
||||
mNewTrack(aTrack) {}
|
||||
|
||||
RefPtr<dom::Promise> ReplaceTrackOperation::CallImpl() {
|
||||
RefPtr<dom::Promise> ReplaceTrackOperation::CallImpl(ErrorResult& aError) {
|
||||
RefPtr<RTCRtpSender> sender = mTransceiver->Sender();
|
||||
// If transceiver.[[Stopped]] is true, return a promise rejected with a newly
|
||||
// created InvalidStateError.
|
||||
if (mTransceiver->Stopped()) {
|
||||
RefPtr<dom::Promise> error = sender->MakePromise();
|
||||
RefPtr<dom::Promise> error = sender->MakePromise(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_LOG(gSenderLog, LogLevel::Debug,
|
||||
("%s Cannot call replaceTrack when transceiver is stopped",
|
||||
__FUNCTION__));
|
||||
@@ -560,7 +570,10 @@ RefPtr<dom::Promise> ReplaceTrackOperation::CallImpl() {
|
||||
}
|
||||
|
||||
// Let p be a new promise.
|
||||
RefPtr<dom::Promise> p = sender->MakePromise();
|
||||
RefPtr<dom::Promise> p = sender->MakePromise(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!sender->SeamlessTrackSwitch(mNewTrack)) {
|
||||
MOZ_LOG(gSenderLog, LogLevel::Info,
|
||||
@@ -586,7 +599,7 @@ RefPtr<dom::Promise> ReplaceTrackOperation::CallImpl() {
|
||||
}
|
||||
|
||||
already_AddRefed<dom::Promise> RTCRtpSender::ReplaceTrack(
|
||||
dom::MediaStreamTrack* aWithTrack) {
|
||||
dom::MediaStreamTrack* aWithTrack, ErrorResult& aError) {
|
||||
// If withTrack is non-null and withTrack.kind differs from the transceiver
|
||||
// kind of transceiver, return a promise rejected with a newly created
|
||||
// TypeError.
|
||||
@@ -596,7 +609,10 @@ already_AddRefed<dom::Promise> RTCRtpSender::ReplaceTrack(
|
||||
nsString oldKind;
|
||||
mTransceiverImpl->GetKind(oldKind);
|
||||
if (newKind != oldKind) {
|
||||
RefPtr<dom::Promise> error = MakePromise();
|
||||
RefPtr<dom::Promise> error = MakePromise(aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
error->MaybeRejectWithTypeError(
|
||||
"Cannot replaceTrack with a different kind!");
|
||||
return error.forget();
|
||||
@@ -610,16 +626,20 @@ already_AddRefed<dom::Promise> RTCRtpSender::ReplaceTrack(
|
||||
// Return the result of chaining the following steps to connection's
|
||||
// operations chain:
|
||||
RefPtr<PeerConnectionImpl::Operation> op =
|
||||
new ReplaceTrackOperation(mPc, mTransceiverImpl, aWithTrack);
|
||||
new ReplaceTrackOperation(mPc, mTransceiverImpl, aWithTrack, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
// Static analysis forces us to use a temporary.
|
||||
auto pc = mPc;
|
||||
return pc->Chain(op);
|
||||
return pc->Chain(op, aError);
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* RTCRtpSender::GetParentObject() const { return mWindow; }
|
||||
|
||||
already_AddRefed<dom::Promise> RTCRtpSender::MakePromise() const {
|
||||
return mPc->MakePromise();
|
||||
already_AddRefed<dom::Promise> RTCRtpSender::MakePromise(
|
||||
ErrorResult& aError) const {
|
||||
return mPc->MakePromise(aError);
|
||||
}
|
||||
|
||||
bool RTCRtpSender::SeamlessTrackSwitch(
|
||||
|
||||
@@ -56,10 +56,11 @@ class RTCRtpSender : public nsISupports, public nsWrapperCache {
|
||||
RTCDtlsTransport* GetTransport() const;
|
||||
RTCDTMFSender* GetDtmf() const;
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
already_AddRefed<Promise> ReplaceTrack(MediaStreamTrack* aWithTrack);
|
||||
already_AddRefed<Promise> GetStats();
|
||||
already_AddRefed<Promise> ReplaceTrack(MediaStreamTrack* aWithTrack,
|
||||
ErrorResult& aError);
|
||||
already_AddRefed<Promise> GetStats(ErrorResult& aError);
|
||||
already_AddRefed<Promise> SetParameters(
|
||||
const dom::RTCRtpParameters& aParameters);
|
||||
const dom::RTCRtpParameters& aParameters, ErrorResult& aError);
|
||||
void GetParameters(RTCRtpParameters& aParameters) const;
|
||||
|
||||
nsPIDOMWindowInner* GetParentObject() const;
|
||||
@@ -79,7 +80,7 @@ class RTCRtpSender : public nsISupports, public nsWrapperCache {
|
||||
bool HasTrack(const dom::MediaStreamTrack* aTrack) const;
|
||||
bool IsMyPc(const PeerConnectionImpl* aPc) const { return mPc.get() == aPc; }
|
||||
RefPtr<MediaPipelineTransmit> GetPipeline() const;
|
||||
already_AddRefed<dom::Promise> MakePromise() const;
|
||||
already_AddRefed<dom::Promise> MakePromise(ErrorResult& aError) const;
|
||||
bool SeamlessTrackSwitch(const RefPtr<MediaStreamTrack>& aWithTrack);
|
||||
bool SetSenderTrackWithClosedCheck(const RefPtr<MediaStreamTrack>& aTrack);
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ bool MIDIPort::SysexEnabled() const {
|
||||
return mPort->SysexEnabled();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> MIDIPort::Open() {
|
||||
already_AddRefed<Promise> MIDIPort::Open(ErrorResult& aError) {
|
||||
LOG("MIDIPort::Open");
|
||||
MOZ_ASSERT(mPort);
|
||||
RefPtr<Promise> p;
|
||||
@@ -147,10 +147,9 @@ already_AddRefed<Promise> MIDIPort::Open() {
|
||||
p = mOpeningPromise;
|
||||
return p.forget();
|
||||
}
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(GetOwner());
|
||||
p = Promise::Create(go, rv);
|
||||
if (rv.Failed()) {
|
||||
p = Promise::Create(go, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
mOpeningPromise = p;
|
||||
@@ -158,7 +157,7 @@ already_AddRefed<Promise> MIDIPort::Open() {
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> MIDIPort::Close() {
|
||||
already_AddRefed<Promise> MIDIPort::Close(ErrorResult& aError) {
|
||||
LOG("MIDIPort::Close");
|
||||
MOZ_ASSERT(mPort);
|
||||
RefPtr<Promise> p;
|
||||
@@ -166,10 +165,9 @@ already_AddRefed<Promise> MIDIPort::Close() {
|
||||
p = mClosingPromise;
|
||||
return p.forget();
|
||||
}
|
||||
ErrorResult rv;
|
||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(GetOwner());
|
||||
p = Promise::Create(go, rv);
|
||||
if (rv.Failed()) {
|
||||
p = Promise::Create(go, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
mClosingPromise = p;
|
||||
|
||||
@@ -54,8 +54,8 @@ class MIDIPort : public DOMEventTargetHelper,
|
||||
MIDIPortDeviceState State() const;
|
||||
bool SysexEnabled() const;
|
||||
|
||||
already_AddRefed<Promise> Open();
|
||||
already_AddRefed<Promise> Close();
|
||||
already_AddRefed<Promise> Open(ErrorResult& aError);
|
||||
already_AddRefed<Promise> Close(ErrorResult& aError);
|
||||
|
||||
// MIDIPorts observe the death of their parent MIDIAccess object, and delete
|
||||
// their reference accordingly.
|
||||
|
||||
@@ -752,11 +752,9 @@ already_AddRefed<Promise> StorageManager::Estimate(ErrorResult& aRv) {
|
||||
aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> StorageManager::GetDirectory() {
|
||||
IgnoredErrorResult rv;
|
||||
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> StorageManager::GetDirectory(ErrorResult& aRv) {
|
||||
RefPtr<Promise> promise = Promise::Create(GetParentObject(), aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class StorageManager final : public nsISupports, public nsWrapperCache {
|
||||
|
||||
already_AddRefed<Promise> Estimate(ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> GetDirectory();
|
||||
already_AddRefed<Promise> GetDirectory(ErrorResult& aRv);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(StorageManager)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -62,74 +62,88 @@ class IOUtils final {
|
||||
|
||||
static already_AddRefed<Promise> Read(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const ReadOptions& aOptions);
|
||||
const ReadOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> ReadUTF8(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const ReadUTF8Options& aOptions);
|
||||
const ReadUTF8Options& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> ReadJSON(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const ReadUTF8Options& aOptions);
|
||||
const ReadUTF8Options& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> Write(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const Uint8Array& aData,
|
||||
const WriteOptions& aOptions);
|
||||
const WriteOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> WriteUTF8(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const nsACString& aString,
|
||||
const WriteOptions& aOptions);
|
||||
const WriteOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> WriteJSON(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
JS::Handle<JS::Value> aValue,
|
||||
const WriteOptions& aOptions);
|
||||
const WriteOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> Move(GlobalObject& aGlobal,
|
||||
const nsAString& aSourcePath,
|
||||
const nsAString& aDestPath,
|
||||
const MoveOptions& aOptions);
|
||||
const MoveOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> Remove(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const RemoveOptions& aOptions);
|
||||
const RemoveOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> MakeDirectory(
|
||||
GlobalObject& aGlobal, const nsAString& aPath,
|
||||
const MakeDirectoryOptions& aOptions);
|
||||
const MakeDirectoryOptions& aOptions, ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> Stat(GlobalObject& aGlobal,
|
||||
const nsAString& aPath);
|
||||
const nsAString& aPath,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> Copy(GlobalObject& aGlobal,
|
||||
const nsAString& aSourcePath,
|
||||
const nsAString& aDestPath,
|
||||
const CopyOptions& aOptions);
|
||||
const CopyOptions& aOptions,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> SetModificationTime(
|
||||
GlobalObject& aGlobal, const nsAString& aPath,
|
||||
const Optional<int64_t>& aModification);
|
||||
const Optional<int64_t>& aModification, ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> GetChildren(
|
||||
GlobalObject& aGlobal, const nsAString& aPath,
|
||||
const GetChildrenOptions& aOptions);
|
||||
const GetChildrenOptions& aOptions, ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> SetPermissions(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
uint32_t aPermissions,
|
||||
const bool aHonorUmask);
|
||||
const bool aHonorUmask,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> Exists(GlobalObject& aGlobal,
|
||||
const nsAString& aPath);
|
||||
const nsAString& aPath,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> CreateUniqueFile(
|
||||
GlobalObject& aGlobal, const nsAString& aParent, const nsAString& aPrefix,
|
||||
const uint32_t aPermissions);
|
||||
static already_AddRefed<Promise> CreateUniqueFile(GlobalObject& aGlobal,
|
||||
const nsAString& aParent,
|
||||
const nsAString& aPrefix,
|
||||
const uint32_t aPermissions,
|
||||
ErrorResult& aError);
|
||||
static already_AddRefed<Promise> CreateUniqueDirectory(
|
||||
GlobalObject& aGlobal, const nsAString& aParent, const nsAString& aPrefix,
|
||||
const uint32_t aPermissions);
|
||||
const uint32_t aPermissions, ErrorResult& aError);
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -139,30 +153,36 @@ class IOUtils final {
|
||||
const nsAString& aParent,
|
||||
const nsAString& aPrefix,
|
||||
const uint32_t aFileType,
|
||||
const uint32_t aPermissions);
|
||||
const uint32_t aPermissions,
|
||||
ErrorResult& aError);
|
||||
|
||||
public:
|
||||
#if defined(XP_WIN)
|
||||
static already_AddRefed<Promise> GetWindowsAttributes(GlobalObject& aGlobal,
|
||||
const nsAString& aPath);
|
||||
const nsAString& aPath,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> SetWindowsAttributes(
|
||||
GlobalObject& aGlobal, const nsAString& aPath,
|
||||
const mozilla::dom::WindowsFileAttributes& aAttrs);
|
||||
const mozilla::dom::WindowsFileAttributes& aAttrs, ErrorResult& aError);
|
||||
#elif defined(XP_MACOSX)
|
||||
static already_AddRefed<Promise> HasMacXAttr(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const nsACString& aAttr);
|
||||
const nsACString& aAttr,
|
||||
ErrorResult& aError);
|
||||
static already_AddRefed<Promise> GetMacXAttr(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const nsACString& aAttr);
|
||||
const nsACString& aAttr,
|
||||
ErrorResult& aError);
|
||||
static already_AddRefed<Promise> SetMacXAttr(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const nsACString& aAttr,
|
||||
const Uint8Array& aValue);
|
||||
const Uint8Array& aValue,
|
||||
ErrorResult& aError);
|
||||
static already_AddRefed<Promise> DelMacXAttr(GlobalObject& aGlobal,
|
||||
const nsAString& aPath,
|
||||
const nsACString& aAttr);
|
||||
const nsACString& aAttr,
|
||||
ErrorResult& aError);
|
||||
#endif
|
||||
|
||||
static void GetProfileBeforeChange(GlobalObject& aGlobal,
|
||||
@@ -201,6 +221,7 @@ class IOUtils final {
|
||||
|
||||
template <typename Fn>
|
||||
static already_AddRefed<Promise> WithPromiseAndState(GlobalObject& aGlobal,
|
||||
ErrorResult& aError,
|
||||
Fn aFn);
|
||||
|
||||
/**
|
||||
@@ -223,7 +244,8 @@ class IOUtils final {
|
||||
*
|
||||
* @return The new promise, or |nullptr| on failure.
|
||||
*/
|
||||
static already_AddRefed<Promise> CreateJSPromise(GlobalObject& aGlobal);
|
||||
static already_AddRefed<Promise> CreateJSPromise(GlobalObject& aGlobal,
|
||||
ErrorResult& aError);
|
||||
|
||||
// Allow conversion of |InternalFileInfo| with |ToJSValue|.
|
||||
friend bool ToJSValue(JSContext* aCx,
|
||||
|
||||
@@ -81,15 +81,10 @@ void PublicKeyCredential::SetResponse(RefPtr<AuthenticatorResponse> aResponse) {
|
||||
/* static */
|
||||
already_AddRefed<Promise>
|
||||
PublicKeyCredential::IsUserVerifyingPlatformAuthenticatorAvailable(
|
||||
GlobalObject& aGlobal) {
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aGlobal.Context());
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(globalObject, rv);
|
||||
if (rv.Failed()) {
|
||||
GlobalObject& aGlobal, ErrorResult& aError) {
|
||||
RefPtr<Promise> promise =
|
||||
Promise::Create(xpc::CurrentNativeGlobal(aGlobal.Context()), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -125,16 +120,11 @@ PublicKeyCredential::IsUserVerifyingPlatformAuthenticatorAvailable(
|
||||
|
||||
/* static */
|
||||
already_AddRefed<Promise>
|
||||
PublicKeyCredential::IsExternalCTAP2SecurityKeySupported(
|
||||
GlobalObject& aGlobal) {
|
||||
nsIGlobalObject* globalObject = xpc::CurrentNativeGlobal(aGlobal.Context());
|
||||
if (NS_WARN_IF(!globalObject)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(globalObject, rv);
|
||||
if (rv.Failed()) {
|
||||
PublicKeyCredential::IsExternalCTAP2SecurityKeySupported(GlobalObject& aGlobal,
|
||||
ErrorResult& aError) {
|
||||
RefPtr<Promise> promise =
|
||||
Promise::Create(xpc::CurrentNativeGlobal(aGlobal.Context()), aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,11 @@ class PublicKeyCredential final : public Credential {
|
||||
void SetResponse(RefPtr<AuthenticatorResponse>);
|
||||
|
||||
static already_AddRefed<Promise>
|
||||
IsUserVerifyingPlatformAuthenticatorAvailable(GlobalObject& aGlobal);
|
||||
IsUserVerifyingPlatformAuthenticatorAvailable(GlobalObject& aGlobal,
|
||||
ErrorResult& aError);
|
||||
|
||||
static already_AddRefed<Promise> IsExternalCTAP2SecurityKeySupported(
|
||||
GlobalObject& aGlobal);
|
||||
GlobalObject& aGlobal, ErrorResult& aError);
|
||||
|
||||
void GetClientExtensionResults(
|
||||
AuthenticationExtensionsClientOutputs& aResult);
|
||||
|
||||
@@ -223,14 +223,13 @@ WebAuthnManager::~WebAuthnManager() {
|
||||
|
||||
already_AddRefed<Promise> WebAuthnManager::MakeCredential(
|
||||
const PublicKeyCredentialCreationOptions& aOptions,
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal) {
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal, ErrorResult& aError) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mParent);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(global, rv);
|
||||
if (rv.Failed()) {
|
||||
RefPtr<Promise> promise = Promise::Create(global, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -256,9 +255,9 @@ already_AddRefed<Promise> WebAuthnManager::MakeCredential(
|
||||
|
||||
nsString origin;
|
||||
nsCString rpId;
|
||||
rv = GetOrigin(mParent, origin, rpId);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
promise->MaybeReject(std::move(rv));
|
||||
nsresult rv = GetOrigin(mParent, origin, rpId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
promise->MaybeReject(rv);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
@@ -453,14 +452,13 @@ already_AddRefed<Promise> WebAuthnManager::MakeCredential(
|
||||
|
||||
already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||
const PublicKeyCredentialRequestOptions& aOptions,
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal) {
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal, ErrorResult& aError) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mParent);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(global, rv);
|
||||
if (rv.Failed()) {
|
||||
RefPtr<Promise> promise = Promise::Create(global, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -486,9 +484,9 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||
|
||||
nsString origin;
|
||||
nsCString rpId;
|
||||
rv = GetOrigin(mParent, origin, rpId);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
promise->MaybeReject(std::move(rv));
|
||||
nsresult rv = GetOrigin(mParent, origin, rpId);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
promise->MaybeReject(rv);
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
@@ -535,9 +533,9 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||
}
|
||||
|
||||
nsAutoCString clientDataJSON;
|
||||
nsresult srv = AssembleClientData(origin, challenge, u"webauthn.get"_ns,
|
||||
aOptions.mExtensions, clientDataJSON);
|
||||
if (NS_WARN_IF(NS_FAILED(srv))) {
|
||||
rv = AssembleClientData(origin, challenge, u"webauthn.get"_ns,
|
||||
aOptions.mExtensions, clientDataJSON);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
promise->MaybeReject(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return promise.forget();
|
||||
}
|
||||
@@ -614,8 +612,8 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||
}
|
||||
|
||||
// We need the SHA-256 hash of the appId.
|
||||
srv = HashCString(NS_ConvertUTF16toUTF8(appId), appIdHash);
|
||||
if (NS_WARN_IF(NS_FAILED(srv))) {
|
||||
rv = HashCString(NS_ConvertUTF16toUTF8(appId), appIdHash);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
promise->MaybeReject(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return promise.forget();
|
||||
}
|
||||
@@ -657,15 +655,14 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> WebAuthnManager::Store(
|
||||
const Credential& aCredential) {
|
||||
already_AddRefed<Promise> WebAuthnManager::Store(const Credential& aCredential,
|
||||
ErrorResult& aError) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mParent);
|
||||
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(global, rv);
|
||||
if (rv.Failed()) {
|
||||
RefPtr<Promise> promise = Promise::Create(global, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,13 +85,14 @@ class WebAuthnManager final : public WebAuthnManagerBase, public AbortFollower {
|
||||
|
||||
already_AddRefed<Promise> MakeCredential(
|
||||
const PublicKeyCredentialCreationOptions& aOptions,
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal);
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal, ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> GetAssertion(
|
||||
const PublicKeyCredentialRequestOptions& aOptions,
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal);
|
||||
const Optional<OwningNonNull<AbortSignal>>& aSignal, ErrorResult& aError);
|
||||
|
||||
already_AddRefed<Promise> Store(const Credential& aCredential);
|
||||
already_AddRefed<Promise> Store(const Credential& aCredential,
|
||||
ErrorResult& aError);
|
||||
|
||||
// WebAuthnManagerBase
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ partial interface Document {
|
||||
|
||||
// Mozilla-internal document extensions specific to error pages.
|
||||
partial interface Document {
|
||||
[Func="Document::CallerIsTrustedAboutCertError"]
|
||||
[Func="Document::CallerIsTrustedAboutCertError", NewObject]
|
||||
Promise<any> addCertException(boolean isTemporary);
|
||||
|
||||
[Func="Document::CallerIsTrustedAboutHttpsOnlyError"]
|
||||
|
||||
@@ -26,10 +26,14 @@ interface FileSystemDirectoryHandle : FileSystemHandle {
|
||||
FileSystemDirectoryIterator keys();
|
||||
FileSystemDirectoryIterator values();
|
||||
|
||||
[NewObject]
|
||||
Promise<FileSystemFileHandle> getFileHandle(USVString name, optional FileSystemGetFileOptions options = {});
|
||||
[NewObject]
|
||||
Promise<FileSystemDirectoryHandle> getDirectoryHandle(USVString name, optional FileSystemGetDirectoryOptions options = {});
|
||||
|
||||
[NewObject]
|
||||
Promise<void> removeEntry(USVString name, optional FileSystemRemoveOptions options = {});
|
||||
|
||||
[NewObject]
|
||||
Promise<sequence<USVString>?> resolve(FileSystemHandle possibleDescendant);
|
||||
};
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
// a natively supported `async iterable`.
|
||||
[Exposed=(Window,Worker), SecureContext, LegacyNoInterfaceObject]
|
||||
interface FileSystemDirectoryIterator {
|
||||
[NewObject]
|
||||
Promise<any> next();
|
||||
};
|
||||
|
||||
@@ -10,10 +10,12 @@ dictionary FileSystemCreateWritableOptions {
|
||||
// TODO: Add Serializable
|
||||
[Exposed=(Window,Worker), SecureContext, Pref="dom.fs.enabled"]
|
||||
interface FileSystemFileHandle : FileSystemHandle {
|
||||
[NewObject]
|
||||
Promise<File> getFile();
|
||||
|
||||
[NewObject]
|
||||
Promise<FileSystemWritableFileStream> createWritable(optional FileSystemCreateWritableOptions options = {});
|
||||
|
||||
[Exposed=DedicatedWorker]
|
||||
[Exposed=DedicatedWorker, NewObject]
|
||||
Promise<FileSystemSyncAccessHandle> createSyncAccessHandle();
|
||||
};
|
||||
|
||||
@@ -14,5 +14,6 @@ interface FileSystemHandle {
|
||||
readonly attribute FileSystemHandleKind kind;
|
||||
readonly attribute USVString name;
|
||||
|
||||
[NewObject]
|
||||
Promise<boolean> isSameEntry(FileSystemHandle other);
|
||||
};
|
||||
|
||||
@@ -13,8 +13,12 @@ interface FileSystemSyncAccessHandle {
|
||||
unsigned long long read(([AllowShared] ArrayBufferView or [AllowShared] ArrayBuffer) buffer, optional FileSystemReadWriteOptions options = {});
|
||||
unsigned long long write(([AllowShared] ArrayBufferView or [AllowShared] ArrayBuffer) buffer, optional FileSystemReadWriteOptions options = {});
|
||||
|
||||
[NewObject]
|
||||
Promise<void> truncate([EnforceRange] unsigned long long size);
|
||||
[NewObject]
|
||||
Promise<unsigned long long> getSize();
|
||||
[NewObject]
|
||||
Promise<void> flush();
|
||||
[NewObject]
|
||||
Promise<void> close();
|
||||
};
|
||||
|
||||
@@ -20,7 +20,10 @@ typedef (BufferSource or Blob or USVString or WriteParams) FileSystemWriteChunkT
|
||||
|
||||
[Exposed=(Window,Worker), SecureContext, Pref="dom.fs.enabled"]
|
||||
interface FileSystemWritableFileStream : WritableStream {
|
||||
[NewObject]
|
||||
Promise<void> write(FileSystemWriteChunkType data);
|
||||
[NewObject]
|
||||
Promise<void> seek(unsigned long long position);
|
||||
[NewObject]
|
||||
Promise<void> truncate(unsigned long long size);
|
||||
};
|
||||
|
||||
@@ -34,7 +34,9 @@ interface MIDIPort : EventTarget {
|
||||
readonly attribute MIDIPortDeviceState state;
|
||||
readonly attribute MIDIPortConnectionState connection;
|
||||
attribute EventHandler onstatechange;
|
||||
[Throws]
|
||||
Promise<MIDIPort> open();
|
||||
[Throws]
|
||||
Promise<MIDIPort> close();
|
||||
};
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ interface PeerConnectionImpl {
|
||||
unsigned short maxTime, unsigned short maxNum,
|
||||
boolean externalNegotiated, unsigned short stream);
|
||||
|
||||
[Throws]
|
||||
Promise<any> chain(ChainedOperation op);
|
||||
void updateNegotiationNeeded();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
interface RTCRtpReceiver {
|
||||
readonly attribute MediaStreamTrack track;
|
||||
readonly attribute RTCDtlsTransport? transport;
|
||||
[NewObject]
|
||||
Promise<RTCStatsReport> getStats();
|
||||
sequence<RTCRtpContributingSource> getContributingSources();
|
||||
sequence<RTCRtpSynchronizationSource> getSynchronizationSources();
|
||||
|
||||
@@ -12,9 +12,12 @@
|
||||
interface RTCRtpSender {
|
||||
readonly attribute MediaStreamTrack? track;
|
||||
readonly attribute RTCDtlsTransport? transport;
|
||||
[NewObject]
|
||||
Promise<void> setParameters (optional RTCRtpParameters parameters = {});
|
||||
RTCRtpParameters getParameters();
|
||||
[Throws]
|
||||
Promise<void> replaceTrack(MediaStreamTrack? withTrack);
|
||||
[NewObject]
|
||||
Promise<RTCStatsReport> getStats();
|
||||
[Pref="media.peerconnection.dtmf.enabled"]
|
||||
readonly attribute RTCDTMFSender? dtmf;
|
||||
|
||||
@@ -29,6 +29,6 @@ dictionary StorageEstimate {
|
||||
|
||||
[SecureContext]
|
||||
partial interface StorageManager {
|
||||
[Pref="dom.fs.enabled"]
|
||||
[Pref="dom.fs.enabled", NewObject]
|
||||
Promise<FileSystemDirectoryHandle> getDirectory();
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ interface PublicKeyCredential : Credential {
|
||||
|
||||
[SecureContext]
|
||||
partial interface PublicKeyCredential {
|
||||
static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
|
||||
[NewObject] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
|
||||
// isExternalCTAP2SecurityKeySupported is non-standard; see Bug 1526023
|
||||
static Promise<boolean> isExternalCTAP2SecurityKeySupported();
|
||||
[NewObject] static Promise<boolean> isExternalCTAP2SecurityKeySupported();
|
||||
};
|
||||
|
||||
[SecureContext, Pref="security.webauth.webauthn",
|
||||
|
||||
@@ -71,10 +71,9 @@ JSObject* FluentBundleAsyncIterator::WrapObject(
|
||||
return FluentBundleAsyncIterator_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> FluentBundleAsyncIterator::Next() {
|
||||
ErrorResult rv;
|
||||
RefPtr<Promise> promise = Promise::Create(mGlobal, rv);
|
||||
if (rv.Failed()) {
|
||||
already_AddRefed<Promise> FluentBundleAsyncIterator::Next(ErrorResult& aError) {
|
||||
RefPtr<Promise> promise = Promise::Create(mGlobal, aError);
|
||||
if (aError.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class FluentBundleAsyncIterator final : public nsWrapperCache {
|
||||
nsIGlobalObject* GetParentObject() const { return mGlobal; }
|
||||
|
||||
// WebIDL
|
||||
already_AddRefed<dom::Promise> Next();
|
||||
already_AddRefed<dom::Promise> Next(ErrorResult& aError);
|
||||
already_AddRefed<FluentBundleAsyncIterator> Values();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user