From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/entries-api/META.yml | 4 + testing/web-platform/tests/entries-api/README.md | 9 ++ .../tests/entries-api/errors-manual.html | 61 +++++++++ .../file-webkitRelativePath-manual.html | 33 +++++ .../tests/entries-api/filesystem-manual.html | 40 ++++++ ...filesystemdirectoryentry-attributes-manual.html | 37 ++++++ ...lesystemdirectoryentry-createReader-manual.html | 23 ++++ ...lesystemdirectoryentry-getDirectory-manual.html | 128 +++++++++++++++++++ .../filesystemdirectoryentry-getFile-manual.html | 115 +++++++++++++++++ .../filesystemdirectoryentry-getParent-manual.html | 17 +++ .../filesystemdirectoryreader-manual.html | 77 ++++++++++++ .../filesystementry-attributes-manual.html | 29 +++++ .../filesystementry-getParent-manual.html | 27 ++++ .../filesystemfileentry-attributes-manual.html | 37 ++++++ .../filesystemfileentry-file-manual.html | 26 ++++ .../filesystemfileentry-getParent-manual.html | 17 +++ .../tests/entries-api/idlharness-manual.window.js | 46 +++++++ .../tests/entries-api/idlharness.window.js | 15 +++ testing/web-platform/tests/entries-api/support.js | 138 +++++++++++++++++++++ .../tests/entries-api/support/a/b/c/3.txt | 0 .../tests/entries-api/support/a/b/c/d/1.txt | 0 .../tests/entries-api/support/a/b/c/d/2.txt | 0 .../tests/entries-api/support/upload.txt | 0 .../tests/entries-api/support/upload/file.txt | 0 .../tests/entries-api/support/upload/subdir/1.txt | 0 .../tests/entries-api/support/upload/subdir/2.txt | 0 .../tests/entries-api/support/upload/subdir/3.txt | 0 27 files changed, 879 insertions(+) create mode 100644 testing/web-platform/tests/entries-api/META.yml create mode 100644 testing/web-platform/tests/entries-api/README.md create mode 100644 testing/web-platform/tests/entries-api/errors-manual.html create mode 100644 testing/web-platform/tests/entries-api/file-webkitRelativePath-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystem-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemdirectoryentry-attributes-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemdirectoryentry-createReader-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemdirectoryentry-getDirectory-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemdirectoryentry-getFile-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemdirectoryentry-getParent-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemdirectoryreader-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystementry-attributes-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystementry-getParent-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemfileentry-attributes-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemfileentry-file-manual.html create mode 100644 testing/web-platform/tests/entries-api/filesystemfileentry-getParent-manual.html create mode 100644 testing/web-platform/tests/entries-api/idlharness-manual.window.js create mode 100644 testing/web-platform/tests/entries-api/idlharness.window.js create mode 100644 testing/web-platform/tests/entries-api/support.js create mode 100644 testing/web-platform/tests/entries-api/support/a/b/c/3.txt create mode 100644 testing/web-platform/tests/entries-api/support/a/b/c/d/1.txt create mode 100644 testing/web-platform/tests/entries-api/support/a/b/c/d/2.txt create mode 100644 testing/web-platform/tests/entries-api/support/upload.txt create mode 100644 testing/web-platform/tests/entries-api/support/upload/file.txt create mode 100644 testing/web-platform/tests/entries-api/support/upload/subdir/1.txt create mode 100644 testing/web-platform/tests/entries-api/support/upload/subdir/2.txt create mode 100644 testing/web-platform/tests/entries-api/support/upload/subdir/3.txt (limited to 'testing/web-platform/tests/entries-api') diff --git a/testing/web-platform/tests/entries-api/META.yml b/testing/web-platform/tests/entries-api/META.yml new file mode 100644 index 0000000000..69f68452f2 --- /dev/null +++ b/testing/web-platform/tests/entries-api/META.yml @@ -0,0 +1,4 @@ +spec: https://wicg.github.io/entries-api/ +suggested_reviewers: + - aliams + - inexorabletash diff --git a/testing/web-platform/tests/entries-api/README.md b/testing/web-platform/tests/entries-api/README.md new file mode 100644 index 0000000000..7c08ba837b --- /dev/null +++ b/testing/web-platform/tests/entries-api/README.md @@ -0,0 +1,9 @@ +Tests for the [Files and Directory Entries API](https://github.com/wicg/entries-api) + +* [Explainer](https://github.com/WICG/entries-api/blob/gh-pages/EXPLAINER.md) +* [Draft Specification](https://wicg.github.io/entries-api/) + +Unfortunately, most of the tests are **manual** and require drag-and-drop of test +data files, which can be found in the `entries-api/support` directory. The tests +can be run via [wpt.live](http://wpt.live/entries-api/), but a local clone +of the repo is required for access to the test data files. diff --git a/testing/web-platform/tests/entries-api/errors-manual.html b/testing/web-platform/tests/entries-api/errors-manual.html new file mode 100644 index 0000000000..f7134982af --- /dev/null +++ b/testing/web-platform/tests/entries-api/errors-manual.html @@ -0,0 +1,61 @@ + + +Entries API: Errors manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/file-webkitRelativePath-manual.html b/testing/web-platform/tests/entries-api/file-webkitRelativePath-manual.html new file mode 100644 index 0000000000..695ccc47c3 --- /dev/null +++ b/testing/web-platform/tests/entries-api/file-webkitRelativePath-manual.html @@ -0,0 +1,33 @@ + + +Entries API: File webitRelativePath manual test + + + + +Select the support/a directory: + + + + diff --git a/testing/web-platform/tests/entries-api/filesystem-manual.html b/testing/web-platform/tests/entries-api/filesystem-manual.html new file mode 100644 index 0000000000..9e84b10c08 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystem-manual.html @@ -0,0 +1,40 @@ + + +Entries API: FileSystem manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemdirectoryentry-attributes-manual.html b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-attributes-manual.html new file mode 100644 index 0000000000..9422c014ac --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-attributes-manual.html @@ -0,0 +1,37 @@ + + +Entries API: FileSystemDirectoryEntry attributes manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemdirectoryentry-createReader-manual.html b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-createReader-manual.html new file mode 100644 index 0000000000..f9369c6f74 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-createReader-manual.html @@ -0,0 +1,23 @@ + + +Entries API: FileSystemDirectoryEntry createReader() manual test + + + + + + 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 @@ + + +Entries API: FileSystemDirectoryEntry.getDirectory() manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getFile-manual.html b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getFile-manual.html new file mode 100644 index 0000000000..3acd2fbd76 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getFile-manual.html @@ -0,0 +1,115 @@ + + +Entries API: FileSystemDirectoryEntry.getFile() manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getParent-manual.html b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getParent-manual.html new file mode 100644 index 0000000000..20c2a707d3 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemdirectoryentry-getParent-manual.html @@ -0,0 +1,17 @@ + + +Entries API: FileSystemDirectoryEntry getParent() manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemdirectoryreader-manual.html b/testing/web-platform/tests/entries-api/filesystemdirectoryreader-manual.html new file mode 100644 index 0000000000..55f0fc4e70 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemdirectoryreader-manual.html @@ -0,0 +1,77 @@ + + +Entries API: FileSystemDirectoryReader manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystementry-attributes-manual.html b/testing/web-platform/tests/entries-api/filesystementry-attributes-manual.html new file mode 100644 index 0000000000..9f2431b87e --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystementry-attributes-manual.html @@ -0,0 +1,29 @@ + + +Entries API: FileSystemEntry attributes manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystementry-getParent-manual.html b/testing/web-platform/tests/entries-api/filesystementry-getParent-manual.html new file mode 100644 index 0000000000..7110bdcfbc --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystementry-getParent-manual.html @@ -0,0 +1,27 @@ + + +Entries API: FileSystemEntry getParent() manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemfileentry-attributes-manual.html b/testing/web-platform/tests/entries-api/filesystemfileentry-attributes-manual.html new file mode 100644 index 0000000000..113773e82d --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemfileentry-attributes-manual.html @@ -0,0 +1,37 @@ + + +Entries API: FileSystemFileEntry attributes manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemfileentry-file-manual.html b/testing/web-platform/tests/entries-api/filesystemfileentry-file-manual.html new file mode 100644 index 0000000000..7ac29c0b13 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemfileentry-file-manual.html @@ -0,0 +1,26 @@ + + +Entries API: FileSystemFileEntry file() manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/filesystemfileentry-getParent-manual.html b/testing/web-platform/tests/entries-api/filesystemfileentry-getParent-manual.html new file mode 100644 index 0000000000..fea77348a6 --- /dev/null +++ b/testing/web-platform/tests/entries-api/filesystemfileentry-getParent-manual.html @@ -0,0 +1,17 @@ + + +Entries API: FileSystemFileEntry getParent() manual test + + + + + + diff --git a/testing/web-platform/tests/entries-api/idlharness-manual.window.js b/testing/web-platform/tests/entries-api/idlharness-manual.window.js new file mode 100644 index 0000000000..9f2731bf1d --- /dev/null +++ b/testing/web-platform/tests/entries-api/idlharness-manual.window.js @@ -0,0 +1,46 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js +// META: script=support.js + +'use strict'; + +let resolve; +let globalItem; +let globalEntry; + +let entriesPromise = new Promise(r => { + resolve = r; +}); + +entry_test((t, entry, item) => { + assert_true(entry.isDirectory); + resolve(getEntriesAsPromise(entry)); + globalItem = item; + globalEntry = entry; + t.done(); +}); + +idl_test( + ['entries-api'], + ['FileAPI', 'html', 'dom'], + async idl_array => { + const entries = await entriesPromise; + window.samples = { + item: globalItem, + dirEntry: entries.filter(entry => entry.isDirectory)[0], + fileEntry: entries.filter(entry => entry.isFile)[0], + fileSystem: globalEntry.filesystem, + }; + + idl_array.add_objects({ + File: ['new File([], "example.txt")'], + HTMLInputElement: ['document.createElement("input")'], + DataTransferItem: ['samples.item'], + FileSystemEntry: [], + FileSystemDirectoryEntry: ['samples.dirEntry'], + FileSystemDirectoryReader: ['samples.dirEntry.createReader()'], + FileSystemFileEntry: ['samples.fileEntry'], + FileSystem: ['samples.fileSystem'], + }); + } +); diff --git a/testing/web-platform/tests/entries-api/idlharness.window.js b/testing/web-platform/tests/entries-api/idlharness.window.js new file mode 100644 index 0000000000..32527be514 --- /dev/null +++ b/testing/web-platform/tests/entries-api/idlharness.window.js @@ -0,0 +1,15 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +'use strict'; + +idl_test( + ['entries-api'], + ['FileAPI', 'html', 'dom'], + idl_array => { + idl_array.add_objects({ + File: ['new File([], "example.txt")'], + HTMLInputElement: ['document.createElement("input")'], + }); + } +); diff --git a/testing/web-platform/tests/entries-api/support.js b/testing/web-platform/tests/entries-api/support.js new file mode 100644 index 0000000000..1cf3ad95b9 --- /dev/null +++ b/testing/web-platform/tests/entries-api/support.js @@ -0,0 +1,138 @@ +// ---------------------------------------- +// Test Utilities +// ---------------------------------------- + +setup({explicit_timeout: true}); + +const tests = []; +window.addEventListener('DOMContentLoaded', e => { + const header = document.createElement('h1'); + header.innerText = document.title; + document.body.appendChild(header); + const elem = document.createElement('div'); + elem.style.cssText = 'height: 50px; border: 1px dotted red;'; + elem.innerHTML = 'Drop or paste the support/upload directory here.'; + document.body.appendChild(elem); + elem.addEventListener('dragover', e => { + e.preventDefault(); + }); + const onDropOrPaste = dataTransfer => { + for (let i = 0; i < dataTransfer.items.length; ++i) { + const item = dataTransfer.items[i]; + if (item.kind !== 'file') + continue; + const entry = item.webkitGetAsEntry(); + elem.parentElement.removeChild(elem); + tests.forEach(f => f(entry, item)); + break; + } + }; + elem.addEventListener('drop', e => { + e.preventDefault(); + onDropOrPaste(e.dataTransfer); + }); + elem.addEventListener('paste', e => { + e.preventDefault(); + onDropOrPaste(e.clipboardData); + }); +}); + + +// Registers a test to be run when an entry is dropped. Calls |func| +// with (test, entry, item); |func| must call `test.done()` when complete. +function entry_test(func, description) { + const test = async_test(description); + tests.push(test.step_func((entry, item) => func(test, entry, item))); +} + +// Registers a test to be run when an entry is dropped. Digs the named +// |file| out of the dropped entry and calls |func| with +// (test, file_entry); |func| must call `test.done()` when complete. +function file_entry_test(name, func, description) { + return entry_test((t, entry, item) => { + getChildEntry(entry, name, + t.step_func((entry) => func(t, entry)), + t.unreached_func('Did not find expected file: ' + name)); + }, description); +} + + +// ---------------------------------------- +// Paths +// ---------------------------------------- + +const INVALID_PATHS = [ + '\x00', 'a-\x00-b', + '\\', 'a-\\-b' +]; +const EMPTY_PATHS = ['', null, undefined]; +const NOT_FOUND_PATHS = [ + 'nope', + '/upload/nope', + './nope', + 'subdir/../nope', + '\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f', + '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f', +]; + +const DIR_PATHS = [ + 'subdir', + '/upload/subdir', + './subdir', + 'subdir/.', + 'subdir/../subdir', + 'subdir/./../subdir', + 'subdir/../subdir/.', + '//upload/subdir', + '/upload//subdir', + './/subdir', + 'subdir//.', +]; +const FILE_PATHS = [ + 'file.txt', + '/upload/file.txt', + 'subdir/../file.txt', + '//upload/file.txt', + '/upload//file.txt', + 'subdir/./../file.txt', +]; + +// ---------------------------------------- +// Helpers +// ---------------------------------------- + +// Wrapper for FileSystemDirectoryReader that yields all entries via a +// Promise. + +function getEntriesAsPromise(dirEntry) { + return new Promise((resolve, reject) => { + const result = []; + const reader = dirEntry.createReader(); + const doBatch = () => { + reader.readEntries(entries => { + if (entries.length > 0) { + entries.forEach(e => result.push(e)); + doBatch(); + } else { + resolve(result); + } + }, reject); + }; + doBatch(); + }); +} + + +// Wrapper for FileSystemDirectoryReader that yields a single entry by +// name via a callback. Can be used instead of getFile() or +// getDirectory() since not all implementations support those. + +function getChildEntry(dirEntry, name, callback, errback) { + getEntriesAsPromise(dirEntry) + .then(entries => { + const entry = entries.filter(entry => entry.name === name)[0]; + if (!entry) + throw new Error('No such file: ' + name); + return entry; + }).then(callback, errback); +} diff --git a/testing/web-platform/tests/entries-api/support/a/b/c/3.txt b/testing/web-platform/tests/entries-api/support/a/b/c/3.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/a/b/c/d/1.txt b/testing/web-platform/tests/entries-api/support/a/b/c/d/1.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/a/b/c/d/2.txt b/testing/web-platform/tests/entries-api/support/a/b/c/d/2.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/upload.txt b/testing/web-platform/tests/entries-api/support/upload.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/upload/file.txt b/testing/web-platform/tests/entries-api/support/upload/file.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/upload/subdir/1.txt b/testing/web-platform/tests/entries-api/support/upload/subdir/1.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/upload/subdir/2.txt b/testing/web-platform/tests/entries-api/support/upload/subdir/2.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/testing/web-platform/tests/entries-api/support/upload/subdir/3.txt b/testing/web-platform/tests/entries-api/support/upload/subdir/3.txt new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3