diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/FileAPI/filelist-section | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.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/FileAPI/filelist-section')
5 files changed, 186 insertions, 0 deletions
diff --git a/testing/web-platform/tests/FileAPI/filelist-section/filelist.html b/testing/web-platform/tests/FileAPI/filelist-section/filelist.html new file mode 100644 index 0000000000..b97dcde19f --- /dev/null +++ b/testing/web-platform/tests/FileAPI/filelist-section/filelist.html @@ -0,0 +1,57 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset='utf-8'> + <title>FileAPI Test: filelist</title> + <link rel='author' title='Intel' href='http://www.intel.com'> + <link rel='help' href='http://dev.w3.org/2006/webapi/FileAPI/#filelist-section'> + <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-length"> + <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-item"> + <script src='/resources/testharness.js'></script> + <script src='/resources/testharnessreport.js'></script> + </head> + + <body> + <form name='uploadData' style="display:none"> + <input type='file' id='fileChooser'> + </form> + <div id='log'></div> + + <script> + var fileList; + + setup(function () { + fileList = document.querySelector('#fileChooser').files; + }); + + test(function () { + assert_true('FileList' in window, 'window has a FileList property'); + }, 'Check if window has a FileList property'); + + test(function () { + assert_equals(FileList.length, 0, 'FileList.length is 0'); + }, 'Check if FileList.length is 0'); + + test(function () { + assert_true(fileList.item instanceof Function, 'item is a instanceof Function'); + }, 'Check if item is a instanceof Function'); + + test(function() { + assert_inherits(fileList, 'item', 'item is a method of fileList'); + }, 'Check if item is a method of fileList'); + + test(function() { + assert_equals(fileList.item(0), null, 'item method returns null'); + }, 'Check if the item method returns null when no file selected'); + + test(function() { + assert_inherits(fileList, 'length', 'length is fileList attribute'); + }, 'Check if length is fileList\'s attribute'); + + test(function() { + assert_equals(fileList.length, 0, 'fileList length is 0'); + }, 'Check if the fileList length is 0 when no file selected'); + </script> + + </body> +</html> diff --git a/testing/web-platform/tests/FileAPI/filelist-section/filelist_multiple_selected_files-manual.html b/testing/web-platform/tests/FileAPI/filelist-section/filelist_multiple_selected_files-manual.html new file mode 100644 index 0000000000..2efaa059fa --- /dev/null +++ b/testing/web-platform/tests/FileAPI/filelist-section/filelist_multiple_selected_files-manual.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset='utf-8'> + <title>FileAPI Test: filelist_multiple_selected_files</title> + <link rel='author' title='Intel' href='http://www.intel.com'> + <link rel='help' href='http://dev.w3.org/2006/webapi/FileAPI/#filelist-section'> + <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-length"> + <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-item"> + <script src='/resources/testharness.js'></script> + <script src='/resources/testharnessreport.js'></script> + </head> + + <body> + <form name='uploadData'> + <input type='file' id='fileChooser' multiple> + </form> + <div> + <p>Test steps:</p> + <ol> + <li>Download <a href='support/upload.txt'>upload.txt</a>, <a href="support/upload.zip">upload.zip</a> to local.</li> + <li>Select the local two files (upload.txt, upload.zip) to run the test.</li> + </ol> + </div> + + <div id='log'></div> + + <script> + var fileInput = document.querySelector('#fileChooser'); + var fileList; + + setup({explicit_done: true, explicit_timeout: true}); + + on_event(fileInput, 'change', function(evt) { + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_equals(fileList.length, 2, 'fileList length is 2'); + }, 'Check if the fileList length is 2 when selected two files'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_true(fileList.item(0) instanceof File, 'item method is instanceof File'); + }, 'Check if the item method returns the File interface when selected two files'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_not_equals(fileList.item(1), null, 'item(1) is not null'); + }, 'Check if item(1) is not null when selected two files. Index must be treated by user agents as value for the position of a File object in the FileList, with 0 representing the first file.'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_equals(fileList.item(2), null, 'item(2) is null'); + }, 'Check if item(2) is null when selected two files'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_array_equals([fileList.item(0).name, fileList.item(1).name], ['upload.txt', 'upload.zip'], 'file name string is the name of selected files "upload.txt", "upload.zip"'); + }, 'Check if the file name string is the name of selected files'); + + done(); + }); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/FileAPI/filelist-section/filelist_selected_file-manual.html b/testing/web-platform/tests/FileAPI/filelist-section/filelist_selected_file-manual.html new file mode 100644 index 0000000000..966aadda61 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/filelist-section/filelist_selected_file-manual.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset='utf-8'> + <title>FileAPI Test: filelist_selected_file</title> + <link rel='author' title='Intel' href='http://www.intel.com'> + <link rel='help' href='http://dev.w3.org/2006/webapi/FileAPI/#filelist-section'> + <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-length"> + <link rel="help" href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-item"> + <script src='/resources/testharness.js'></script> + <script src='/resources/testharnessreport.js'></script> + </head> + + <body> + <form name='uploadData'> + <input type='file' id='fileChooser'> + </form> + <div> + <p>Test steps:</p> + <ol> + <li>Download <a href='support/upload.txt'>upload.txt</a> to local.</li> + <li>Select the local upload.txt file to run the test.</li> + </ol> + </div> + + <div id='log'></div> + + <script> + var fileInput = document.querySelector('#fileChooser'); + var fileList; + + setup({explicit_done: true, explicit_timeout: true}); + + on_event(fileInput, 'change', function(evt) { + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_equals(fileList.length, 1, 'fileList length is 1'); + }, 'Check if the fileList length is 1 when selected one file'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_true(fileList.item(0) instanceof File, 'item method is instanceof File'); + }, 'Check if the item method returns the File interface when selected one file'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_not_equals(fileList.item(0), null, 'item(0) is not null'); + }, 'Check if item(0) is not null when selected one file. Index must be treated by user agents as value for the position of a File object in the FileList, with 0 representing the first file.'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_equals(fileList.item(1), null, 'item(1) is null'); + }, 'Check if item(1) is null when selected one file only'); + + test(function() { + fileList = document.querySelector('#fileChooser').files; + assert_equals(fileList.item(0).name, 'upload.txt', 'file name string is "upload.txt"'); + }, 'Check if the file name string is the selected "upload.txt"'); + + done(); + }); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/FileAPI/filelist-section/support/upload.txt b/testing/web-platform/tests/FileAPI/filelist-section/support/upload.txt new file mode 100644 index 0000000000..f45965b711 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/filelist-section/support/upload.txt @@ -0,0 +1 @@ +Hello, this is test file for file upload. diff --git a/testing/web-platform/tests/FileAPI/filelist-section/support/upload.zip b/testing/web-platform/tests/FileAPI/filelist-section/support/upload.zip Binary files differnew file mode 100644 index 0000000000..a933d6a949 --- /dev/null +++ b/testing/web-platform/tests/FileAPI/filelist-section/support/upload.zip |