graphics_WebGLPerformance: rev sources.

This revs the tests to commit 3729e8afac99:
http://hg.mozilla.org/users/bjacob_mozilla.com/webgl-perf-tests/raw-file/3729e8afac99/index.html

In addition fix average computation/log(0) handling. 0ms should
basically be treated as 1ms for geometric average computation.
Now practically with the new revision 0ms doesn't even happen on
Samus, so we are kind of good for a while. If this happens with a
faster machine again we can always multiply |repeat| with 10 or so.

BUG=chromium:548352
TEST=Ran on lumpy, link, samus.

Change-Id: Ie75b314979dc75e379b3d8788a91ad6f1e5d7059
Reviewed-on: https://chromium-review.googlesource.com/309517
Commit-Ready: Ilja Friedel <ihf@chromium.org>
Tested-by: Ilja Friedel <ihf@chromium.org>
Reviewed-by: Haixia Shi <hshi@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309912
diff --git a/client/deps/webgl_perf/files/0001-Patch-index.html.patch b/client/deps/webgl_perf/files/0001-Patch-index.html.patch
new file mode 100644
index 0000000..973f583
--- /dev/null
+++ b/client/deps/webgl_perf/files/0001-Patch-index.html.patch
@@ -0,0 +1,42 @@
+From 0e9cf719da76a6da8dd8b67517198490a9b9b271 Mon Sep 17 00:00:00 2001
+From: "Ilja H. Friedel" <ihf@chromium.org>
+Date: Tue, 27 Oct 2015 21:59:58 -0700
+Subject: [PATCH 1/2] Patch index.html
+
+so it works with autotest graphics_WebGLPerformance.
+
+BUG=chromium:341333
+---
+ index.html | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/index.html b/index.html
+index 66b498b..0d0891b 100644
+--- a/index.html
++++ b/index.html
+@@ -13,6 +13,10 @@
+   var sumOfResults = 0;
+   var sumOfLogResults = 0;
+   var numberOfResults = 0;
++  // These variables are used to communicate with autotest.
++  var test_report = "Tests did not complete.";
++  var time_ms_geom_mean = -1.0;
++  var test_completed = false;
+   var rawResults = {};
+   var useiframe = document.location.hash.indexOf("useWindow") == -1;
+   var testwindow;
+@@ -67,7 +71,10 @@
+     }
+     t += "</table>";
+     resultsDiv.innerHTML = t;
+-
++    // Fill out copy of results for autotest harness.
++    time_ms_geom_mean = Math.round(100 * Math.exp(sumOfLogResults / numberOfResults)) / 100;
++    test_report = t;
++    test_completed = true;
+     if (window.SpeedTests) {
+       // we loaded the speedtest framework, so send the results
+       var sr = { value: Math.exp(sumOfLogResults / numberOfResults),
+-- 
+2.1.2
+
diff --git a/client/deps/webgl_perf/files/0002-Always-increment-numberOfResults.patch b/client/deps/webgl_perf/files/0002-Always-increment-numberOfResults.patch
new file mode 100644
index 0000000..dd8803f
--- /dev/null
+++ b/client/deps/webgl_perf/files/0002-Always-increment-numberOfResults.patch
@@ -0,0 +1,27 @@
+From 59b56e0f7e70166bb78a3266feeae8a205e25f05 Mon Sep 17 00:00:00 2001
+From: "Ilja H. Friedel" <ihf@chromium.org>
+Date: Tue, 27 Oct 2015 22:53:32 -0700
+Subject: [PATCH 2/2] Always increment numberOfResults.
+
+BUG=chromium:548352
+---
+ index.html | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/index.html b/index.html
+index 0d0891b..75c096d 100644
+--- a/index.html
++++ b/index.html
+@@ -90,8 +90,8 @@
+       if (e.data.testResult) {
+         sumOfResults += e.data.testResult;
+         sumOfLogResults += Math.log(e.data.testResult);
+-        numberOfResults++;
+       }
++      numberOfResults++;
+       currentPageIndex++;
+       startCurrentTestPage();
+     }
+-- 
+2.1.2
+
diff --git a/client/deps/webgl_perf/files/webgl-performance-0.0.1.tar.bz2 b/client/deps/webgl_perf/files/webgl-performance-0.0.1.tar.bz2
deleted file mode 100644
index e00cac7..0000000
--- a/client/deps/webgl_perf/files/webgl-performance-0.0.1.tar.bz2
+++ /dev/null
Binary files differ
diff --git a/client/deps/webgl_perf/files/webgl-performance-0.0.2.patch b/client/deps/webgl_perf/files/webgl-performance-0.0.2.patch
deleted file mode 100644
index 5f1ef39..0000000
--- a/client/deps/webgl_perf/files/webgl-performance-0.0.2.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-From ea268329149aea6e21c2c0a571eafa0abd7ab9ea Mon Sep 17 00:00:00 2001
-From: "Ilja H. Friedel" <ihf@chromium.org>
-Date: Wed, 5 Feb 2014 22:05:22 -0800
-Subject: [PATCH] Patch webgl-performance-tests.html
-
-so it works with autotest graphics_WebGLPerformance.
-
-BUG=chromium:341333
----
- webgl-performance-tests.html | 18 +++++++++++++-----
- 1 file changed, 13 insertions(+), 5 deletions(-)
-
-diff --git a/webgl-performance-tests.html b/webgl-performance-tests.html
-index a3533e7..026490e 100644
---- a/webgl-performance-tests.html
-+++ b/webgl-performance-tests.html
-@@ -2,6 +2,7 @@
- <head>
-   <meta charset="utf-8">
- </head>
-+
- <script>
-   var testPageURLs = [];
-   var testsRun = [];
-@@ -11,7 +12,10 @@
-   var sumOfResults = 0;
-   var sumOfLogResults = 0;
-   var numberOfResults = 0;
--
-+  // These variables are used to communicate with autotests. 
-+  var test_report = "Tests did not complete.";
-+  var time_ms_geom_mean = -1.0;
-+  var test_completed = false;
- 
-   function startCurrentTestPage() {
-     if (currentPageIndex < testPageURLs.length) {
-@@ -22,7 +26,7 @@
-       testframe.src = testPageURLs[currentPageIndex];
-     } else {
-       testframe.parentNode.removeChild(testframe);
--      var t = "<b>WebGL Performance Regression Test Results</b><br/><br/>" +
-+      var msg = "<b>WebGL Performance Regression Test Results</b><br/><br/>" +
-               "Keep in mind that these tests are not realistic workloads. These are not " +
-               "benchmarks aiming to compare browser or GPU performance. These are only useful " +
-               "to catch performance regressions in a given browser and system.<br/><br/>" +
-@@ -41,10 +45,14 @@
-           result = "<font color='blue'>Skipped</font>";
-         else
-           result = testsRun[i].testResult + "&nbsp;ms";
--        t += "<tr style='background-color:" + color + "'><td><a href='" + testPageURLs[i] + "'>" + testPageURLs[i] + "</a></td><td>" + result + "</td><td><i>" + testsRun[i].testDescription + "</i></td></tr>";
-+        msg += "<tr style='background-color:" + color + "'><td><a href='" + testPageURLs[i] + "'>" + testPageURLs[i] + "</a></td><td>" + result + "</td><td><i>" + testsRun[i].testDescription + "</i></td></tr>";
-       }
--      t += "</table>";
--      resultsDiv.innerHTML = t;
-+      msg += "</table>";
-+      resultsDiv.innerHTML = msg;
-+      // Fill out copy of results for autotest harness.
-+      time_ms_geom_mean = Math.round(100 * Math.exp(sumOfLogResults / numberOfResults)) / 100;
-+      test_report = msg;
-+      test_completed = true;
-     }
-   }
- 
--- 
-1.9.0.rc1.175.g0b1dcb5
-
diff --git a/client/deps/webgl_perf/files/webgl-performance-0.0.2.tar.bz2 b/client/deps/webgl_perf/files/webgl-performance-0.0.2.tar.bz2
new file mode 100644
index 0000000..ecba346
--- /dev/null
+++ b/client/deps/webgl_perf/files/webgl-performance-0.0.2.tar.bz2
Binary files differ
diff --git a/client/deps/webgl_perf/webgl_perf.py b/client/deps/webgl_perf/webgl_perf.py
index 584c168..bdca12c 100755
--- a/client/deps/webgl_perf/webgl_perf.py
+++ b/client/deps/webgl_perf/webgl_perf.py
@@ -9,11 +9,12 @@
 
 version = 1
 
