diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/XMLHttpRequest/send-usp.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/XMLHttpRequest/send-usp.js')
-rw-r--r-- | testing/web-platform/tests/XMLHttpRequest/send-usp.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/testing/web-platform/tests/XMLHttpRequest/send-usp.js b/testing/web-platform/tests/XMLHttpRequest/send-usp.js new file mode 100644 index 000000000..c00b2e0e0 --- /dev/null +++ b/testing/web-platform/tests/XMLHttpRequest/send-usp.js @@ -0,0 +1,48 @@ +const NUM_TESTS = 128; + +function encode(n) { + if (n === 0x20) { + return "\x2B"; + } + + if (n === 0x2A || n === 0x2D || n === 0x2E || + (0x30 <= n && n <= 0x39) || (0x41 <= n && n <= 0x5A) || + n === 0x5F || (0x61 <= n && n <= 0x7A)) { + return String.fromCharCode(n); + } + + var s = n.toString(16).toUpperCase(); + return "%" + (s.length === 2 ? s : '0' + s); +} + +function run_test() { + var tests = []; + var overall_test = async_test("Overall fetch with URLSearchParams"); + for (var i = 0; i < NUM_TESTS; i++) { + // Multiple subtests so that failures can be fine-grained + tests[i] = async_test("XMLHttpRequest.send(URLSearchParams) (" + i + ")"); + } + + // We use a single XHR since this test tends to time out + // with 128 consecutive fetches when run in parallel + // with many other WPT tests. + var x = new XMLHttpRequest(); + x.onload = overall_test.step_func(function() { + var response_split = x.response.split("&"); + overall_test.done(); + for (var i = 0; i < NUM_TESTS; i++) { + tests[i].step(function() { + assert_equals(response_split[i], "a" + i + "="+encode(i)); + tests[i].done(); + }); + } + }); + x.onerror = overall_test.unreached_func(); + + x.open("POST", "resources/content.py"); + var usp = new URLSearchParams(); + for (var i = 0; i < NUM_TESTS; i++) { + usp.append("a" + i, String.fromCharCode(i)); + } + x.send(usp) +} |