diff --git a/test/font/fontutils.js b/test/font/fontutils.js index e3af860bf..72938203e 100644 --- a/test/font/fontutils.js +++ b/test/font/fontutils.js @@ -65,26 +65,16 @@ function encodeFontData(data) { return buffer; } -function ttx(data) { - return new Promise((resolve, reject) => { - const xhr = new XMLHttpRequest(); - xhr.open("POST", "/ttx"); - - const encodedData = encodeFontData(data); - xhr.setRequestHeader("Content-type", "text/plain"); - xhr.setRequestHeader("Content-length", encodedData.length); - - xhr.onreadystatechange = function getPdfOnreadystatechange(e) { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - resolve(xhr.responseText); - } else { - reject(new Error(xhr.statusText)); - } - } - }; - xhr.send(encodedData); +async function ttx(data) { + const response = await fetch("/ttx", { + method: "POST", + body: encodeFontData(data), }); + + if (!response.ok) { + throw new Error(response.statusText); + } + return response.text(); } function verifyTtxOutput(output) {