<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198428] trunk/PerformanceTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198428">198428</a></dd>
<dt>Author</dt> <dd>jonlee@apple.com</dd>
<dt>Date</dt> <dd>2016-03-18 10:58:11 -0700 (Fri, 18 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 &quot;link&quot; 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 &quot;link&quot; 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkPerformanceTestsAnimometerdeveloperhtml">trunk/PerformanceTests/Animometer/developer.html</a></li>
<li><a href="#trunkPerformanceTestsAnimometerresourcesdebugrunneranimometercss">trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.css</a></li>
<li><a href="#trunkPerformanceTestsAnimometerresourcesdebugrunneranimometerjs">trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.js</a></li>
<li><a href="#trunkPerformanceTestsAnimometerresourcesextensionsjs">trunk/PerformanceTests/Animometer/resources/extensions.js</a></li>
<li><a href="#trunkPerformanceTestsChangeLog">trunk/PerformanceTests/ChangeLog</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkPerformanceTestsAnimometerdeveloperhtml"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/developer.html (198427 => 198428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/developer.html        2016-03-18 17:48:14 UTC (rev 198427)
+++ trunk/PerformanceTests/Animometer/developer.html        2016-03-18 17:58:11 UTC (rev 198428)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx">                 &lt;table id=&quot;results-header&quot;&gt;&lt;/table&gt;
</span><span class="cx">             &lt;/div&gt;
</span><del>-            &lt;button onclick=&quot;benchmarkController.startBenchmark()&quot;&gt;Test Again&lt;/button&gt;
</del><ins>+            &lt;button onclick=&quot;benchmarkController.restartBenchmark()&quot;&gt;Test Again&lt;/button&gt;
</ins><span class="cx">             &lt;p&gt;
</span><span class="cx">                 'j': Show JSON results&lt;br/&gt;
</span><span class="cx">                 's': Select various results for copy/paste (use repeatedly to cycle)
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometerresourcesdebugrunneranimometercss"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.css (198427 => 198428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.css        2016-03-18 17:48:14 UTC (rev 198427)
+++ trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.css        2016-03-18 17:58:11 UTC (rev 198428)
</span><span class="lines">@@ -104,6 +104,13 @@
</span><span class="cx">     content: '\25BC';
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.tree .link {
+    cursor: pointer;
+    color: #999;
+    font-style: italic;
+    margin-left: 2em;
+}
+
</ins><span class="cx"> @media screen and (max-device-width: 414px) {
</span><span class="cx">     .tree {
</span><span class="cx">         padding-left: 1em;
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometerresourcesdebugrunneranimometerjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/resources/debug-runner/animometer.js (198427 => 198428)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -190,8 +190,13 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return options;
</span><ins>+    },
+
+    updateDisplay: function()
+    {
+        document.body.className = &quot;display-&quot; + optionsManager.valueForOption(&quot;display&quot;);
</ins><span class="cx">     }
</span><del>-}
</del><ins>+};
</ins><span class="cx"> 
</span><span class="cx"> window.suitesManager =
</span><span class="cx"> {
</span><span class="lines">@@ -299,7 +304,29 @@
</span><span class="cx">         testCheckbox.suiteCheckbox = suiteCheckbox;
</span><span class="cx"> 
</span><span class="cx">         suiteCheckbox.testsElements.push(testElement);
</span><del>-        span.appendChild(document.createTextNode(&quot; &quot; + test.name));
</del><ins>+        span.appendChild(document.createTextNode(&quot; &quot; + test.name + &quot; &quot;));
+
+        testElement.appendChild(document.createTextNode(&quot; &quot;));
+        var link = Utilities.createElement(&quot;span&quot;, {}, testElement);
+        link.classList.add(&quot;link&quot;);
+        link.textContent = &quot;link&quot;;
+        link.suiteName = Utilities.stripNonASCIICharacters(suiteCheckbox.suite.name);
+        link.testName = test.name;
+        link.onclick = function(event) {
+            var element = event.target;
+            var title = &quot;Link to run “&quot; + element.testName + &quot;” with current options:&quot;;
+            var url = location.href.split(/[?#]/)[0];
+            var options = optionsManager.updateLocalStorageFromUI();
+            Utilities.extendObject(options, {
+                &quot;suite-name&quot;: element.suiteName,
+                &quot;test-name&quot;: Utilities.stripNonASCIICharacters(element.testName)
+            });
+            var complexity = suitesManager._editElement(element.parentNode).value;
+            if (complexity)
+                options.complexity = complexity;
+            prompt(title, url + Utilities.convertObjectToQueryString(options));
+        };
+
</ins><span class="cx">         var complexity = Utilities.createElement(&quot;input&quot;, { type: &quot;number&quot; }, testElement);
</span><span class="cx">         complexity.relatedCheckbox = testCheckbox;
</span><span class="cx">         complexity.oninput = function(event) {
</span><span class="lines">@@ -320,7 +347,7 @@
</span><span class="cx">             var suiteCheckbox = this._checkboxElement(suiteElement);
</span><span class="cx"> 
</span><span class="cx">             suite.tests.forEach(function(test) {
</span><del>-                var testElement = this._createTestElement(listElement, test, suiteCheckbox);
</del><ins>+                this._createTestElement(listElement, test, suiteCheckbox);
</ins><span class="cx">             }, this);
</span><span class="cx">         }, this);
</span><span class="cx">     },
</span><span class="lines">@@ -339,11 +366,6 @@
</span><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span><del>-    updateDisplay: function()
-    {
-        document.body.className = &quot;display-&quot; + optionsManager.valueForOption(&quot;display&quot;);
-    },
-
</del><span class="cx">     updateUIFromLocalStorage: function()
</span><span class="cx">     {
</span><span class="cx">         var suitesElements = this._suitesElements();
</span><span class="lines">@@ -407,6 +429,35 @@
</span><span class="cx">         return suites;
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    suitesFromQueryString: function(suiteName, testName)
+    {
+        var suites = [];
+        var suiteRegExp = new RegExp(suiteName, &quot;i&quot;);
+        var testRegExp = new RegExp(testName, &quot;i&quot;);
+
+        for (var i = 0; i &lt; Suites.length; ++i) {
+            var suite = Suites[i];
+            if (!Utilities.stripNonASCIICharacters(suite.name).match(suiteRegExp))
+                continue;
+
+            var test;
+            for (var j = 0; j &lt; 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;
+    },
+
</ins><span class="cx">     updateLocalStorageFromJSON: function(results)
</span><span class="cx">     {
</span><span class="cx">         for (var suiteName in results[Strings.json.results.tests]) {
</span><span class="lines">@@ -433,9 +484,13 @@
</span><span class="cx">         document.forms[&quot;time-graph-options&quot;].addEventListener(&quot;change&quot;, benchmarkController.onTimeGraphOptionsChanged, true);
</span><span class="cx">         document.forms[&quot;complexity-graph-options&quot;].addEventListener(&quot;change&quot;, benchmarkController.onComplexityGraphOptionsChanged, true);
</span><span class="cx">         optionsManager.updateUIFromLocalStorage();
</span><ins>+        optionsManager.updateDisplay();
+
+        if (benchmarkController.startBenchmarkImmediatelyIfEncoded())
+            return;
+
</ins><span class="cx">         suitesManager.createElements();
</span><span class="cx">         suitesManager.updateUIFromLocalStorage();
</span><del>-        suitesManager.updateDisplay();
</del><span class="cx">         suitesManager.updateEditsElementsState();
</span><span class="cx"> 
</span><span class="cx">         var dropTarget = document.getElementById(&quot;drop-target&quot;);
</span><span class="lines">@@ -466,7 +521,6 @@
</span><span class="cx">             reader.readAsText(file);
</span><span class="cx">             document.title = &quot;File: &quot; + reader.filename;
</span><span class="cx">         }, false);
</span><del>-
</del><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     onBenchmarkOptionsChanged: function(event)
</span><span class="lines">@@ -476,17 +530,38 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         if (event.target.name == &quot;display&quot;) {
</span><del>-            suitesManager.updateDisplay();
</del><ins>+            optionsManager.updateDisplay();
</ins><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     startBenchmark: function()
</span><span class="cx">     {
</span><del>-        var options = optionsManager.updateLocalStorageFromUI();
-        var suites = suitesManager.updateLocalStorageFromUI();
-        this._startBenchmark(suites, options, &quot;running-test&quot;);
</del><ins>+        benchmarkController.options = optionsManager.updateLocalStorageFromUI();
+        benchmarkController.suites = suitesManager.updateLocalStorageFromUI();
+        this._startBenchmark(benchmarkController.suites, benchmarkController.options, &quot;running-test&quot;);
</ins><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    startBenchmarkImmediatelyIfEncoded: function()
+    {
+        benchmarkController.options = Utilities.convertQueryStringToObject(location.search);
+        if (!benchmarkController.options)
+            return false;
+
+        benchmarkController.suites = suitesManager.suitesFromQueryString(benchmarkController.options[&quot;suite-name&quot;], benchmarkController.options[&quot;test-name&quot;]);
+        if (!benchmarkController.suites.length)
+            return false;
+
+        setTimeout(function() {
+            this._startBenchmark(benchmarkController.suites, benchmarkController.options, &quot;running-test&quot;);
+        }.bind(this), 0);
+        return true;
+    },
+
+    restartBenchmark: function()
+    {
+        this._startBenchmark(benchmarkController.suites, benchmarkController.options, &quot;running-test&quot;);
+    },
+
</ins><span class="cx">     showResults: function()
</span><span class="cx">     {
</span><span class="cx">         if (!this.addedKeyEvent) {
</span></span></pre></div>
<a id="trunkPerformanceTestsAnimometerresourcesextensionsjs"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/Animometer/resources/extensions.js (198427 => 198428)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -118,6 +118,35 @@
</span><span class="cx">         element.style[property] = element.style[this.browserPrefix().js + property[0].toUpperCase() + property.substr(1)] = value;
</span><span class="cx">     },
</span><span class="cx"> 
</span><ins>+    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) + &quot;=&quot; + encodeURIComponent(object[property]));
+        }
+        return &quot;?&quot; + queryString.join(&quot;&amp;&quot;);
+    },
+
+    convertQueryStringToObject: function(queryString)
+    {
+        queryString = queryString.substring(1);
+        if (!queryString)
+            return null;
+
+        var object = {};
+        queryString.split(&quot;&amp;&quot;).forEach(function(parameter) {
+            var components = parameter.split(&quot;=&quot;);
+            object[components[0]] = components[1];
+        });
+        return object;
+    },
+
</ins><span class="cx">     progressValue: function(value, min, max)
</span><span class="cx">     {
</span><span class="cx">         return (value - min) / (max - min);
</span></span></pre></div>
<a id="trunkPerformanceTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/PerformanceTests/ChangeLog (198427 => 198428)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/PerformanceTests/ChangeLog        2016-03-18 17:48:14 UTC (rev 198427)
+++ trunk/PerformanceTests/ChangeLog        2016-03-18 17:58:11 UTC (rev 198428)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-03-18  Jon Lee  &lt;jonlee@apple.com&gt;
+
+        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 &quot;link&quot; 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 &quot;link&quot; 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.
+
</ins><span class="cx"> 2016-03-16  Jon Lee  &lt;jonlee@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a new benchmark test
</span></span></pre>
</div>
</div>

</body>
</html>