B2G/gecko/content/base/test/file_csp_redirects_page.sjs
// This file serves pages which can optionally specify a Content Security Policy
This file serves pages which can optionally specify a Content Security Policy
This file serves pages which can optionally specify a Content Security Policy
function handleRequest(request, response)
{
  var query = {};
  request.queryString.split('&').forEach(function (val) {
    var [name, value] = val.split('=');
    query[name] = unescape(value);
  });
  response.setHeader("Cache-Control", "no-cache", false);
  response.setHeader("Content-Type", "text/html", false);
  var resource = "/tests/content/base/test/file_csp_redirects_resource.sjs";
  if (query["csp"] == 1) {
    response.setHeader("X-Content-Security-Policy", "allow 'self'", false);
  }
  if (query["testid"] == "font-src") {
    var resp = '<style type="text/css"> @font-face { font-family:' +
               '"Redirecting Font"; src: url("' + resource +
               '?res=font&redir=other&id=font-src-redir")} #test{font-family:' +
               '"Redirecting Font"}</style></head><body>' +
               '<div id="test">test</div></body>';
    response.write(resp);
    return;
  }
  if (query["testid"] == "frame-src") {
    response.write('<iframe src="'+resource+'?res=iframe&redir=other&id=frame-src-redir"></iframe>');
    return;
  }
  if (query["testid"] == "img-src") {
    response.write('<img src="'+resource+'?res=image&redir=other&id=img-src-redir" />');
    return;
  }
  if (query["testid"] == "media-src") {
    response.write('<video src="'+resource+'?res=media&redir=other&id=media-src-redir"></video>');
    return;
  }
  if (query["testid"] == "object-src") {
    response.write('<object type="text/html" data="'+resource+'?res=object&redir=other&id=object-src-redir"></object>');
    return;
  }
  if (query["testid"] == "script-src") {
    response.write('<script src="'+resource+'?res=script&redir=other&id=script-src-redir"></script>');
    return;
  }
  if (query["testid"] == "style-src") {
    response.write('<link rel="stylesheet" type="text/css" href="'+resource+'?res=style&redir=other&id=style-src-redir"></script>');
    return;
  }
  if (query["testid"] == "worker") {
    response.write('<script src="'+resource+'?res=worker&redir=other&id=worker-redir"></script>');
    return;
  }
  if (query["testid"] == "xhr-src") {
    response.write('<script src="'+resource+'?res=xhr"></script>');
    return;
  }
}
function handleRequest ( request , response ) { var query = { } ; request . queryString . split ( '&' ) . forEach ( function ( val ) { var [ name , value ] = val . split ( '=' ) ; query [ name ] = unescape ( value ) ; } ) ; response . setHeader ( "Cache-Control" , "no-cache" , false ) ; response . setHeader ( "Content-Type" , "text/html" , false ) ; var resource = "/tests/content/base/test/file_csp_redirects_resource.sjs" ; if ( query [ "csp" ] == 1 ) { response . setHeader ( "X-Content-Security-Policy" , "allow 'self'" , false ) ; } if ( query [ "testid" ] == "font-src" ) { var resp = '<style type="text/css"> @font-face { font-family:' + '"Redirecting Font"; src: url("' + resource + '?res=font&redir=other&id=font-src-redir")} #test{font-family:' + '"Redirecting Font"}</style></head><body>' + '<div id="test">test</div></body>' ; response . write ( resp ) ; return ; } if ( query [ "testid" ] == "frame-src" ) { response . write ( '<iframe src="' + resource + '?res=iframe&redir=other&id=frame-src-redir"></iframe>' ) ; return ; } if ( query [ "testid" ] == "img-src" ) { response . write ( '<img src="' + resource + '?res=image&redir=other&id=img-src-redir" />' ) ; return ; } if ( query [ "testid" ] == "media-src" ) { response . write ( '<video src="' + resource + '?res=media&redir=other&id=media-src-redir"></video>' ) ; return ; } if ( query [ "testid" ] == "object-src" ) { response . write ( '<object type="text/html" data="' + resource + '?res=object&redir=other&id=object-src-redir"></object>' ) ; return ; } if ( query [ "testid" ] == "script-src" ) { response . write ( '<script src="' + resource + '?res=script&redir=other&id=script-src-redir"></script>' ) ; return ; } if ( query [ "testid" ] == "style-src" ) { response . write ( '<link rel="stylesheet" type="text/css" href="' + resource + '?res=style&redir=other&id=style-src-redir"></script>' ) ; return ; } if ( query [ "testid" ] == "worker" ) { response . write ( '<script src="' + resource + '?res=worker&redir=other&id=worker-redir"></script>' ) ; return ; } if ( query [ "testid" ] == "xhr-src" ) { response . write ( '<script src="' + resource + '?res=xhr"></script>' ) ; return ; } }
This file serves pages which can optionally specify a Content Security Policy
This file serves pages which can optionally specify a Content Security Policy
// CSP header value // downloadable font that redirects to another site // iframe that redirects to another site // image that redirects to another site // video content that redirects to another site // object content that redirects to another site // external script that redirects to another site // external stylesheet that redirects to another site // worker script resource that redirects to another site // script that XHR's to a resource that redirects to another site