Bug 1188718 - Don't change the currently selected tab when clicking on the audio mute button; r=jaws

This commit is contained in:
Ehsan Akhgari 2015-07-28 22:43:08 -04:00
parent 1d232631d8
commit 75148dc060
2 changed files with 38 additions and 12 deletions

View File

@ -5920,7 +5920,8 @@
if (this.selected) {
this.style.MozUserFocus = 'ignore';
this.clientTop; // just using this to flush style updates
} else if (this.mOverCloseButton) {
} else if (this.mOverCloseButton ||
this._overPlayingIcon) {
// Prevent tabbox.xml from selecting the tab.
event.stopPropagation();
}

View File

@ -10,15 +10,13 @@ function* wait_for_tab_playing_event(tab, expectPlaying) {
});
}
function* test_tooltip(icon, expectedTooltip) {
function disable_non_test_mouse(disable) {
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
utils.disableNonTestMouseEvents(disable);
}
let tooltip = document.getElementById("tabbrowser-tab-tooltip");
function disable_non_test_mouse(disable) {
let utils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
utils.disableNonTestMouseEvents(disable);
}
function* hover_icon(icon, tooltip) {
disable_non_test_mouse(true);
let popupShownPromise = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
@ -26,15 +24,26 @@ function* test_tooltip(icon, expectedTooltip) {
EventUtils.synthesizeMouse(icon, 2, 2, {type: "mousemove"});
EventUtils.synthesizeMouse(icon, 3, 3, {type: "mousemove"});
EventUtils.synthesizeMouse(icon, 4, 4, {type: "mousemove"});
yield popupShownPromise;
is(tooltip.getAttribute("label"), expectedTooltip, "Correct tooltip expected");
return popupShownPromise;
}
function leave_icon(icon) {
EventUtils.synthesizeMouse(icon, 0, 0, {type: "mouseout"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
disable_non_test_mouse(false);
}
function* test_tooltip(icon, expectedTooltip) {
let tooltip = document.getElementById("tabbrowser-tab-tooltip");
yield hover_icon(icon, tooltip);
is(tooltip.getAttribute("label"), expectedTooltip, "Correct tooltip expected");
leave_icon(icon);
}
function* test_mute_tab(tab, icon, expectMuted) {
let mutedPromise = BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
if (event.detail.changed.indexOf("muted") >= 0) {
@ -44,7 +53,15 @@ function* test_mute_tab(tab, icon, expectMuted) {
return false;
});
let activeTab = gBrowser.selectedTab;
let tooltip = document.getElementById("tabbrowser-tab-tooltip");
yield hover_icon(icon, tooltip);
EventUtils.synthesizeMouseAtCenter(icon, {button: 0});
leave_icon(icon);
is(gBrowser.selectedTab, activeTab, "Clicking on mute should not change the currently selected tab");
return mutedPromise;
}
@ -89,6 +106,14 @@ function* test_on_browser(browser) {
yield test_playing_icon_on_tab(tab, browser, true);
gBrowser.unpinTab(tab);
// Retest with another browser in the foreground tab
if (gBrowser.selectedBrowser.currentURI.spec == PAGE) {
yield BrowserTestUtils.withNewTab({
gBrowser,
url: "data:text/html,test"
}, () => test_on_browser(browser));
}
}
add_task(function*() {