summaryrefslogtreecommitdiffstats
path: root/dom/security/test/general/file_nosniff_navigation.sjs
blob: 8d1de13828b618132032759390be810401e96b69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Custom *.sjs file specifically for the needs of Bug 1286861

// small red image
const IMG = atob(
  "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12" +
  "P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");

function getSniffableContent(selector){
  switch(selector){
  case "xml":
    return `<?xml version="1.0"?><test/>`;
  case "html":
    return `<!Doctype html> <html> <head></head> <body> Test test </body></html>`;
  case "css":
    return `*{ color: pink !important; }`;
  case 'json':
      return `{ 'test':'yes' }`;
  case 'img':
      return IMG;
  }
  return "Basic UTF-8 Text";
}

function handleRequest(request, response)
{
  // avoid confusing cache behaviors
  response.setHeader('X-Content-Type-Options', 'nosniff'); // Disable Sniffing
  response.setHeader("Content-Type","*/*");  // Try Browser to force sniffing. 
  response.write(getSniffableContent(request.queryString));
  return;
}