From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../resources/file_handlers-member.js | 39 +++++++++++++++++++++ .../resources/file_handlers-member.webmanifest | 21 +++++++++++ .../resources/file_handlers-sample-file.txt | 1 + .../file_handlers-member/resources/icon.png | Bin 0 -> 3799 bytes 4 files changed, 61 insertions(+) create mode 100644 testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.js create mode 100644 testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-member.webmanifest create mode 100644 testing/web-platform/tests/appmanifest/file_handlers-member/resources/file_handlers-sample-file.txt create mode 100644 testing/web-platform/tests/appmanifest/file_handlers-member/resources/icon.png (limited to 'testing/web-platform/tests/appmanifest/file_handlers-member/resources') 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 new file mode 100644 index 0000000000..c177ad8dbd Binary files /dev/null and b/testing/web-platform/tests/appmanifest/file_handlers-member/resources/icon.png differ -- cgit v1.2.3