Bug 1109764 - Correctly toggle the details view buttons in the performance tool. r=vp

This commit is contained in:
Jordan Santell 2014-12-10 14:45:00 +01:00
Родитель 3f9f2ff3bd
Коммит 91615d22fc
2 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -25,22 +25,20 @@ function spawnTest () {
is(viewName, "waterfall", "DETAILS_VIEW_SELECTED fired with view name");
checkViews(DetailsView, doc, "waterfall");
yield teardown(panel);
finish();
}
function checkViews (DetailsView, doc, currentView) {
for (let viewName in DetailsView.views) {
let view = DetailsView.views[viewName].el;
let button = doc.querySelector("toolbarbutton[data-view='" + viewName + "']");
for (let viewName in DetailsView.viewIndexes) {
let button = doc.querySelector(`toolbarbutton[data-view="${viewName}"]`);
is(DetailsView.el.selectedIndex, DetailsView.viewIndexes[currentView],
`DetailsView correctly has ${currentView} selected.`);
if (viewName === currentView) {
ok(!view.getAttribute("hidden"), view + " view displayed");
ok(button.getAttribute("checked"), view + " button checked");
ok(button.getAttribute("checked"), `${viewName} button checked`);
} else {
ok(view.getAttribute("hidden"), view + " view hidden");
ok(!button.getAttribute("checked"), view + " button not checked");
ok(!button.getAttribute("checked"), `${viewName} button not checked`);
}
}
}

Просмотреть файл

@ -45,6 +45,14 @@ let DetailsView = {
*/
selectView: function (selectedView) {
this.el.selectedIndex = this.viewIndexes[selectedView];
for (let button of $$("toolbarbutton[data-view]", $("#details-toolbar"))) {
if (button.getAttribute("data-view") === selectedView)
button.setAttribute("checked", true);
else
button.removeAttribute("checked");
}
this.emit(EVENTS.DETAILS_VIEW_SELECTED, selectedView);
},