Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui.js

Issue 13712005: Move GardeningServer out of BuildSlaveSupport (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 var ui = ui || {};
27
28 (function () {
29
30 ui.displayURLForBuilder = function(builderName)
31 {
32 return config.kPlatforms[config.currentPlatform].waterfallURL + '?' + $.para m({
33 'builder': builderName
34 });
35 }
36
37 ui.displayNameForBuilder = function(builderName)
38 {
39 return builderName.replace(/Webkit /, '');
40 }
41
42 ui.urlForTest = function(testName)
43 {
44 return 'http://trac.webkit.org/browser/trunk/LayoutTests/' + testName;
45 }
46
47 ui.urlForFlakinessDashboard = function(opt_testNameList)
48 {
49 var testsParameter = opt_testNameList ? opt_testNameList.join(',') : '';
50 return 'http://test-results.appspot.com/dashboards/flakiness_dashboard.html# tests=' + encodeURIComponent(testsParameter);
51 }
52
53 ui.urlForEmbeddedFlakinessDashboard = function(opt_testNameList)
54 {
55 if (config.kPlatforms[config.currentPlatform].useFlakinessDashboard)
56 return ui.urlForFlakinessDashboard(opt_testNameList) + '&showChrome=fals e';
57
58 return 'about:blank';
59 }
60
61 ui.rolloutReasonForTestNameList = function(testNameList)
62 {
63 return 'Broke:\n' + testNameList.map(function(testName) {
64 return '* ' + testName;
65 }).join('\n');
66 }
67
68 ui.onebar = base.extends('div', {
69 init: function()
70 {
71 this.id = 'onebar';
72 this.innerHTML =
73 '<div><select id="platform-picker"></select></div>' +
74 '<ul>' +
75 '<li><a href="#unexpected">Unexpected Failures</a></li>' +
76 '<li><a href="#expected">Expected Failures</a></li>' +
77 '<li><a href="#results">Results</a></li>' +
78 '<li><a href="#perf">perf</a></li>' +
79 '</ul>' +
80 '<div id="unexpected"></div>' +
81 '<div id="expected"></div>' +
82 '<div id="results"></div>' +
83 '<div id="perf"></div>';
84 this._tabNames = [
85 'unexpected',
86 'expected',
87 'results',
88 'perf',
89 ]
90
91 this._tabIndexToSavedScrollOffset = {};
92 this._tabs = $(this).tabs({
93 disabled: [2],
94 show: function(event, ui) { this._restoreScrollOffset(ui.index); },
95 });
96 },
97 _buildPlatformsPopup: function() {
98 // FIXME: find a better place to do this.
99 var urlPlatform = base.getURLParameter('platform');
100 if (urlPlatform)
101 config.setPlatform(urlPlatform);
102
103 var platformSelect = document.getElementById('platform-picker');
104 var currentPlatformIndex = 0;
105 Object.keys(config.kPlatforms).sort().forEach(function(platformName) {
106 var option = document.createElement('option');
107 option.innerText = config.kPlatforms[platformName].label;
108 option._platform = platformName;
109 if (platformName == config.currentPlatform)
110 currentPlatformIndex = platformSelect.childNodes.length;
111 platformSelect.appendChild(option);
112 });
113
114 platformSelect.addEventListener('change', function() {
115 window.location.search = '?platform=' + platformSelect.options[platf ormSelect.selectedIndex]._platform;
116 });
117
118 platformSelect.selectedIndex = currentPlatformIndex;
119 },
120 _saveScrollOffset: function() {
121 var tabIndex = this._tabs.tabs('option', 'selected');
122 this._tabIndexToSavedScrollOffset[tabIndex] = document.body.scrollTop;
123 },
124 _restoreScrollOffset: function(tabIndex)
125 {
126 document.body.scrollTop = this._tabIndexToSavedScrollOffset[tabIndex] || 0;
127 },
128 _setupHistoryHandlers: function()
129 {
130 function currentHash() {
131 var hash = window.location.hash;
132 return (!hash || hash == '#') ? '#unexpected' : hash;
133 }
134
135 var self = this;
136 $('.ui-tabs-nav a').bind('mouseup', function(event) {
137 var href = event.target.getAttribute('href');
138 var hash = currentHash();
139 if (href != hash) {
140 self._saveScrollOffset();
141 window.location = href
142 }
143 });
144
145 window.onhashchange = function(event) {
146 var tabName = currentHash().substring(1);
147 self._selectInternal(tabName);
148 };
149
150 // When navigating from the browser chrome, we'll
151 // scroll to the #tabname contents. popstate fires before
152 // we scroll, so we can save the scroll offset first.
153 window.onpopstate = function() {
154 self._saveScrollOffset();
155 };
156 },
157 attach: function()
158 {
159 document.body.insertBefore(this, document.body.firstChild);
160 this._setupHistoryHandlers();
161 this._buildPlatformsPopup();
162 },
163 tabNamed: function(tabName)
164 {
165 if (this._tabNames.indexOf(tabName) == -1)
166 return null;
167 tab = document.getElementById(tabName);
168 // We perform this sanity check below to make sure getElementById
169 // hasn't given us a node in some other unrelated part of the document.
170 // that shouldn't happen normally, but it could happen if an attacker
171 // has somehow sneakily added a node to our document.
172 if (tab.parentNode != this)
173 return null;
174 return tab;
175 },
176 unexpected: function()
177 {
178 return this.tabNamed('unexpected');
179 },
180 expected: function()
181 {
182 return this.tabNamed('expected');
183 },
184 results: function()
185 {
186 return this.tabNamed('results');
187 },
188 perf: function()
189 {
190 return this.tabNamed('perf');
191 },
192 _selectInternal: function(tabName) {
193 var tabIndex = this._tabNames.indexOf(tabName);
194 this._tabs.tabs('enable', tabIndex);
195 this._tabs.tabs('select', tabIndex);
196 },
197 select: function(tabName)
198 {
199 this._saveScrollOffset();
200 this._selectInternal(tabName);
201 window.location = '#' + tabName;
202 }
203 });
204
205 // FIXME: Loading a module shouldn't set off a timer. The controller should kic k this off.
206 setInterval(function() {
207 Array.prototype.forEach.call(document.querySelectorAll("time.relative"), fun ction(time) {
208 time.update && time.update();
209 });
210 }, config.kRelativeTimeUpdateFrequency);
211
212 ui.RelativeTime = base.extends('time', {
213 init: function()
214 {
215 this.className = 'relative';
216 },
217 date: function()
218 {
219 return this._date;
220 },
221 update: function()
222 {
223 this.textContent = this._date ? base.relativizeTime(this._date) : '';
224 },
225 setDate: function(date)
226 {
227 this._date = date;
228 this.update();
229 }
230 });
231
232 ui.StatusArea = base.extends('div', {
233 init: function()
234 {
235 // This is a Singleton.
236 if (ui.StatusArea._instance)
237 return ui.StatusArea._instance;
238 ui.StatusArea._instance = this;
239
240 this.className = 'status';
241 document.body.appendChild(this);
242 this._currentId = 0;
243 this._unfinishedIds = {};
244
245 this.appendChild(new ui.actions.List([new ui.actions.Close()]));
246 $(this).bind('close', this.close.bind(this));
247
248 var processing = document.createElement('progress');
249 processing.className = 'process-text';
250 processing.textContent = 'Processing...';
251 this.appendChild(processing);
252 },
253 close: function()
254 {
255 this.style.visibility = 'hidden';
256 Array.prototype.forEach.call(this.querySelectorAll('.status-content'), f unction(node) {
257 node.parentNode.removeChild(node);
258 });
259 },
260 addMessage: function(id, message)
261 {
262 this.style.visibility = 'visible';
263 $(this).addClass('processing');
264
265 var element = document.createElement('div');
266 $(element).addClass('message').text(message);
267
268 var content = this.querySelector('#' + id);
269 if (!content) {
270 content = document.createElement('div');
271 content.id = id;
272 content.className = 'status-content';
273 this.appendChild(content);
274 }
275
276 content.appendChild(element);
277 if (element.offsetTop < this.scrollTop || element.offsetTop + element.of fsetHeight > this.scrollTop + this.offsetHeight)
278 this.scrollTop = element.offsetTop;
279 },
280 // FIXME: It's unclear whether this code could live here or in a controller.
281 addFinalMessage: function(id, message)
282 {
283 this.addMessage(id, message);
284
285 delete this._unfinishedIds[id];
286 if (!Object.keys(this._unfinishedIds).length)
287 $(this).removeClass('processing');
288 },
289 newId: function() {
290 var id = 'status-content-' + ++this._currentId;
291 this._unfinishedIds[id] = 1;
292 return id;
293 }
294 });
295
296 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698