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

This commit is contained in:
Geoff Lankow 2013-06-04 19:55:48 +12:00
parent 734ac3b797
commit f639a552c4
5 changed files with 60 additions and 37 deletions

View File

@ -415,9 +415,9 @@ 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 "status", "method", "file", "domain", "type", "size" or "waterfall".
*/
sortBy: function(aType) {
sortBy: function(aType = "waterfall") {
let target = $("#requests-menu-" + aType + "-button");
let headers = document.querySelectorAll(".requests-menu-header-button");
@ -430,24 +430,17 @@ create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, {
let direction = "";
if (target) {
if (!target.hasAttribute("sorted")) {
target.setAttribute("sorted", direction = "ascending");
target.setAttribute("tooltiptext", L10N.getStr("networkMenu.sortedAsc"));
} else if (target.getAttribute("sorted") == "ascending") {
if (target.getAttribute("sorted") == "ascending") {
target.setAttribute("sorted", direction = "descending");
target.setAttribute("tooltiptext", L10N.getStr("networkMenu.sortedDesc"));
} else {
target.removeAttribute("sorted");
target.removeAttribute("tooltiptext");
target.setAttribute("sorted", direction = "ascending");
target.setAttribute("tooltiptext", L10N.getStr("networkMenu.sortedAsc"));
}
}
// Sort by timing.
if (!target || !direction) {
this.sortContents(this._byTiming);
}
// Sort by whatever was requested.
else switch (aType) {
switch (aType) {
case "status":
if (direction == "ascending") {
this.sortContents(this._byStatus);
@ -490,6 +483,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 +924,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,19 @@
</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"
class="plain requests-menu-waterfall"
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

@ -68,9 +68,8 @@ function test() {
});
function resetSorting() {
for (let i = 0; i < 3; i++) {
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
}
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
}
function testButtons(aFilterType) {

View File

@ -143,7 +143,7 @@ function test() {
})
.then(() => {
info("Clearing sort.");
RequestsMenu.sortBy(null);
RequestsMenu.sortBy();
return testContents([0, 1, 2, 3, 4]);
})
.then(() => {

View File

@ -43,10 +43,10 @@ function test() {
return testContents([4, 3, 2, 1, 0]);
})
.then(() => {
info("Clearing status sort.");
info("Testing status sort, ascending. Checking sort loops correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-status-button"));
testHeaders();
return testContents([0, 2, 4, 3, 1]);
testHeaders("status", "ascending");
return testContents([0, 1, 2, 3, 4]);
})
.then(() => {
info("Testing method sort, ascending.");
@ -61,10 +61,10 @@ function test() {
return testContents([4, 3, 2, 1, 0]);
})
.then(() => {
info("Clearing method sort.");
info("Testing method sort, ascending. Checking sort loops correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-method-button"));
testHeaders();
return testContents([0, 2, 4, 3, 1]);
testHeaders("method", "ascending");
return testContents([0, 1, 2, 3, 4]);
})
.then(() => {
info("Testing file sort, ascending.");
@ -79,10 +79,10 @@ function test() {
return testContents([4, 3, 2, 1, 0]);
})
.then(() => {
info("Clearing file sort.");
info("Testing file sort, ascending. Checking sort loops correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-file-button"));
testHeaders();
return testContents([0, 2, 4, 3, 1]);
testHeaders("file", "ascending");
return testContents([0, 1, 2, 3, 4]);
})
.then(() => {
info("Testing type sort, ascending.");
@ -97,10 +97,10 @@ function test() {
return testContents([4, 3, 2, 1, 0]);
})
.then(() => {
info("Clearing type sort.");
info("Testing type sort, ascending. Checking sort loops correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-type-button"));
testHeaders();
return testContents([0, 2, 4, 3, 1]);
testHeaders("type", "ascending");
return testContents([0, 1, 2, 3, 4]);
})
.then(() => {
info("Testing size sort, ascending.");
@ -115,9 +115,27 @@ function test() {
return testContents([4, 3, 2, 1, 0]);
})
.then(() => {
info("Clearing size sort.");
info("Testing size sort, ascending. Checking sort loops correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-size-button"));
testHeaders();
testHeaders("size", "ascending");
return testContents([0, 1, 2, 3, 4]);
})
.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.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
testHeaders("waterfall", "descending");
return testContents([4, 2, 0, 1, 3]);
})
.then(() => {
info("Testing waterfall sort, ascending. Checking sort loops correctly.");
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-waterfall-button"));
testHeaders("waterfall", "ascending");
return testContents([0, 2, 4, 3, 1]);
})
.then(() => {