Bug 1924993 - [devtools] Debugger tests wait before typing in conditional panel r...
[gecko.git] / devtools / client / netmonitor / test / html_params-test-page.html
blob3d657a5e87e6d801ca6105339ee1323c43ef5ca1
1 <!-- Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ -->
3 <!doctype html>
5 <html>
6 <head>
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>
12 </head>
14 <body>
15 <p>Request params type test</p>
17 <script type="text/javascript">
18 /* exported performRequests */
19 "use strict";
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) {
27 resolve();
30 xhr.send();
31 });
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) {
41 resolve();
44 xhr.send(requestBody);
45 });
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");
68 await get("baz", "");
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");
75 </script>
76 </body>
78 </html>