Bump jQuery to same version that dromaeo.com uses.
[WebKit-https.git] / PerformanceTests / Dromaeo / resources / dromaeorunner.js
1 (function(){
2      var ITERATION_COUNT = 5;
3      var DRT  = {
4          baseURL: "./resources/dromaeo/web/index.html",
5
6          setup: function(testName) {
7              var iframe = document.createElement("iframe");
8              var url = DRT.baseURL + "?" + testName + '&numTests=' + ITERATION_COUNT;
9              iframe.setAttribute("src", url);
10              document.body.insertBefore(iframe, document.body.firstChild);
11              iframe.addEventListener(
12                  "load", function() {
13                      DRT.targetDocument = iframe.contentDocument;
14                      DRT.targetWindow = iframe.contentDocument.defaultView;
15                  });
16
17              window.addEventListener(
18                  "message",
19                  function(event) {
20                      switch(event.data.name) {
21                      case "dromaeo:ready":
22                          DRT.start();
23                          break;
24                      case "dromaeo:progress":
25                          DRT.progress(event.data);
26                          break;
27                      case "dromaeo:alldone":
28                          DRT.teardown(event.data);
29                          break;
30                      }
31                  });
32          },
33
34          testObject: function(name) {
35              return {customIterationCount: ITERATION_COUNT, doNotMeasureMemoryUsage: true, doNotIgnoreInitialRun: true, unit: 'runs/s',
36                 name: name, continueTesting: !!name};
37          },
38
39          start: function() {
40              DRT.targetWindow.postMessage({ name: "dromaeo:start" } , "*");
41          },
42
43          progress: function(message) {
44             var score = message.status.score;
45             if (score)
46                 PerfTestRunner.reportValues(this.testObject(score.name), score.times);
47          },
48
49          teardown: function(data) {
50              PerfTestRunner.log('');
51
52              var tests = data.result;
53              var times = [];
54              for (var i = 0; i < tests.length; ++i) {
55                  for (var j = 0; j < tests[i].times.length; ++j) {
56                      var runsPerSecond = tests[i].times[j];
57                      times[j] = (times[j] || 0) + 1 / runsPerSecond;
58                  }
59              }
60
61              PerfTestRunner.reportValues(this.testObject(), times.map(function (time) { return 1 / time; }));
62          },
63
64          targetDelegateOf: function(functionName) {
65              return function() {
66                  DRT.targetWindow[functionName].apply(null, arguments);
67              };
68          },
69
70          log: function(text) {
71              PerfTestRunner.log(text);
72          }
73      };
74
75      // These functions are referred from htmlrunner.js
76      this.startTest = DRT.targetDelegateOf("startTest");
77      this.test = DRT.targetDelegateOf("test");
78      this.endTest = DRT.targetDelegateOf("endTest");
79      this.prep = DRT.targetDelegateOf("prep");
80
81      window.DRT = DRT;
82  })();