+
 def setup(topdir):
     """Unpack tarball to src/ and apply patch.
     @param topdir: The directory of this deps.
     """
-    tarball='webgl-performance-0.0.1.tar.bz2'
+    tarball = 'webgl-performance-0.0.2.tar.bz2'
     srcdir = os.path.join(topdir, 'src')
     filesdir = os.path.join(topdir, 'files')
     shutil.rmtree(srcdir, ignore_errors=True)
@@ -22,8 +23,11 @@
         os.mkdir(srcdir)
         utils.extract_tarball_to_dir(tarball_path, srcdir)
     os.chdir(srcdir)
-    utils.system('patch -p1 < ../files/webgl-performance-0.0.2.patch')
+    utils.system('patch -p1 < ../files/0001-Patch-index.html.patch')
+    utils.system(
+        'patch -p1 < ../files/0002-Always-increment-numberOfResults.patch')
     shutil.copy('../files/favicon.ico', srcdir)
 
+
 pwd = os.getcwd()
 utils.update_version(pwd + '/src', True, version, setup, pwd)
diff --git a/client/site_tests/graphics_WebGLPerformance/graphics_WebGLPerformance.py b/client/site_tests/graphics_WebGLPerformance/graphics_WebGLPerformance.py
index e7001d3..2837596 100644
--- a/client/site_tests/graphics_WebGLPerformance/graphics_WebGLPerformance.py
+++ b/client/site_tests/graphics_WebGLPerformance/graphics_WebGLPerformance.py
@@ -2,7 +2,15 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-"""This is a client side WebGL performance test."""
+"""This is a client side WebGL performance test.
+
+http://hg.mozilla.org/users/bjacob_mozilla.com/webgl-perf-tests/raw-file/3729e8afac99/index.html
+
+From the sources:
+Keep in mind that these tests are not realistic workloads. These are not
+benchmarks aiming to compare browser or GPU performance. These are only useful
+to catch performance regressions in a given browser and system.
+"""
 
 import logging, os, time
 
