2010-05-27 16:12:32 +00:00
|
|
|
// SJS file for CSP violation report test
|
2014-02-18 14:47:53 +00:00
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=548193
|
2010-05-27 16:12:32 +00:00
|
|
|
function handleRequest(request, response)
|
|
|
|
{
|
|
|
|
var query = {};
|
|
|
|
request.queryString.split('&').forEach(function (val) {
|
|
|
|
var [name, value] = val.split('=');
|
|
|
|
query[name] = unescape(value);
|
|
|
|
});
|
|
|
|
|
|
|
|
response.setHeader("Content-Type", "text/html", false);
|
|
|
|
|
|
|
|
// avoid confusing cache behaviors
|
|
|
|
response.setHeader("Cache-Control", "no-cache", false);
|
|
|
|
|
|
|
|
// set CSP header
|
2014-06-09 21:26:09 +00:00
|
|
|
response.setHeader("Content-Security-Policy",
|
|
|
|
"default-src 'self'; report-uri http://mochi.test:8888/csp-report.cgi",
|
2010-05-27 16:12:32 +00:00
|
|
|
false);
|
|
|
|
|
|
|
|
// content which will trigger a violation report
|
|
|
|
response.write('<html><body>');
|
|
|
|
response.write('<img src="http://example.org/tests/content/base/test/file_CSP.sjs?testid=img_bad&type=img/png"> </img>');
|
|
|
|
response.write('</body></html>');
|
|
|
|
}
|