20
20
#include " mozilla/dom/StorageManager.h"
21
21
#include " mozilla/ipc/FileDescriptorUtils.h"
22
22
#include " mozilla/ipc/IPCCore.h"
23
+ #include " mozilla/net/CookieJarSettings.h"
23
24
#include " nsDirectoryServiceDefs.h"
24
25
#include " nsIFile.h"
25
26
@@ -33,6 +34,12 @@ namespace mozilla::dom::fs::test {
33
34
class TestFileSystemRequestHandler : public ::testing::Test {
34
35
protected:
35
36
void SetUp () override {
37
+ mMockGlobal = GetMockGlobal ();
38
+ mGlobal = mMockGlobal ;
39
+
40
+ mCookieJarSettings = mozilla::net::CookieJarSettings::Create (
41
+ mozilla::net::CookieJarSettings::CreateMode::eRegular,
42
+ /* Should resist fingerprinting */ true );
36
43
mListener = MakeAndAddRef<ExpectResolveCalled>();
37
44
38
45
mChild = FileSystemChildMetadata (" parent" _ns, u" ChildName" _ns);
@@ -92,17 +99,30 @@ class TestFileSystemRequestHandler : public ::testing::Test {
92
99
ASSERT_TRUE (mManager ->IsShutdown ());
93
100
}
94
101
95
- nsIGlobalObject* mGlobal = GetGlobal();
102
+ void AllowStorageAccess () {
103
+ EXPECT_CALL (*mMockGlobal , GetCookieJarSettings ())
104
+ .WillOnce (::testing::Return (&*mCookieJarSettings ));
105
+
106
+ EXPECT_CALL (*mMockGlobal , GetStorageAccess ())
107
+ .WillOnce (::testing::Return (mozilla::StorageAccess::eAllow));
108
+ }
109
+
110
+ MockGlobalObject* mMockGlobal ;
111
+ nsCOMPtr<nsIGlobalObject> mGlobal ;
112
+
96
113
RefPtr<ExpectResolveCalled> mListener ;
97
114
98
115
FileSystemChildMetadata mChild ;
99
116
FileSystemEntryMetadata mEntry ;
100
117
nsString mName ;
101
118
RefPtr<TestFileSystemManagerChild> mFileSystemManagerChild ;
102
119
RefPtr<FileSystemManager> mManager ;
120
+ RefPtr<nsICookieJarSettings> mCookieJarSettings ;
103
121
};
104
122
105
123
TEST_F (TestFileSystemRequestHandler, isGetRootHandleSuccessful) {
124
+ AllowStorageAccess ();
125
+
106
126
auto fakeResponse = [](auto && aResolve, auto && /* aReject */ ) {
107
127
EntryId expected = " expected" _ns;
108
128
FileSystemGetHandleResponse response (expected);
@@ -132,6 +152,8 @@ TEST_F(TestFileSystemRequestHandler, isGetRootHandleBlockedAfterShutdown) {
132
152
}
133
153
134
154
TEST_F (TestFileSystemRequestHandler, isGetDirectoryHandleSuccessful) {
155
+ AllowStorageAccess ();
156
+
135
157
auto fakeResponse = [](const auto & /* aRequest */ , auto && aResolve,
136
158
auto && /* aReject */ ) {
137
159
EntryId expected = " expected" _ns;
@@ -164,6 +186,8 @@ TEST_F(TestFileSystemRequestHandler, isGetDirectoryHandleBlockedAfterShutdown) {
164
186
}
165
187
166
188
TEST_F (TestFileSystemRequestHandler, isGetFileHandleSuccessful) {
189
+ AllowStorageAccess ();
190
+
167
191
auto fakeResponse = [](const auto & /* aRequest */ , auto && aResolve,
168
192
auto && /* aReject */ ) {
169
193
EntryId expected = " expected" _ns;
@@ -195,6 +219,8 @@ TEST_F(TestFileSystemRequestHandler, isGetFileHandleBlockedAfterShutdown) {
195
219
}
196
220
197
221
TEST_F (TestFileSystemRequestHandler, isGetFileSuccessful) {
222
+ AllowStorageAccess ();
223
+
198
224
auto fakeResponse = [](const auto & /* aRequest */ , auto && aResolve,
199
225
auto && /* aReject */ ) {
200
226
// We have to create a temporary file
@@ -276,6 +302,8 @@ TEST_F(TestFileSystemRequestHandler, isGetWritableBlockedAfterShutdown) {
276
302
}
277
303
278
304
TEST_F (TestFileSystemRequestHandler, isGetEntriesSuccessful) {
305
+ AllowStorageAccess ();
306
+
279
307
auto fakeResponse = [](const auto & /* aRequest */ , auto && aResolve,
280
308
auto && /* aReject */ ) {
281
309
nsTArray<FileSystemEntryMetadata> files;
@@ -320,6 +348,8 @@ TEST_F(TestFileSystemRequestHandler, isGetEntriesBlockedAfterShutdown) {
320
348
}
321
349
322
350
TEST_F (TestFileSystemRequestHandler, isRemoveEntrySuccessful) {
351
+ AllowStorageAccess ();
352
+
323
353
auto fakeResponse = [](const auto & /* aRequest */ , auto && aResolve,
324
354
auto && /* aReject */ ) {
325
355
FileSystemRemoveEntryResponse response (mozilla::void_t {});
0 commit comments