Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: tools/page_cycler/webpagereplay/extension/start.js

Issue 9956045: Add Web Page Replay test to page cycler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 document.cookie = "__navigated_to_report=0; path=/";
6 document.cookie = "__pc_done=0; path=/";
7 document.cookie = "__pc_timings=; path=/";
8
9 function dirname(path) {
10 var match = path.match(/(.*)\//);
11 if (match) {
12 return match[1];
13 } else {
14 return '.';
15 }
16 }
17
18 function IsWprRecordMode() {
19 var kStatusUrl = "http://wprwprwpr/web-page-replay-command-status";
20 var isRecordMode;
21 var xhr = new XMLHttpRequest();
22 var useAsync = false;
23 xhr.open("GET", kStatusUrl, useAsync);
24 xhr.timeout = 500;
25 xhr.onreadystatechange = function() {
26 if (xhr.readyState == 4 && xhr.status == 200) {
27 var status = JSON.parse(xhr.responseText);
28 isRecordMode = status['is_record_mode'];
29 console.log('WPR record mode?: ' + isRecordMode);
30 }
31 };
32 try {
33 xhr.send();
34 } catch(e) {
35 throw "Web Page Replay is not responding. Start WPR to continue."
36 }
37 return isRecordMode;
38 }
39
40
41 function TryStart() {
42 console.log('try start');
43 var status_element = document.getElementById('status');
44
45 var config_json;
46 var config;
47 try {
48 config_json = document.getElementById('json').textContent;
49 config = JSON.parse(config_json);
50 } catch(err) {
51 console.log("Bad json data: " + config_json);
52 status_element.textContent = "Exception: " + err + "\njson data: " +
53 config_json;
54 return;
55 }
56 var isRecordMode = false;
57 try {
58 isRecordMode = IsWprRecordMode();
59 } catch (err) {
60 status_element.textContent = err;
61 setTimeout(TryStart, 5000);
62 return;
63 }
64
65 try {
66 var testDir = dirname(window.location.pathname);
67 var reportUrl = "file://" + dirname(dirname(testDir)) +
68 "/common/report.html";
69 config["testDir"] = testDir;
70 config["reportUrl"] = reportUrl;
71 config["isRecordMode"] = isRecordMode;
72 var port = chrome.extension.connect();
73 port.postMessage({message: 'start', benchmark: config});
74 console.log('sending start message: page count, ' +
75 config['pageSets'].length);
76 } catch(err) {
77 console.log("TryStart retrying after exception: " + err);
78 status_element.textContent = "Exception: " + err;
79 setTimeout(TryStart, 1000);
80 return;
81 }
82 status_element.textContent = "STARTING";
83 }
84
85 // We wait before starting the test just to let chrome warm up better.
86 setTimeout(TryStart, 250);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698