From 6d8222aec92fe8657bc068214acbed0eb680f43c Mon Sep 17 00:00:00 2001 From: "jnd@chromium.org" Date: Mon, 26 Sep 2011 09:45:37 +0000 Subject: Cleanup duplicated start.js files, merge them into one place and change 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 --- tools/page_cycler/common/start.js | 67 +++++++++++++--------- .../database/delete-transactions/start.html | 2 +- .../database/insert-transactions/start.html | 2 +- .../database/pseudo-random-transactions/start.html | 2 +- .../start.html | 2 +- .../database/select-readtransactions/start.html | 2 +- .../database/select-transactions/start.html | 2 +- tools/page_cycler/database/start.js | 59 ------------------- .../database/update-transactions/start.html | 2 +- .../page_cycler/indexed_db/basic_insert/start.html | 2 +- tools/page_cycler/indexed_db/start.js | 59 ------------------- 11 files changed, 49 insertions(+), 152 deletions(-) delete mode 100644 tools/page_cycler/database/start.js delete mode 100644 tools/page_cycler/indexed_db/start.js (limited to 'tools/page_cycler') diff --git a/tools/page_cycler/common/start.js b/tools/page_cycler/common/start.js index 5f5f055..f43994e 100644 --- a/tools/page_cycler/common/start.js +++ b/tools/page_cycler/common/start.js @@ -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); } @@ -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); @@ -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("

Note: You must have started chrome with --enable-file-cookies --js-flags=\"--expose_gc\" for this test to work manually.

"); - if (!window.gc) - document.write("

WARNING: window.gc is not defined. Test results may be unreliable!

"); + if (!window.gc) { + document.write('

WARNING: window.gc is not ' + + 'defined. Test results may be unreliable! You must ' + + 'started chrome also with --js-flags=\"--expose_gc\"' + + ' for this test to work manually

'); + } } diff --git a/tools/page_cycler/database/delete-transactions/start.html b/tools/page_cycler/database/delete-transactions/start.html index 596e60c..4f5d3eb 100644 --- a/tools/page_cycler/database/delete-transactions/start.html +++ b/tools/page_cycler/database/delete-transactions/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/database/insert-transactions/start.html b/tools/page_cycler/database/insert-transactions/start.html index f8538de..6c18a36 100644 --- a/tools/page_cycler/database/insert-transactions/start.html +++ b/tools/page_cycler/database/insert-transactions/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/database/pseudo-random-transactions/start.html b/tools/page_cycler/database/pseudo-random-transactions/start.html index 6278291..f2dd9c6 100644 --- a/tools/page_cycler/database/pseudo-random-transactions/start.html +++ b/tools/page_cycler/database/pseudo-random-transactions/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/database/select-readtransactions-read-results/start.html b/tools/page_cycler/database/select-readtransactions-read-results/start.html index bbb0aef..ee4038c 100644 --- a/tools/page_cycler/database/select-readtransactions-read-results/start.html +++ b/tools/page_cycler/database/select-readtransactions-read-results/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/database/select-readtransactions/start.html b/tools/page_cycler/database/select-readtransactions/start.html index 6833f1b..383fb20 100644 --- a/tools/page_cycler/database/select-readtransactions/start.html +++ b/tools/page_cycler/database/select-readtransactions/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/database/select-transactions/start.html b/tools/page_cycler/database/select-transactions/start.html index ce9d2e9..33da99f 100644 --- a/tools/page_cycler/database/select-transactions/start.html +++ b/tools/page_cycler/database/select-transactions/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/database/start.js b/tools/page_cycler/database/start.js deleted file mode 100644 index 6b7be5b..0000000 --- a/tools/page_cycler/database/start.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -document.title = 'page cycler'; - -document.cookie = '__navigated_to_report=0; path=/'; -document.cookie = '__pc_done=0; path=/'; -document.cookie = '__pc_timings=; path=/'; - -var options = location.search.substring(1).split('&'); - -function getOption(name) { - 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); - } - } - return null; -} - -function start() { - var iterations = document.getElementById('iterations').value; - window.resizeTo(800, 800); - var url = 'index.html?n=' + iterations + '&i=0&td=0'; - window.location = url; -} - -function renderForm() { - var form = document.createElement('form'); - form.onsubmit = function(e) { - start(); - e.preventDefault(); - }; - - var label = document.createTextNode('Iterations: '); - form.appendChild(label); - - var input = document.createElement('input'); - input.id = 'iterations'; - input.type = 'number'; - var iterations = getOption('iterations'); - input.value = iterations ? iterations : '5'; - form.appendChild(input); - - input = document.createElement('input'); - input.type = 'submit'; - input.value = 'Start'; - form.appendChild(input); - - document.body.appendChild(form); -} - -renderForm(); - -// should we start automatically? -if (location.search.match('auto=1')) - start(); diff --git a/tools/page_cycler/database/update-transactions/start.html b/tools/page_cycler/database/update-transactions/start.html index 2c2e2a0..aa346f7 100644 --- a/tools/page_cycler/database/update-transactions/start.html +++ b/tools/page_cycler/database/update-transactions/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/indexed_db/basic_insert/start.html b/tools/page_cycler/indexed_db/basic_insert/start.html index ecdc393..9711869 100644 --- a/tools/page_cycler/indexed_db/basic_insert/start.html +++ b/tools/page_cycler/indexed_db/basic_insert/start.html @@ -4,6 +4,6 @@

Note: You must have started chrome with --enable-file-cookies for this test to work manually.

- + diff --git a/tools/page_cycler/indexed_db/start.js b/tools/page_cycler/indexed_db/start.js deleted file mode 100644 index 6b7be5b..0000000 --- a/tools/page_cycler/indexed_db/start.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -document.title = 'page cycler'; - -document.cookie = '__navigated_to_report=0; path=/'; -document.cookie = '__pc_done=0; path=/'; -document.cookie = '__pc_timings=; path=/'; - -var options = location.search.substring(1).split('&'); - -function getOption(name) { - 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); - } - } - return null; -} - -function start() { - var iterations = document.getElementById('iterations').value; - window.resizeTo(800, 800); - var url = 'index.html?n=' + iterations + '&i=0&td=0'; - window.location = url; -} - -function renderForm() { - var form = document.createElement('form'); - form.onsubmit = function(e) { - start(); - e.preventDefault(); - }; - - var label = document.createTextNode('Iterations: '); - form.appendChild(label); - - var input = document.createElement('input'); - input.id = 'iterations'; - input.type = 'number'; - var iterations = getOption('iterations'); - input.value = iterations ? iterations : '5'; - form.appendChild(input); - - input = document.createElement('input'); - input.type = 'submit'; - input.value = 'Start'; - form.appendChild(input); - - document.body.appendChild(form); -} - -renderForm(); - -// should we start automatically? -if (location.search.match('auto=1')) - start(); -- cgit v1.1