content/base/test/file_x-frame-options_page.sjs

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/test/file_x-frame-options_page.sjs	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +// SJS file for X-Frame-Options mochitests
     1.5 +function handleRequest(request, response)
     1.6 +{
     1.7 +  var query = {};
     1.8 +  var BOUNDARY = "BOUNDARYOMG3984";
     1.9 +  request.queryString.split('&').forEach(function (val) {
    1.10 +    var [name, value] = val.split('=');
    1.11 +    query[name] = unescape(value);
    1.12 +  });
    1.13 +
    1.14 +  if (query['multipart'] == "1") {
    1.15 +    response.setHeader("Content-Type", "multipart/x-mixed-replace;boundary=" + BOUNDARY, false);
    1.16 +    response.setHeader("Cache-Control", "no-cache", false);
    1.17 +    response.setStatusLine(request.httpVersion, 200, "OK");
    1.18 +    response.write("--" + BOUNDARY + "\r\n");
    1.19 +    response.write("Content-Type: text/html\r\n\r\n");
    1.20 +  } else {
    1.21 +    response.setHeader("Content-Type", "text/html", false);
    1.22 +    response.setHeader("Cache-Control", "no-cache", false);
    1.23 +  }
    1.24 +
    1.25 +  var testHeaders = {
    1.26 +    "deny": "DENY",
    1.27 +    "sameorigin": "SAMEORIGIN",
    1.28 +    "sameorigin2": "SAMEORIGIN, SAMEORIGIN",
    1.29 +    "sameorigin3": "SAMEORIGIN,SAMEORIGIN , SAMEORIGIN",
    1.30 +    "mixedpolicy": "DENY,SAMEORIGIN",
    1.31 +
    1.32 +    /* added for bug 836132 */
    1.33 +    "afa": "ALLOW-FROM http://mochi.test:8888/",
    1.34 +    "afd": "ALLOW-FROM http://example.com/",
    1.35 +    "afa1": "ALLOW-FROM http://mochi.test:8888",
    1.36 +    "afd1": "ALLOW-FROM:example.com",
    1.37 +    "afd2": "ALLOW-FROM: example.com",
    1.38 +    "afd3": "ALLOW-FROM example.com",
    1.39 +    "afd4": "ALLOW-FROM:http://example.com",
    1.40 +    "afd5": "ALLOW-FROM: http://example.com",
    1.41 +    "afd6": "ALLOW-FROM http://example.com",
    1.42 +    "afd7": "ALLOW-FROM:mochi.test:8888",
    1.43 +    "afd8": "ALLOW-FROM: mochi.test:8888",
    1.44 +    "afd9": "ALLOW-FROM:http://mochi.test:8888",
    1.45 +    "afd10": "ALLOW-FROM: http://mochi.test:8888",
    1.46 +    "afd11": "ALLOW-FROM mochi.test:8888",
    1.47 +    "afd12": "ALLOW-FROM",
    1.48 +    "afd13": "ALLOW-FROM ",
    1.49 +    "afd14": "ALLOW-FROM:"
    1.50 +  };
    1.51 +
    1.52 +  if (testHeaders.hasOwnProperty(query['xfo'])) {
    1.53 +    response.setHeader("X-Frame-Options", testHeaders[query['xfo']], false);
    1.54 +  }
    1.55 +
    1.56 +  // from the test harness we'll be checking for the presence of this element
    1.57 +  // to test if the page loaded
    1.58 +  response.write("<h1 id=\"test\">" + query["testid"] + "</h1>");
    1.59 +
    1.60 +  if (query['multipart'] == "1") {
    1.61 +    response.write("\r\n--" + BOUNDARY + "\r\n");
    1.62 +  }
    1.63 +}

mercurial