Bug 874363 - The timeline header in the Netmonitor should be clickable; r=vporof

This commit is contained in:
Geoff Lankow 2013-06-04 20:07:09 +12:00
parent 863cef57d8
commit 2b57d4f7cd
3 changed files with 50 additions and 15 deletions

View File

@ -415,7 +415,7 @@ create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, {
* Sorts all network requests in this container by a specified detail.
*
* @param string aType
* Either null, "status", "method", "file", "domain", "type" or "size".
* Either null, "status", "method", "file", "domain", "type", "size" or "waterfall".
*/
sortBy: function(aType) {
let target = $("#requests-menu-" + aType + "-button");
@ -442,12 +442,17 @@ create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, {
}
}
// Sort by timing.
// Sort by timing. Set the header attributes so that clicking on the
// header reverses the sort direction.
if (!target || !direction) {
this.sortContents(this._byTiming);
aType = "waterfall";
target = $("#requests-menu-waterfall-button");
target.setAttribute("sorted", direction = "ascending");
target.setAttribute("tooltiptext", L10N.getStr("networkMenu.sortedAsc"));
}
// Sort by whatever was requested.
else switch (aType) {
switch (aType) {
case "status":
if (direction == "ascending") {
this.sortContents(this._byStatus);
@ -490,6 +495,13 @@ create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, {
this.sortContents((a, b) => !this._bySize(a, b));
}
break;
case "waterfall":
if (direction == "ascending") {
this.sortContents(this._byTiming);
} else {
this.sortContents((a, b) => !this._byTiming(a, b));
}
break;
}
},
@ -924,7 +936,7 @@ create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, {
* The current waterfall scale.
*/
_showWaterfallDivisionLabels: function(aScale) {
let container = $("#requests-menu-waterfall-header-box");
let container = $("#requests-menu-waterfall-button");
let availableWidth = this._waterfallWidth - REQUESTS_WATERFALL_SAFE_BOUNDS;
// Nuke all existing labels.

View File

@ -82,13 +82,18 @@
</hbox>
<hbox id="requests-menu-waterfall-header-box"
class="requests-menu-header requests-menu-waterfall"
align="center">
<label id="requests-menu-waterfall-label"
class="plain requests-menu-waterfall"
value="&netmonitorUI.toolbar.waterfall;"/>
align="center"
flex="1">
<button id="requests-menu-waterfall-button"
class="requests-menu-header-button requests-menu-waterfall"
onclick="NetMonitorView.RequestsMenu.sortBy('waterfall')"
pack="start"
flex="1">
<label id="requests-menu-waterfall-label"
value="&netmonitorUI.toolbar.waterfall;"/>
</button>
</hbox>
</hbox>
<spacer id="toolbar-spacer" flex="1"/>
<toolbarbutton id="details-pane-toggle"
class="devtools-toolbarbutton"
tooltiptext="&netmonitorUI.panesButton.tooltip;"

View File

@ -45,7 +45,7 @@ function test() {
.then(() => {
info("Clearing status sort.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
testHeaders();
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {
@ -63,7 +63,7 @@ function test() {
.then(() => {
info("Clearing method sort.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
testHeaders();
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {
@ -81,7 +81,7 @@ function test() {
.then(() => {
info("Clearing file sort.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
testHeaders();
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {
@ -99,7 +99,7 @@ function test() {
.then(() => {
info("Clearing type sort.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
testHeaders();
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {
@ -117,9 +117,27 @@ function test() {
.then(() => {
info("Clearing size sort.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
testHeaders();
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {
info("Testing waterfall sort, descending.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
testHeaders("waterfall", "descending");
return testContents([4, 2, 0, 1, 3]);
})
.then(() => {
info("Testing waterfall sort, ascending.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {
info("Testing waterfall sort, descending. Checking sort cycles correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
testHeaders("waterfall", "descending");
return testContents([4, 2, 0, 1, 3]);
})
.then(() => {
return teardown(aMonitor);
})