Auto merge of #11556 - Manishearth:make-fetch-happen, r=jdm

Make fetch happen

<!-- Please describe your changes on the following line: -->
Moves XHR over to the fetch backend.

Previous PR: https://github.com/servo/servo/pull/114

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors (Will fix later)

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11556)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-11 19:30:28 -05:00 committed by GitHub
commit 0c11e8340b
33 changed files with 861 additions and 1085 deletions

View file

@ -1,5 +0,0 @@
[send-authentication-basic-setrequestheader-existing-session.htm]
type: testharness
[XMLHttpRequest: send() - "Basic" authenticated request using setRequestHeader() when there is an existing session]
expected: FAIL

View file

@ -1,5 +0,0 @@
[send-authentication-basic.htm]
type: testharness
[XMLHttpRequest: send() - "Basic" authenticated requests with user name and password passed to open()]
expected: FAIL

View file

@ -0,0 +1,8 @@
[send-conditional.htm]
type: testharness
[XMLHttpRequest: send() - conditional requests (tag)]
expected: FAIL
[XMLHttpRequest: send() - conditional requests (date)]
expected: FAIL

View file

@ -15,9 +15,12 @@
[charset given but wrong, fix it (known MIME, bogus charset)]
expected: FAIL
[charset given but wrong, fix it (known MIME, actual charset)]
expected: FAIL
[If multiple charset parameters are given, all should be rewritten]
expected: FAIL
[Correct text/plain MIME with charset]
expected: FAIL
[charset given but wrong, fix it (known MIME, actual charset)]
expected: FAIL

View file

@ -1,5 +0,0 @@
[send-entity-body-get-head.htm]
type: testharness
[XMLHttpRequest: send() - non-empty data argument and GET/HEAD (HEAD)]
expected: FAIL

View file

@ -0,0 +1,14 @@
[send-redirect-to-cors.htm]
type: testharness
[XMLHttpRequest: send() - Redirect to CORS-enabled resource (301)]
expected: FAIL
[XMLHttpRequest: send() - Redirect to CORS-enabled resource (302)]
expected: FAIL
[XMLHttpRequest: send() - Redirect to CORS-enabled resource (303)]
expected: FAIL
[XMLHttpRequest: send() - Redirect to CORS-enabled resource (307)]
expected: FAIL

View file

@ -1,14 +0,0 @@
[send-redirect-to-non-cors.htm]
type: testharness
[XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (301)]
expected: FAIL
[XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (302)]
expected: FAIL
[XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (303)]
expected: FAIL
[XMLHttpRequest: send() - Redirect to cross-origin resource, not CORS-enabled (307)]
expected: FAIL

View file

@ -33,6 +33,3 @@
[Allow origin: [tab\]http://web-platform.test:8000]
expected: FAIL
[Disallow origin: http://web-platform.test:8000/]
expected: FAIL

View file

@ -33,12 +33,3 @@
[Allow origin: [tab\]http://web-platform.test:8000]
expected: FAIL
[Disallow origin: http://web-platform.test:8000/]
expected: FAIL
[Disallow multiple headers (, *)]
expected: FAIL
[Disallow multiple headers (*, )]
expected: FAIL

View file

@ -1,17 +1,8 @@
[preflight-cache.htm]
type: testharness
[Test preflight]
expected: FAIL
[preflight for x-print should be cached]
expected: FAIL
[age = 0, should not be cached]
expected: FAIL
[age = -1, should not be cached]
expected: FAIL
[preflight first request, second from cache, wait, third should preflight again]
expected: FAIL

View file

@ -62,24 +62,12 @@
[local (*) to remote (http://web-platform.test:8000), expect origin=http://web-platform.test:8000]
expected: FAIL
[local (*) to remote (null), expect to fail]
expected: FAIL
[local (*) to remote (none), expect to fail]
expected: FAIL
[local (http://web-platform.test:8000) to remote (*), expect origin=http://web-platform.test:8000]
expected: FAIL
[local (http://web-platform.test:8000) to remote (http://web-platform.test:8000), expect origin=http://web-platform.test:8000]
expected: FAIL
[local (http://web-platform.test:8000) to remote (null), expect to fail]
expected: FAIL
[local (http://web-platform.test:8000) to remote (none), expect to fail]
expected: FAIL
[local (null) to remote (*), expect origin=http://web-platform.test:8000]
expected: FAIL
@ -110,27 +98,3 @@
[remote (http://web-platform.test:8000) to remote2 (null), expect origin=null]
expected: FAIL
[remote (http://www1.web-platform.test:8000) to remote (*), expect to fail]
expected: FAIL
[remote (null) to remote2 (*), expect to fail]
expected: FAIL
[remote (none) to remote2 (*), expect to fail]
expected: FAIL
[remote (none) to remote2 (*), expect to fail]
expected: FAIL
[remote (null) to remote (*), expect to fail]
expected: FAIL
[remote (none) to remote (*), expect to fail]
expected: FAIL
[remote (none) to local (*), expect to fail]
expected: FAIL
[remote (null) to local (*), expect to fail]
expected: FAIL

View file

@ -1,8 +0,0 @@
[redirect-preflight-2.htm]
type: testharness
[Same-origin custom-header request, redirect to cross-origin succeeds after doing a preflight]
expected: FAIL
[Same-origin custom-header request, redirect to cross-origin fails after doing a non-successful preflight]
expected: FAIL

View file

@ -9,6 +9,3 @@
[getResponse: don't expose x-nonexposed]
expected: FAIL
[getAllResponseHeaders: don't expose x-nonexposed]
expected: FAIL

View file

@ -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)
}