summaryrefslogtreecommitdiffstats
path: root/testing/talos/talos/startup_test/tspaint_test.html
blob: 9561105b7b2d78b4bd434dcb28e7894b453701a7 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this file,
   - You can obtain one at http://mozilla.org/MPL/2.0/.  -->
<html>
<meta charset="utf-8">
<!-- Pick off begin time as a cgi argument and print it out -->
<!-- call this with an arg, e.g. file://foo/startup-test.html?begin=12345678 -->
<!-- In-line this to avoid compilation. -->
<script>
window.onerror = (message, source, lineno) => {
  dump(`TEST-UNEXPECTED-FAIL | tspaint_test | ${source}, line ${lineno}: ${message}\n`);
};
</script>
<script language="Javascript" type="text/javascript" src="../talos-powers/content/TalosPowersContent.js"></script>
<script language="Javascript" type="text/javascript" src="../talos-powers/content/TalosContentProfiler.js"></script>
<script language="javascript" type="text/javascript">

async function painted() {
  window.removeEventListener("MozAfterPaint", painted, true);

  await TalosPowers.loadPromise;

  await TalosContentProfiler.pause();
  await TalosContentProfiler.initFromURLQueryParams(location.search);
  await TalosContentProfiler.finishStartupProfiling();

  let startupInfo = await TalosPowersContent.getStartupInfo();

  let startupTime = startupInfo.firstPaint - startupInfo.process;

  document.body.textContent = "Startup time = " + startupTime + " ms";
  if (window.dump) {
    dump("__start_report" + startupTime + "__end_report\n\n");
  }
  dumpConsoleAndQuit();
}

function failed() {
  if (window.dump) {
    dump("BROWSER FAILED TO GENERATE MOZAFTERPAINT IN 5 SECONDS\n");
  }
  dumpConsoleAndQuit();
}

function dumpConsoleAndQuit() {
  TalosPowersContent.dumpConsole();

  // Close window asynchronously, there might still be startup operations that still need to run
  window.setTimeout(function() {
    if (window.dump) {
      dump("__startTimestamp" + window.performance.now() + "__endTimestamp\n");
    }
    TalosPowersContent.goQuitApplication();
  }, 0);
}

window.addEventListener("MozAfterPaint", painted, true);
setTimeout(failed, 5000);

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