summaryrefslogtreecommitdiffstats
path: root/testing/talos/talos/tests/a11y/dhtml.html
blob: ebd11b72c3d1b0e63112501a57e22000fb27f079 (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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<meta charset="utf-8">
<head>
<title>accessibility perf for dhtml</title>
<script src="resource://talos-powers/TalosContentProfiler.js"></script>
<script>
  /* globals initAccessibility */
  // based on: http://hacks.mozilla.org/2010/05/better-performance-with-lazy-frame-construction/
  var ppDate = null;
  var startTime;

  function doInsertion() {
    if (!initAccessibility()) {
      dump("__FAILinit:AccessibilityUnvailable__FAIL");
      return;
    }

    TalosContentProfiler.resume("a11y: Begin dhtml test", true).then(() => {
      var container = document.getElementById("container");
      var lastchild = document.getElementById("lastchild");

      startTime = window.performance.now();

      var i, div;
      for (i = 0; i < 2000; i++) {
        div = document.createElement("div");
        div.innerHTML = "<input type='text' value='a bc def g hijkl mn op qrs'/>";
        container.insertBefore(div, lastchild);
      }
      for (i = 0; i < 2000; i++) {
        div = document.createElement("div");
        div.innerHTML = "<ul><li>foo<ul><li>bar</li></ul></li><li>baz</li></ul>";
        container.insertBefore(div, lastchild);
      }
      for (i = 0; i < 2000; i++) {
        div = document.createElement("div");

        // eslint-disable-next-line no-unsanitized/property
        div.innerHTML = "<div role='progressbar'>progressbar</div>" +
                        "<span id='span" + i + "'>cb</span>";
        container.appendChild(div);
      }
      document.documentElement.offsetLeft; // flush layout
      setTimeout(postProcessingRecord, 0, startTime);
    });
  }

  function postProcessingRecord(start) {
    let delta = window.performance.now() - start;
    TalosContentProfiler.pause("a11y: dhtml test", true, startTime).then(() => {
      tpRecordTime(delta, window.performance.timing.navigationStart + start);
    });
  }
</script>
</head>
<body onload="doInsertion();">
  <div id="container" role="application"><div id="lastchild"></div></div>
</body>
</html>