Bug 1719855 - Take over preventDefaulted infomation for long-tap events to the origin...
[gecko.git] / dom / performance / tests / serverTiming.sjs
blob8a93829fa544791e2d72059260bc2f5756198c25
1 var responseServerTiming = [
2   { metric: "metric1", duration: "123.4", description: "description1" },
3   { metric: "metric2", duration: "456.78", description: "description2" },
4 ];
5 var trailerServerTiming = [
6   { metric: "metric3", duration: "789.11", description: "description3" },
7   { metric: "metric4", duration: "1112.13", description: "description4" },
8 ];
10 function createServerTimingHeader(headerData) {
11   var header = "";
12   for (var i = 0; i < headerData.length; i++) {
13     header +=
14       "Server-Timing:" +
15       headerData[i].metric +
16       ";" +
17       "dur=" +
18       headerData[i].duration +
19       ";" +
20       "desc=" +
21       headerData[i].description +
22       "\r\n";
23   }
24   return header;
27 function handleRequest(request, response) {
28   var body = "c\r\ndata reached\r\n3\r\nhej\r\n0\r\n";
30   response.seizePower();
31   response.write("HTTP/1.1 200 OK\r\n");
32   response.write("Content-Type: text/plain\r\n");
33   response.write(createServerTimingHeader(responseServerTiming));
35   response.write("Transfer-Encoding: chunked\r\n");
36   response.write("\r\n");
37   response.write(body);
38   response.write(createServerTimingHeader(trailerServerTiming));
39   response.write("\r\n");
40   response.finish();