Modified: trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.js (198427 => 198428)
--- trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.js 2016-03-18 17:48:14 UTC (rev 198427)
+++ trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.js 2016-03-18 17:58:11 UTC (rev 198428)
@@ -190,8 +190,13 @@
}
return options;
+ },
+
+ updateDisplay: function()
+ {
+ document.body.className = "display-" + optionsManager.valueForOption("display");
}
-}
+};
window.suitesManager =
{
@@ -299,7 +304,29 @@
testCheckbox.suiteCheckbox = suiteCheckbox;
suiteCheckbox.testsElements.push(testElement);
- span.appendChild(document.createTextNode(" " + test.name));
+ span.appendChild(document.createTextNode(" " + test.name + " "));
+
+ testElement.appendChild(document.createTextNode(" "));
+ var link = Utilities.createElement("span", {}, testElement);
+ link.classList.add("link");
+ link.textContent = "link";
+ link.suiteName = Utilities.stripNonASCIICharacters(suiteCheckbox.suite.name);
+ link.testName = test.name;
+ link._onclick_ = function(event) {
+ var element = event.target;
+ var title = "Link to run “" + element.testName + "” with current options:";
+ var url = ""
+ var options = optionsManager.updateLocalStorageFromUI();
+ Utilities.extendObject(options, {
+ "suite-name": element.suiteName,
+ "test-name": Utilities.stripNonASCIICharacters(element.testName)
+ });
+ var complexity = suitesManager._editElement(element.parentNode).value;
+ if (complexity)
+ options.complexity = complexity;
+ prompt(title, url + Utilities.convertObjectToQueryString(options));
+ };
+
var complexity = Utilities.createElement("input", { type: "number" }, testElement);
complexity.relatedCheckbox = testCheckbox;
complexity._oninput_ = function(event) {
@@ -320,7 +347,7 @@
var suiteCheckbox = this._checkboxElement(suiteElement);
suite.tests.forEach(function(test) {
- var testElement = this._createTestElement(listElement, test, suiteCheckbox);
+ this._createTestElement(listElement, test, suiteCheckbox);
}, this);
}, this);
},
@@ -339,11 +366,6 @@
}
},
- updateDisplay: function()
- {
- document.body.className = "display-" + optionsManager.valueForOption("display");
- },
-
updateUIFromLocalStorage: function()
{
var suitesElements = this._suitesElements();
@@ -407,6 +429,35 @@
return suites;
},
+ suitesFromQueryString: function(suiteName, testName)
+ {
+ var suites = [];
+ var suiteRegExp = new RegExp(suiteName, "i");
+ var testRegExp = new RegExp(testName, "i");
+
+ for (var i = 0; i < Suites.length; ++i) {
+ var suite = Suites[i];
+ if (!Utilities.stripNonASCIICharacters(suite.name).match(suiteRegExp))
+ continue;
+
+ var test;
+ for (var j = 0; j < suite.tests.length; ++j) {
+ suiteTest = suite.tests[j];
+ if (Utilities.stripNonASCIICharacters(suiteTest.name).match(testRegExp)) {
+ test = suiteTest;
+ break;
+ }
+ }
+
+ if (!test)
+ continue;
+
+ suites.push(new Suite(suiteName, [test]));
+ };
+
+ return suites;
+ },
+
updateLocalStorageFromJSON: function(results)
{
for (var suiteName in results[Strings.json.results.tests]) {
@@ -433,9 +484,13 @@
document.forms["time-graph-options"].addEventListener("change", benchmarkController.onTimeGraphOptionsChanged, true);
document.forms["complexity-graph-options"].addEventListener("change", benchmarkController.onComplexityGraphOptionsChanged, true);
optionsManager.updateUIFromLocalStorage();
+ optionsManager.updateDisplay();
+
+ if (benchmarkController.startBenchmarkImmediatelyIfEncoded())
+ return;
+
suitesManager.createElements();
suitesManager.updateUIFromLocalStorage();
- suitesManager.updateDisplay();
suitesManager.updateEditsElementsState();
var dropTarget = document.getElementById("drop-target");
@@ -466,7 +521,6 @@
reader.readAsText(file);
document.title = "File: " + reader.filename;
}, false);
-
},
onBenchmarkOptionsChanged: function(event)
@@ -476,17 +530,38 @@
return;
}
if (event.target.name == "display") {
- suitesManager.updateDisplay();
+ optionsManager.updateDisplay();
}
},
startBenchmark: function()
{
- var options = optionsManager.updateLocalStorageFromUI();
- var suites = suitesManager.updateLocalStorageFromUI();
- this._startBenchmark(suites, options, "running-test");
+ benchmarkController.options = optionsManager.updateLocalStorageFromUI();
+ benchmarkController.suites = suitesManager.updateLocalStorageFromUI();
+ this._startBenchmark(benchmarkController.suites, benchmarkController.options, "running-test");
},
+ startBenchmarkImmediatelyIfEncoded: function()
+ {
+ benchmarkController.options = Utilities.convertQueryStringToObject(location.search);
+ if (!benchmarkController.options)
+ return false;
+
+ benchmarkController.suites = suitesManager.suitesFromQueryString(benchmarkController.options["suite-name"], benchmarkController.options["test-name"]);
+ if (!benchmarkController.suites.length)
+ return false;
+
+ setTimeout(function() {
+ this._startBenchmark(benchmarkController.suites, benchmarkController.options, "running-test");
+ }.bind(this), 0);
+ return true;
+ },
+
+ restartBenchmark: function()
+ {
+ this._startBenchmark(benchmarkController.suites, benchmarkController.options, "running-test");
+ },
+
showResults: function()
{
if (!this.addedKeyEvent) {
Modified: trunk/PerformanceTests/Animometer/resources/extensions.js (198427 => 198428)
--- trunk/PerformanceTests/Animometer/resources/extensions.js 2016-03-18 17:48:14 UTC (rev 198427)
+++ trunk/PerformanceTests/Animometer/resources/extensions.js 2016-03-18 17:58:11 UTC (rev 198428)
@@ -118,6 +118,35 @@
element.style[property] = element.style[this.browserPrefix().js + property[0].toUpperCase() + property.substr(1)] = value;
},
+ stripNonASCIICharacters: function(inputString)
+ {
+ return inputString.replace(/[ .,]/g, '');
+ },
+
+ convertObjectToQueryString: function(object)
+ {
+ var queryString = [];
+ for (var property in object) {
+ if (object.hasOwnProperty(property))
+ queryString.push(encodeURIComponent(property) + "=" + encodeURIComponent(object[property]));
+ }
+ return "?" + queryString.join("&");
+ },
+
+ convertQueryStringToObject: function(queryString)
+ {
+ queryString = queryString.substring(1);
+ if (!queryString)
+ return null;
+
+ var object = {};
+ queryString.split("&").forEach(function(parameter) {
+ var components = parameter.split("=");
+ object[components[0]] = components[1];
+ });
+ return object;
+ },
+
progressValue: function(value, min, max)
{
return (value - min) / (max - min);
Modified: trunk/PerformanceTests/ChangeLog (198427 => 198428)
--- trunk/PerformanceTests/ChangeLog 2016-03-18 17:48:14 UTC (rev 198427)
+++ trunk/PerformanceTests/ChangeLog 2016-03-18 17:58:11 UTC (rev 198428)
@@ -1,3 +1,38 @@
+2016-03-18 Jon Lee <[email protected]>
+
+ Add support for statically linking to a specific test
+ https://bugs.webkit.org/show_bug.cgi?id=155631
+
+ Rubber-stamped by Darin Adler.
+
+ * Animometer/developer.html: Update to call restartBenchmark instead so that it works for
+ both the preset and the manually set test sessions.
+ * Animometer/resources/debug-runner/animometer.css:
+ (.tree .link): Style the "link" UI.
+ * Animometer/resources/debug-runner/animometer.js: Move updateDisplay from suitesManager
+ to optionsManager since this is a visual option and has nothing to do with the suites
+ settings. Update the construction of the test UI by including a "link" after each test.
+ Clicking on that link brings up a JS prompt with a URL and a query string with the current
+ parameters of the controller, and selected test. Pasting this URL into the location bar will
+ automatically start running the selected test.
+ (suitesManager.suitesFromQueryString): Iterate through the Suites and tests and find the one
+ that matches the provided parameters. Returns an object similar to the form in
+ suitesManager.updateLocalStorageFromUI.
+ (benchmarkController.initialize): After settings up the events and options, try parsing the
+ query string and running the benchmark immediately. Otherwise, fall back to the form.
+ (benchmarkController.startBenchmark): Store the options and suites into member variables for
+ reuse in restartBenchmark.
+ (benchmarkController.startBenchmarkImmediatelyIfEncoded): Convert the query string to an object.
+ If that's successful, find the suite and test referenced in the query string. Start the benchmark if
+ the search for the test succeeded.
+ * Animometer/resources/extensions.js:
+ (Utilities.stripNonASCIICharacters): Helper method to convert the name of the suite and test
+ into a query-string-friendly version.
+ (Utilities.convertObjectToQueryString): Helper method to convert an object to query string
+ format.
+ (Utilities.convertQueryStringToObject): Helper method to convert query string into an object
+ with properties and values.
+
2016-03-16 Jon Lee <[email protected]>
Add a new benchmark test