summaryrefslogtreecommitdiffstats
path: root/dom/reporting/tests/test_delivering.html
blob: 2c552273e0ef245f5b2d2cd0c8bcf49271307b98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for delivering reports</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>

<script type="application/javascript">

// Setting prefs.
SpecialPowers.pushPrefEnv({ set: [
  ["dom_reporting_delivering_timeout", 1],
  ["dom_reporting_delivering_maxFailures", 2],
  ["dom.reporting.delivering.maxReports", 3],
]})

// Tests run in iframes because the origin must be secure for report-to header.
.then(_ => {
  window.addEventListener("message", e => {
    if (e.data.type == "finish") {
      SimpleTest.finish();
      return;
    }

    if (e.data.type == "test") {
      ok(e.data.check, e.data.msg);
      return;
    }

    ok(false, "Invalid message");
  });

  let ifr = document.createElement("iframe");
  ifr.src = "https://example.org/tests/dom/reporting/tests/iframe_delivering.html";

  document.body.appendChild(ifr);
});

SimpleTest.waitForExplicitFinish();

</script>
</body>
</html>