talos/startup_test/tresize-test.html
author Joel Maher <jmaher@mozilla.com>
Tue, 04 Feb 2014 11:40:27 -0500
changeset 736 79702830f03dc0aa5b0aa8357d2dccae1e924a1a
parent 672 bf91b5b2a434fa94a58018e3381fa7ac4708ecca
child 752 b4907f0b27d37cc4eb1d9f9811070b03451ff5bf
permissions -rw-r--r--
Bug 966133 - Intermittent talosError: Timeout (20/20) exceeded on http://localhost/page_load_test/tp5n/* [browser_output.txt. r=dminor

<!-- 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>
<script language="Javascript" type="text/javascript" src="../scripts/MozillaFileLogger.js"></script>
<script language="JavaScript" type="text/javascript" src="../page_load_test/quit.js"></script>
<script language="javascript" type="text/javascript">

/*
 * tresize-test - A purer form of paint measurement than tpaint. This
 * test opens a single window positioned at 10,10 and sized to 425,425,
 * then resizes the window outward |max| times measuring the amount of
 * time it takes to repaint each resize. Dumps the resulting dataset
 * and average to stdout or logfile.
 */ 

var dataSet = new Array();
var dims = 425;
var increment = 2;
var count = 0;
var max = 300;

var dumpDataSet = false;
var closeOnFinished = true;

function painted() {
  window.removeEventListener("MozAfterPaint", painted, true);
  var paintTime = window.performance.now();
  dataSet[count].end = paintTime;
  setTimeout(resizeCompleted, 20);
}

function resizeTest() {
  try {
    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
    dims += increment;
    var startTime = window.performance.now();
    dataSet[count] = {};
    dataSet[count].start = startTime;
    window.addEventListener("MozAfterPaint", painted, true);
    window.resizeTo(dims,dims);
  } catch(ex) { dump(ex + '\n'); }
}

function testCompleted() {
  try {
    var total = 0;
    diffs = [];
    for (var idx = 0; idx < count; idx++) {
      var diff = dataSet[idx].end - dataSet[idx].start;
      total += diff;
      diffs.push(diff);
    }
    var average = (total/count);
    if (dumpDataSet) {
      dumpLog('__start_reporttresize-test.html,' + diffs + '__end_report\n');
    } else {
      dumpLog('__start_report' + average + '__end_report\n');
    }
    dumpLog('__startTimestamp' + Date.now() + '__endTimestamp\n');

    if (closeOnFinished) {
      window.setTimeout(function() {
        if (goQuitApplication != null)
          goQuitApplication();
        if (closeOnFinished)
          window.close();
      }, 0);
    }
  } catch(ex) { dump(ex + '\n'); }
}

function resizeCompleted() {
  count++;
  if (count >= max) {
    testCompleted();
  } else {
    resizeTest();
  }
}

try {
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  window.moveTo(10,10);
  window.resizeTo(dims,dims);
  resizeTest();
} catch(ex) { dump(ex + '\n'); }

</script>
<body id="body">
<div style="text-align:center; margin-left:auto; margin-right:auto; background-color:Silver; width:100px; height:100%;">RESIZE</div>
</body>
</html>