1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
5 // Checks that document-builder.sjs works as expected
6 add_task(async function assertHtmlParam() {
7 const html = "<main><h1>I'm built different</h1></main>";
10 const params = new URLSearchParams({
14 params.append("headers", "x-header-1:a");
15 params.append("headers", "x-header-2:b");
17 const startTime = performance.now();
18 const request = new Request(
19 `https://example.com/document-builder.sjs?${params}`
21 info("Do a fetch request to document-builder.sjs");
22 const response = await fetch(request);
23 const duration = performance.now() - startTime;
25 is(response.status, 200, "Response is a 200");
28 `The delay parameter works as expected (took ${duration}ms)`
31 const responseText = await response.text();
32 is(responseText, html, "The response has the expected content");
35 response.headers.get("content-type"),
37 "response has the expected content-type"
40 response.headers.get("x-header-1"),
42 "first header was set as expected"
45 response.headers.get("x-header-2"),
47 "second header was set as expected"
51 add_task(async function assertFileParam() {
52 const file = `browser/testing/mochitest/tests/browser/dummy.html`;
53 const request = new Request(
54 `https://example.com/document-builder.sjs?file=${file}`
57 info("Do a fetch request to document-builder.sjs with a `file` parameter");
58 const response = await fetch(request);
59 is(response.status, 200, "Response is a 200");
61 response.headers.get("content-type"),
63 "response has the expected content-type"
66 const responseText = await response.text();
67 const parser = new DOMParser();
68 const doc = parser.parseFromString(responseText, "text/html");
70 doc.body.innerHTML.trim(),
71 "This is a dummy page",
72 "The response has the file content"