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 document.cookie = "__navigated_to_report=0; path=/";
6 document.cookie = "__pc_done=0; path=/";
7 document.cookie = "__pc_timings=; path=/";
9 function dirname(path) {
10 var match = path.match(/(.*)\//);
18 function IsWprRecordMode() {
19 var kStatusUrl = "http://wprwprwpr/web-page-replay-command-status";
21 var xhr = new XMLHttpRequest();
23 xhr.open("GET", kStatusUrl, useAsync);
24 xhr.onreadystatechange = function() {
25 if (xhr.readyState == 4 && xhr.status == 200) {
26 var status = JSON.parse(xhr.responseText);
27 isRecordMode = status["is_record_mode"];
28 console.log("WPR record mode?: " + isRecordMode);
34 throw "Web Page Replay is not responding. Start WPR to continue."
41 console.log("try start");
42 var status_element = document.getElementById("status");
47 config_json = document.getElementById("json").textContent;
48 config = JSON.parse(config_json);
50 console.log("Bad json data: " + config_json);
51 status_element.textContent = "Exception: " + err + "\njson data: " +
55 var isRecordMode = false;
57 isRecordMode = IsWprRecordMode();
59 status_element.textContent = err;
60 setTimeout(TryStart, 5000);
64 if (!config["shouldStart"]) {
65 status_element.textContent =
66 "Press 'Start' to continue (or load this page with 'auto=1').";
71 var reportDir = dirname(dirname(window.location.pathname)) + "/common";
72 config["reportUrl"] = "file://" + reportDir + "/report.html";
73 config["isRecordMode"] = isRecordMode;
74 var port = chrome.runtime.connect();
75 port.postMessage({message: "start", benchmark: config});
76 console.log("sending start message: page count, " +
77 config["pageSets"].length);
79 console.log("TryStart retrying after exception: " + err);
80 status_element.textContent = "Exception: " + err;
81 setTimeout(TryStart, 1000);
84 status_element.textContent = "STARTING";
87 // We wait before starting the test just to let chrome warm up better.
88 setTimeout(TryStart, 250);