=> {
      e.stopPropagation();
      // We count the violation reports. We expect one each for "abc" test cases, and one
      // for the "done" line at the end, which signals the end of the test run.
      if (e.sample.includes("done")) {
        resolve(count);
      } else if (e.sample.includes("abc")) {
        count++;
      } else {
        reject();
      }
    });
  }).then(counter => {
    assert_equals(counter, testCases.length, "event count");
  });
}, "Count SecurityPolicyViolation events.");

