зеркало из https://github.com/mozilla/gecko-dev.git
ctrlTab browser chrome test: make utility functions private to avoid naming conflicts
This commit is contained in:
Родитель
342cf1e320
Коммит
623eca0732
|
@ -31,48 +31,52 @@ function test() {
|
|||
ok(eventConsumed, "Ctrl+Tab consumed by the tabbed browser if one tab is open");
|
||||
is(focusedWindow.location, document.commandDispatcher.focusedWindow.location,
|
||||
"Ctrl+Tab doesn't change focus if one tab is open");
|
||||
}
|
||||
|
||||
function pressCtrlTab() EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
|
||||
function releaseCtrl() EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
|
||||
/* private utitily functions */
|
||||
function pressCtrlTab()
|
||||
EventUtils.synthesizeKey("VK_TAB", { ctrlKey: true });
|
||||
|
||||
function ctrlTabTest(tabsToSelect, tabTimes, expectedIndex) {
|
||||
tabsToSelect.forEach(function (index) {
|
||||
gBrowser.selectedTab = gBrowser.mTabs[index];
|
||||
});
|
||||
function releaseCtrl()
|
||||
EventUtils.synthesizeKey("VK_CONTROL", { type: "keyup" });
|
||||
|
||||
var indexStart = gBrowser.tabContainer.selectedIndex;
|
||||
var tabCount = gBrowser.mTabs.length;
|
||||
var normalized = tabTimes % tabCount;
|
||||
var where = normalized == 1 ? "back to the previously selected tab" :
|
||||
normalized + " tabs back in most-recently-selected order";
|
||||
function ctrlTabTest(tabsToSelect, tabTimes, expectedIndex) {
|
||||
tabsToSelect.forEach(function (index) {
|
||||
gBrowser.selectedTab = gBrowser.mTabs[index];
|
||||
});
|
||||
|
||||
for (let i = 0; i < tabTimes; i++) {
|
||||
pressCtrlTab();
|
||||
var indexStart = gBrowser.tabContainer.selectedIndex;
|
||||
var tabCount = gBrowser.mTabs.length;
|
||||
var normalized = tabTimes % tabCount;
|
||||
var where = normalized == 1 ? "back to the previously selected tab" :
|
||||
normalized + " tabs back in most-recently-selected order";
|
||||
|
||||
if (tabCount > 2)
|
||||
is(gBrowser.tabContainer.selectedIndex, indexStart,
|
||||
"Selected tab doesn't change while tabbing");
|
||||
for (let i = 0; i < tabTimes; i++) {
|
||||
pressCtrlTab();
|
||||
|
||||
if (tabCount > 2)
|
||||
is(gBrowser.tabContainer.selectedIndex, indexStart,
|
||||
"Selected tab doesn't change while tabbing");
|
||||
}
|
||||
|
||||
if (tabCount > 2) {
|
||||
ok(ctrlTab.panel.state == "showing" || ctrlTab.panel.state == "open",
|
||||
"With " + tabCount + " tabs open, Ctrl+Tab opens the preview panel");
|
||||
|
||||
is(ctrlTab.label.value, gBrowser.mTabs[expectedIndex].label,
|
||||
"Preview panel displays label of expected tab");
|
||||
|
||||
releaseCtrl();
|
||||
|
||||
ok(ctrlTab.panel.state == "hiding" || ctrlTab.panel.state == "closed",
|
||||
"Releasing Ctrl closes the preview panel");
|
||||
} else {
|
||||
ok(ctrlTab.panel.state == "hiding" || ctrlTab.panel.state == "closed",
|
||||
"With " + tabCount + " tabs open, Ctrl+Tab doesn't open the preview panel");
|
||||
}
|
||||
|
||||
is(gBrowser.tabContainer.selectedIndex, expectedIndex,
|
||||
"With "+ tabCount +" tabs open and tab " + indexStart
|
||||
+ " selected, Ctrl+Tab*" + tabTimes + " goes " + where);
|
||||
}
|
||||
|
||||
if (tabCount > 2) {
|
||||
ok(ctrlTab.panel.state == "showing" || ctrlTab.panel.state == "open",
|
||||
"With " + tabCount + " tabs open, Ctrl+Tab opens the preview panel");
|
||||
|
||||
is(ctrlTab.label.value, gBrowser.mTabs[expectedIndex].label,
|
||||
"Preview panel displays label of expected tab");
|
||||
|
||||
releaseCtrl();
|
||||
|
||||
ok(ctrlTab.panel.state == "hiding" || ctrlTab.panel.state == "closed",
|
||||
"Releasing Ctrl closes the preview panel");
|
||||
} else {
|
||||
ok(ctrlTab.panel.state == "hiding" || ctrlTab.panel.state == "closed",
|
||||
"With " + tabCount + " tabs open, Ctrl+Tab doesn't open the preview panel");
|
||||
}
|
||||
|
||||
is(gBrowser.tabContainer.selectedIndex, expectedIndex,
|
||||
"With "+ tabCount +" tabs open and tab " + indexStart
|
||||
+ " selected, Ctrl+Tab*" + tabTimes + " goes " + where);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче