--- a/devtools/client/netmonitor/test/html_params-test-page.html
+++ b/devtools/client/netmonitor/test/html_params-test-page.html
@@ -13,60 +13,49 @@
<body>
<p>Request params type test</p>
<script type="text/javascript">
/* exported performRequests */
"use strict";
- function get(address, query) {
- const xhr = new XMLHttpRequest();
- xhr.open("GET", address + query, true);
- xhr.send();
- }
-
- function post(address, query, contentType, postBody) {
- const xhr = new XMLHttpRequest();
- xhr.open("POST", address + query, true);
- xhr.setRequestHeader("content-type", contentType);
- xhr.send(postBody);
+ async function get(address, query) {
+ return new Promise(resolve => {
+ const xhr = new XMLHttpRequest();
+ xhr.open("GET", address + query, true);
+ xhr.onreadystatechange = function() {
+ if (this.readyState == this.DONE) {
+ resolve();
+ }
+ };
+ xhr.send();
+ });
}
- function performRequests() {
- const urlencoded = "application/x-www-form-urlencoded";
-
- /* eslint-disable max-nested-callbacks */
- setTimeout(function() {
- post("baz", "?a", urlencoded, '{ "foo": "bar" }');
-
- setTimeout(function() {
- post("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
-
- setTimeout(function() {
- post("baz", "?a=b", urlencoded, "?foo=bar");
-
- setTimeout(function() {
- post("baz", "?a", undefined, '{ "foo": "bar" }');
+ async function post(address, query, contentType, postBody) {
+ return new Promise(resolve => {
+ const xhr = new XMLHttpRequest();
+ xhr.open("POST", address + query, true);
+ xhr.setRequestHeader("content-type", contentType);
+ xhr.onreadystatechange = function() {
+ if (this.readyState == this.DONE) {
+ resolve();
+ }
+ };
+ xhr.send(postBody);
+ });
+ }
- setTimeout(function() {
- post("baz", "?a=b", undefined, '{ "foo": "bar" }');
-
- setTimeout(function() {
- post("baz", "?a=b", undefined, "?foo=bar");
-
- setTimeout(function() {
- get("baz", "");
-
- // Done.
- }, 10);
- }, 10);
- }, 10);
- }, 10);
- }, 10);
- }, 10);
- }, 10);
- /* eslint-enable max-nested-callbacks */
+ async function performRequests() {
+ const urlencoded = "application/x-www-form-urlencoded";
+ await post("baz", "?a", urlencoded, '{ "foo": "bar" }');
+ await post("baz", "?a=b", urlencoded, '{ "foo": "bar" }');
+ await post("baz", "?a=b", urlencoded, "?foo=bar");
+ await post("baz", "?a", undefined, '{ "foo": "bar" }');
+ await post("baz", "?a=b", undefined, '{ "foo": "bar" }');
+ await post("baz", "?a=b", undefined, "?foo=bar");
+ await get("baz", "");
}
</script>
</body>
</html>