1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var __c = ""; // that's good enough for me.
11 var __results = false;
14 function __get_cookie(name) {
15 var cookies = document.cookie.split("; ");
16 for (var i = 0; i < cookies.length; ++i) {
17 var t = cookies[i].split("=");
18 if (t[0] == name && t[1])
23 function __pages() { // fetch lazily
24 if (!("data" in this))
25 this.data = __get_cookie("__pc_pages").split(",");
28 function __get_timings() {
29 if (sessionStorage != null &&
30 sessionStorage.getItem("__pc_timings") != null) {
31 return sessionStorage["__pc_timings"];
33 return __get_cookie("__pc_timings");
36 function __set_timings(timings) {
37 if (sessionStorage == null)
38 document.cookie = "__pc_timings=" + timings + "; path=/";
40 sessionStorage["__pc_timings"]=timings;
42 function __ontimeout() {
45 // Call GC twice to cleanup JS heap before starting a new test.
52 var oldTimings = __get_timings();
53 if (oldTimings != "") {
54 timings = oldTimings + "," + timings;
56 __set_timings(timings);
58 var ts = (new Date()).getTime();
59 var tlag = (ts - __te) - __TIMEOUT;
62 if (__cycle == (__pages().length * __iterations)) {
63 document.cookie = "__pc_done=1; path=/";
64 doc = "../../common/report.html";
66 console.log("Pages: [" + __get_cookie('__pc_pages') + "]");
67 console.log("times: [" + __get_timings() + "]");
70 doc = "../" + __pages()[__page] + "/index.html";
73 var url = doc + "?n=" + __iterations + "&i=" + __cycle + "&p=" + __page +
74 "&ts=" + ts + "&td=" + __td + "&tf=" + __tf;
75 document.location.href = url;
79 // Set a variable to indicate that the result report page is loaded.
80 document.cookie = "__navigated_to_report=1; path=/";
83 var unused = document.body.offsetHeight; // force layout
85 var ts = 0, td = 0, te = (new Date()).getTime(), tf = 0;
87 var s = document.location.search;
89 var params = s.substring(1).split('&');
90 for (var i = 0; i < params.length; ++i) {
91 var f = params[i].split('=');
94 // No calculation, just viewing
100 __cycle = (f[1] - 0) + 1;
103 __page = ((f[1] - 0) + 1) % __pages().length;
120 __tf = tf; // record t-fudge
122 setTimeout("__ontimeout()", __TIMEOUT);
125 if (window.attachEvent)
126 window.attachEvent("onload", __onload);
128 addEventListener("load", __onload, false);