summaryrefslogtreecommitdiffstats
path: root/dom/fs/test/gtest/api
diff options
context:
space:
mode:
Diffstat (limited to 'dom/fs/test/gtest/api')
-rw-r--r--dom/fs/test/gtest/api/TestFileSystemDirectoryHandle.cpp234
-rw-r--r--dom/fs/test/gtest/api/TestFileSystemFileHandle.cpp149
-rw-r--r--dom/fs/test/gtest/api/TestFileSystemHandle.cpp131
-rw-r--r--dom/fs/test/gtest/api/moz.build21
4 files changed, 535 insertions, 0 deletions
diff --git a/dom/fs/test/gtest/api/TestFileSystemDirectoryHandle.cpp b/dom/fs/test/gtest/api/TestFileSystemDirectoryHandle.cpp
new file mode 100644
index 0000000000..9114f3bb33
--- /dev/null
+++ b/dom/fs/test/gtest/api/TestFileSystemDirectoryHandle.cpp
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "FileSystemMocks.h"
+#include "gtest/gtest.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/dom/FileSystemDirectoryHandle.h"
+#include "mozilla/dom/FileSystemDirectoryHandleBinding.h"
+#include "mozilla/dom/FileSystemHandle.h"
+#include "mozilla/dom/FileSystemHandleBinding.h"
+#include "mozilla/dom/FileSystemManager.h"
+#include "mozilla/dom/StorageManager.h"
+#include "nsIGlobalObject.h"
+
+using ::testing::_;
+
+namespace mozilla::dom::fs::test {
+
+class TestFileSystemDirectoryHandle : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ // TODO: Fix the test to not depend on CreateFileSystemManagerParent
+ // failure because of the pref set to false.
+ nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
+ prefs->SetBoolPref("dom.fs.enabled", false);
+
+ mRequestHandler = MakeUnique<MockFileSystemRequestHandler>();
+ mMetadata = FileSystemEntryMetadata("dir"_ns, u"Directory"_ns,
+ /* directory */ true);
+ mName = u"testDir"_ns;
+ mManager = MakeAndAddRef<FileSystemManager>(mGlobal, nullptr);
+ }
+
+ void TearDown() override {
+ nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
+ prefs->SetBoolPref("dom.fs.enabled", true);
+
+ if (!mManager->IsShutdown()) {
+ mManager->Shutdown();
+ }
+ }
+
+ nsIGlobalObject* mGlobal = GetGlobal();
+ const IterableIteratorBase::IteratorType mIteratorType =
+ IterableIteratorBase::IteratorType::Keys;
+ UniquePtr<MockFileSystemRequestHandler> mRequestHandler;
+ FileSystemEntryMetadata mMetadata;
+ nsString mName;
+ RefPtr<FileSystemManager> mManager;
+};
+
+TEST_F(TestFileSystemDirectoryHandle, constructDirectoryHandleRefPointer) {
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata);
+
+ ASSERT_TRUE(dirHandle);
+}
+
+TEST_F(TestFileSystemDirectoryHandle, initIterator) {
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ RefPtr<FileSystemDirectoryHandle::iterator_t> iterator =
+ new FileSystemDirectoryHandle::iterator_t(dirHandle.get(), mIteratorType);
+ IgnoredErrorResult rv;
+ dirHandle->InitAsyncIteratorData(iterator->Data(), mIteratorType, rv);
+ ASSERT_TRUE(iterator->Data().mImpl);
+}
+
+class MockFileSystemDirectoryIteratorImpl final
+ : public FileSystemDirectoryIterator::Impl {
+ public:
+ MOCK_METHOD(already_AddRefed<Promise>, Next,
+ (nsIGlobalObject * aGlobal, RefPtr<FileSystemManager>& aManager,
+ ErrorResult& aError),
+ (override));
+};
+
+TEST_F(TestFileSystemDirectoryHandle, isNextPromiseReturned) {
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ auto mockIter = MakeUnique<MockFileSystemDirectoryIteratorImpl>();
+ IgnoredErrorResult error;
+ EXPECT_CALL(*mockIter, Next(_, _, _))
+ .WillOnce(::testing::Return(Promise::Create(mGlobal, error)));
+
+ RefPtr<FileSystemDirectoryHandle::iterator_t> iterator =
+ MakeAndAddRef<FileSystemDirectoryHandle::iterator_t>(dirHandle.get(),
+ mIteratorType);
+ iterator->Data().mImpl = std::move(mockIter);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise =
+ dirHandle->GetNextIterationResult(iterator.get(), rv);
+ ASSERT_TRUE(promise);
+}
+
+TEST_F(TestFileSystemDirectoryHandle, isHandleKindDirectory) {
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ ASSERT_EQ(FileSystemHandleKind::Directory, dirHandle->Kind());
+}
+
+TEST_F(TestFileSystemDirectoryHandle, isFileHandleReturned) {
+ EXPECT_CALL(*mRequestHandler, GetFileHandle(_, _, _, _, _))
+ .WillOnce(::testing::ReturnArg<3>());
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ FileSystemGetFileOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->GetFileHandle(mName, options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, doesGetFileHandleFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata);
+
+ ASSERT_TRUE(dirHandle);
+
+ FileSystemGetFileOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->GetFileHandle(mName, options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, isDirectoryHandleReturned) {
+ EXPECT_CALL(*mRequestHandler, GetDirectoryHandle(_, _, _, _, _))
+ .WillOnce(::testing::ReturnArg<3>());
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ FileSystemGetDirectoryOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->GetDirectoryHandle(mName, options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, doesGetDirectoryHandleFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata);
+
+ ASSERT_TRUE(dirHandle);
+
+ FileSystemGetDirectoryOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->GetDirectoryHandle(mName, options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, isRemoveEntrySuccessful) {
+ EXPECT_CALL(*mRequestHandler, RemoveEntry(_, _, _, _, _))
+ .WillOnce(::testing::ReturnArg<3>());
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ FileSystemRemoveOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->RemoveEntry(mName, options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, doesRemoveEntryFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata);
+
+ ASSERT_TRUE(dirHandle);
+
+ FileSystemRemoveOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->RemoveEntry(mName, options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, isResolveSuccessful) {
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata,
+ mRequestHandler.release());
+
+ ASSERT_TRUE(dirHandle);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->Resolve(*dirHandle, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+}
+
+TEST_F(TestFileSystemDirectoryHandle, doesResolveFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemDirectoryHandle> dirHandle =
+ MakeAndAddRef<FileSystemDirectoryHandle>(mGlobal, mManager, mMetadata);
+
+ ASSERT_TRUE(dirHandle);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->Resolve(*dirHandle, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+} // namespace mozilla::dom::fs::test
diff --git a/dom/fs/test/gtest/api/TestFileSystemFileHandle.cpp b/dom/fs/test/gtest/api/TestFileSystemFileHandle.cpp
new file mode 100644
index 0000000000..615d907f48
--- /dev/null
+++ b/dom/fs/test/gtest/api/TestFileSystemFileHandle.cpp
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "FileSystemMocks.h"
+#include "fs/FileSystemChildFactory.h"
+#include "gtest/gtest.h"
+#include "mozilla/UniquePtr.h"
+#include "mozilla/dom/FileSystemFileHandle.h"
+#include "mozilla/dom/FileSystemFileHandleBinding.h"
+#include "mozilla/dom/FileSystemHandle.h"
+#include "mozilla/dom/FileSystemHandleBinding.h"
+#include "mozilla/dom/FileSystemManager.h"
+#include "mozilla/dom/Promise.h"
+#include "mozilla/dom/StorageManager.h"
+#include "nsIGlobalObject.h"
+
+namespace mozilla::dom::fs::test {
+
+class TestFileSystemFileHandle : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ // TODO: Fix the test to not depend on CreateFileSystemManagerParent
+ // failure because of the pref set to false.
+ nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
+ prefs->SetBoolPref("dom.fs.enabled", false);
+
+ mRequestHandler = MakeUnique<MockFileSystemRequestHandler>();
+ mMetadata =
+ FileSystemEntryMetadata("file"_ns, u"File"_ns, /* directory */ false);
+ mManager = MakeAndAddRef<FileSystemManager>(mGlobal, nullptr);
+ }
+
+ void TearDown() override {
+ nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
+ prefs->SetBoolPref("dom.fs.enabled", true);
+
+ if (!mManager->IsShutdown()) {
+ mManager->Shutdown();
+ }
+ }
+
+ nsIGlobalObject* mGlobal = GetGlobal();
+ UniquePtr<MockFileSystemRequestHandler> mRequestHandler;
+ FileSystemEntryMetadata mMetadata;
+ RefPtr<FileSystemManager> mManager;
+};
+
+TEST_F(TestFileSystemFileHandle, constructFileHandleRefPointer) {
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+}
+
+TEST_F(TestFileSystemFileHandle, isHandleKindFile) {
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ ASSERT_EQ(FileSystemHandleKind::File, fileHandle->Kind());
+}
+
+TEST_F(TestFileSystemFileHandle, isFileReturned) {
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->GetFile(rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+}
+
+TEST_F(TestFileSystemFileHandle, doesGetFileFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->GetFile(rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+TEST_F(TestFileSystemFileHandle, isWritableReturned) {
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ FileSystemCreateWritableOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->CreateWritable(options, rv);
+
+ // XXX This should be reverted back to check NS_OK once bug 1798513 is fixed.
+#if 0
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+#else
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_NOT_IMPLEMENTED));
+#endif
+}
+
+TEST_F(TestFileSystemFileHandle, doesCreateWritableFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ FileSystemCreateWritableOptions options;
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->CreateWritable(options, rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+TEST_F(TestFileSystemFileHandle, isSyncAccessHandleReturned) {
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->CreateSyncAccessHandle(rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+}
+
+TEST_F(TestFileSystemFileHandle, doesCreateSyncAccessHandleFailOnNullGlobal) {
+ mGlobal = nullptr;
+ RefPtr<FileSystemFileHandle> fileHandle = MakeAndAddRef<FileSystemFileHandle>(
+ mGlobal, mManager, mMetadata, mRequestHandler.release());
+
+ ASSERT_TRUE(fileHandle);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->CreateSyncAccessHandle(rv);
+
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_ERROR_UNEXPECTED));
+}
+
+} // namespace mozilla::dom::fs::test
diff --git a/dom/fs/test/gtest/api/TestFileSystemHandle.cpp b/dom/fs/test/gtest/api/TestFileSystemHandle.cpp
new file mode 100644
index 0000000000..19cdc98a84
--- /dev/null
+++ b/dom/fs/test/gtest/api/TestFileSystemHandle.cpp
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "FileSystemMocks.h"
+#include "fs/FileSystemChildFactory.h"
+#include "gtest/gtest.h"
+#include "mozilla/dom/FileSystemDirectoryHandle.h"
+#include "mozilla/dom/FileSystemFileHandle.h"
+#include "mozilla/dom/FileSystemHandle.h"
+#include "mozilla/dom/FileSystemHandleBinding.h"
+#include "mozilla/dom/FileSystemManager.h"
+#include "mozilla/dom/StorageManager.h"
+#include "nsIGlobalObject.h"
+
+namespace mozilla::dom::fs::test {
+
+class TestFileSystemHandle : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ // TODO: Fix the test to not depend on CreateFileSystemManagerParent
+ // failure because of the pref set to false.
+ nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
+ prefs->SetBoolPref("dom.fs.enabled", false);
+
+ mDirMetadata = FileSystemEntryMetadata("dir"_ns, u"Directory"_ns,
+ /* directory */ true);
+ mFileMetadata =
+ FileSystemEntryMetadata("file"_ns, u"File"_ns, /* directory */ false);
+ mManager = MakeAndAddRef<FileSystemManager>(mGlobal, nullptr);
+ }
+
+ void TearDown() override {
+ nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
+ prefs->SetBoolPref("dom.fs.enabled", true);
+
+ if (!mManager->IsShutdown()) {
+ mManager->Shutdown();
+ }
+ }
+
+ nsIGlobalObject* mGlobal = GetGlobal();
+ FileSystemEntryMetadata mDirMetadata;
+ FileSystemEntryMetadata mFileMetadata;
+ RefPtr<FileSystemManager> mManager;
+};
+
+TEST_F(TestFileSystemHandle, createAndDestroyHandles) {
+ RefPtr<FileSystemHandle> dirHandle =
+ new FileSystemDirectoryHandle(mGlobal, mManager, mDirMetadata);
+ RefPtr<FileSystemHandle> fileHandle =
+ new FileSystemFileHandle(mGlobal, mManager, mFileMetadata);
+
+ EXPECT_TRUE(dirHandle);
+ EXPECT_TRUE(fileHandle);
+}
+
+TEST_F(TestFileSystemHandle, areFileNamesAsExpected) {
+ RefPtr<FileSystemHandle> dirHandle =
+ new FileSystemDirectoryHandle(mGlobal, mManager, mDirMetadata);
+ RefPtr<FileSystemHandle> fileHandle =
+ new FileSystemFileHandle(mGlobal, mManager, mFileMetadata);
+
+ auto GetEntryName = [](const RefPtr<FileSystemHandle>& aHandle) {
+ DOMString domName;
+ aHandle->GetName(domName);
+ nsString result;
+ domName.ToString(result);
+ return result;
+ };
+
+ const nsString& dirName = GetEntryName(dirHandle);
+ EXPECT_TRUE(mDirMetadata.entryName().Equals(dirName));
+
+ const nsString& fileName = GetEntryName(fileHandle);
+ EXPECT_TRUE(mFileMetadata.entryName().Equals(fileName));
+}
+
+TEST_F(TestFileSystemHandle, isParentObjectReturned) {
+ ASSERT_TRUE(mGlobal);
+ RefPtr<FileSystemHandle> dirHandle =
+ new FileSystemDirectoryHandle(mGlobal, mManager, mDirMetadata);
+
+ ASSERT_EQ(mGlobal, dirHandle->GetParentObject());
+}
+
+TEST_F(TestFileSystemHandle, areHandleKindsAsExpected) {
+ RefPtr<FileSystemHandle> dirHandle =
+ new FileSystemDirectoryHandle(mGlobal, mManager, mDirMetadata);
+ RefPtr<FileSystemHandle> fileHandle =
+ new FileSystemFileHandle(mGlobal, mManager, mFileMetadata);
+
+ EXPECT_EQ(FileSystemHandleKind::Directory, dirHandle->Kind());
+ EXPECT_EQ(FileSystemHandleKind::File, fileHandle->Kind());
+}
+
+TEST_F(TestFileSystemHandle, isDifferentEntry) {
+ RefPtr<FileSystemHandle> dirHandle =
+ new FileSystemDirectoryHandle(mGlobal, mManager, mDirMetadata);
+ RefPtr<FileSystemHandle> fileHandle =
+ new FileSystemFileHandle(mGlobal, mManager, mFileMetadata);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = dirHandle->IsSameEntry(*fileHandle, rv);
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+ ASSERT_TRUE(promise);
+ ASSERT_EQ(Promise::PromiseState::Resolved, promise->State());
+
+ nsString result;
+ ASSERT_NSEQ(NS_OK, GetAsString(promise, result));
+ ASSERT_STREQ(u"false"_ns, result);
+}
+
+TEST_F(TestFileSystemHandle, isSameEntry) {
+ RefPtr<FileSystemHandle> fileHandle =
+ new FileSystemFileHandle(mGlobal, mManager, mFileMetadata);
+
+ IgnoredErrorResult rv;
+ RefPtr<Promise> promise = fileHandle->IsSameEntry(*fileHandle, rv);
+ ASSERT_TRUE(rv.ErrorCodeIs(NS_OK));
+ ASSERT_TRUE(promise);
+ ASSERT_EQ(Promise::PromiseState::Resolved, promise->State());
+
+ nsString result;
+ ASSERT_NSEQ(NS_OK, GetAsString(promise, result));
+ ASSERT_STREQ(u"true"_ns, result);
+}
+
+} // namespace mozilla::dom::fs::test
diff --git a/dom/fs/test/gtest/api/moz.build b/dom/fs/test/gtest/api/moz.build
new file mode 100644
index 0000000000..eb8416a3ba
--- /dev/null
+++ b/dom/fs/test/gtest/api/moz.build
@@ -0,0 +1,21 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at http://mozilla.org/MPL/2.0/.
+
+UNIFIED_SOURCES = [
+ "TestFileSystemDirectoryHandle.cpp",
+ "TestFileSystemFileHandle.cpp",
+ "TestFileSystemHandle.cpp",
+]
+
+include("/ipc/chromium/chromium-config.mozbuild")
+
+FINAL_LIBRARY = "xul-gtest"
+
+LOCAL_INCLUDES += [
+ "/dom/fs/api",
+ "/dom/fs/include",
+ "/dom/fs/test/gtest",
+]