зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1183135
- Update tab position attributes when a tab becomes visually selected rather than synchronously when switching tabs. r=mconley
MozReview-Commit-ID: Lvf0edXlwTu --HG-- extra : rebase_source : ca5899905428ce3d295eeb0211f02b5799c908f2
This commit is contained in:
Родитель
c98b461048
Коммит
51eab9cbe5
|
@ -1074,8 +1074,6 @@ window._gBrowser = {
|
|||
updateUserContextUIIndicator();
|
||||
gIdentityHandler.updateSharingIndicator();
|
||||
|
||||
this.tabContainer._setPositionalAttributes();
|
||||
|
||||
// Enable touch events to start a native dragging
|
||||
// session to allow the user to easily drag the selected tab.
|
||||
// This is currently only supported on Windows.
|
||||
|
@ -1083,6 +1081,8 @@ window._gBrowser = {
|
|||
newTab.setAttribute("touchdownstartsdrag", "true");
|
||||
|
||||
if (!gMultiProcessBrowser) {
|
||||
this.tabContainer._setPositionalAttributes();
|
||||
|
||||
document.commandDispatcher.unlock();
|
||||
|
||||
let event = new CustomEvent("TabSwitchDone", {
|
||||
|
|
|
@ -266,7 +266,7 @@
|
|||
this._beforeSelectedTab.removeAttribute("beforeselected-visible");
|
||||
}
|
||||
|
||||
if (this.selectedItem.closing || selectedIndex == 0) {
|
||||
if (this.selectedItem.closing || selectedIndex <= 0) {
|
||||
this._beforeSelectedTab = null;
|
||||
} else {
|
||||
let beforeSelectedTab = visibleTabs[selectedIndex - 1];
|
||||
|
|
|
@ -23,6 +23,7 @@ skip-if = !e10s
|
|||
run-if = debug || devedition || nightly_build # Requires startupRecorder.js, which isn't shipped everywhere by default
|
||||
[browser_tabclose_grow.js]
|
||||
[browser_tabclose.js]
|
||||
skip-if = true # bug 1448497
|
||||
[browser_tabopen.js]
|
||||
[browser_tabopen_squeeze.js]
|
||||
[browser_tabstrip_overflow_underflow.js]
|
||||
|
|
|
@ -8,8 +8,13 @@ function addTab(aURL) {
|
|||
tabs.push(gBrowser.addTab(aURL, {skipAnimation: true}));
|
||||
}
|
||||
|
||||
function testAttrib(elem, attrib, attribValue, msg) {
|
||||
is(elem.hasAttribute(attrib), attribValue, msg);
|
||||
function switchTab(index) {
|
||||
return BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[index]);
|
||||
}
|
||||
|
||||
function testAttrib(tabIndex, attrib, expected) {
|
||||
is(gBrowser.tabs[tabIndex].hasAttribute(attrib), expected,
|
||||
`tab #${tabIndex} should${expected ? "" : "n't"} have the ${attrib} attribute`);
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
|
@ -24,121 +29,101 @@ add_task(async function setup() {
|
|||
// Add several new tabs in sequence, hiding some, to ensure that the
|
||||
// correct attributes get set
|
||||
add_task(async function test() {
|
||||
gBrowser.selectedTab = gBrowser.tabs[0];
|
||||
await switchTab(0);
|
||||
|
||||
testAttrib(gBrowser.tabs[0], "first-visible-tab", true,
|
||||
"First tab marked first-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[4], "last-visible-tab", true,
|
||||
"Fifth tab marked last-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[0], "selected", true, "First tab marked selected!");
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", false,
|
||||
"First tab not marked beforeselected-visible!");
|
||||
testAttrib(0, "first-visible-tab", true);
|
||||
testAttrib(4, "last-visible-tab", true);
|
||||
testAttrib(0, "visuallyselected", true);
|
||||
testAttrib(0, "beforeselected-visible", false);
|
||||
|
||||
gBrowser.selectedTab = gBrowser.tabs[2];
|
||||
await switchTab(2);
|
||||
|
||||
testAttrib(gBrowser.tabs[2], "selected", true, "Third tab marked selected!");
|
||||
testAttrib(gBrowser.tabs[1], "beforeselected-visible", true,
|
||||
"Second tab marked beforeselected-visible!");
|
||||
testAttrib(2, "visuallyselected", true);
|
||||
testAttrib(1, "beforeselected-visible", true);
|
||||
|
||||
gBrowser.hideTab(gBrowser.tabs[1]);
|
||||
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", true,
|
||||
"First tab marked beforeselected-visible!");
|
||||
testAttrib(0, "beforeselected-visible", true);
|
||||
|
||||
gBrowser.showTab(gBrowser.tabs[1]);
|
||||
|
||||
testAttrib(gBrowser.tabs[1], "beforeselected-visible", true,
|
||||
"Second tab marked beforeselected-visible!");
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", false,
|
||||
"First tab not marked beforeselected-visible!");
|
||||
testAttrib(1, "beforeselected-visible", true);
|
||||
testAttrib(0, "beforeselected-visible", false);
|
||||
|
||||
gBrowser.selectedTab = gBrowser.tabs[1];
|
||||
await switchTab(1);
|
||||
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", true,
|
||||
"First tab marked beforeselected-visible!");
|
||||
testAttrib(0, "beforeselected-visible", true);
|
||||
|
||||
gBrowser.hideTab(gBrowser.tabs[0]);
|
||||
|
||||
testAttrib(gBrowser.tabs[0], "first-visible-tab", false,
|
||||
"Hidden first tab not marked first-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[1], "first-visible-tab", true,
|
||||
"Second tab marked first-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", false,
|
||||
"First tab not marked beforeselected-visible!");
|
||||
testAttrib(0, "first-visible-tab", false);
|
||||
testAttrib(1, "first-visible-tab", true);
|
||||
testAttrib(0, "beforeselected-visible", false);
|
||||
|
||||
gBrowser.showTab(gBrowser.tabs[0]);
|
||||
|
||||
testAttrib(gBrowser.tabs[0], "first-visible-tab", true,
|
||||
"First tab marked first-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", true,
|
||||
"First tab marked beforeselected-visible!");
|
||||
testAttrib(0, "first-visible-tab", true);
|
||||
testAttrib(0, "beforeselected-visible", true);
|
||||
|
||||
gBrowser.moveTabTo(gBrowser.selectedTab, 3);
|
||||
|
||||
testAttrib(gBrowser.tabs[2], "beforeselected-visible", true,
|
||||
"Third tab marked beforeselected-visible!");
|
||||
testAttrib(2, "beforeselected-visible", true);
|
||||
});
|
||||
|
||||
add_task(function test_hoverOne() {
|
||||
gBrowser.selectedTab = gBrowser.tabs[0];
|
||||
add_task(async function test_hoverOne() {
|
||||
await switchTab(0);
|
||||
EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[4], { type: "mousemove" });
|
||||
testAttrib(gBrowser.tabs[3], "beforehovered", true, "Fourth tab marked beforehovered");
|
||||
testAttrib(3, "beforehovered", true);
|
||||
EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[3], { type: "mousemove" });
|
||||
testAttrib(gBrowser.tabs[2], "beforehovered", true, "Third tab marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[2], "afterhovered", false, "Third tab not marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[4], "afterhovered", true, "Fifth tab marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[4], "beforehovered", false, "Fifth tab not marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[0], "beforehovered", false, "First tab not marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[0], "afterhovered", false, "First tab not marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[1], "beforehovered", false, "Second tab not marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[1], "afterhovered", false, "Second tab not marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[3], "beforehovered", false, "Fourth tab not marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[3], "afterhovered", false, "Fourth tab not marked afterhovered!");
|
||||
testAttrib(2, "beforehovered", true);
|
||||
testAttrib(2, "afterhovered", false);
|
||||
testAttrib(4, "afterhovered", true);
|
||||
testAttrib(4, "beforehovered", false);
|
||||
testAttrib(0, "beforehovered", false);
|
||||
testAttrib(0, "afterhovered", false);
|
||||
testAttrib(1, "beforehovered", false);
|
||||
testAttrib(1, "afterhovered", false);
|
||||
testAttrib(3, "beforehovered", false);
|
||||
testAttrib(3, "afterhovered", false);
|
||||
});
|
||||
|
||||
// Test that the afterhovered and beforehovered attributes are still there when
|
||||
// a tab is selected and then unselected again. See bug 856107.
|
||||
add_task(function test_hoverStatePersistence() {
|
||||
add_task(async function test_hoverStatePersistence() {
|
||||
gBrowser.removeTab(tabs.pop());
|
||||
|
||||
function assertState() {
|
||||
testAttrib(gBrowser.tabs[0], "beforehovered", true, "First tab still marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[0], "afterhovered", false, "First tab not marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[2], "afterhovered", true, "Third tab still marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[2], "beforehovered", false, "Third tab not marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[1], "beforehovered", false, "Second tab not marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[1], "afterhovered", false, "Second tab not marked afterhovered!");
|
||||
testAttrib(gBrowser.tabs[3], "beforehovered", false, "Fourth tab not marked beforehovered!");
|
||||
testAttrib(gBrowser.tabs[3], "afterhovered", false, "Fourth tab not marked afterhovered!");
|
||||
testAttrib(0, "beforehovered", true);
|
||||
testAttrib(0, "afterhovered", false);
|
||||
testAttrib(2, "afterhovered", true);
|
||||
testAttrib(2, "beforehovered", false);
|
||||
testAttrib(1, "beforehovered", false);
|
||||
testAttrib(1, "afterhovered", false);
|
||||
testAttrib(3, "beforehovered", false);
|
||||
testAttrib(3, "afterhovered", false);
|
||||
}
|
||||
|
||||
gBrowser.selectedTab = gBrowser.tabs[3];
|
||||
await switchTab(3);
|
||||
EventUtils.synthesizeMouseAtCenter(gBrowser.tabs[1], { type: "mousemove" });
|
||||
assertState();
|
||||
gBrowser.selectedTab = gBrowser.tabs[1];
|
||||
await switchTab(1);
|
||||
assertState();
|
||||
gBrowser.selectedTab = gBrowser.tabs[3];
|
||||
await switchTab(3);
|
||||
assertState();
|
||||
});
|
||||
|
||||
add_task(function test_pinning() {
|
||||
gBrowser.removeTab(tabs.pop());
|
||||
gBrowser.selectedTab = gBrowser.tabs[3];
|
||||
testAttrib(gBrowser.tabs[3], "last-visible-tab", true,
|
||||
"Fourth tab marked last-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[3], "selected", true, "Fourth tab marked selected!");
|
||||
testAttrib(gBrowser.tabs[2], "beforeselected-visible", true,
|
||||
"Third tab marked beforeselected-visible!");
|
||||
add_task(async function test_pinning() {
|
||||
testAttrib(3, "last-visible-tab", true);
|
||||
testAttrib(3, "visuallyselected", true);
|
||||
testAttrib(2, "beforeselected-visible", true);
|
||||
// Causes gBrowser.tabs to change indices
|
||||
gBrowser.pinTab(gBrowser.tabs[3]);
|
||||
testAttrib(gBrowser.tabs[3], "last-visible-tab", true,
|
||||
"Fourth tab marked last-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[0], "first-visible-tab", true,
|
||||
"First tab marked first-visible-tab!");
|
||||
testAttrib(gBrowser.tabs[2], "beforeselected-visible", false,
|
||||
"Third tab not marked beforeselected-visible!");
|
||||
testAttrib(gBrowser.tabs[0], "selected", true, "First tab marked selected!");
|
||||
gBrowser.selectedTab = gBrowser.tabs[1];
|
||||
testAttrib(gBrowser.tabs[0], "beforeselected-visible", true,
|
||||
"First tab marked beforeselected-visible!");
|
||||
testAttrib(3, "last-visible-tab", true);
|
||||
testAttrib(0, "first-visible-tab", true);
|
||||
testAttrib(2, "beforeselected-visible", false);
|
||||
testAttrib(0, "visuallyselected", true);
|
||||
await switchTab(1);
|
||||
testAttrib(0, "beforeselected-visible", true);
|
||||
});
|
||||
|
||||
add_task(function cleanup() {
|
||||
|
|
|
@ -437,6 +437,7 @@ class AsyncTabSwitcher {
|
|||
this.lastVisibleTab._visuallySelected = false;
|
||||
|
||||
this.visibleTab._visuallySelected = true;
|
||||
this.tabbrowser.tabContainer._setPositionalAttributes();
|
||||
}
|
||||
|
||||
this.lastVisibleTab = this.visibleTab;
|
||||
|
|
Загрузка…
Ссылка в новой задаче