summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/url/urlencoded-parser.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/url/urlencoded-parser.any.js
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/web-platform/tests/url/urlencoded-parser.any.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/testing/web-platform/tests/url/urlencoded-parser.any.js b/testing/web-platform/tests/url/urlencoded-parser.any.js
new file mode 100644
index 0000000000..46b932bb01
--- /dev/null
+++ b/testing/web-platform/tests/url/urlencoded-parser.any.js
@@ -0,0 +1,67 @@
+[
+ { "input": "test", "output": [["test", ""]] },
+ { "input": "\uFEFFtest=\uFEFF", "output": [["\uFEFFtest", "\uFEFF"]] },
+ { "input": "%EF%BB%BFtest=%EF%BB%BF", "output": [["\uFEFFtest", "\uFEFF"]] },
+ { "input": "%FE%FF", "output": [["\uFFFD\uFFFD", ""]] },
+ { "input": "%FF%FE", "output": [["\uFFFD\uFFFD", ""]] },
+ { "input": "†&†=x", "output": [["†", ""], ["†", "x"]] },
+ { "input": "%C2", "output": [["\uFFFD", ""]] },
+ { "input": "%C2x", "output": [["\uFFFDx", ""]] },
+ { "input": "_charset_=windows-1252&test=%C2x", "output": [["_charset_", "windows-1252"], ["test", "\uFFFDx"]] },
+ { "input": '', "output": [] },
+ { "input": 'a', "output": [['a', '']] },
+ { "input": 'a=b', "output": [['a', 'b']] },
+ { "input": 'a=', "output": [['a', '']] },
+ { "input": '=b', "output": [['', 'b']] },
+ { "input": '&', "output": [] },
+ { "input": '&a', "output": [['a', '']] },
+ { "input": 'a&', "output": [['a', '']] },
+ { "input": 'a&a', "output": [['a', ''], ['a', '']] },
+ { "input": 'a&b&c', "output": [['a', ''], ['b', ''], ['c', '']] },
+ { "input": 'a=b&c=d', "output": [['a', 'b'], ['c', 'd']] },
+ { "input": 'a=b&c=d&', "output": [['a', 'b'], ['c', 'd']] },
+ { "input": '&&&a=b&&&&c=d&', "output": [['a', 'b'], ['c', 'd']] },
+ { "input": 'a=a&a=b&a=c', "output": [['a', 'a'], ['a', 'b'], ['a', 'c']] },
+ { "input": 'a==a', "output": [['a', '=a']] },
+ { "input": 'a=a+b+c+d', "output": [['a', 'a b c d']] },
+ { "input": '%=a', "output": [['%', 'a']] },
+ { "input": '%a=a', "output": [['%a', 'a']] },
+ { "input": '%a_=a', "output": [['%a_', 'a']] },
+ { "input": '%61=a', "output": [['a', 'a']] },
+ { "input": '%61+%4d%4D=', "output": [['a MM', '']] },
+ { "input": "id=0&value=%", "output": [['id', '0'], ['value', '%']] },
+ { "input": "b=%2sf%2a", "output": [['b', '%2sf*']]},
+ { "input": "b=%2%2af%2a", "output": [['b', '%2*f*']]},
+ { "input": "b=%%2a", "output": [['b', '%*']]}
+].forEach((val) => {
+ test(() => {
+ let sp = new URLSearchParams(val.input),
+ i = 0
+ for (let item of sp) {
+ assert_array_equals(item, val.output[i])
+ i++
+ }
+ }, "URLSearchParams constructed with: " + val.input)
+
+ promise_test(() => {
+ let init = new Request("about:blank", { body: val.input, method: "LADIDA", headers: {"Content-Type": "application/x-www-form-urlencoded;charset=windows-1252"} }).formData()
+ return init.then((fd) => {
+ let i = 0
+ for (let item of fd) {
+ assert_array_equals(item, val.output[i])
+ i++
+ }
+ })
+ }, "request.formData() with input: " + val.input)
+
+ promise_test(() => {
+ let init = new Response(val.input, { headers: {"Content-Type": "application/x-www-form-urlencoded;charset=shift_jis"} }).formData()
+ return init.then((fd) => {
+ let i = 0
+ for (let item of fd) {
+ assert_array_equals(item, val.output[i])
+ i++
+ }
+ })
+ }, "response.formData() with input: " + val.input)
+});