1 <!-- Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ -->
7 <meta charset=
"utf-8"/>
8 <meta http-equiv=
"Cache-Control" content=
"no-cache, no-store, must-revalidate" />
9 <meta http-equiv=
"Pragma" content=
"no-cache" />
10 <meta http-equiv=
"Expires" content=
"0" />
11 <title>Network Monitor test page
</title>
15 <p>Request params type test
</p>
17 <script type=
"text/javascript">
18 /* exported performRequests */
21 async
function get(address
, query
) {
22 return new Promise(resolve
=> {
23 const xhr
= new XMLHttpRequest();
24 xhr
.open("GET", address
+ query
, true);
25 xhr
.onreadystatechange = function() {
26 if (this.readyState
== this.DONE
) {
34 async
function request(address
, query
, contentType
, requestBody
, method
) {
35 return new Promise(resolve
=> {
36 const xhr
= new XMLHttpRequest();
37 xhr
.open(method
, address
+ query
, true);
38 xhr
.setRequestHeader("content-type", contentType
);
39 xhr
.onreadystatechange = function() {
40 if (this.readyState
== this.DONE
) {
44 xhr
.send(requestBody
);
48 async
function post(address
, query
, contentType
, postBody
) {
49 return request(address
, query
, contentType
, postBody
, "POST");
52 async
function patch(address
, query
, contentType
, patchBody
) {
53 return request(address
, query
, contentType
, patchBody
, "PATCH");
56 async
function put(address
, query
, contentType
, putBody
) {
57 return request(address
, query
, contentType
, putBody
, "PUT");
60 async
function performRequests() {
61 const urlencoded
= "application/x-www-form-urlencoded";
62 await
post("baz", "?a", urlencoded
, '{ "foo": "bar" }');
63 await
post("baz", "?a=b", urlencoded
, '{ "foo": "bar" }');
64 await
post("baz", "?a=b", urlencoded
, "?foo=bar=123=xyz");
65 await
post("baz", "?a", undefined, '{ "foo": "bar" }');
66 await
post("baz", "?a=b", undefined, '{ "foo": "bar" }');
67 await
post("baz", "?a=b", undefined, "?foo=bar");
69 await
patch("baz", "?a=b", urlencoded
, '{ "foo": "bar" }');
70 await
put("baz", "?a=b", urlencoded
, '{ "foo": "bar" }');
71 await
get("baz", "?species=in=(52,60)");
72 await
get("baz", "?a=&a=b");
73 await
get("baz", "?a=b&a=c&d=1");