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/appmanifest/file_handlers-member/resources | |
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/appmanifest/file_handlers-member/resources')
4 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.js b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.js new file mode 100644 index 0000000000..87ec82ef9a --- /dev/null +++ b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.js @@ -0,0 +1,39 @@ +// Since this is a manual test, disable the automatic timeout. +setup({explicit_timeout: true}); + +// Redirect to https if using http, because File System Access API (previously +// Native FileSystem API) isn't supported in http. +if (location.protocol !== 'https:') { + location.replace( + `https:${location.href.substring(location.protocol.length)}` + ); +} + +test(function() { + assert_true('serviceWorker' in navigator); +}, 'serviceWorker exists') + +navigator.serviceWorker.register( + 'file_handlers-member-service-worker.js'); + +test(function() { + assert_true('launchQueue' in window); +}, 'File Handling API enabled'); + +test(function() { + assert_true('showOpenFilePicker' in window); +}, 'File System Access API enabled'); + +promise_test(async t => { + const launchParams = await new Promise(resolve => { + window.launchQueue.setConsumer(resolve); + }); + + assert_equals(launchParams.files.length, 1, 'Wrong number of files found'); + + const readHandle = await launchParams.files[0].getFile(); + assert_equals(readHandle.name, 'file_handlers-sample-file.txt'); + + const fileContents = await readHandle.text(); + assert_equals(fileContents, 'File handling WPT - Hello world!\n'); +}, 'launchQueue works as expected'); diff --git a/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.webmanifest b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.webmanifest new file mode 100644 index 0000000000..1cc5bf4aa9 --- /dev/null +++ b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.webmanifest @@ -0,0 +1,21 @@ +{ + "name": "File Handling WPT", + "icons": [ + { + "src": "icon.png", + "sizes": "144x144" + } + ], + "start_url": "../file_handlers-member-manual.tentative.html", + "display": "standalone", + "scope": "../../file_handlers-member/", + "file_handlers": [ + { + "action": "../file_handlers-member-manual.tentative.html", + "name": "Plain Text", + "accept": { + "text/plain": [".txt"] + } + } + ] +} diff --git a/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-sample-file.txt b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-sample-file.txt new file mode 100644 index 0000000000..5c8a71969c --- /dev/null +++ b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-sample-file.txt @@ -0,0 +1 @@ +File handling WPT - Hello world! diff --git a/testing/web-platform/tests/appmanifest/file_handlers-member/resources/icon.png b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/icon.png Binary files differnew file mode 100644 index 0000000000..c177ad8dbd --- /dev/null +++ b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/icon.png |