aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-06-10 15:34:05 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-06-10 20:55:32 +0530
commit8b9479f8bf13efa0cc174a84e1775c4926278cef (patch)
treecf4bff83b0ddd7896cf1dea95ad8e2f00cd9bcbc
parentfd6f9bd4110e9fa725a257148d537fa6f0392a61 (diff)
downloadservo-8b9479f8bf13efa0cc174a84e1775c4926278cef.tar.gz
servo-8b9479f8bf13efa0cc174a84e1775c4926278cef.zip
Make send-usp tests less timeout-prone
-rw-r--r--tests/wpt/web-platform-tests/XMLHttpRequest/send-usp.js49
1 files changed, 29 insertions, 20 deletions
diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/send-usp.js b/tests/wpt/web-platform-tests/XMLHttpRequest/send-usp.js
index 56e9e09640f..c00b2e0e0ca 100644
--- a/tests/wpt/web-platform-tests/XMLHttpRequest/send-usp.js
+++ b/tests/wpt/web-platform-tests/XMLHttpRequest/send-usp.js
@@ -1,3 +1,5 @@
+const NUM_TESTS = 128;
+
function encode(n) {
if (n === 0x20) {
return "\x2B";
@@ -13,27 +15,34 @@ function encode(n) {
return "%" + (s.length === 2 ? s : '0' + s);
}
-function do_test(n) {
- async_test(function() {
- var x = new XMLHttpRequest();
- x.onload = this.step_func_done(function(e) {
- assert_equals(x.response, "a=" + encode(n))
- });
- x.onerror = this.unreached_func();
- x.open("POST", "resources/content.py");
- var usp = new URLSearchParams();
- usp.append("a", String.fromCharCode(n));
- x.send(usp)
- }, "XMLHttpRequest.send(URLSearchParams) (" + n + ")");
-}
-
function run_test() {
- var i = 0;
- add_result_callback(function() {
- if (++i === 128) {
- return;
+ 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();
+ });
}
- do_test(i);
});
- do_test(i);
+ 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)
}