summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html')
-rw-r--r--testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html128
1 files changed, 128 insertions, 0 deletions
diff --git a/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html
new file mode 100644
index 0000000000..d78bb66df7
--- /dev/null
+++ b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Entries API: FileSystemDirectoryEntry.getDirectory() manual test</title>
+<link rel=help href="https://wicg.github.io/entries-api/#dom-filesystemdirectoryentry-getdirectory">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support.js"></script>
+
+<script>
+entry_test((t, entry) => {
+ assert_idl_attribute(entry, 'getDirectory', 'FileSystemDirectoryEntry has getDirectory');
+ assert_equals(typeof entry.getDirectory, 'function', 'getDirectory() is a method');
+
+ t.done();
+}, 'FileSystemDirectoryEntry - getDirectory()');
+
+INVALID_PATHS.forEach(path => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ path,
+ {},
+ t.unreached_func('getDirectory should fail'),
+ t.step_func(error => {
+ assert_equals(error.name, 'TypeMismatchError',
+ 'getDirectory() should fail if given invalid path');
+ t.done();
+ }));
+ }, 'FileSystemDirectoryEntry.getDirectory() - invalid path: ' + JSON.stringify(path));
+});
+
+EMPTY_PATHS.forEach(path => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ path,
+ {},
+ t.step_func(dir => {
+ assert_true(dir.isDirectory,
+ 'empty path should yield FileSystemDirectoryEntry');
+ assert_equals(dir.name, entry.name,
+ 'empty path should yield same directory');
+ assert_equals(dir.fullPath, entry.fullPath,
+ 'empty path should yield same directory');
+ t.done();
+ }),
+ t.unreached_func('getDirectory should not fail')
+ );
+ }, 'FileSystemDirectoryEntry.getDirectory() - empty path: '
+ + JSON.stringify(path) || 'undefined');
+});
+
+DIR_PATHS.forEach(path => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ path,
+ {create: true},
+ t.unreached_func('getDirectory should fail'),
+ t.step_func(error => {
+ assert_equals(error.name, 'SecurityError',
+ 'getDirectory() should fail with security error if ' +
+ 'create option is set');
+ t.done();
+ }));
+ }, 'FileSystemDirectoryEntry.getDirectory() - {create:true}: ' + path);
+});
+
+NOT_FOUND_PATHS.forEach(path => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ path,
+ {},
+ t.unreached_func('getDirectory should fail'),
+ t.step_func(error => {
+ assert_equals(error.name, 'NotFoundError',
+ 'getDirectory() should fail with not found');
+ t.done();
+ }));
+ }, 'FileSystemDirectoryEntry.getDirectory() - not found: ' + path);
+});
+
+FILE_PATHS.forEach(path => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ path,
+ {},
+ t.unreached_func('getDirectory should fail'),
+ t.step_func(error => {
+ assert_equals(error.name, 'TypeMismatchError',
+ 'getDirectory() should fail if type is file');
+ t.done();
+ }));
+ }, 'FileSystemDirectoryEntry.getDirectory() - directory: ' + path);
+});
+
+DIR_PATHS.forEach(path => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ path,
+ {},
+ t.step_func(e => {
+ assert_false(e.isFile);
+ assert_true(e.isDirectory);
+ assert_equals(e.name, 'subdir');
+ t.done();
+ }),
+ t.unreached_func('getDirectory should not fail')
+ );
+ }, 'FileSystemDirectoryEntry.getDirectory() - directory: ' + path);
+});
+
+[
+ {path: '.', name: 'upload'},
+ {path: '/', name: ''}
+].forEach(test_case => {
+ entry_test((t, entry) => {
+ entry.getDirectory(
+ test_case.path,
+ {},
+ t.step_func(e => {
+ assert_false(e.isFile);
+ assert_true(e.isDirectory);
+ assert_equals(e.name, test_case.name);
+ t.done();
+ }),
+ t.unreached_func('getDirectory should not fail')
+ );
+ }, 'FileSystemDirectoryEntry.getDirectory() - directory: ' + test_case.path);
+});
+</script>