diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 12 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/mozilla/resources/content.py | 18 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/mozilla/send-arraybuffer.htm | 50 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/mozilla/send-blob.htm | 62 |
4 files changed, 142 insertions, 0 deletions
diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index cbfb62f8af3..deee3a3eeb2 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6120,6 +6120,18 @@ "url": "/_mozilla/mozilla/script_type.html" } ], + "mozilla/send-arraybuffer.htm": [ + { + "path": "mozilla/send-arraybuffer.htm", + "url": "/_mozilla/mozilla/send-arraybuffer.htm" + } + ], + "mozilla/send-blob.htm": [ + { + "path": "mozilla/send-blob.htm", + "url": "/_mozilla/mozilla/send-blob.htm" + } + ], "mozilla/sequence-hole.html": [ { "path": "mozilla/sequence-hole.html", diff --git a/tests/wpt/mozilla/tests/mozilla/resources/content.py b/tests/wpt/mozilla/tests/mozilla/resources/content.py new file mode 100644 index 00000000000..9369f21171c --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/resources/content.py @@ -0,0 +1,18 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + + +def main(request, response): + headers = [("Content-type", "text/plain"), + ("X-Request-Method", request.method), + ("X-Request-Query", request.url_parts.query if request.url_parts.query else "NO"), + ("X-Request-Content-Length", request.headers.get("Content-Length", "NO")), + ("X-Request-Content-Type", request.headers.get("Content-Type", "NO"))] + + if "content" in request.GET: + content = request.GET.first("content") + else: + content = request.body + + return headers, content diff --git a/tests/wpt/mozilla/tests/mozilla/send-arraybuffer.htm b/tests/wpt/mozilla/tests/mozilla/send-arraybuffer.htm new file mode 100644 index 00000000000..9b297c8f232 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/send-arraybuffer.htm @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<html> +<head> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[1]"/> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute" data-tested-assertations="following::ol[1]/li[3]"/> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute" data-tested-assertations="following::ol[1]/li[3]"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <title>XMLHttpRequest: The send() method: ArrayBuffer data</title> +</head> + +<body> + <div id="log"></div> + + <script type="text/javascript"> + var test = async_test(); + + test.step(function() + { + var xhr = new XMLHttpRequest(); + var buf = new ArrayBuffer(5); + var arr = new Uint8Array(buf); + arr[0] = 0x48; + arr[1] = 0x65; + arr[2] = 0x6c; + arr[3] = 0x6c; + arr[4] = 0x6f; + + xhr.onreadystatechange = function() + { + if (xhr.readyState == 4) + { + test.step(function() + { + var arr = xhr.response; + assert_equals(xhr.status, 200); + assert_equals(typeof arr, "string"); + assert_equals(arr, "[object ArrayBuffer]"); + + test.done(); + }); + } + }; + + xhr.open("POST", "./resources/content.py", true); + xhr.send(buf); + }); + </script> +</body> +</html> diff --git a/tests/wpt/mozilla/tests/mozilla/send-blob.htm b/tests/wpt/mozilla/tests/mozilla/send-blob.htm new file mode 100644 index 00000000000..895aae6d77b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/send-blob.htm @@ -0,0 +1,62 @@ +<!DOCTYPE html> +<html> +<head> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[2]/p[3]"/> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute" data-tested-assertations="following::ol[1]/li[3]"/> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetype-attribute" data-tested-assertations="following::ol[1]/li[4]"/> + <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute" data-tested-assertations="following::a[contains(@href,'#blob-response-entity-body')]/.."/> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <title>XMLHttpRequest: The send() method: Blob data</title> +</head> + +<body> + <div id="log"></div> + + <script type="text/javascript"> + var test = async_test(); + + test.step(function() + { + var xhr = new XMLHttpRequest(); + var xhr2 = new XMLHttpRequest(); + + var content = "Hello"; + var blob; + + xhr.onreadystatechange = function() + { + if (xhr.readyState == 4) + { + test.step(function() + { + blob = xhr.response; + assert_equals(typeof blob, "string"); + assert_true(blob == "Hello", "Blob equals Hello"); + + xhr2.open("POST", "resources/content.py", true); + xhr2.send(blob); + }); + } + } + + xhr2.onreadystatechange = function() + { + if (xhr2.readyState == 4) + { + test.step(function() + { + assert_equals(xhr2.status, 200); + assert_equals(xhr2.response, content); + test.done(); + }); + } + }; + + xhr.open("GET", "./resources/content.py?content=" + content, true); + xhr.send(); + }); + </script> +</body> +</html> |