Auto merge of #12700 - jeenalee:jeena-requestAPI, r=jdm

Implement the Request API

<!-- Please describe your changes on the following line: -->
This PR implements the [Request API](https://fetch.spec.whatwg.org/#request-class) for the Fetch API, including its attributes and constructor, and introduces changes in relevant files.

This Request integrates `net_traits::request::Request` and `dom::headers`.

There are few related TODOs and comments:
1. `net_traits::request::Request`'s `headers` field does not point to `dom::request::Request`'s `headers_reflector`.
2. Every Constructor step that involves `Readable Stream` object is not implemented.
3. Every Constructor step that involves `entry settings object` or `environment settings object` is not implemented.
4. `./mach build -d` does not report any error, but prints a few warnings about unused variables related to (1) and (2).
5. Enum `ReferrerPolicy` generated by `RequestBinding` does not match `net_traits::request::Request`'s implementation.
6. `Promise`s in Body webidl are commented out.

---
<!-- 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
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #11895 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests  because tests for the Request API already exists, but this commit does not implement the interface fully.

<!-- 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="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12700)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-12 23:54:49 -05:00 committed by GitHub
commit 78160bf3f9
18 changed files with 1082 additions and 399 deletions

View file

@ -3,21 +3,12 @@
[Create headers from empty object]
expected: FAIL
[Create headers with sequence]
expected: FAIL
[Create headers with OpenEndedDictionary]
expected: FAIL
[Create headers with existing headers]
expected: FAIL
[Check append method]
expected: FAIL
[Check set method]
expected: FAIL
[Check has method]
expected: FAIL

View file

@ -3,12 +3,3 @@
[Create headers, names use characters with different case]
expected: FAIL
[Check append method, names use characters with different case]
expected: FAIL
[Check set method, names use characters with different case]
expected: FAIL
[Check delete method, names use characters with different case]
expected: FAIL

View file

@ -3,12 +3,6 @@
[Create headers using same name for different values]
expected: FAIL
[Check delete and has methods when using same name for different values]
expected: FAIL
[Check set methods when called with already used name]
expected: FAIL
[Check append methods when called with already used name]
expected: FAIL

View file

@ -1,8 +1,5 @@
[headers-errors.html]
type: testharness
[Headers forEach throws if argument is not callable]
expected: FAIL
[Headers forEach loop should stop if callback is throwing exception]
expected: FAIL

View file

@ -3,9 +3,3 @@
[Create headers with not normalized values]
expected: FAIL
[Check append method whith not normalized values]
expected: FAIL
[Check set method whith not normalized values]
expected: FAIL

View file

@ -1,62 +1,5 @@
[request-error.html]
type: testharness
[RequestInit's window is not null]
expected: FAIL
[Input URL is not valid]
expected: FAIL
[Input URL has credentials]
expected: FAIL
[RequestInit's mode is navigate]
expected: FAIL
[RequestInit's referrer is invalid]
expected: FAIL
[RequestInit's referrer has invalid origin]
expected: FAIL
[RequestInit's method is invalid]
expected: FAIL
[RequestInit's method is forbidden]
expected: FAIL
[RequestInit's mode is no-cors and method is not simple]
expected: FAIL
[RequestInit's mode is no-cors and integrity is not empty]
expected: FAIL
[RequestInit's cache mode is only-if-cached and mode is not same-origin]
expected: FAIL
[Request should get its content-type from the init request]
expected: FAIL
[Request should not get its content-type from the init request if init headers are provided]
expected: FAIL
[Request should get its content-type from the body if none is provided]
expected: FAIL
[Request should get its content-type from init headers if one is provided]
expected: FAIL
[Bad referrerPolicy init parameter value]
expected: FAIL
[Bad mode init parameter value]
expected: FAIL
[Bad credentials init parameter value]
expected: FAIL
[Bad cache init parameter value]
expected: FAIL
[Bad redirect init parameter value]
expected: FAIL

View file

@ -1,110 +1,5 @@
[request-headers.html]
type: testharness
[Adding valid request header "Content-Type: OK"]
expected: FAIL
[Adding valid request header "Potato: OK"]
expected: FAIL
[Adding valid request header "proxy: OK"]
expected: FAIL
[Adding valid request header "proxya: OK"]
expected: FAIL
[Adding valid request header "sec: OK"]
expected: FAIL
[Adding valid request header "secb: OK"]
expected: FAIL
[Adding invalid request header "Accept-Charset: KO"]
expected: FAIL
[Adding invalid request header "accept-charset: KO"]
expected: FAIL
[Adding invalid request header "ACCEPT-ENCODING: KO"]
expected: FAIL
[Adding invalid request header "Accept-Encoding: KO"]
expected: FAIL
[Adding invalid request header "Access-Control-Request-Headers: KO"]
expected: FAIL
[Adding invalid request header "Access-Control-Request-Method: KO"]
expected: FAIL
[Adding invalid request header "Connection: KO"]
expected: FAIL
[Adding invalid request header "Content-Length: KO"]
expected: FAIL
[Adding invalid request header "Cookie: KO"]
expected: FAIL
[Adding invalid request header "Cookie2: KO"]
expected: FAIL
[Adding invalid request header "Date: KO"]
expected: FAIL
[Adding invalid request header "DNT: KO"]
expected: FAIL
[Adding invalid request header "Expect: KO"]
expected: FAIL
[Adding invalid request header "Host: KO"]
expected: FAIL
[Adding invalid request header "Keep-Alive: KO"]
expected: FAIL
[Adding invalid request header "Origin: KO"]
expected: FAIL
[Adding invalid request header "Referer: KO"]
expected: FAIL
[Adding invalid request header "TE: KO"]
expected: FAIL
[Adding invalid request header "Trailer: KO"]
expected: FAIL
[Adding invalid request header "Transfer-Encoding: KO"]
expected: FAIL
[Adding invalid request header "Upgrade: KO"]
expected: FAIL
[Adding invalid request header "Via: KO"]
expected: FAIL
[Adding invalid request header "Proxy-: KO"]
expected: FAIL
[Adding invalid request header "proxy-a: KO"]
expected: FAIL
[Adding invalid request header "Sec-: KO"]
expected: FAIL
[Adding invalid request header "sec-b: KO"]
expected: FAIL
[Adding valid no-cors request header "Accept: OK"]
expected: FAIL
[Adding valid no-cors request header "Accept-Language: OK"]
expected: FAIL
[Adding valid no-cors request header "content-language: OK"]
expected: FAIL
[Adding valid no-cors request header "content-type: application/x-www-form-urlencoded"]
expected: FAIL
@ -123,42 +18,6 @@
[Adding valid no-cors request header "CONTENT-type: text/plain;charset=UTF-8"]
expected: FAIL
[Adding invalid no-cors request header "Content-Type: KO"]
expected: FAIL
[Adding invalid no-cors request header "Potato: KO"]
expected: FAIL
[Adding invalid no-cors request header "proxy: KO"]
expected: FAIL
[Adding invalid no-cors request header "proxya: KO"]
expected: FAIL
[Adding invalid no-cors request header "sec: KO"]
expected: FAIL
[Adding invalid no-cors request header "secb: KO"]
expected: FAIL
[Check that request constructor is filtering headers provided as init parameter]
expected: FAIL
[Check that no-cors request constructor is filtering headers provided as init parameter]
expected: FAIL
[Check that no-cors request constructor is filtering headers provided as part of request parameter]
expected: FAIL
[Request should get its content-type from the init request]
expected: FAIL
[Request should not get its content-type from the init request if init headers are provided]
expected: FAIL
[Request should get its content-type from the body if none is provided]
expected: FAIL
[Request should get its content-type from init headers if one is provided]
expected: FAIL

View file

@ -1,35 +1,5 @@
[request-init-001.sub.html]
type: testharness
[Check method init value of GET and associated getter]
expected: FAIL
[Check method init value of HEAD and associated getter]
expected: FAIL
[Check method init value of POST and associated getter]
expected: FAIL
[Check method init value of PUT and associated getter]
expected: FAIL
[Check method init value of DELETE and associated getter]
expected: FAIL
[Check method init value of OPTIONS and associated getter]
expected: FAIL
[Check method init value of head and associated getter]
expected: FAIL
[Check referrer init value of /relative/ressource and associated getter]
expected: FAIL
[Check referrer init value of http://web-platform.test:8000/relative/ressource?query=true#fragment and associated getter]
expected: FAIL
[Check referrer init value of http://web-platform.test:8000/ and associated getter]
expected: FAIL
[Check referrer init value of about:client and associated getter]
expected: FAIL
@ -39,69 +9,3 @@
[Check referrerPolicy init value of and associated getter]
expected: FAIL
[Check referrerPolicy init value of no-referrer and associated getter]
expected: FAIL
[Check referrerPolicy init value of no-referrer-when-downgrade and associated getter]
expected: FAIL
[Check referrerPolicy init value of origin and associated getter]
expected: FAIL
[Check referrerPolicy init value of origin-when-cross-origin and associated getter]
expected: FAIL
[Check referrerPolicy init value of unsafe-url and associated getter]
expected: FAIL
[Check mode init value of same-origin and associated getter]
expected: FAIL
[Check mode init value of no-cors and associated getter]
expected: FAIL
[Check mode init value of cors and associated getter]
expected: FAIL
[Check credentials init value of omit and associated getter]
expected: FAIL
[Check credentials init value of same-origin and associated getter]
expected: FAIL
[Check credentials init value of include and associated getter]
expected: FAIL
[Check cache init value of default and associated getter]
expected: FAIL
[Check cache init value of no-store and associated getter]
expected: FAIL
[Check cache init value of reload and associated getter]
expected: FAIL
[Check cache init value of no-cache and associated getter]
expected: FAIL
[Check cache init value of force-cache and associated getter]
expected: FAIL
[Check redirect init value of follow and associated getter]
expected: FAIL
[Check redirect init value of error and associated getter]
expected: FAIL
[Check redirect init value of manual and associated getter]
expected: FAIL
[Check integrity init value of and associated getter]
expected: FAIL
[Check integrity init value of AZERTYUIOP1234567890 and associated getter]
expected: FAIL
[Check window init value of null and associated getter]
expected: FAIL

View file

@ -1,3 +1,23 @@
[request-structure.html]
type: testharness
expected: TIMEOUT
[Request has arrayBuffer method]
expected: FAIL
[Request has blob method]
expected: FAIL
[Request has formData method]
expected: FAIL
[Request has json method]
expected: FAIL
[Request has text method]
expected: FAIL
[Check headers attribute]
expected: FAIL
[Check referrer attribute]
expected: FAIL

View file

@ -147,6 +147,7 @@ test_interfaces([
"ProgressEvent",
"RadioNodeList",
"Range",
"Request",
"Screen",
"Storage",
"StorageEvent",

View file

@ -89,6 +89,7 @@ test_interfaces([
"ProgressEvent",
"RadioNodeList",
"Range",
"Request",
"Screen",
"Storage",
"StorageEvent",