tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

feature-policy-report-json.js (935B)


      1 /**
      2 * @fileoverview functions for ensuring feature policy report is serializable
      3 */
      4 
      5 const check_report_json = (report) => {
      6  // Ensures toJSON method exists on report.
      7  assert_equals(typeof report.toJSON, "function");
      8  const report_json = report.toJSON();
      9  // Ensures toJSON() call is successful.
     10  assert_equals(report.type, report_json.type);
     11  assert_equals(report.url, report_json.url);
     12  assert_equals(report.body.featureId, report_json.body.featureId);
     13  assert_equals(report.body.disposition, report_json.body.disposition);
     14  assert_equals(report.body.sourceFile, report_json.body.sourceFile);
     15  assert_equals(report.body.lineNumber, report_json.body.lineNumber);
     16  assert_equals(report.body.columnNumber, report_json.body.columnNumber);
     17  // Ensures JSON.stringify() serializes the report correctly.
     18  assert_false(JSON.stringify(report) === "{}");
     19  assert_equals(JSON.stringify(report), JSON.stringify(report_json));
     20 }