Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1 | // Copyright (C) 2012 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Redistribution and use in source and binary forms, with or without |
| 4 | // modification, are permitted provided that the following conditions are |
| 5 | // met: |
| 6 | // |
| 7 | // * Redistributions of source code must retain the above copyright |
| 8 | // notice, this list of conditions and the following disclaimer. |
| 9 | // * Redistributions in binary form must reproduce the above |
| 10 | // copyright notice, this list of conditions and the following disclaimer |
| 11 | // in the documentation and/or other materials provided with the |
| 12 | // distribution. |
| 13 | // * Neither the name of Google Inc. nor the names of its |
| 14 | // contributors may be used to endorse or promote products derived from |
| 15 | // this software without specific prior written permission. |
| 16 | // |
| 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | |
| 29 | ////////////////////////////////////////////////////////////////////////////// |
| 30 | // CONSTANTS |
| 31 | ////////////////////////////////////////////////////////////////////////////// |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 32 | var FORWARD = 'forward'; |
| 33 | var BACKWARD = 'backward'; |
| 34 | var GTEST_MODIFIERS = ['FLAKY', 'FAILS', 'MAYBE', 'DISABLED']; |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 35 | var TEST_URL_BASE_PATH_FOR_BROWSING = 'http://src.chromium.org/viewvc/blink/trunk/LayoutTests/'; |
| 36 | var TEST_URL_BASE_PATH_FOR_XHR = 'http://src.chromium.org/blink/trunk/LayoutTests/'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 37 | var TEST_RESULTS_BASE_PATH = 'http://build.chromium.org/f/chromium/layout_test_results/'; |
| 38 | var GPU_RESULTS_BASE_PATH = 'http://chromium-browser-gpu-tests.commondatastorage.googleapis.com/runs/' |
| 39 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 40 | var RELEASE_TIMEOUT = 6; |
| 41 | var DEBUG_TIMEOUT = 12; |
| 42 | var SLOW_MULTIPLIER = 5; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 43 | var CHUNK_SIZE = 25; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 44 | |
| 45 | // FIXME: Figure out how to make this not be hard-coded. |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 46 | // Probably just include in the results.json files and get it from there. |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 47 | var VIRTUAL_SUITES = { |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 48 | 'virtual/gpu/fast/canvas': 'fast/canvas', |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 49 | 'virtual/gpu/canvas/philip': 'canvas/philip', |
| 50 | 'virtual/threaded/compositing/visibility': 'compositing/visibility', |
| 51 | 'virtual/threaded/compositing/webgl': 'compositing/webgl', |
| 52 | 'virtual/gpu/fast/hidpi': 'fast/hidpi', |
| 53 | 'virtual/softwarecompositing': 'compositing', |
| 54 | 'virtual/deferred/fast/images': 'fast/images', |
| 55 | 'virtual/gpu/compositedscrolling/overflow': 'compositing/overflow', |
| 56 | 'virtual/gpu/compositedscrolling/scrollbars': 'scrollbars', |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 59 | var ACTUAL_RESULT_SUFFIXES = ['expected.txt', 'expected.png', 'actual.txt', 'actual.png', 'diff.txt', 'diff.png', 'wdiff.html', 'crash-log.txt']; |
| 60 | |
| 61 | var EXPECTATIONS_ORDER = ACTUAL_RESULT_SUFFIXES.filter(function(suffix) { |
| 62 | return !string.endsWith(suffix, 'png'); |
| 63 | }).map(function(suffix) { |
| 64 | return suffix.split('.')[0] |
| 65 | }); |
| 66 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 67 | var resourceLoader; |
| 68 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 69 | function generatePage(historyInstance) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 70 | { |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 71 | if (historyInstance.crossDashboardState.useTestData) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 72 | return; |
| 73 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 74 | document.body.innerHTML = '<div id="loading-ui">LOADING...</div>'; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 75 | resourceLoader.showErrors(); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 76 | |
| 77 | // tests expands to all tests that match the CSV list. |
| 78 | // result expands to all tests that ever have the given result |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 79 | if (historyInstance.dashboardSpecificState.tests || historyInstance.dashboardSpecificState.result) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 80 | generatePageForIndividualTests(individualTests()); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 81 | else |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 82 | generatePageForBuilder(historyInstance.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder()); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 83 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 84 | for (var builder in currentBuilders()) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 85 | processTestResultsForBuilderAsync(builder); |
| 86 | |
| 87 | postHeightChangedMessage(); |
| 88 | } |
| 89 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 90 | function handleValidHashParameter(historyInstance, key, value) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 91 | { |
| 92 | switch(key) { |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 93 | case 'result': |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 94 | case 'tests': |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 95 | history.validateParameter(historyInstance.dashboardSpecificState, key, value, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 96 | function() { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 97 | return string.isValidName(value); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 98 | }); |
| 99 | return true; |
| 100 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 101 | case 'builder': |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 102 | history.validateParameter(historyInstance.dashboardSpecificState, key, value, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 103 | function() { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 104 | return value in currentBuilders(); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 105 | }); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 106 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 107 | return true; |
| 108 | |
| 109 | case 'sortColumn': |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 110 | history.validateParameter(historyInstance.dashboardSpecificState, key, value, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 111 | function() { |
| 112 | // Get all possible headers since the actual used set of headers |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 113 | // depends on the values in historyInstance.dashboardSpecificState, which are currently being set. |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 114 | var headers = tableHeaders(true); |
| 115 | for (var i = 0; i < headers.length; i++) { |
| 116 | if (value == sortColumnFromTableHeader(headers[i])) |
| 117 | return true; |
| 118 | } |
| 119 | return value == 'test' || value == 'builder'; |
| 120 | }); |
| 121 | return true; |
| 122 | |
| 123 | case 'sortOrder': |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 124 | history.validateParameter(historyInstance.dashboardSpecificState, key, value, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 125 | function() { |
| 126 | return value == FORWARD || value == BACKWARD; |
| 127 | }); |
| 128 | return true; |
| 129 | |
| 130 | case 'resultsHeight': |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 131 | case 'revision': |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 132 | history.validateParameter(historyInstance.dashboardSpecificState, key, Number(value), |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 133 | function() { |
| 134 | return value.match(/^\d+$/); |
| 135 | }); |
| 136 | return true; |
| 137 | |
| 138 | case 'showChrome': |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 139 | case 'showExpectations': |
| 140 | case 'showFlaky': |
| 141 | case 'showLargeExpectations': |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 142 | case 'showNonFlaky': |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 143 | case 'showSlow': |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 144 | case 'showSkip': |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 145 | case 'showUnexpectedPasses': |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 146 | case 'showWontFix': |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 147 | historyInstance.dashboardSpecificState[key] = value == 'true'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 148 | return true; |
| 149 | |
| 150 | default: |
| 151 | return false; |
| 152 | } |
| 153 | } |
| 154 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 155 | // @param {Object} params New or modified query parameters as key: value. |
| 156 | function handleQueryParameterChange(historyInstance, params) |
| 157 | { |
| 158 | for (key in params) { |
| 159 | if (key == 'tests') { |
| 160 | // Entering cross-builder view, only keep valid keys for that view. |
| 161 | for (var currentKey in historyInstance.dashboardSpecificState) { |
| 162 | if (isInvalidKeyForCrossBuilderView(currentKey)) { |
| 163 | delete historyInstance.dashboardSpecificState[currentKey]; |
| 164 | } |
| 165 | } |
| 166 | } else if (isInvalidKeyForCrossBuilderView(key)) { |
| 167 | delete historyInstance.dashboardSpecificState.tests; |
| 168 | delete historyInstance.dashboardSpecificState.result; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | return true; |
| 173 | } |
| 174 | |
| 175 | var defaultDashboardSpecificStateValues = { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 176 | sortOrder: BACKWARD, |
| 177 | sortColumn: 'flakiness', |
| 178 | showExpectations: false, |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 179 | // FIXME: Show flaky tests by default if you have a builder picked. |
| 180 | // Ideally, we'd fix the dashboard to not pick a default builder and have |
| 181 | // you pick one. In the interim, this is a good way to make the default |
| 182 | // page load faster since we don't need to generate/layout a large table. |
| 183 | showFlaky: false, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 184 | showLargeExpectations: false, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 185 | showChrome: true, |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 186 | showWontFix: false, |
| 187 | showNonFlaky: false, |
| 188 | showSkip: false, |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 189 | showUnexpectedPasses: false, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 190 | resultsHeight: 300, |
| 191 | revision: null, |
| 192 | tests: '', |
| 193 | result: '', |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 194 | builder: null |
| 195 | }; |
| 196 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 197 | var DB_SPECIFIC_INVALIDATING_PARAMETERS = { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 198 | 'tests' : 'builder', |
| 199 | 'testType': 'builder', |
| 200 | 'group': 'builder' |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 201 | }; |
| 202 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 203 | var flakinessConfig = { |
| 204 | defaultStateValues: defaultDashboardSpecificStateValues, |
| 205 | generatePage: generatePage, |
| 206 | handleValidHashParameter: handleValidHashParameter, |
| 207 | handleQueryParameterChange: handleQueryParameterChange, |
| 208 | invalidatingHashParameters: DB_SPECIFIC_INVALIDATING_PARAMETERS |
| 209 | }; |
| 210 | |
| 211 | // FIXME(jparent): Eventually remove all usage of global history object. |
| 212 | var g_history = new history.History(flakinessConfig); |
| 213 | g_history.parseCrossDashboardParameters(); |
| 214 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 215 | ////////////////////////////////////////////////////////////////////////////// |
| 216 | // GLOBALS |
| 217 | ////////////////////////////////////////////////////////////////////////////// |
| 218 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 219 | var g_perBuilderFailures = {}; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 220 | // Maps test path to an array of {builder, testResults} objects. |
| 221 | var g_testToResultsMap = {}; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 222 | |
| 223 | function createResultsObjectForTest(test, builder) |
| 224 | { |
| 225 | return { |
| 226 | test: test, |
| 227 | builder: builder, |
| 228 | // HTML for display of the results in the flakiness column |
| 229 | html: '', |
| 230 | flips: 0, |
| 231 | slowestTime: 0, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 232 | isFlaky: false, |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 233 | bugs: [], |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 234 | expectations : '', |
| 235 | rawResults: '', |
| 236 | // List of all the results the test actually has. |
| 237 | actualResults: [] |
| 238 | }; |
| 239 | } |
| 240 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 241 | var TestTrie = function(builders, resultsByBuilder) |
| 242 | { |
| 243 | this._trie = {}; |
| 244 | |
| 245 | for (var builder in builders) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 246 | if (!resultsByBuilder[builder]) { |
| 247 | console.warn("No results for builder: ", builder) |
| 248 | continue; |
| 249 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 250 | var testsForBuilder = resultsByBuilder[builder].tests; |
| 251 | for (var test in testsForBuilder) |
| 252 | this._addTest(test.split('/'), this._trie); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | TestTrie.prototype.forEach = function(callback, startingTriePath) |
| 257 | { |
| 258 | var testsTrie = this._trie; |
| 259 | if (startingTriePath) { |
| 260 | var splitPath = startingTriePath.split('/'); |
| 261 | while (splitPath.length && testsTrie) |
| 262 | testsTrie = testsTrie[splitPath.shift()]; |
| 263 | } |
| 264 | |
| 265 | if (!testsTrie) |
| 266 | return; |
| 267 | |
| 268 | function traverse(trie, triePath) { |
| 269 | if (trie == true) |
| 270 | callback(triePath); |
| 271 | else { |
| 272 | for (var member in trie) |
| 273 | traverse(trie[member], triePath ? triePath + '/' + member : member); |
| 274 | } |
| 275 | } |
| 276 | traverse(testsTrie, startingTriePath); |
| 277 | } |
| 278 | |
| 279 | TestTrie.prototype._addTest = function(test, trie) |
| 280 | { |
| 281 | var rootComponent = test.shift(); |
| 282 | if (!test.length) { |
| 283 | if (!trie[rootComponent]) |
| 284 | trie[rootComponent] = true; |
| 285 | return; |
| 286 | } |
| 287 | |
| 288 | if (!trie[rootComponent] || trie[rootComponent] == true) |
| 289 | trie[rootComponent] = {}; |
| 290 | this._addTest(test, trie[rootComponent]); |
| 291 | } |
| 292 | |
| 293 | // Map of all tests to true values. This is just so we can have the list of |
| 294 | // all tests across all the builders. |
| 295 | var g_allTestsTrie; |
| 296 | |
| 297 | function getAllTestsTrie() |
| 298 | { |
| 299 | if (!g_allTestsTrie) |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 300 | g_allTestsTrie = new TestTrie(currentBuilders(), g_resultsByBuilder); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 301 | |
| 302 | return g_allTestsTrie; |
| 303 | } |
| 304 | |
| 305 | // Returns an array of tests to be displayed in the individual tests view. |
| 306 | // Note that a directory can be listed as a test, so we expand that into all |
| 307 | // tests in the directory. |
| 308 | function individualTests() |
| 309 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 310 | if (g_history.dashboardSpecificState.result) |
| 311 | return allTestsWithResult(g_history.dashboardSpecificState.result); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 312 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 313 | if (!g_history.dashboardSpecificState.tests) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 314 | return []; |
| 315 | |
| 316 | return individualTestsForSubstringList(); |
| 317 | } |
| 318 | |
| 319 | function substringList() |
| 320 | { |
| 321 | // Convert windows slashes to unix slashes. |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 322 | var tests = g_history.dashboardSpecificState.tests.replace(/\\/g, '/'); |
| 323 | var separator = string.contains(tests, ' ') ? ' ' : ','; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 324 | var testList = tests.split(separator); |
| 325 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 326 | if (g_history.isLayoutTestResults()) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 327 | return testList; |
| 328 | |
| 329 | var testListWithoutModifiers = []; |
| 330 | testList.forEach(function(path) { |
| 331 | GTEST_MODIFIERS.forEach(function(modifier) { |
| 332 | path = path.replace('.' + modifier + '_', '.'); |
| 333 | }); |
| 334 | testListWithoutModifiers.push(path); |
| 335 | }); |
| 336 | return testListWithoutModifiers; |
| 337 | } |
| 338 | |
| 339 | function individualTestsForSubstringList() |
| 340 | { |
| 341 | var testList = substringList(); |
| 342 | |
| 343 | // Put the tests into an object first and then move them into an array |
| 344 | // as a way of deduping. |
| 345 | var testsMap = {}; |
| 346 | for (var i = 0; i < testList.length; i++) { |
| 347 | var path = testList[i]; |
| 348 | |
| 349 | // Ignore whitespace entries as they'd match every test. |
| 350 | if (path.match(/^\s*$/)) |
| 351 | continue; |
| 352 | |
| 353 | var hasAnyMatches = false; |
| 354 | getAllTestsTrie().forEach(function(triePath) { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 355 | if (string.caseInsensitiveContains(triePath, path)) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 356 | testsMap[triePath] = 1; |
| 357 | hasAnyMatches = true; |
| 358 | } |
| 359 | }); |
| 360 | |
| 361 | // If a path doesn't match any tests, then assume it's a full path |
| 362 | // to a test that passes on all builders. |
| 363 | if (!hasAnyMatches) |
| 364 | testsMap[path] = 1; |
| 365 | } |
| 366 | |
| 367 | var testsArray = []; |
| 368 | for (var test in testsMap) |
| 369 | testsArray.push(test); |
| 370 | return testsArray; |
| 371 | } |
| 372 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 373 | function allTestsWithResult(result) |
| 374 | { |
| 375 | processTestRunsForAllBuilders(); |
| 376 | var retVal = []; |
| 377 | |
| 378 | getAllTestsTrie().forEach(function(triePath) { |
| 379 | for (var i = 0; i < g_testToResultsMap[triePath].length; i++) { |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 380 | if (g_testToResultsMap[triePath][i].actualResults.indexOf(result.toUpperCase()) != -1) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 381 | retVal.push(triePath); |
| 382 | break; |
| 383 | } |
| 384 | } |
| 385 | }); |
| 386 | |
| 387 | return retVal; |
| 388 | } |
| 389 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 390 | function processTestResultsForBuilderAsync(builder) |
| 391 | { |
| 392 | setTimeout(function() { processTestRunsForBuilder(builder); }, 0); |
| 393 | } |
| 394 | |
| 395 | function processTestRunsForAllBuilders() |
| 396 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 397 | for (var builder in currentBuilders()) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 398 | processTestRunsForBuilder(builder); |
| 399 | } |
| 400 | |
| 401 | function processTestRunsForBuilder(builderName) |
| 402 | { |
| 403 | if (g_perBuilderFailures[builderName]) |
| 404 | return; |
| 405 | |
| 406 | if (!g_resultsByBuilder[builderName]) { |
| 407 | console.error('No tests found for ' + builderName); |
| 408 | g_perBuilderFailures[builderName] = []; |
| 409 | return; |
| 410 | } |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 411 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 412 | var failures = []; |
| 413 | var allTestsForThisBuilder = g_resultsByBuilder[builderName].tests; |
| 414 | |
| 415 | for (var test in allTestsForThisBuilder) { |
| 416 | var resultsForTest = createResultsObjectForTest(test, builderName); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 417 | |
| 418 | var rawTest = g_resultsByBuilder[builderName].tests[test]; |
| 419 | resultsForTest.rawTimes = rawTest.times; |
| 420 | var rawResults = rawTest.results; |
| 421 | resultsForTest.rawResults = rawResults; |
| 422 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 423 | if (rawTest.expected) |
| 424 | resultsForTest.expectations = rawTest.expected; |
| 425 | |
| 426 | if (rawTest.bugs) |
| 427 | resultsForTest.bugs = rawTest.bugs; |
| 428 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 429 | var failureMap = g_resultsByBuilder[builderName][results.FAILURE_MAP]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 430 | // FIXME: Switch to resultsByBuild |
| 431 | var times = resultsForTest.rawTimes; |
| 432 | var numTimesSeen = 0; |
| 433 | var numResultsSeen = 0; |
| 434 | var resultsIndex = 0; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 435 | var resultsMap = {} |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 436 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 437 | for (var i = 0; i < times.length; i++) { |
| 438 | numTimesSeen += times[i][results.RLE.LENGTH]; |
| 439 | |
| 440 | while (rawResults[resultsIndex] && numTimesSeen > (numResultsSeen + rawResults[resultsIndex][results.RLE.LENGTH])) { |
| 441 | numResultsSeen += rawResults[resultsIndex][results.RLE.LENGTH]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 442 | resultsIndex++; |
| 443 | } |
| 444 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 445 | if (rawResults && rawResults[resultsIndex]) { |
| 446 | var result = rawResults[resultsIndex][results.RLE.VALUE]; |
| 447 | resultsMap[failureMap[result]] = true; |
| 448 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 449 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 450 | resultsForTest.slowestTime = Math.max(resultsForTest.slowestTime, times[i][results.RLE.VALUE]); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 453 | resultsForTest.actualResults = Object.keys(resultsMap); |
| 454 | |
| 455 | results.determineFlakiness(failureMap, rawResults, resultsForTest); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 456 | failures.push(resultsForTest); |
| 457 | |
| 458 | if (!g_testToResultsMap[test]) |
| 459 | g_testToResultsMap[test] = []; |
| 460 | g_testToResultsMap[test].push(resultsForTest); |
| 461 | } |
| 462 | |
| 463 | g_perBuilderFailures[builderName] = failures; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 464 | } |
| 465 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 466 | function linkHTMLToOpenWindow(url, text) |
| 467 | { |
| 468 | return '<a href="' + url + '" target="_blank">' + text + '</a>'; |
| 469 | } |
| 470 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 471 | // Returns whether the result for index'th result for testName on builder was |
| 472 | // a failure. |
| 473 | function isFailure(builder, testName, index) |
| 474 | { |
| 475 | var currentIndex = 0; |
| 476 | var rawResults = g_resultsByBuilder[builder].tests[testName].results; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 477 | var failureMap = g_resultsByBuilder[builder][results.FAILURE_MAP]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 478 | for (var i = 0; i < rawResults.length; i++) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 479 | currentIndex += rawResults[i][results.RLE.LENGTH]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 480 | if (currentIndex > index) |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 481 | return results.isFailingResult(failureMap, rawResults[i][results.RLE.VALUE]); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 482 | } |
| 483 | console.error('Index exceeds number of results: ' + index); |
| 484 | } |
| 485 | |
| 486 | // Returns an array of indexes for all builds where this test failed. |
| 487 | function indexesForFailures(builder, testName) |
| 488 | { |
| 489 | var rawResults = g_resultsByBuilder[builder].tests[testName].results; |
| 490 | var buildNumbers = g_resultsByBuilder[builder].buildNumbers; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 491 | var failureMap = g_resultsByBuilder[builder][results.FAILURE_MAP]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 492 | var index = 0; |
| 493 | var failures = []; |
| 494 | for (var i = 0; i < rawResults.length; i++) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 495 | var numResults = rawResults[i][results.RLE.LENGTH]; |
| 496 | if (results.isFailingResult(failureMap, rawResults[i][results.RLE.VALUE])) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 497 | for (var j = 0; j < numResults; j++) |
| 498 | failures.push(index + j); |
| 499 | } |
| 500 | index += numResults; |
| 501 | } |
| 502 | return failures; |
| 503 | } |
| 504 | |
| 505 | // Returns the path to the failure log for this non-webkit test. |
| 506 | function pathToFailureLog(testName) |
| 507 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 508 | return '/steps/' + g_history.crossDashboardState.testType + '/logs/' + testName.split('.')[1] |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | function showPopupForBuild(e, builder, index, opt_testName) |
| 512 | { |
| 513 | var html = ''; |
| 514 | |
| 515 | var time = g_resultsByBuilder[builder].secondsSinceEpoch[index]; |
| 516 | if (time) { |
| 517 | var date = new Date(time * 1000); |
| 518 | html += date.toLocaleDateString() + ' ' + date.toLocaleTimeString(); |
| 519 | } |
| 520 | |
| 521 | var buildNumber = g_resultsByBuilder[builder].buildNumbers[index]; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 522 | var master = builders.master(builder); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 523 | var buildBasePath = master.logPath(builder, buildNumber); |
| 524 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 525 | html += '<ul><li>' + linkHTMLToOpenWindow(buildBasePath, 'Build log'); |
| 526 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 527 | if (g_resultsByBuilder[builder][results.BLINK_REVISIONS]) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 528 | html += '</li><li>Blink: ' + ui.html.blinkRevisionLink(g_resultsByBuilder[builder], index) + '</li>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 529 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 530 | html += '</li><li>Chromium: ' + ui.html.chromiumRevisionLink(g_resultsByBuilder[builder], index) + '</li>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 531 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 532 | var chromeRevision = g_resultsByBuilder[builder].chromeRevision[index]; |
| 533 | if (chromeRevision && g_history.isLayoutTestResults()) { |
| 534 | html += '<li><a href="' + TEST_RESULTS_BASE_PATH + currentBuilders()[builder] + |
| 535 | '/' + chromeRevision + '/layout-test-results.zip">layout-test-results.zip</a></li>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 536 | } |
| 537 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 538 | if (!g_history.isLayoutTestResults() && opt_testName && isFailure(builder, opt_testName, index)) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 539 | html += '<li>' + linkHTMLToOpenWindow(buildBasePath + pathToFailureLog(opt_testName), 'Failure log') + '</li>'; |
| 540 | |
| 541 | html += '</ul>'; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 542 | ui.popup.show(e.target, html); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 543 | } |
| 544 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 545 | function classNameForFailureString(failure) |
| 546 | { |
| 547 | return failure.replace(/(\+|\ )/, ''); |
| 548 | } |
| 549 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 550 | function htmlForTestResults(test) |
| 551 | { |
| 552 | var html = ''; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 553 | var testResults = test.rawResults.concat(); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 554 | var times = test.rawTimes.concat(); |
| 555 | var builder = test.builder; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 556 | var master = builders.master(builder); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 557 | var buildNumbers = g_resultsByBuilder[builder].buildNumbers; |
| 558 | |
| 559 | var indexToReplaceCurrentResult = -1; |
| 560 | var indexToReplaceCurrentTime = -1; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 561 | for (var i = 0; i < buildNumbers.length; i++) { |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 562 | var currentResultArray, currentTimeArray, innerHTML, resultString; |
| 563 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 564 | if (i > indexToReplaceCurrentResult) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 565 | currentResultArray = testResults.shift(); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 566 | if (currentResultArray) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 567 | resultString = g_resultsByBuilder[builder][results.FAILURE_MAP][currentResultArray[results.RLE.VALUE]]; |
| 568 | indexToReplaceCurrentResult += currentResultArray[results.RLE.LENGTH]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 569 | } else { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 570 | resultString = results.NO_DATA; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 571 | indexToReplaceCurrentResult += buildNumbers.length; |
| 572 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | if (i > indexToReplaceCurrentTime) { |
| 576 | currentTimeArray = times.shift(); |
| 577 | var currentTime = 0; |
| 578 | if (currentResultArray) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 579 | currentTime = currentTimeArray[results.RLE.VALUE]; |
| 580 | indexToReplaceCurrentTime += currentTimeArray[results.RLE.LENGTH]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 581 | } else |
| 582 | indexToReplaceCurrentTime += buildNumbers.length; |
| 583 | |
| 584 | innerHTML = currentTime || ' '; |
| 585 | } |
| 586 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 587 | html += '<td title="' + resultString + '. Click for more info." class="results ' + classNameForFailureString(resultString) + |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 588 | '" onclick=\'showPopupForBuild(event, "' + builder + '",' + i + ',"' + test.test + '")\'>' + innerHTML; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 589 | } |
| 590 | return html; |
| 591 | } |
| 592 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 593 | function shouldShowTest(testResult) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 594 | { |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 595 | if (!g_history.isLayoutTestResults()) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 596 | return true; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 597 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 598 | if (testResult.expectations == 'WONTFIX') |
| 599 | return g_history.dashboardSpecificState.showWontFix; |
| 600 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 601 | if (testResult.expectations == results.SKIP) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 602 | return g_history.dashboardSpecificState.showSkip; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 603 | |
| 604 | if (testResult.isFlaky) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 605 | return g_history.dashboardSpecificState.showFlaky; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 606 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 607 | return g_history.dashboardSpecificState.showNonFlaky; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | function createBugHTML(test) |
| 611 | { |
| 612 | var symptom = test.isFlaky ? 'flaky' : 'failing'; |
| 613 | var title = encodeURIComponent('Layout Test ' + test.test + ' is ' + symptom); |
| 614 | var description = encodeURIComponent('The following layout test is ' + symptom + ' on ' + |
| 615 | '[insert platform]\n\n' + test.test + '\n\nProbable cause:\n\n' + |
| 616 | '[insert probable cause]'); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 617 | |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 618 | url = 'https://code.google.com/p/chromium/issues/entry?template=Layout%20Test%20Failure&summary=' + title + '&comment=' + description; |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 619 | return '<a href="' + url + '">File new bug</a>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | function isCrossBuilderView() |
| 623 | { |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 624 | return g_history.dashboardSpecificState.tests || g_history.dashboardSpecificState.result; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | function tableHeaders(opt_getAll) |
| 628 | { |
| 629 | var headers = []; |
| 630 | if (isCrossBuilderView() || opt_getAll) |
| 631 | headers.push('builder'); |
| 632 | |
| 633 | if (!isCrossBuilderView() || opt_getAll) |
| 634 | headers.push('test'); |
| 635 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 636 | if (g_history.isLayoutTestResults() || opt_getAll) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 637 | headers.push('bugs', 'expectations'); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 638 | |
| 639 | headers.push('slowest run', 'flakiness (numbers are runtimes in seconds)'); |
| 640 | return headers; |
| 641 | } |
| 642 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 643 | function linkifyBugs(bugs) |
| 644 | { |
| 645 | var html = ''; |
| 646 | bugs.forEach(function(bug) { |
| 647 | var bugHtml; |
| 648 | if (string.startsWith(bug, 'Bug(')) |
| 649 | bugHtml = bug; |
| 650 | else |
| 651 | bugHtml = '<a href="http://' + bug + '">' + bug + '</a>'; |
| 652 | html += '<div>' + bugHtml + '</div>' |
| 653 | }); |
| 654 | return html; |
| 655 | } |
| 656 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 657 | function htmlForSingleTestRow(test) |
| 658 | { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 659 | var headers = tableHeaders(); |
| 660 | var html = ''; |
| 661 | for (var i = 0; i < headers.length; i++) { |
| 662 | var header = headers[i]; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 663 | if (string.startsWith(header, 'test') || string.startsWith(header, 'builder')) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 664 | // If isCrossBuilderView() is true, we're just viewing a single test |
| 665 | // with results for many builders, so the first column is builder names |
| 666 | // instead of test paths. |
| 667 | var testCellClassName = 'test-link' + (isCrossBuilderView() ? ' builder-name' : ''); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 668 | var testCellHTML = isCrossBuilderView() ? test.builder : '<span class="link" onclick="g_history.setQueryParameter(\'tests\',\'' + test.test +'\');">' + test.test + '</span>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 669 | |
| 670 | html += '<tr><td class="' + testCellClassName + '">' + testCellHTML; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 671 | } else if (string.startsWith(header, 'bugs')) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 672 | // FIXME: linkify bugs. |
| 673 | html += '<td class=options-container>' + (linkifyBugs(test.bugs) || createBugHTML(test)); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 674 | else if (string.startsWith(header, 'expectations')) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 675 | html += '<td class=options-container>' + test.expectations; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 676 | else if (string.startsWith(header, 'slowest')) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 677 | html += '<td>' + (test.slowestTime ? test.slowestTime + 's' : ''); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 678 | else if (string.startsWith(header, 'flakiness')) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 679 | html += htmlForTestResults(test); |
| 680 | } |
| 681 | return html; |
| 682 | } |
| 683 | |
| 684 | function sortColumnFromTableHeader(headerText) |
| 685 | { |
| 686 | return headerText.split(' ', 1)[0]; |
| 687 | } |
| 688 | |
| 689 | function htmlForTableColumnHeader(headerName, opt_fillColSpan) |
| 690 | { |
| 691 | // Use the first word of the header title as the sortkey |
| 692 | var thisSortValue = sortColumnFromTableHeader(headerName); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 693 | var arrowHTML = thisSortValue == g_history.dashboardSpecificState.sortColumn ? |
| 694 | '<span class=' + g_history.dashboardSpecificState.sortOrder + '>' + (g_history.dashboardSpecificState.sortOrder == FORWARD ? '↑' : '↓' ) + '</span>' : ''; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 695 | return '<th sortValue=' + thisSortValue + |
| 696 | // Extend last th through all the rest of the columns. |
| 697 | (opt_fillColSpan ? ' colspan=10000' : '') + |
| 698 | // Extra span here is so flex boxing actually centers. |
| 699 | // There's probably a better way to do this with CSS only though. |
| 700 | '><div class=table-header-content><span></span>' + arrowHTML + |
| 701 | '<span class=header-text>' + headerName + '</span>' + arrowHTML + '</div></th>'; |
| 702 | } |
| 703 | |
| 704 | function htmlForTestTable(rowsHTML, opt_excludeHeaders) |
| 705 | { |
| 706 | var html = '<table class=test-table>'; |
| 707 | if (!opt_excludeHeaders) { |
| 708 | html += '<thead><tr>'; |
| 709 | var headers = tableHeaders(); |
| 710 | for (var i = 0; i < headers.length; i++) |
| 711 | html += htmlForTableColumnHeader(headers[i], i == headers.length - 1); |
| 712 | html += '</tr></thead>'; |
| 713 | } |
| 714 | return html + '<tbody>' + rowsHTML + '</tbody></table>'; |
| 715 | } |
| 716 | |
| 717 | function appendHTML(html) |
| 718 | { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 719 | // InnerHTML to a div that's not in the document. This is |
| 720 | // ~300ms faster in Safari 4 and Chrome 4 on mac. |
| 721 | var div = document.createElement('div'); |
| 722 | div.innerHTML = html; |
| 723 | document.body.appendChild(div); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 724 | postHeightChangedMessage(); |
| 725 | } |
| 726 | |
| 727 | function alphanumericCompare(column, reverse) |
| 728 | { |
| 729 | return reversibleCompareFunction(function(a, b) { |
| 730 | // Put null entries at the bottom |
| 731 | var a = a[column] ? String(a[column]) : 'z'; |
| 732 | var b = b[column] ? String(b[column]) : 'z'; |
| 733 | |
| 734 | if (a < b) |
| 735 | return -1; |
| 736 | else if (a == b) |
| 737 | return 0; |
| 738 | else |
| 739 | return 1; |
| 740 | }, reverse); |
| 741 | } |
| 742 | |
| 743 | function numericSort(column, reverse) |
| 744 | { |
| 745 | return reversibleCompareFunction(function(a, b) { |
| 746 | a = parseFloat(a[column]); |
| 747 | b = parseFloat(b[column]); |
| 748 | return a - b; |
| 749 | }, reverse); |
| 750 | } |
| 751 | |
| 752 | function reversibleCompareFunction(compare, reverse) |
| 753 | { |
| 754 | return function(a, b) { |
| 755 | return compare(reverse ? b : a, reverse ? a : b); |
| 756 | }; |
| 757 | } |
| 758 | |
| 759 | function changeSort(e) |
| 760 | { |
| 761 | var target = e.currentTarget; |
| 762 | e.preventDefault(); |
| 763 | |
| 764 | var sortValue = target.getAttribute('sortValue'); |
| 765 | while (target && target.tagName != 'TABLE') |
| 766 | target = target.parentNode; |
| 767 | |
| 768 | var sort = 'sortColumn'; |
| 769 | var orderKey = 'sortOrder'; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 770 | if (sortValue == g_history.dashboardSpecificState[sort] && g_history.dashboardSpecificState[orderKey] == FORWARD) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 771 | order = BACKWARD; |
| 772 | else |
| 773 | order = FORWARD; |
| 774 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 775 | g_history.setQueryParameter(sort, sortValue, orderKey, order); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 776 | } |
| 777 | |
| 778 | function sortTests(tests, column, order) |
| 779 | { |
| 780 | var resultsProperty, sortFunctionGetter; |
| 781 | if (column == 'flakiness') { |
| 782 | sortFunctionGetter = numericSort; |
| 783 | resultsProperty = 'flips'; |
| 784 | } else if (column == 'slowest') { |
| 785 | sortFunctionGetter = numericSort; |
| 786 | resultsProperty = 'slowestTime'; |
| 787 | } else { |
| 788 | sortFunctionGetter = alphanumericCompare; |
| 789 | resultsProperty = column; |
| 790 | } |
| 791 | |
| 792 | tests.sort(sortFunctionGetter(resultsProperty, order == BACKWARD)); |
| 793 | } |
| 794 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 795 | function htmlForIndividualTestOnAllBuilders(test) |
| 796 | { |
| 797 | processTestRunsForAllBuilders(); |
| 798 | |
| 799 | var testResults = g_testToResultsMap[test]; |
| 800 | if (!testResults) |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 801 | return '<div class="not-found">Test not found. Either it does not exist, is skipped or passes on all recorded runs.</div>'; |
| 802 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 803 | var html = ''; |
| 804 | var shownBuilders = []; |
| 805 | for (var j = 0; j < testResults.length; j++) { |
| 806 | shownBuilders.push(testResults[j].builder); |
| 807 | html += htmlForSingleTestRow(testResults[j]); |
| 808 | } |
| 809 | |
| 810 | var skippedBuilders = [] |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 811 | for (builder in currentBuilders()) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 812 | if (shownBuilders.indexOf(builder) == -1) |
| 813 | skippedBuilders.push(builder); |
| 814 | } |
| 815 | |
| 816 | var skippedBuildersHtml = ''; |
| 817 | if (skippedBuilders.length) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 818 | skippedBuildersHtml = '<div>The following builders either don\'t run this test (e.g. it\'s skipped) or all recorded runs passed:</div>' + |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 819 | '<div class=skipped-builder-list><div class=skipped-builder>' + skippedBuilders.join('</div><div class=skipped-builder>') + '</div></div>'; |
| 820 | } |
| 821 | |
| 822 | return htmlForTestTable(html) + skippedBuildersHtml; |
| 823 | } |
| 824 | |
| 825 | function htmlForIndividualTestOnAllBuildersWithResultsLinks(test) |
| 826 | { |
| 827 | processTestRunsForAllBuilders(); |
| 828 | |
| 829 | var testResults = g_testToResultsMap[test]; |
| 830 | var html = ''; |
| 831 | html += htmlForIndividualTestOnAllBuilders(test); |
| 832 | |
| 833 | html += '<div class=expectations test=' + test + '><div>' + |
| 834 | linkHTMLToToggleState('showExpectations', 'results') |
| 835 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 836 | if (g_history.isLayoutTestResults() || g_history.isGPUTestResults()) { |
| 837 | if (g_history.isLayoutTestResults()) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 838 | html += ' | ' + linkHTMLToToggleState('showLargeExpectations', 'large thumbnails'); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 839 | html += ' | <b>Only shows actual results/diffs from the most recent *failure* on each bot.</b>'; |
| 840 | } else { |
| 841 | html += ' | <span>Results height:<input ' + |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 842 | 'onchange="g_history.setQueryParameter(\'resultsHeight\',this.value)" value="' + |
| 843 | g_history.dashboardSpecificState.resultsHeight + '" style="width:2.5em">px</span>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 844 | } |
| 845 | html += '</div></div>'; |
| 846 | return html; |
| 847 | } |
| 848 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 849 | function maybeAddPngChecksum(expectationDiv, pngUrl) |
| 850 | { |
| 851 | // pngUrl gets served from the browser cache since we just loaded it in an |
| 852 | // <img> tag. |
| 853 | loader.request(pngUrl, |
| 854 | function(xhr) { |
| 855 | // Convert the first 2k of the response to a byte string. |
| 856 | var bytes = xhr.responseText.substring(0, 2048); |
| 857 | for (var position = 0; position < bytes.length; ++position) |
| 858 | bytes[position] = bytes[position] & 0xff; |
| 859 | |
| 860 | // Look for the comment. |
| 861 | var commentKey = 'tEXtchecksum\x00'; |
| 862 | var checksumPosition = bytes.indexOf(commentKey); |
| 863 | if (checksumPosition == -1) |
| 864 | return; |
| 865 | |
| 866 | var checksum = bytes.substring(checksumPosition + commentKey.length, checksumPosition + commentKey.length + 32); |
| 867 | var checksumContainer = document.createElement('span'); |
| 868 | checksumContainer.innerText = 'Embedded checksum: ' + checksum; |
| 869 | checksumContainer.setAttribute('class', 'pngchecksum'); |
| 870 | expectationDiv.parentNode.appendChild(checksumContainer); |
| 871 | }, |
| 872 | function(xhr) {}, |
| 873 | true); |
| 874 | } |
| 875 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 876 | function getOrCreate(className, parent) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 877 | { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 878 | var element = parent.querySelector('.' + className); |
| 879 | if (!element) { |
| 880 | element = document.createElement('div'); |
| 881 | element.className = className; |
| 882 | parent.appendChild(element); |
| 883 | } |
| 884 | return element; |
| 885 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 886 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 887 | function handleExpectationsItemLoad(title, item, itemType, parent) |
| 888 | { |
| 889 | item.className = 'expectation'; |
| 890 | if (g_history.dashboardSpecificState.showLargeExpectations) |
| 891 | item.className += ' large'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 892 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 893 | var titleContainer = document.createElement('h3'); |
| 894 | titleContainer.className = 'expectations-title'; |
| 895 | titleContainer.textContent = title; |
| 896 | |
| 897 | var itemContainer = document.createElement('span'); |
| 898 | itemContainer.appendChild(titleContainer); |
| 899 | itemContainer.className = 'expectations-item ' + title; |
| 900 | itemContainer.appendChild(item); |
| 901 | |
| 902 | // Separate text and image results into separate divs.. |
| 903 | var typeContainer = getOrCreate(itemType, parent); |
| 904 | |
| 905 | // Insert results in a consistent order. |
| 906 | var index = EXPECTATIONS_ORDER.indexOf(title); |
| 907 | while (index < EXPECTATIONS_ORDER.length) { |
| 908 | index++; |
| 909 | var elementAfter = typeContainer.querySelector('.' + EXPECTATIONS_ORDER[index]); |
| 910 | if (elementAfter) { |
| 911 | typeContainer.insertBefore(itemContainer, elementAfter); |
| 912 | break; |
| 913 | } |
| 914 | } |
| 915 | if (!itemContainer.parentNode) |
| 916 | typeContainer.appendChild(itemContainer); |
| 917 | |
| 918 | handleFinishedLoadingExpectations(parent); |
| 919 | } |
| 920 | |
| 921 | function addExpectationItem(expectationsContainers, parentContainer, url, opt_builder) |
| 922 | { |
| 923 | // Group expectations by builder, putting test and reference files first. |
| 924 | var builder = opt_builder || "Test and reference files"; |
| 925 | var container = expectationsContainers[builder]; |
| 926 | |
| 927 | if (!container) { |
| 928 | container = document.createElement('div'); |
| 929 | container.className = 'expectations-container'; |
| 930 | container.setAttribute('data-builder', builder); |
| 931 | parentContainer.appendChild(container); |
| 932 | expectationsContainers[builder] = container; |
| 933 | } |
| 934 | |
| 935 | var numUnloaded = container.getAttribute('data-unloaded') || 0; |
| 936 | container.setAttribute('data-unloaded', ++numUnloaded); |
| 937 | |
| 938 | var isImage = url.match(/\.png$/); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 939 | |
| 940 | var appendExpectationsItem = function(item) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 941 | var itemType = isImage ? 'image' : 'text'; |
| 942 | handleExpectationsItemLoad(expectationsTitle(url), item, itemType, container); |
| 943 | }; |
| 944 | |
| 945 | var handleLoadError = function() { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 946 | handleFinishedLoadingExpectations(container); |
| 947 | }; |
| 948 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 949 | if (isImage) { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 950 | var dummyNode = document.createElement('img'); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 951 | dummyNode.onload = function() { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 952 | var item = dummyNode; |
| 953 | maybeAddPngChecksum(item, url); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 954 | appendExpectationsItem(item); |
| 955 | } |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 956 | dummyNode.onerror = handleLoadError; |
| 957 | dummyNode.src = url; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 958 | } else { |
| 959 | loader.request(url, |
| 960 | function(xhr) { |
| 961 | var item = document.createElement('pre'); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 962 | if (string.endsWith(url, '-wdiff.html')) |
| 963 | item.innerHTML = xhr.responseText; |
| 964 | else |
| 965 | item.textContent = xhr.responseText; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 966 | appendExpectationsItem(item); |
| 967 | }, |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 968 | handleLoadError); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 969 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 970 | } |
| 971 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 972 | function handleFinishedLoadingExpectations(container) |
| 973 | { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 974 | var numUnloaded = container.getAttribute('data-unloaded') - 1; |
| 975 | container.setAttribute('data-unloaded', numUnloaded); |
| 976 | if (numUnloaded) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 977 | return; |
| 978 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 979 | if (!container.firstChild) { |
| 980 | container.remove(); |
| 981 | return; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 982 | } |
| 983 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 984 | var builder = container.getAttribute('data-builder'); |
| 985 | if (!builder) |
| 986 | return; |
| 987 | |
| 988 | var header = document.createElement('h2'); |
| 989 | header.textContent = builder; |
| 990 | container.insertBefore(header, container.firstChild); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 991 | } |
| 992 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 993 | function expectationsTitle(url) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 994 | { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 995 | var matchingSuffixes = ACTUAL_RESULT_SUFFIXES.filter(function(suffix) { |
| 996 | return string.endsWith(url, suffix); |
| 997 | }); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 998 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 999 | if (matchingSuffixes.length) |
| 1000 | return matchingSuffixes[0].split('.')[0]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1001 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1002 | var parts = url.split('/'); |
| 1003 | return parts[parts.length - 1]; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1004 | } |
| 1005 | |
| 1006 | function loadExpectations(expectationsContainer) |
| 1007 | { |
| 1008 | var test = expectationsContainer.getAttribute('test'); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1009 | if (g_history.isLayoutTestResults()) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1010 | loadExpectationsLayoutTests(test, expectationsContainer); |
| 1011 | else { |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1012 | var testResults = g_testToResultsMap[test]; |
| 1013 | for (var i = 0; i < testResults.length; i++) |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1014 | if (g_history.isGPUTestResults()) |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1015 | loadGPUResultsForBuilder(testResults[i].builder, test, expectationsContainer); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1016 | else |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1017 | loadNonWebKitResultsForBuilder(testResults[i].builder, test, expectationsContainer); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | function gpuResultsPath(chromeRevision, builder) |
| 1022 | { |
| 1023 | return chromeRevision + '_' + builder.replace(/[^A-Za-z0-9]+/g, '_'); |
| 1024 | } |
| 1025 | |
| 1026 | function loadGPUResultsForBuilder(builder, test, expectationsContainer) |
| 1027 | { |
| 1028 | var container = document.createElement('div'); |
| 1029 | container.className = 'expectations-container'; |
| 1030 | container.innerHTML = '<div><b>' + builder + '</b></div>'; |
| 1031 | expectationsContainer.appendChild(container); |
| 1032 | |
| 1033 | var failureIndex = indexesForFailures(builder, test)[0]; |
| 1034 | |
| 1035 | var buildNumber = g_resultsByBuilder[builder].buildNumbers[failureIndex]; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1036 | var pathToLog = builders.master(builder).logPath(builder, buildNumber) + pathToFailureLog(test); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1037 | |
| 1038 | var chromeRevision = g_resultsByBuilder[builder].chromeRevision[failureIndex]; |
| 1039 | var resultsUrl = GPU_RESULTS_BASE_PATH + gpuResultsPath(chromeRevision, builder); |
| 1040 | var filename = test.split(/\./)[1] + '.png'; |
| 1041 | |
| 1042 | appendNonWebKitResults(container, pathToLog, 'non-webkit-results'); |
| 1043 | appendNonWebKitResults(container, resultsUrl + '/gen/' + filename, 'gpu-test-results', 'Generated'); |
| 1044 | appendNonWebKitResults(container, resultsUrl + '/ref/' + filename, 'gpu-test-results', 'Reference'); |
| 1045 | appendNonWebKitResults(container, resultsUrl + '/diff/' + filename, 'gpu-test-results', 'Diff'); |
| 1046 | } |
| 1047 | |
| 1048 | function loadNonWebKitResultsForBuilder(builder, test, expectationsContainer) |
| 1049 | { |
| 1050 | var failureIndexes = indexesForFailures(builder, test); |
| 1051 | var container = document.createElement('div'); |
| 1052 | container.innerHTML = '<div><b>' + builder + '</b></div>'; |
| 1053 | expectationsContainer.appendChild(container); |
| 1054 | for (var i = 0; i < failureIndexes.length; i++) { |
| 1055 | // FIXME: This doesn't seem to work anymore. Did the paths change? |
| 1056 | // Once that's resolved, see if we need to try each GTEST_MODIFIERS prefix as well. |
| 1057 | var buildNumber = g_resultsByBuilder[builder].buildNumbers[failureIndexes[i]]; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1058 | var pathToLog = builders.master(builder).logPath(builder, buildNumber) + pathToFailureLog(test); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1059 | appendNonWebKitResults(container, pathToLog, 'non-webkit-results'); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | function appendNonWebKitResults(container, url, itemClassName, opt_title) |
| 1064 | { |
| 1065 | // Use a script tag to detect whether the URL 404s. |
| 1066 | // Need to use a script tag since the URL is cross-domain. |
| 1067 | var dummyNode = document.createElement('script'); |
| 1068 | dummyNode.src = url; |
| 1069 | |
| 1070 | dummyNode.onload = function() { |
| 1071 | var item = document.createElement('iframe'); |
| 1072 | item.src = dummyNode.src; |
| 1073 | item.className = itemClassName; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1074 | item.style.height = g_history.dashboardSpecificState.resultsHeight + 'px'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1075 | |
| 1076 | if (opt_title) { |
| 1077 | var childContainer = document.createElement('div'); |
| 1078 | childContainer.style.display = 'inline-block'; |
| 1079 | var title = document.createElement('div'); |
| 1080 | title.textContent = opt_title; |
| 1081 | childContainer.appendChild(title); |
| 1082 | childContainer.appendChild(item); |
| 1083 | container.replaceChild(childContainer, dummyNode); |
| 1084 | } else |
| 1085 | container.replaceChild(item, dummyNode); |
| 1086 | } |
| 1087 | dummyNode.onerror = function() { |
| 1088 | container.removeChild(dummyNode); |
| 1089 | } |
| 1090 | |
| 1091 | container.appendChild(dummyNode); |
| 1092 | } |
| 1093 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1094 | function lookupVirtualTestSuite(test) { |
| 1095 | for (var suite in VIRTUAL_SUITES) { |
| 1096 | if (test.indexOf(suite) != -1) |
| 1097 | return suite; |
| 1098 | } |
| 1099 | return ''; |
| 1100 | } |
| 1101 | |
| 1102 | function baseTest(test, suite) { |
| 1103 | base = VIRTUAL_SUITES[suite]; |
| 1104 | return base ? test.replace(suite, base) : test; |
| 1105 | } |
| 1106 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1107 | function loadTestAndReferenceFiles(expectationsContainers, expectationsContainer, test) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1108 | var testWithoutSuffix = test.substring(0, test.lastIndexOf('.')); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1109 | var reftest_html_file = testWithoutSuffix + "-expected.html"; |
| 1110 | var reftest_mismatch_html_file = testWithoutSuffix + "-expected-mismatch.html"; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1111 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1112 | var suite = lookupVirtualTestSuite(test); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1113 | if (suite) { |
| 1114 | loadTestAndReferenceFiles(expectationsContainers, expectationsContainer, baseTest(test, suite)); |
| 1115 | return; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1116 | } |
| 1117 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1118 | addExpectationItem(expectationsContainers, expectationsContainer, TEST_URL_BASE_PATH_FOR_XHR + test); |
| 1119 | addExpectationItem(expectationsContainers, expectationsContainer, TEST_URL_BASE_PATH_FOR_XHR + reftest_html_file); |
| 1120 | addExpectationItem(expectationsContainers, expectationsContainer, TEST_URL_BASE_PATH_FOR_XHR + reftest_mismatch_html_file); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1121 | } |
| 1122 | |
| 1123 | function loadExpectationsLayoutTests(test, expectationsContainer) |
| 1124 | { |
| 1125 | // Map from file extension to container div for expectations of that type. |
| 1126 | var expectationsContainers = {}; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1127 | loadTestAndReferenceFiles(expectationsContainers, expectationsContainer, test); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1128 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1129 | var testWithoutSuffix = test.substring(0, test.lastIndexOf('.')); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1130 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1131 | for (var builder in currentBuilders()) { |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 1132 | var actualResultsBase = TEST_RESULTS_BASE_PATH + currentBuilders()[builder] + '/results/layout-test-results/'; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1133 | ACTUAL_RESULT_SUFFIXES.forEach(function(suffix) {{ |
| 1134 | addExpectationItem(expectationsContainers, expectationsContainer, actualResultsBase + testWithoutSuffix + '-' + suffix, builder); |
| 1135 | }}) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | // Add a clearing element so floated elements don't bleed out of their |
| 1139 | // containing block. |
| 1140 | var br = document.createElement('br'); |
| 1141 | br.style.clear = 'both'; |
| 1142 | expectationsContainer.appendChild(br); |
| 1143 | } |
| 1144 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1145 | function appendExpectations() |
| 1146 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1147 | var expectations = g_history.dashboardSpecificState.showExpectations ? document.getElementsByClassName('expectations') : []; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1148 | // Loading expectations is *very* slow. Use a large timeout to avoid |
| 1149 | // totally hanging the renderer. |
| 1150 | performChunkedAction(expectations, function(chunk) { |
| 1151 | for (var i = 0, len = chunk.length; i < len; i++) |
| 1152 | loadExpectations(chunk[i]); |
| 1153 | postHeightChangedMessage(); |
| 1154 | |
| 1155 | }, hideLoadingUI, 10000); |
| 1156 | } |
| 1157 | |
| 1158 | function hideLoadingUI() |
| 1159 | { |
| 1160 | var loadingDiv = $('loading-ui'); |
| 1161 | if (loadingDiv) |
| 1162 | loadingDiv.style.display = 'none'; |
| 1163 | postHeightChangedMessage(); |
| 1164 | } |
| 1165 | |
| 1166 | function generatePageForIndividualTests(tests) |
| 1167 | { |
| 1168 | console.log('Number of tests: ' + tests.length); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1169 | if (g_history.dashboardSpecificState.showChrome) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1170 | appendHTML(htmlForNavBar()); |
| 1171 | performChunkedAction(tests, function(chunk) { |
| 1172 | appendHTML(htmlForIndividualTests(chunk)); |
| 1173 | }, appendExpectations, 500); |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1174 | if (g_history.dashboardSpecificState.showChrome) { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1175 | $('tests-input').value = g_history.dashboardSpecificState.tests; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1176 | $('result-input').value = g_history.dashboardSpecificState.result; |
| 1177 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1178 | } |
| 1179 | |
| 1180 | function performChunkedAction(tests, handleChunk, onComplete, timeout, opt_index) { |
| 1181 | var index = opt_index || 0; |
| 1182 | setTimeout(function() { |
| 1183 | var chunk = Array.prototype.slice.call(tests, index * CHUNK_SIZE, (index + 1) * CHUNK_SIZE); |
| 1184 | if (chunk.length) { |
| 1185 | handleChunk(chunk); |
| 1186 | performChunkedAction(tests, handleChunk, onComplete, timeout, ++index); |
| 1187 | } else |
| 1188 | onComplete(); |
| 1189 | // No need for a timeout on the first chunked action. |
| 1190 | }, index ? timeout : 0); |
| 1191 | } |
| 1192 | |
| 1193 | function htmlForIndividualTests(tests) |
| 1194 | { |
| 1195 | var testsHTML = []; |
| 1196 | for (var i = 0; i < tests.length; i++) { |
| 1197 | var test = tests[i]; |
| 1198 | var testNameHtml = ''; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1199 | if (g_history.dashboardSpecificState.showChrome || tests.length > 1) { |
| 1200 | if (g_history.isLayoutTestResults()) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1201 | var suite = lookupVirtualTestSuite(test); |
| 1202 | var base = suite ? baseTest(test, suite) : test; |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1203 | var versionControlUrl = TEST_URL_BASE_PATH_FOR_BROWSING + base; |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 1204 | testNameHtml += '<h2>' + linkHTMLToOpenWindow(versionControlUrl, test) + '</h2>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1205 | } else |
| 1206 | testNameHtml += '<h2>' + test + '</h2>'; |
| 1207 | } |
| 1208 | |
| 1209 | testsHTML.push(testNameHtml + htmlForIndividualTestOnAllBuildersWithResultsLinks(test)); |
| 1210 | } |
| 1211 | return testsHTML.join('<hr>'); |
| 1212 | } |
| 1213 | |
| 1214 | function htmlForNavBar() |
| 1215 | { |
| 1216 | var extraHTML = ''; |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1217 | var html = ui.html.testTypeSwitcher(false, extraHTML, isCrossBuilderView()); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1218 | html += '<div class=forms><form id=result-form ' + |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1219 | 'onsubmit="g_history.setQueryParameter(\'result\', result.value);' + |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1220 | 'return false;">Show all tests with result: ' + |
| 1221 | '<input name=result placeholder="e.g. CRASH" id=result-input>' + |
| 1222 | '</form><form id=tests-form ' + |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1223 | 'onsubmit="g_history.setQueryParameter(\'tests\', tests.value);' + |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1224 | 'return false;"><span>Show tests on all platforms: </span>' + |
| 1225 | '<input name=tests ' + |
| 1226 | 'placeholder="Comma or space-separated list of tests or partial ' + |
| 1227 | 'paths to show test results across all builders, e.g., ' + |
| 1228 | 'foo/bar.html,foo/baz,domstorage" id=tests-input></form>' + |
| 1229 | '<span class=link onclick="showLegend()">Show legend [type ?]</span></div>'; |
| 1230 | return html; |
| 1231 | } |
| 1232 | |
| 1233 | function checkBoxToToggleState(key, text) |
| 1234 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1235 | var stateEnabled = g_history.dashboardSpecificState[key]; |
| 1236 | return '<label><input type=checkbox ' + (stateEnabled ? 'checked ' : '') + 'onclick="g_history.setQueryParameter(\'' + key + '\', ' + !stateEnabled + ')">' + text + '</label> '; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1237 | } |
| 1238 | |
| 1239 | function linkHTMLToToggleState(key, linkText) |
| 1240 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1241 | var stateEnabled = g_history.dashboardSpecificState[key]; |
| 1242 | return '<span class=link onclick="g_history.setQueryParameter(\'' + key + '\', ' + !stateEnabled + ')">' + (stateEnabled ? 'Hide' : 'Show') + ' ' + linkText + '</span>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | function headerForTestTableHtml() |
| 1246 | { |
| 1247 | return '<h2 style="display:inline-block">Failing tests</h2>' + |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1248 | checkBoxToToggleState('showFlaky', 'Show flaky') + |
| 1249 | checkBoxToToggleState('showNonFlaky', 'Show non-flaky') + |
| 1250 | checkBoxToToggleState('showSkip', 'Show Skip') + |
| 1251 | checkBoxToToggleState('showWontFix', 'Show WontFix'); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1252 | } |
| 1253 | |
| 1254 | function generatePageForBuilder(builderName) |
| 1255 | { |
| 1256 | processTestRunsForBuilder(builderName); |
| 1257 | |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1258 | var filteredResults = g_perBuilderFailures[builderName].filter(shouldShowTest); |
| 1259 | sortTests(filteredResults, g_history.dashboardSpecificState.sortColumn, g_history.dashboardSpecificState.sortOrder); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1260 | |
| 1261 | var testsHTML = ''; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1262 | if (filteredResults.length) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1263 | var tableRowsHTML = ''; |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1264 | for (var i = 0; i < filteredResults.length; i++) |
| 1265 | tableRowsHTML += htmlForSingleTestRow(filteredResults[i]) |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1266 | testsHTML = htmlForTestTable(tableRowsHTML); |
| 1267 | } else { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1268 | if (g_history.isLayoutTestResults()) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1269 | testsHTML += '<div>Fill in one of the text inputs or checkboxes above to show failures.</div>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1270 | else |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1271 | testsHTML += '<div>No tests have failed!</div>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | var html = htmlForNavBar(); |
| 1275 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1276 | if (g_history.isLayoutTestResults()) |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1277 | html += headerForTestTableHtml(); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1278 | |
| 1279 | html += '<br>' + testsHTML; |
| 1280 | appendHTML(html); |
| 1281 | |
| 1282 | var ths = document.getElementsByTagName('th'); |
| 1283 | for (var i = 0; i < ths.length; i++) { |
| 1284 | ths[i].addEventListener('click', changeSort, false); |
| 1285 | ths[i].className = "sortable"; |
| 1286 | } |
| 1287 | |
| 1288 | hideLoadingUI(); |
| 1289 | } |
| 1290 | |
| 1291 | var VALID_KEYS_FOR_CROSS_BUILDER_VIEW = { |
| 1292 | tests: 1, |
| 1293 | result: 1, |
| 1294 | showChrome: 1, |
| 1295 | showExpectations: 1, |
| 1296 | showLargeExpectations: 1, |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1297 | resultsHeight: 1, |
| 1298 | revision: 1 |
| 1299 | }; |
| 1300 | |
| 1301 | function isInvalidKeyForCrossBuilderView(key) |
| 1302 | { |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1303 | return !(key in VALID_KEYS_FOR_CROSS_BUILDER_VIEW) && !(key in history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1304 | } |
| 1305 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1306 | function hideLegend() |
| 1307 | { |
| 1308 | var legend = $('legend'); |
| 1309 | if (legend) |
| 1310 | legend.parentNode.removeChild(legend); |
| 1311 | } |
| 1312 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1313 | function showLegend() |
| 1314 | { |
| 1315 | var legend = $('legend'); |
| 1316 | if (!legend) { |
| 1317 | legend = document.createElement('div'); |
| 1318 | legend.id = 'legend'; |
| 1319 | document.body.appendChild(legend); |
| 1320 | } |
| 1321 | |
| 1322 | var html = '<div id=legend-toggle onclick="hideLegend()">Hide ' + |
| 1323 | 'legend [type esc]</div><div id=legend-contents>'; |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1324 | |
| 1325 | // Just grab the first failureMap. Technically, different builders can have different maps if they |
| 1326 | // haven't all cycled after the map was changed, but meh. |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1327 | var failureMap = g_resultsByBuilder[Object.keys(g_resultsByBuilder)[0]][results.FAILURE_MAP]; |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1328 | for (var expectation in failureMap) { |
| 1329 | var failureString = failureMap[expectation]; |
| 1330 | html += '<div class=' + classNameForFailureString(failureString) + '>' + failureString + '</div>'; |
| 1331 | } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1332 | |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1333 | if (g_history.isLayoutTestResults()) { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1334 | html += '</div><br style="clear:both">' + |
Torne (Richard Coles) | 5267f70 | 2013-06-11 10:57:24 +0100 | [diff] [blame^] | 1335 | '</div>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1336 | |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1337 | html += '<div>RELEASE TIMEOUTS:</div>' + |
| 1338 | htmlForSlowTimes(RELEASE_TIMEOUT) + |
| 1339 | '<div>DEBUG TIMEOUTS:</div>' + |
| 1340 | htmlForSlowTimes(DEBUG_TIMEOUT); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1341 | } |
| 1342 | |
| 1343 | legend.innerHTML = html; |
| 1344 | } |
| 1345 | |
| 1346 | function htmlForSlowTimes(minTime) |
| 1347 | { |
Torne (Richard Coles) | 93ac45c | 2013-05-29 14:40:20 +0100 | [diff] [blame] | 1348 | return '<ul><li>' + minTime + ' seconds</li><li>' + |
| 1349 | SLOW_MULTIPLIER * minTime + ' seconds if marked Slow in TestExpectations</li></ul>'; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | function postHeightChangedMessage() |
| 1353 | { |
| 1354 | if (window == parent) |
| 1355 | return; |
| 1356 | |
| 1357 | var root = document.documentElement; |
| 1358 | var height = root.offsetHeight; |
| 1359 | if (root.offsetWidth < root.scrollWidth) { |
| 1360 | // We have a horizontal scrollbar. Include it in the height. |
| 1361 | var dummyNode = document.createElement('div'); |
| 1362 | dummyNode.style.overflow = 'scroll'; |
| 1363 | document.body.appendChild(dummyNode); |
| 1364 | var scrollbarWidth = dummyNode.offsetHeight - dummyNode.clientHeight; |
| 1365 | document.body.removeChild(dummyNode); |
| 1366 | height += scrollbarWidth; |
| 1367 | } |
| 1368 | parent.postMessage({command: 'heightChanged', height: height}, '*') |
| 1369 | } |
| 1370 | |
| 1371 | if (window != parent) |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1372 | window.addEventListener('blur', ui.popup.hide); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1373 | |
| 1374 | document.addEventListener('keydown', function(e) { |
| 1375 | if (e.keyIdentifier == 'U+003F' || e.keyIdentifier == 'U+00BF') { |
| 1376 | // WebKit MAC retursn 3F. WebKit WIN returns BF. This is a bug! |
| 1377 | // ? key |
| 1378 | showLegend(); |
| 1379 | } else if (e.keyIdentifier == 'U+001B') { |
| 1380 | // escape key |
| 1381 | hideLegend(); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1382 | ui.popup.hide(); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 1383 | } |
| 1384 | }, false); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1385 | |
| 1386 | window.addEventListener('load', function() { |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 1387 | resourceLoader = new loader.Loader(); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 1388 | resourceLoader.load(); |
| 1389 | }, false); |