@@ -16,6 +24,7 @@
     """WebGL performance graphics test."""
     version = 1
     GSC = None
+    _test_duration_secs = 0
 
     def setup(self):
         self.job.setup_dep(['webgl_perf'])
@@ -29,8 +38,10 @@
         if self.GSC:
             keyvals = self.GSC.get_memory_keyvals()
             for key, val in keyvals.iteritems():
-                self.output_perf_value(description=key, value=val,
-                                       units='bytes', higher_is_better=False)
+                self.output_perf_value(description=key,
+                                       value=val,
+                                       units='bytes',
+                                       higher_is_better=False)
             self.GSC.finalize()
             self.write_perf_keyval(keyvals)
 
@@ -67,56 +78,56 @@
             'Timed out running the test.')
 
         # Get the geometric mean of individual runtimes.
-        time_ms_geom_mean = tab.EvaluateJavaScript(
-                               'time_ms_geom_mean')
+        time_ms_geom_mean = tab.EvaluateJavaScript('time_ms_geom_mean')
         logging.info('WebGLPerformance: time_ms_geom_mean = %f',
-                                      time_ms_geom_mean)
+                     time_ms_geom_mean)
 
         # Output numbers for plotting by harness.
         keyvals = {}
         keyvals['time_ms_geom_mean'] = time_ms_geom_mean
         self.write_perf_keyval(keyvals)
         self.output_perf_value(description='time_geom_mean',
-                               value=time_ms_geom_mean, units='ms',
+                               value=time_ms_geom_mean,
+                               units='ms',
                                higher_is_better=False,
                                graph='time_geom_mean')
         # Add extra value to the graph distinguishing different boards.
         variant = utils.get_board_with_frequency_and_memory()
         desc = 'time_geom_mean-%s' % variant
         self.output_perf_value(description=desc,
-                               value=time_ms_geom_mean, units='ms',
+                               value=time_ms_geom_mean,
+                               units='ms',
                                higher_is_better=False,
                                graph='time_geom_mean')
 
         # Get a copy of the test report.
         test_report = tab.EvaluateJavaScript('test_report')
-        results_path = os.path.join(self.bindir,
-            "../../results/default/graphics_WebGLPerformance/test_report.html")
+        results_path = os.path.join(
+            self.bindir,
+            '../../results/default/graphics_WebGLPerformance/test_report.html')
         f = open(results_path, 'w+')
         f.write(test_report)
         f.close()
 
         tab.Close()
 
-    def run_once(self, test_duration_secs=600, fullscreen=True):
+    def run_once(self, test_duration_secs=1800, fullscreen=True):
         """Finds a brower with telemetry, and run the test.
 
         @param test_duration_secs: The test duration in seconds.
         @param fullscreen: Whether to run the test in fullscreen.
         """
-        self.test_duration_secs = test_duration_secs
+        self._test_duration_secs = test_duration_secs
 
         ext_paths = []
         if fullscreen:
-            ext_paths.append(
-                    os.path.join(self.autodir, 'deps', 'graphics',
-                                 'graphics_test_extension'))
+            ext_paths.append(os.path.join(self.autodir, 'deps', 'graphics',
+                                          'graphics_test_extension'))
 
         with chrome.Chrome(logged_in=False, extension_paths=ext_paths) as cr:
             websrc_dir = os.path.join(self.autodir, 'deps', 'webgl_perf', 'src')
             if not cr.browser.SetHTTPServerDirectories(websrc_dir):
                 raise error.TestError('Unable to start HTTP server')
             test_url = cr.browser.http_server.UrlOf(
-                    os.path.join(websrc_dir, 'webgl-performance-tests.html'))
+                    os.path.join(websrc_dir, 'index.html'))
             self.run_performance_test(cr.browser, test_url)
-