File
Blob: src/wpt/fs-test.ts
| 1 | // Copyright (c) 2017-2025 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | import { type TestRunnerConfig } from 'harness/harness'; |
| 6 | |
| 7 | const root = await navigator.storage.getDirectory(); |
| 8 | const tmp = await root.getDirectoryHandle('tmp'); |
| 9 | // The root is read-only, so we need to use a writable subdirectory |
| 10 | // to actually run the tests. |
| 11 | navigator.storage.getDirectory = |
| 12 | async (): Promise<FileSystemDirectoryHandle> => { |
| 13 | // Let's create a new random tmp subdirectory for each test run to avoid interference |
| 14 | return tmp.getDirectoryHandle(crypto.randomUUID(), { create: true }); |
| 15 | }; |
| 16 | |
| 17 | export default { |
| 18 | 'FileSystemBaseHandle-IndexedDB.https.any.js': { |
| 19 | comment: 'IndexedDB is not implemented in workers', |
| 20 | disabledTests: true, |
| 21 | }, |
| 22 | 'FileSystemBaseHandle-buckets.https.any.js': { |
| 23 | comment: 'StorageBuckets is not implemented in workers', |
| 24 | disabledTests: true, |
| 25 | }, |
| 26 | 'FileSystemBaseHandle-getUniqueId.https.any.js': { |
| 27 | comment: '...', |
| 28 | expectedFailures: [], |
| 29 | }, |
| 30 | 'FileSystemBaseHandle-isSameEntry.https.any.js': { |
| 31 | comment: '...', |
| 32 | expectedFailures: [], |
| 33 | }, |
| 34 | 'FileSystemBaseHandle-postMessage-BroadcastChannel.https.window.js': { |
| 35 | comment: 'BroadcastChannel is not implemented in workers', |
| 36 | disabledTests: true, |
| 37 | }, |
| 38 | 'FileSystemBaseHandle-postMessage-Error.https.window.js': { |
| 39 | comment: 'postMessage is not implemented in workers', |
| 40 | disabledTests: true, |
| 41 | }, |
| 42 | 'FileSystemBaseHandle-postMessage-MessagePort-frames.https.window.js': { |
| 43 | comment: 'postMessage and MessagePort are not implemented in workers', |
| 44 | disabledTests: true, |
| 45 | }, |
| 46 | 'FileSystemBaseHandle-postMessage-MessagePort-windows.https.window.js': { |
| 47 | comment: 'postMessage and MessagePort are not implemented in workers', |
| 48 | disabledTests: true, |
| 49 | }, |
| 50 | 'FileSystemBaseHandle-postMessage-MessagePort-workers.https.window.js': { |
| 51 | comment: 'postMessage and MessagePort are not implemented in workers', |
| 52 | disabledTests: true, |
| 53 | }, |
| 54 | 'FileSystemBaseHandle-postMessage-frames.https.window.js': { |
| 55 | comment: 'Frames are not implemented in workers', |
| 56 | disabledTests: true, |
| 57 | }, |
| 58 | 'FileSystemBaseHandle-postMessage-windows.https.window.js': { |
| 59 | comment: 'postMessage is not implemented in workers', |
| 60 | disabledTests: true, |
| 61 | }, |
| 62 | 'FileSystemBaseHandle-postMessage-workers.https.window.js': { |
| 63 | comment: 'postMessage is not implemented in workers', |
| 64 | disabledTests: true, |
| 65 | }, |
| 66 | 'FileSystemBaseHandle-remove.https.any.js': { |
| 67 | comment: '...', |
| 68 | disabledTests: [ |
| 69 | // Intentionally unsupported |
| 70 | 'can remove the root of a sandbox file system', |
| 71 | ], |
| 72 | }, |
| 73 | 'FileSystemDirectoryHandle-getDirectoryHandle.https.any.js': { |
| 74 | comment: '...', |
| 75 | expectedFailures: [], |
| 76 | }, |
| 77 | 'FileSystemDirectoryHandle-getFileHandle.https.any.js': { |
| 78 | comment: '...', |
| 79 | expectedFailures: [], |
| 80 | }, |
| 81 | 'FileSystemDirectoryHandle-iteration.https.any.js': { |
| 82 | comment: '...', |
| 83 | expectedFailures: [], |
| 84 | }, |
| 85 | 'FileSystemDirectoryHandle-removeEntry.https.any.js': { |
| 86 | comment: '...', |
| 87 | expectedFailures: [], |
| 88 | }, |
| 89 | 'FileSystemDirectoryHandle-resolve.https.any.js': { |
| 90 | comment: |
| 91 | 'We currently do not implement the resolve() method on directories', |
| 92 | disabledTests: [ |
| 93 | 'Resolve returns empty array for same directory', |
| 94 | 'Resolve returns correct path', |
| 95 | 'Resolve returns correct path with non-ascii characters', |
| 96 | 'Resolve returns null when entry is not a child', |
| 97 | ], |
| 98 | }, |
| 99 | 'FileSystemFileHandle-create-sync-access-handle.https.window.js': { |
| 100 | comment: 'We do not yet implement sync access handles', |
| 101 | disabledTests: ['Attempt to create a sync access handle.'], |
| 102 | }, |
| 103 | 'FileSystemFileHandle-getFile.https.any.js': { |
| 104 | comment: '...', |
| 105 | expectedFailures: [ |
| 106 | // TODO(node-fs): We currently do not implement time stamp modification |
| 107 | // of files via webfs so this test is expected to fail. This is temporary |
| 108 | // until we fully implement these bits, so leaving this as "expectedFailures". |
| 109 | 'getFile() returns last modified time', |
| 110 | ], |
| 111 | }, |
| 112 | 'FileSystemFileHandle-move.https.any.js': { |
| 113 | comment: |
| 114 | 'We do not currently implement the move() method on file system handles', |
| 115 | expectedFailures: [ |
| 116 | // TODO(node-fs): Implement move and enable these tests |
| 117 | 'move(name) to rename a file', |
| 118 | 'get a handle to a moved file', |
| 119 | 'move(name) to rename a file the same name', |
| 120 | 'move("") to rename a file fails', |
| 121 | 'move(name) can be called multiple times', |
| 122 | 'move(name) with a name with path separators should fail', |
| 123 | 'move(name) while the file has an open writable fails', |
| 124 | 'move(name) while the destination file has an open writable fails', |
| 125 | 'move(name) can overwrite an existing file', |
| 126 | 'move(dir, name) to rename a file', |
| 127 | 'move(dir, name) to rename a file the same name', |
| 128 | 'move(dir) to move a file to a new directory', |
| 129 | 'move(dir, "") to move a file to a new directory fails', |
| 130 | 'move(dir, name) to move a file to a new directory', |
| 131 | 'move(dir) can be called multiple times', |
| 132 | 'move(dir, name) can be called multiple times', |
| 133 | 'move(dir, name) with a name with invalid characters should fail', |
| 134 | 'move(dir) while the file has an open writable fails', |
| 135 | 'move(dir, name) while the file has an open writable fails', |
| 136 | 'move(dir) while the destination file has an open writable fails', |
| 137 | 'move(dir) can overwrite an existing file', |
| 138 | 'move(dir, name) while the destination file has an open writable fails', |
| 139 | 'move(dir, name) can overwrite an existing file', |
| 140 | 'FileSystemFileHandles are references, not paths', |
| 141 | ], |
| 142 | }, |
| 143 | 'FileSystemSyncAccessHandle-close.https.worker.js': { |
| 144 | comment: 'We currently do not implement sync access handles', |
| 145 | disabledTests: true, |
| 146 | }, |
| 147 | 'FileSystemSyncAccessHandle-flush.https.worker.js': { |
| 148 | comment: 'We currently do not implement sync access handles', |
| 149 | disabledTests: true, |
| 150 | }, |
| 151 | 'FileSystemSyncAccessHandle-getSize.https.worker.js': { |
| 152 | comment: 'We currently do not implement sync access handles', |
| 153 | disabledTests: true, |
| 154 | }, |
| 155 | 'FileSystemSyncAccessHandle-read-write.https.worker.js': { |
| 156 | comment: 'We currently do not implement sync access handles', |
| 157 | disabledTests: true, |
| 158 | }, |
| 159 | 'FileSystemSyncAccessHandle-truncate.https.worker.js': { |
| 160 | comment: 'We currently do not implement sync access handles', |
| 161 | disabledTests: true, |
| 162 | }, |
| 163 | 'FileSystemWritableFileStream-piped.https.any.js': { |
| 164 | comment: 'The test requires streams/resources/recording-streams.js', |
| 165 | // TODO(node-fs): These tests require a resource file from the streams wpt |
| 166 | // tests... |
| 167 | disabledTests: true, |
| 168 | }, |
| 169 | 'FileSystemWritableFileStream-write.https.any.js': { |
| 170 | comment: '...', |
| 171 | disabledTests: [ |
| 172 | // We don't support this case. In the test a Blob is created from a |
| 173 | // file that is then removed, then that Blob is written to a file. |
| 174 | // Because our blob contains a copy of the original file's data |
| 175 | // and is not a live-reference, the expected error does not occur. |
| 176 | 'write() with an invalid blob to an empty file should reject', |
| 177 | ], |
| 178 | }, |
| 179 | 'FileSystemWritableFileStream.https.any.js': { |
| 180 | comment: |
| 181 | 'There is currently a bug in the web platform tests that causes this to fail', |
| 182 | expectedFailures: [ |
| 183 | 'createWritable() can be called on two handles representing the same file', |
| 184 | ], |
| 185 | }, |
| 186 | 'idlharness.https.any.js': { |
| 187 | comment: |
| 188 | 'Remaining IDL failures: prototype chain issues, operation .length mismatches', |
| 189 | expectedFailures: [ |
| 190 | 'FileSystemHandle interface: operation isSameEntry(FileSystemHandle)', |
| 191 | 'FileSystemFileHandle interface: existence and properties of interface object', |
| 192 | 'FileSystemFileHandle interface: operation getFile()', |
| 193 | 'FileSystemFileHandle interface: operation createWritable(optional FileSystemCreateWritableOptions)', |
| 194 | 'FileSystemDirectoryHandle interface: existence and properties of interface object', |
| 195 | 'FileSystemDirectoryHandle interface: operation getFileHandle(USVString, optional FileSystemGetFileOptions)', |
| 196 | 'FileSystemDirectoryHandle interface: operation getDirectoryHandle(USVString, optional FileSystemGetDirectoryOptions)', |
| 197 | 'FileSystemDirectoryHandle interface: operation removeEntry(USVString, optional FileSystemRemoveOptions)', |
| 198 | 'FileSystemDirectoryHandle interface: operation resolve(FileSystemHandle)', |
| 199 | 'FileSystemWritableFileStream interface: existence and properties of interface object', |
| 200 | 'FileSystemWritableFileStream interface: operation write(FileSystemWriteChunkType)', |
| 201 | 'FileSystemWritableFileStream interface: operation seek(unsigned long long)', |
| 202 | 'FileSystemWritableFileStream interface: operation truncate(unsigned long long)', |
| 203 | 'StorageManager interface: operation getDirectory()', |
| 204 | ], |
| 205 | }, |
| 206 | 'opaque-origin.https.window.js': { |
| 207 | comment: 'Not relevant to workers', |
| 208 | disabledTests: true, |
| 209 | }, |
| 210 | 'root-name.https.any.js': { |
| 211 | comment: |
| 212 | 'Our test harness does not actually expose the root directory to the tests', |
| 213 | disabledTests: [ |
| 214 | 'getDirectory returns a directory whose name is the empty string', |
| 215 | ], |
| 216 | }, |
| 217 | |
| 218 | 'script-tests/FileSystemBaseHandle-IndexedDB.js': { |
| 219 | comment: 'script-test files are imported and tested above', |
| 220 | disabledTests: true, |
| 221 | }, |
| 222 | 'script-tests/FileSystemBaseHandle-buckets.js': { |
| 223 | comment: 'script-test files are imported and tested above', |
| 224 | disabledTests: true, |
| 225 | }, |
| 226 | 'script-tests/FileSystemBaseHandle-getUniqueId.js': { |
| 227 | comment: 'script-test files are imported and tested above', |
| 228 | disabledTests: true, |
| 229 | }, |
| 230 | 'script-tests/FileSystemBaseHandle-isSameEntry.js': { |
| 231 | comment: 'script-test files are imported and tested above', |
| 232 | disabledTests: true, |
| 233 | }, |
| 234 | 'script-tests/FileSystemBaseHandle-postMessage-BroadcastChannel.js': { |
| 235 | comment: 'script-test files are imported and tested above', |
| 236 | disabledTests: true, |
| 237 | }, |
| 238 | 'script-tests/FileSystemBaseHandle-postMessage-Error.js': { |
| 239 | comment: 'script-test files are imported and tested above', |
| 240 | disabledTests: true, |
| 241 | }, |
| 242 | 'script-tests/FileSystemBaseHandle-postMessage-MessagePort-frames.js': { |
| 243 | comment: 'script-test files are imported and tested above', |
| 244 | disabledTests: true, |
| 245 | }, |
| 246 | 'script-tests/FileSystemBaseHandle-postMessage-MessagePort-windows.js': { |
| 247 | comment: 'script-test files are imported and tested above', |
| 248 | disabledTests: true, |
| 249 | }, |
| 250 | 'script-tests/FileSystemBaseHandle-postMessage-MessagePort-workers.js': { |
| 251 | comment: 'script-test files are imported and tested above', |
| 252 | disabledTests: true, |
| 253 | }, |
| 254 | 'script-tests/FileSystemBaseHandle-postMessage-frames.js': { |
| 255 | comment: 'script-test files are imported and tested above', |
| 256 | disabledTests: true, |
| 257 | }, |
| 258 | 'script-tests/FileSystemBaseHandle-postMessage-windows.js': { |
| 259 | comment: 'script-test files are imported and tested above', |
| 260 | disabledTests: true, |
| 261 | }, |
| 262 | 'script-tests/FileSystemBaseHandle-postMessage-workers.js': { |
| 263 | comment: 'script-test files are imported and tested above', |
| 264 | disabledTests: true, |
| 265 | }, |
| 266 | 'script-tests/FileSystemBaseHandle-remove.js': { |
| 267 | comment: 'script-test files are imported and tested above', |
| 268 | disabledTests: true, |
| 269 | }, |
| 270 | 'script-tests/FileSystemDirectoryHandle-getDirectoryHandle.js': { |
| 271 | comment: 'script-test files are imported and tested above', |
| 272 | disabledTests: true, |
| 273 | }, |
| 274 | 'script-tests/FileSystemDirectoryHandle-getFileHandle.js': { |
| 275 | comment: 'script-test files are imported and tested above', |
| 276 | disabledTests: true, |
| 277 | }, |
| 278 | 'script-tests/FileSystemDirectoryHandle-iteration.js': { |
| 279 | comment: 'script-test files are imported and tested above', |
| 280 | disabledTests: true, |
| 281 | }, |
| 282 | 'script-tests/FileSystemDirectoryHandle-removeEntry.js': { |
| 283 | comment: 'script-test files are imported and tested above', |
| 284 | disabledTests: true, |
| 285 | }, |
| 286 | 'script-tests/FileSystemDirectoryHandle-resolve.js': { |
| 287 | comment: 'script-test files are imported and tested above', |
| 288 | disabledTests: true, |
| 289 | }, |
| 290 | 'script-tests/FileSystemFileHandle-create-sync-access-handle.js': { |
| 291 | comment: 'script-test files are imported and tested above', |
| 292 | disabledTests: true, |
| 293 | }, |
| 294 | 'script-tests/FileSystemFileHandle-getFile.js': { |
| 295 | comment: 'script-test files are imported and tested above', |
| 296 | disabledTests: true, |
| 297 | }, |
| 298 | 'script-tests/FileSystemFileHandle-move.js': { |
| 299 | comment: 'script-test files are imported and tested above', |
| 300 | disabledTests: true, |
| 301 | }, |
| 302 | 'script-tests/FileSystemObserver-writable-file-stream.js': { |
| 303 | comment: 'script-test files are imported and tested above', |
| 304 | disabledTests: true, |
| 305 | }, |
| 306 | 'script-tests/FileSystemObserver.js': { |
| 307 | comment: 'script-test files are imported and tested above', |
| 308 | disabledTests: true, |
| 309 | }, |
| 310 | 'script-tests/FileSystemSyncAccessHandle-flush.js': { |
| 311 | comment: 'script-test files are imported and tested above', |
| 312 | disabledTests: true, |
| 313 | }, |
| 314 | 'script-tests/FileSystemWritableFileStream-piped.js': { |
| 315 | comment: 'script-test files are imported and tested above', |
| 316 | disabledTests: true, |
| 317 | }, |
| 318 | 'script-tests/FileSystemWritableFileStream-write.js': { |
| 319 | comment: 'script-test files are imported and tested above', |
| 320 | disabledTests: true, |
| 321 | }, |
| 322 | 'script-tests/FileSystemWritableFileStream.js': { |
| 323 | comment: 'script-test files are imported and tested above', |
| 324 | disabledTests: true, |
| 325 | }, |
| 326 | } satisfies TestRunnerConfig; |