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

Unified Diff: chrome/test/data/third_party/spaceport/js/index.js

Issue 10134041: Add test data for spaceport benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/third_party/spaceport/js/index.js
diff --git a/chrome/test/data/third_party/spaceport/js/index.js b/chrome/test/data/third_party/spaceport/js/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..059a57a670cb2c57d9700e764c96bf4219fd2563
--- /dev/null
+++ b/chrome/test/data/third_party/spaceport/js/index.js
@@ -0,0 +1,120 @@
+define([ 'tests/performance', 'testDom', 'testRunner', 'tables', 'util/report', 'util/ensureCallback', 'fullReport' ], function (performance, testDom, testRunner, tables, report, ensureCallback, fullReport) {
+ function testDone(err, name, results) {
+ var domId = name.replace(/[^a-z0-9]/gi, '-');
+ testDom.endTest(domId, err, results);
+ }
+
+ function allTestsDone(err, results) {
+ if (err) {
+ console.error(err);
+ return;
+ }
+
+ var allTestResultsEl = document.getElementById('all-test-results');
+ allTestResultsEl.textContent = fullReport.csvReport(results);
+ }
+
+ registerOnLoad(function () {
+ var table = report.tableTemplate('performance-sprites', report.makeTableLayout(tables.performance.sprites));
+ var tablePlaceholder = document.getElementById('performance-sprites-placeholder');
+ tablePlaceholder.parentNode.replaceChild(table, tablePlaceholder);
+
+ table = report.tableTemplate('performance-text', report.makeTableLayout(tables.performance.text));
+ tablePlaceholder = document.getElementById('performance-text-placeholder');
+ tablePlaceholder.parentNode.replaceChild(table, tablePlaceholder);
+
+ var performanceTestsRunning = false;
+ var runPerformanceTestsButton = document.getElementById('start-performance-tests');
+ var uploadPerformanceTestsButton = document.getElementById('upload-performance-tests');
+
+ function setRunning(isRunning) {
+ performanceTestsRunning = isRunning;
+ runPerformanceTestsButton.disabled = isRunning;
+ uploadPerformanceTestsButton.disabled = isRunning;
+ }
+
+ function runPerformanceTests(callback) {
+ callback = ensureCallback(callback);
+
+ testRunner.run('performance', performance, {
+ done: function (err, results) {
+ allTestsDone(err, results);
+ callback(err, results);
+ },
+ step: function (err, name, results) {
+ shortName = name.replace('performance.sprites.image.', '');
+ if (results) {
+ console.log(shortName + ": " + results.objectCount);
+ } else {
+ console.log(shortName + ": 0");
+ }
+ return testDone(err, name, results);
+ }
+ });
+ }
+
+ function runAndUploadPerformanceTests(callback) {
+ callback = ensureCallback(callback);
+
+ runPerformanceTests(function (err, results) {
+ if (err) return callback(err);
+
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ // Complete
+ callback(null);
+ }
+ };
+ xhr.open('POST', 'results', true);
+ xhr.send(JSON.stringify({
+ agentMetadata: fullReport.getAgentMetadata(),
+ results: results
+ }));
+ });
+ }
+
+ setRunning(false);
+
+ runPerformanceTestsButton.addEventListener('click', function () {
+ if (performanceTestsRunning) {
+ throw new Error('Tests already running');
+ }
+
+ setRunning(true);
+
+ runPerformanceTests(function (err, results) {
+ setRunning(false);
+ });
+ }, false);
+
+ uploadPerformanceTestsButton.addEventListener('click', function () {
+ if (performanceTestsRunning) {
+ throw new Error('Tests already running');
+ }
+
+ setRunning(true);
+
+ runAndUploadPerformanceTests(function (err, results) {
+ setRunning(false);
+ });
+ }, false);
+
+ var getVars = { };
+ if (/^\?/.test(location.search)) {
+ location.search.substr(1).split(/&/g).forEach(function (part) {
+ var equalsIndex = part.indexOf('=');
+
+ if (equalsIndex >= 0) {
+ getVars[part.substr(0, equalsIndex)] = part.substr(equalsIndex + 1);
+ } else {
+ getVars[part] = true;
+ }
+ });
+ }
+
+ if ('auto' in getVars) {
+ runPerformanceTests();
+ }
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698