diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/xhr/formdata/foreach.any.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/xhr/formdata/foreach.any.js')
-rw-r--r-- | testing/web-platform/tests/xhr/formdata/foreach.any.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/xhr/formdata/foreach.any.js b/testing/web-platform/tests/xhr/formdata/foreach.any.js new file mode 100644 index 0000000000..9fc1e2d9b3 --- /dev/null +++ b/testing/web-platform/tests/xhr/formdata/foreach.any.js @@ -0,0 +1,56 @@ +// META: title=FormData: foreach + + var fd = new FormData(); + fd.append('n1', 'v1'); + fd.append('n2', 'v2'); + fd.append('n3', 'v3'); + fd.append('n1', 'v4'); + fd.append('n2', 'v5'); + fd.append('n3', 'v6'); + fd.delete('n2'); + + var file = new File(['hello'], "hello.txt"); + fd.append('f1', file); + + var expected_keys = ['n1', 'n3', 'n1', 'n3', 'f1']; + var expected_values = ['v1', 'v3', 'v4', 'v6', file]; + test(function() { + var mykeys = [], myvalues = []; + for(var entry of fd) { + assert_equals(entry.length, 2, + 'Default iterator should yield key/value pairs'); + mykeys.push(entry[0]); + myvalues.push(entry[1]); + } + assert_array_equals(mykeys, expected_keys, + 'Default iterator should see duplicate keys'); + assert_array_equals(myvalues, expected_values, + 'Default iterator should see non-deleted values'); + }, 'Iterator should return duplicate keys and non-deleted values'); + test(function() { + var mykeys = [], myvalues = []; + for(var entry of fd.entries()) { + assert_equals(entry.length, 2, + 'entries() iterator should yield key/value pairs'); + mykeys.push(entry[0]); + myvalues.push(entry[1]); + } + assert_array_equals(mykeys, expected_keys, + 'entries() iterator should see duplicate keys'); + assert_array_equals(myvalues, expected_values, + 'entries() iterator should see non-deleted values'); + }, 'Entries iterator should return duplicate keys and non-deleted values'); + test(function() { + var mykeys = []; + for(var entry of fd.keys()) + mykeys.push(entry); + assert_array_equals(mykeys, expected_keys, + 'keys() iterator should see duplicate keys'); + }, 'Keys iterator should return duplicates'); + test(function() { + var myvalues = []; + for(var entry of fd.values()) + myvalues.push(entry); + assert_array_equals(myvalues, expected_values, + 'values() iterator should see non-deleted values'); + }, 'Values iterator should return non-deleted values'); |