Skip to content

Commit

Permalink
Cleanup duplicated start.js files, merge them into one place and chan…
Browse files Browse the repository at this point in the history
…ge the test files to use the new start.js

BUG=None
TEST=page cycler
Review URL: http://codereview.chromium.org/7934011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102712 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jnd@chromium.org committed Sep 26, 2011
1 parent e4486da commit 6d8222a
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 152 deletions.
67 changes: 41 additions & 26 deletions tools/page_cycler/common/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This script runs the page cycler. It assumes that __pages is an array
// containing the directories for various pages to exercise.
document.title = 'page cycler';

document.title = "page cycler";
// The __pages is assumed an array which containing the directories for
// various pages to exercise. Some page cycler tests don't have this variable.

var initialPage = __pages[0];
var initialPage;
var hasVariablePages = (typeof __pages != 'undefined') &&
(__pages instanceof Array);
if (hasVariablePages)
initialPage = __pages[0];

document.cookie = "__navigated_to_report=0; path=/";
document.cookie = "__pc_done=0; path=/";
document.cookie = "__pc_pages=" + __pages + "; path=/";
document.cookie = "__pc_timings=; path=/";
document.cookie = '__navigated_to_report=0; path=/';
document.cookie = '__pc_done=0; path=/';
if (hasVariablePages)
document.cookie = '__pc_pages=' + __pages + '; path=/';
document.cookie = '__pc_timings=; path=/';

var options = location.search.substring(1).split('&');

function getopt(name) {
var r = new RegExp("^" + name + "=");
for (i = 0; i < options.length; ++i) {
var r = new RegExp('^' + name + '=');
for (var i = 0; i < options.length; ++i) {
if (options[i].match(r)) {
return options[i].substring(name.length + 1);
}
Expand All @@ -27,29 +32,36 @@ function getopt(name) {
}

function start() {
var iterations = document.getElementById("iterations").value;
var iterations = document.getElementById('iterations').value;
window.resizeTo(800, 800);
var ts = (new Date()).getTime();
var url = initialPage + "/index.html?n=" + iterations + "&i=0&p=0&ts=" + ts + "&td=0";
var url = '';
if (hasVariablePages)
url = initialPage + '/';
url += 'index.html?n=' + iterations + '&i=0&p=0&ts=' + ts + '&td=0';
window.location = url;
}

function render_form() {
var form = document.createElement("FORM");
form.setAttribute("action", "javascript:start()");
var form = document.createElement('FORM');
form.onsubmit = function(e) {
start();
e.preventDefault();
};

var label = document.createTextNode("Iterations: ");
var label = document.createTextNode('Iterations: ');
form.appendChild(label);

var input = document.createElement("INPUT");
input.setAttribute("id", "iterations");
var iterations = getopt("iterations");
input.setAttribute("value", iterations ? iterations : "5");
var input = document.createElement('INPUT');
input.setAttribute('id', 'iterations');
input.setAttribute('type', 'number');
var iterations = getopt('iterations');
input.setAttribute('value', iterations ? iterations : '5');
form.appendChild(input);

input = document.createElement("INPUT");
input.setAttribute("type", "submit");
input.setAttribute("value", "Start");
input = document.createElement('INPUT');
input.setAttribute('type', 'submit');
input.setAttribute('value', 'Start');
form.appendChild(input);

document.body.appendChild(form);
Expand All @@ -58,10 +70,13 @@ function render_form() {
render_form();

// should we start automatically?
if (location.search.match("auto=1")) {
if (location.search.match('auto=1')) {
start();
} else {
document.write("<h3>Note: You must have started chrome with <tt>--enable-file-cookies --js-flags=\"--expose_gc\"</tt> for this test to work manually.</h3>");
if (!window.gc)
document.write("<h3 style='color:red'>WARNING: window.gc is not defined. Test results may be unreliable!</h3>");
if (!window.gc) {
document.write('<h3 style=\'color:red\'>WARNING: window.gc is not ' +
'defined. Test results may be unreliable! You must ' +
'started chrome also with <tt>--js-flags=\"--expose_gc\"' +
'</tt> for this test to work manually</h3>');
}
}
2 changes: 1 addition & 1 deletion tools/page_cycler/database/delete-transactions/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=delete-transactions; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion tools/page_cycler/database/insert-transactions/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=insert-transactions; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=pseudo-random-transactions; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=select-readtransactions-read-results; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=select-readtransactions; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion tools/page_cycler/database/select-transactions/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=select-transactions; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
59 changes: 0 additions & 59 deletions tools/page_cycler/database/start.js

This file was deleted.

2 changes: 1 addition & 1 deletion tools/page_cycler/database/update-transactions/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=update-transactions; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion tools/page_cycler/indexed_db/basic_insert/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<h3>Note: You must have started chrome with <tt>--enable-file-cookies</tt> for
this test to work manually.</h3>
<script>document.cookie = "__pc_pages=basic_insert; path=/";</script>
<script src="../start.js"></script>
<script src="../../common/start.js"></script>
</body>
</html>
59 changes: 0 additions & 59 deletions tools/page_cycler/indexed_db/start.js

This file was deleted.

0 comments on commit 6d8222a

Please sign in to comment.