File: iframe_delivering.html

package info (click to toggle)
firefox 147.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,320 kB
  • sloc: cpp: 7,607,359; javascript: 6,533,295; ansic: 3,775,223; python: 1,415,500; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (92 lines) | stat: -rw-r--r-- 2,691 bytes parent folder | download | duplicates (12)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for delivering reports</title>
</head>
<body>

<script type="application/javascript">

function ok(a, msg) {
  parent.postMessage({type: "test", check: !!a, msg }, "*");
}

function is(a, b, msg) {
  ok(a === b, msg);
}

function finish() {
  parent.postMessage({type: "finish" }, "*");
}

function checkReport() {
  return new Promise(resolve => {
    let id = setInterval(_ => {
      fetch("delivering.sjs?task=check&min=3")
      .then(r => r.text())
      .then(text => {
        if (text) {
          resolve(JSON.parse(text));
          clearInterval(id);
        }
      });
    }, 1000);
  });
}

function runTests(extraParams = "") {
  // Call a deprecating operation.
  for (let i = 0; i < 100; ++i) {
    new TestingDeprecatedInterface();
  }
  ok(true, "Created a deprecated interface");

  // Check if the report has been received.
  return checkReport()
  .then(reports => {
    ok(reports.length >= 3, "We should have received a minimum of 3 reports");

    let report = reports[0];
    is(report.contentType, "application/reports+json", "Correct mime-type");
    is(report.origin, "https://example.org", "Origin correctly set");
    is(report.url, "https://example.org/tests/dom/reporting/tests/delivering.sjs" + extraParams, "URL is correctly set");
    ok(!!report.body, "We have a report.body");
    ok(report.body.age > 0, "Age is correctly set");
    is(report.body.url, window.location.href, "URL is correctly set");
    is(report.body.user_agent, navigator.userAgent, "User-agent matches");
    ok(report.body.type, "deprecation", "Type is fine.");
    ok(!!report.body.body, "We have the real report.body");
    is(report.body.body.id, "DeprecatedTestingInterface", "Correct report.body.id");
    is(report.body.body.message, "TestingDeprecatedInterface is a testing-only interface and this is its testing deprecation message.", "We have a report.body.message");
    is(report.body.body.sourceFile, "https://example.org/tests/dom/reporting/tests/iframe_delivering.html", "report.body.sourceFile");
    is(report.body.body.lineNumber, 40, "report.body.lineNumber");
    is(report.body.body.columnNumber, 5, "report.body.columnNumber");
  });
}

// Let's register a group + endpoint
fetch("delivering.sjs?task=header")
.then(r => r.text())
.then(text => {
  is(text, "OK", "Report-to header sent");
})
.then(_ => {
  return runTests();
})

// Let's register a group + endpoint from a worker
.then(_ => {
  return new Promise(resolve => {
    let w = new Worker("worker_delivering.js");
    w.onmessage = () => resolve();
  });
})
.then(_ => {
  return runTests("&worker=true");
})

.then(finish);

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