Bug 1192840 - fix tests to expect correct csp report content-type r?ckerschb draft
authorFrederik Braun <fbraun@mozilla.com>
Fri, 08 Apr 2016 14:14:38 +0200
changeset 348866 153438cc97f53c61d65f0d66962e5cf0b03b4521
parent 348040 68c0b7d6f16ce5bb023e08050102b5f2fe4aacd8
child 517964 1cf52304f2cbe6cdeff6d5528e0510e79803107c
push id14950
push userfbraun@mozilla.com
push dateFri, 08 Apr 2016 12:31:02 +0000
reviewersckerschb
bugs1192840
milestone48.0a1
Bug 1192840 - fix tests to expect correct csp report content-type r?ckerschb MozReview-Commit-ID: TzpGH63EPF
dom/security/test/unit/test_csp_reports.js
--- a/dom/security/test/unit/test_csp_reports.js
+++ b/dom/security/test/unit/test_csp_reports.js
@@ -28,16 +28,24 @@ const REPORT_SERVER_PATH = "/report";
 function makeReportHandler(testpath, message, expectedJSON) {
   return function(request, response) {
     // we only like "POST" submissions for reports!
     if (request.method !== "POST") {
       do_throw("violation report should be a POST request");
       return;
     }
 
+    // check content-type of report is "application/csp-report"
+    var contentType = request.hasHeader("Content-Type")
+                    ? request.getHeader("Content-Type") : undefined;
+    if (contentType !== "application/csp-report") {
+      do_throw("violation report should have the 'application/csp-report' " +
+               "content-type, when in fact it is " + contentType.toString())
+    }
+
     // obtain violation report
     var reportObj = JSON.parse(
           NetUtil.readInputStreamToString(
             request.bodyInputStream,
             request.bodyInputStream.available()));
 
     // dump("GOT REPORT:\n" + JSON.stringify(reportObj) + "\n");
     // dump("TESTPATH:    " + testpath + "\n");