Bug 1087244 - [mozlog] Fix screenshot links in the HTML formatter. r=jgraham
authorDave Hunt <dave.hunt>
Wed, 22 Oct 2014 07:02:00 +0200
changeset 212094 c1012126b6e9636a71a3926b919ee08eeec9fb04
parent 212093 b2ba88cd08c09e5f26951acc6e4ab1a9a58818bd
child 212095 d85ad6786d389609d671ee53069bb8382e10d04a
push id27697
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:48:53 +0000
treeherdermozilla-central@de805196bbc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1087244
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1087244 - [mozlog] Fix screenshot links in the HTML formatter. r=jgraham
testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py
testing/mozbase/mozlog/mozlog/structured/formatters/html/main.js
--- a/testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py
+++ b/testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py
@@ -1,13 +1,14 @@
 #!/usr/bin/env python
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+import base64
 import cgi
 from datetime import datetime
 import os
 
 from .. import base
 
 from collections import defaultdict
 
@@ -112,32 +113,29 @@ class HTMLFormatter(base.BaseFormatter):
 
         if status in ['SKIP', 'FAIL', 'ERROR']:
             if debug.get('screenshot'):
                 screenshot = 'data:image/png;base64,%s' % debug['screenshot']
                 additional_html.append(html.div(
                     html.a(html.img(src=screenshot), href="#"),
                     class_='screenshot'))
             for name, content in debug.items():
-                try:
-                    if 'screenshot' in name:
-                        href = '#'
-                    else:
-                        # use base64 to avoid that some browser (such as Firefox, Opera)
-                        # treats '#' as the start of another link if the data URL contains.
-                        # use 'charset=utf-8' to show special characters like Chinese.
-                        href = 'data:text/plain;charset=utf-8;base64,%s' % base64.b64encode(content)
-                    links_html.append(html.a(
-                        name.title(),
-                        class_=name,
-                        href=href,
-                        target='_blank'))
-                    links_html.append(' ')
-                except:
-                    pass
+                if 'screenshot' in name:
+                    href = '#'
+                else:
+                    # use base64 to avoid that some browser (such as Firefox, Opera)
+                    # treats '#' as the start of another link if the data URL contains.
+                    # use 'charset=utf-8' to show special characters like Chinese.
+                    href = 'data:text/plain;charset=utf-8;base64,%s' % base64.b64encode(content)
+                links_html.append(html.a(
+                    name.title(),
+                    class_=name,
+                    href=href,
+                    target='_blank'))
+                links_html.append(' ')
 
             log = html.div(class_='log')
             output = data.get('stack', '').splitlines()
             output.extend(data.get('message', '').splitlines())
             for line in output:
                 separator = line.startswith(' ' * 10)
                 if separator:
                     log.append(line[:80])
--- a/testing/mozbase/mozlog/mozlog/structured/formatters/html/main.js
+++ b/testing/mozbase/mozlog/mozlog/structured/formatters/html/main.js
@@ -8,17 +8,17 @@ function toArray(iter) {
     }
     return Array.prototype.slice.call(iter);
 }
 
 function find(selector, elem) {
     if (!elem) {
         elem = document;
     }
-    return toArray(elem.querySelector(selector));
+    return elem.querySelector(selector);
 }
 
 function find_all(selector, elem) {
     if (!elem) {
         elem = document;
     }
     return toArray(elem.querySelectorAll(selector));
 }
@@ -27,17 +27,17 @@ addEventListener("DOMContentLoaded", fun
     reset_sort_headers();
 
     split_debug_onto_two_rows();
 
     find_all('.col-links a.screenshot').forEach(function(elem) {
         elem.addEventListener("click",
                               function(event) {
                                   var node = elem;
-                                  while (node && !node.classList.contains('.results-table-row')) {
+                                  while (node && !node.classList.contains('results-table-row')) {
                                       node = node.parentNode;
                                   }
                                   if (node != null) {
                                       if (node.nextSibling &&
                                           node.nextSibling.classList.contains("debug")) {
                                           var href = find('.screenshot img', node.nextSibling).src;
                                           window.open(href);
                                       }