Commit 43bc186e authored by aroben@apple.com's avatar aroben@apple.com

Show a list of up to 10 recent leaky builds when Leaks Viewer loads

Fixes <http://webkit.org/b/56043> Leaks Viewer should present a list of recent builds to
analyze

Reviewed by David Kilzer and Joe Pecoraro.

* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/LeaksViewer.css:
(#url-prompt): Made this a bit taller to make room for the list of builds.

(#recent-builds-loading-indicator):
(#recent-builds-list):
Added styles for the build list and loading indicator.

* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/LeaksViewer.js:
(LeaksViewer.loaded): Pass the URL from the query through decodeURIComponent before loading
it. This will unescape it.
(LeaksViewer.urlPromptButtonClicked): Moved code from here to _urlChosenFromPrompt.
(LeaksViewer._didLoadRecentBuilds): Added. Stores the builds and updates the prompt.
(LeaksViewer._displayURLPrompt): Start loading the recent leaky builds.
(LeaksViewer._updateURLPrompt): Create a list of the recent leaky builds and add them to the
prompt UI.
(LeaksViewer._urlChosenFromPrompt): Added. Code came from urlPromptButtonClicked. This is
now also used when a recent build is clicked.

* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/RecentBuildsLoader.js: Added.
(RecentBuildsLoader): Store the callback.
(RecentBuildsLoader.prototype.start): Load the N most recent builds from the specified
builder. Find the revision number, leak count, and results URL for each one. Pass the
resulting info to our callback.

* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/Utilities.js:
(range): Added this helper function to return an array containing the integers [0, n).

* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/index.html: Added
RecentBuildsLoader.js and added text to the prompt UI to show the recent builds.

git-svn-id: svn://svn.chromium.org/blink/trunk@81068 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6ae22cd9
......@@ -40,7 +40,7 @@
left: 0;
right: 0;
width: 400px;
height: 200px;
height: 300px;
margin: auto;
background-color: white;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.8);
......@@ -64,6 +64,16 @@
margin-left: 5px;
}
#recent-builds-loading-indicator {
color: gray;
}
#recent-builds-list {
list-style: none;
margin: 0;
padding: 0;
}
.percent-time-status-bar-item {
/* We always show leak counts as real values, not percentages, so this button isn't useful. */
display: none !important;
......
......@@ -47,7 +47,7 @@ var LeaksViewer = {
var url;
var match = /url=([^&]+)/.exec(location.search);
if (match)
url = match[1];
url = decodeURIComponent(match[1]);
if (url)
this._loadLeaksFromURL(url)
......@@ -92,8 +92,7 @@ var LeaksViewer = {
},
urlPromptButtonClicked: function(e) {
this._loadLeaksFromURL(document.getElementById("url").value);
document.getElementById("url-prompt-container").addStyleClass("hidden");
this._urlChosenFromPrompt(document.getElementById("url").value);
},
_didCountLeaksFiles: function(fileCount) {
......@@ -105,6 +104,11 @@ var LeaksViewer = {
this._parser.addLeaksFile(leaksText);
},
_didLoadRecentBuilds: function(builds) {
this._recentBuilds = builds;
this._updateURLPrompt();
},
_didParseLeaksFile: function(profile) {
if (--this.filesLeftToParse)
return;
......@@ -115,6 +119,8 @@ var LeaksViewer = {
_displayURLPrompt: function() {
document.getElementById("url-prompt-container").removeStyleClass("hidden");
document.getElementById("url").focus();
var loader = new RecentBuildsLoader(this._didLoadRecentBuilds.bind(this));
loader.start("SnowLeopard Intel Leaks", this._numberOfRecentBuildsToLoad);
},
_loadLeaksFromURL: function(url) {
......@@ -138,6 +144,8 @@ var LeaksViewer = {
this._updateTitle();
},
_numberOfRecentBuildsToLoad: 10,
_setLoadingIndicatorHidden: function(hidden) {
if (hidden)
this._loadingIndicator.addStyleClass("hidden");
......@@ -156,6 +164,39 @@ var LeaksViewer = {
title += this.url;
document.title = title;
},
_updateURLPrompt: function() {
var recentBuildsContainer = document.getElementById("recent-builds-container");
recentBuildsContainer.removeChildren();
if (this._recentBuilds && this._recentBuilds.length) {
var list = document.createElement("ol");
list.id = "recent-builds-list";
var self = this;
this._recentBuilds.forEach(function(build) {
var link = document.createElement("a");
link.href = document.location.href + "?url=" + encodeURIComponent(build.url);
link.addEventListener("click", function(e) {
self._urlChosenFromPrompt(build.url);
e.preventDefault();
});
link.appendChild(document.createTextNode("r" + build.revision + ": " + build.leakCount + " leaks"));
var item = document.createElement("li");
item.appendChild(link);
list.appendChild(item);
});
recentBuildsContainer.appendChild(list);
} else
recentBuildsContainer.appendChild(document.createTextNode("No recent leaky builds found."));
},
_urlChosenFromPrompt: function(url) {
this._loadLeaksFromURL(url);
document.getElementById("url-prompt-container").addStyleClass("hidden");
},
};
addEventListener("load", LeaksViewer.loaded.bind(LeaksViewer));
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
function RecentBuildsLoader(didLoadRecentBuildsCallback) {
this._didLoadRecentBuildsCallback = didLoadRecentBuildsCallback;
}
RecentBuildsLoader.prototype = {
start: function(builderName, maximumNumberOfBuilds) {
var url = this._buildbotBaseURL + "/json/builders/" + builderName + "/builds/?";
url += range(maximumNumberOfBuilds).map(function(n) { return "select=-" + (n + 1); }).join("&");
var self = this;
getResource(url, function(xhr) {
var data = JSON.parse(xhr.responseText);
var builds = [];
Object.keys(data).forEach(function(buildNumber) {
var build = data[buildNumber];
var buildInfo = {
revision: build.sourceStamp.changes[0].rev,
leakCount: 0,
url: null,
};
for (var stepIndex = 0; stepIndex < build.steps.length; ++stepIndex) {
var step = build.steps[stepIndex];
if (step.name === "layout-test") {
if (!("results" in step))
continue;
// The first item of results is a status code, the second is the status text.
var strings = step.results[1];
for (var stringIndex = 0; stringIndex < strings.length; ++stringIndex) {
var match = /^(\d+) total leaks found!$/.exec(strings[stringIndex]);
if (!match)
continue;
buildInfo.leakCount = parseInt(match[1], 10);
break;
}
} else if (step.name === "MasterShellCommand") {
if (!("urls" in step))
return;
if (!("view results" in step.urls))
return;
buildInfo.url = self._buildbotBaseURL + step.urls["view results"] + "/";
}
if (buildInfo.leakCount && buildInfo.url) {
builds.push(buildInfo);
break;
}
}
});
self._didLoadRecentBuildsCallback(builds);
});
},
_buildbotBaseURL: "http://build.webkit.org/",
};
......@@ -34,3 +34,9 @@ function getResource(url, callback) {
xhr.send();
}
function range(n) {
var result = new Array(n);
for (var i = 0; i < n; ++i)
result[i] = i;
return result;
}
......@@ -55,6 +55,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
<script src=LeaksLoader.js></script>
<script src=LeaksParser.js></script>
<script src=LeaksViewer.js></script>
<script src=RecentBuildsLoader.js></script>
<script src=Utilities.js></script>
</head>
<body>
......@@ -67,8 +68,12 @@ THE POSSIBILITY OF SUCH DAMAGE.
</div>
<div id=url-prompt-container class=hidden>
<div id=url-prompt>
<p>Please enter the URL of a build results page or leaks file:</p>
<p>Enter the URL of a build results page or leaks file:</p>
<input id=url type=url><button onclick='LeaksViewer.urlPromptButtonClicked(event)'>Fetch leaks</button>
<p>Or choose a recent build:</p>
<div id=recent-builds-container>
<p id=recent-builds-loading-indicator>Loading builds&hellip;</p>
</div>
</div>
</div>
</body>
......
2011-03-14 Adam Roben <aroben@apple.com>
Show a list of up to 10 recent leaky builds when Leaks Viewer loads
Fixes <http://webkit.org/b/56043> Leaks Viewer should present a list of recent builds to
analyze
Reviewed by David Kilzer and Joe Pecoraro.
* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/LeaksViewer.css:
(#url-prompt): Made this a bit taller to make room for the list of builds.
(#recent-builds-loading-indicator):
(#recent-builds-list):
Added styles for the build list and loading indicator.
* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/LeaksViewer.js:
(LeaksViewer.loaded): Pass the URL from the query through decodeURIComponent before loading
it. This will unescape it.
(LeaksViewer.urlPromptButtonClicked): Moved code from here to _urlChosenFromPrompt.
(LeaksViewer._didLoadRecentBuilds): Added. Stores the builds and updates the prompt.
(LeaksViewer._displayURLPrompt): Start loading the recent leaky builds.
(LeaksViewer._updateURLPrompt): Create a list of the recent leaky builds and add them to the
prompt UI.
(LeaksViewer._urlChosenFromPrompt): Added. Code came from urlPromptButtonClicked. This is
now also used when a recent build is clicked.
* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/RecentBuildsLoader.js: Added.
(RecentBuildsLoader): Store the callback.
(RecentBuildsLoader.prototype.start): Load the N most recent builds from the specified
builder. Find the revision number, leak count, and results URL for each one. Pass the
resulting info to our callback.
* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/Utilities.js:
(range): Added this helper function to return an array containing the integers [0, n).
* BuildSlaveSupport/build.webkit.org-config/public_html/LeaksViewer/index.html: Added
RecentBuildsLoader.js and added text to the prompt UI to show the recent builds.
2011-03-14 Mark Rowe <mrowe@apple.com>
Reviewed by Oliver Hunt.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment