diff --git a/dom/fs/api/FileSystemHandle.cpp b/dom/fs/api/FileSystemHandle.cpp index 65680d59c7b0..c752bdc61452 100644 --- a/dom/fs/api/FileSystemHandle.cpp +++ b/dom/fs/api/FileSystemHandle.cpp @@ -103,7 +103,11 @@ already_AddRefed FileSystemHandle::IsSameEntry( return nullptr; } - promise->MaybeReject(NS_ERROR_NOT_IMPLEMENTED); + // Handles the case of "dir = createdir foo; removeEntry(foo); file = + // createfile foo; issameentry(dir, file)" + const bool result = mMetadata.entryId().Equals(aOther.mMetadata.entryId()) && + Kind() == aOther.Kind(); + promise->MaybeResolve(result); return promise.forget(); } diff --git a/dom/fs/test/gtest/api/TestFileSystemHandle.cpp b/dom/fs/test/gtest/api/TestFileSystemHandle.cpp index adb653c317e5..a176bfc7982b 100644 --- a/dom/fs/test/gtest/api/TestFileSystemHandle.cpp +++ b/dom/fs/test/gtest/api/TestFileSystemHandle.cpp @@ -96,11 +96,11 @@ TEST_F(TestFileSystemHandle, isDifferentEntry) { RefPtr promise = dirHandle->IsSameEntry(*fileHandle, rv); ASSERT_TRUE(rv.ErrorCodeIs(NS_OK)); ASSERT_TRUE(promise); - ASSERT_EQ(Promise::PromiseState::Rejected, promise->State()); + ASSERT_EQ(Promise::PromiseState::Resolved, promise->State()); nsString result; ASSERT_NSEQ(NS_OK, GetAsString(promise, result)); - ASSERT_STREQ(u"NS_ERROR_NOT_IMPLEMENTED"_ns, result); + ASSERT_STREQ(u"false"_ns, result); } TEST_F(TestFileSystemHandle, isSameEntry) { @@ -111,11 +111,11 @@ TEST_F(TestFileSystemHandle, isSameEntry) { RefPtr promise = fileHandle->IsSameEntry(*fileHandle, rv); ASSERT_TRUE(rv.ErrorCodeIs(NS_OK)); ASSERT_TRUE(promise); - ASSERT_EQ(Promise::PromiseState::Rejected, promise->State()); + ASSERT_EQ(Promise::PromiseState::Resolved, promise->State()); nsString result; ASSERT_NSEQ(NS_OK, GetAsString(promise, result)); - ASSERT_STREQ(u"NS_ERROR_NOT_IMPLEMENTED"_ns, result); + ASSERT_STREQ(u"true"_ns, result); } } // namespace mozilla::dom::fs::test