summaryrefslogtreecommitdiffstats
path: root/dom/security/test/general/file_nosniff_navigation.sjs
diff options
context:
space:
mode:
Diffstat (limited to 'dom/security/test/general/file_nosniff_navigation.sjs')
-rw-r--r--dom/security/test/general/file_nosniff_navigation.sjs32
1 files changed, 32 insertions, 0 deletions
diff --git a/dom/security/test/general/file_nosniff_navigation.sjs b/dom/security/test/general/file_nosniff_navigation.sjs
new file mode 100644
index 0000000000..8d1de13828
--- /dev/null
+++ b/dom/security/test/general/file_nosniff_navigation.sjs
@@ -0,0 +1,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;
+}
+