tor-browser

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

generateTestReport.html (1596B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <title>Reporting: Generate Test Report</title>
      4 <link rel="author" title="Paul Meyer" href="paulmeyer@chromium.org">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/resources/testdriver.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <script>
     10  // Test that the "generate_test_report" API works.
     11  async_test(function(test) {
     12    var observer = new ReportingObserver(function(reports) {
     13      test.step(function() {
     14        assert_equals(reports.length, 1);
     15        // Ensure that the contents of the report are valid.
     16        assert_equals(reports[0].type, "test");
     17        assert_true(reports[0].url.endsWith("reporting/generateTestReport.html"));
     18        assert_equals(reports[0].body.message, "Test message.");
     19        // Ensure that the toJSON() call of the report are valid.
     20        const reportJSON = reports[0].toJSON();
     21        assert_equals(reports[0].type, reportJSON.type);
     22        assert_equals(reports[0].url, reportJSON.url);
     23        assert_equals(reports[0].body.message, reportJSON.body.message);
     24        // Ensure that report can be successfully JSON serialized.
     25        assert_equals(JSON.stringify(reports[0]), JSON.stringify(reportJSON));
     26      });
     27      test.done();
     28    });
     29    observer.observe();
     30 
     31    // This should result in a "test" type report being generated and observed.
     32    test_driver.generate_test_report("Test message.")
     33      .catch(test.unreached_func('generate test report failed'));
     34  }, "Generate Test Report");
     35 </script>