servo: Merge #20434 - Typed array support for XMLHttpRequest's send API (from nupurbaghel:typed-array-xml); r=jdm

<!-- Please describe your changes on the following line: -->

---
<!-- 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 #20343

<!-- Either: -->
- [x] Updated some tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

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

Source-Repo: https://github.com/servo/servo
Source-Revision: 0c148809c1528a969f80f205dce570a5db606374

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : e3dc749e3f9aa4e03199e86564b6d9b63457a753
This commit is contained in:
Nupur Baghel 2018-03-29 02:02:37 -04:00
parent 50d1673187
commit fff9aa307c
2 changed files with 5 additions and 1 deletions

View File

@ -13,7 +13,7 @@
*/
// https://fetch.spec.whatwg.org/#bodyinit
typedef (Blob or /*BufferSource or */ FormData or DOMString or URLSearchParams) BodyInit;
typedef (Blob or BufferSource or FormData or DOMString or URLSearchParams) BodyInit;
enum XMLHttpRequestResponseType {
"",

View File

@ -520,6 +520,8 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
Some(DocumentOrBodyInit::FormData(ref formdata)) => Some(formdata.extract()),
Some(DocumentOrBodyInit::String(ref str)) => Some(str.extract()),
Some(DocumentOrBodyInit::URLSearchParams(ref urlsp)) => Some(urlsp.extract()),
Some(DocumentOrBodyInit::ArrayBuffer(ref typedarray)) => Some((typedarray.to_vec(), None)),
Some(DocumentOrBodyInit::ArrayBufferView(ref typedarray)) => Some((typedarray.to_vec(), None)),
None => None,
};
@ -1441,6 +1443,8 @@ impl Extractable for BodyInit {
BodyInit::URLSearchParams(ref usp) => usp.extract(),
BodyInit::Blob(ref b) => b.extract(),
BodyInit::FormData(ref formdata) => formdata.extract(),
BodyInit::ArrayBuffer(ref typedarray) => ((typedarray.to_vec(), None)),
BodyInit::ArrayBufferView(ref typedarray) => ((typedarray.to_vec(), None)),
}
}
}